diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Bindings/ManualBindings.cpp | 25 | ||||
-rw-r--r-- | src/Scoreboard.cpp | 16 | ||||
-rw-r--r-- | src/Scoreboard.h | 3 |
3 files changed, 44 insertions, 0 deletions
diff --git a/src/Bindings/ManualBindings.cpp b/src/Bindings/ManualBindings.cpp index 523244ed2..91e80acbc 100644 --- a/src/Bindings/ManualBindings.cpp +++ b/src/Bindings/ManualBindings.cpp @@ -2756,6 +2756,30 @@ static int tolua_cRoot_GetFurnaceRecipe(lua_State * tolua_S) +static int tolua_cScoreboard_GetTeamNames(lua_State * L) +{ + cLuaState S(L); + if ( + !S.CheckParamUserType(1, "cScoreboard") || + !S.CheckParamEnd(2) + ) + { + return 0; + } + + // Get the groups: + cScoreboard * Scoreboard = reinterpret_cast<cScoreboard *>(tolua_tousertype(L, 1, nullptr)); + AStringVector Teams = Scoreboard->GetTeamNames(); + + // Push the results: + S.Push(Teams); + return 1; +} + + + + + static int tolua_cHopperEntity_GetOutputBlockPos(lua_State * tolua_S) { // function cHopperEntity::GetOutputBlockPos() @@ -3532,6 +3556,7 @@ void cManualBindings::Bind(lua_State * tolua_S) tolua_beginmodule(tolua_S, "cScoreboard"); tolua_function(tolua_S, "ForEachObjective", ForEach<cScoreboard, cObjective, &cScoreboard::ForEachObjective>); tolua_function(tolua_S, "ForEachTeam", ForEach<cScoreboard, cTeam, &cScoreboard::ForEachTeam>); + tolua_function(tolua_S, "GetTeamNames", tolua_cScoreboard_GetTeamNames); tolua_endmodule(tolua_S); tolua_beginmodule(tolua_S, "cStringCompression"); diff --git a/src/Scoreboard.cpp b/src/Scoreboard.cpp index 5e416c0d1..4dde5b2dd 100644 --- a/src/Scoreboard.cpp +++ b/src/Scoreboard.cpp @@ -416,6 +416,22 @@ cTeam * cScoreboard::GetTeam(const AString & a_Name) +AStringVector cScoreboard::GetTeamNames() +{ + AStringVector TeamNames; + + for (const auto & Team: m_Teams) + { + TeamNames.push_back(Team.first); + } + + return TeamNames; +} + + + + + cTeam * cScoreboard::QueryPlayerTeam(const AString & a_Name) { cCSLock Lock(m_CSTeams); diff --git a/src/Scoreboard.h b/src/Scoreboard.h index 092cfd8ed..597c502c7 100644 --- a/src/Scoreboard.h +++ b/src/Scoreboard.h @@ -256,6 +256,9 @@ public: // tolua_end + /** Retrieves the list of team names */ + AStringVector GetTeamNames(); + /** Send this scoreboard to the specified client */ void SendTo(cClientHandle & a_Client); |