Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scoreboard implementation #3953

Open
wants to merge 58 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
dbccb02
Initial work on team network packets.
lkolbly Aug 10, 2017
742d7f0
Made scoreboard send updates for more cTeam events.
lkolbly Aug 11, 2017
fbca038
Changing to enums for actions.
lkolbly Aug 13, 2017
aa07fc4
Added code to tell clients about the world scoreboard as they're adde…
lkolbly Aug 13, 2017
7c662df
Added cObjective::GetPlayers.
lkolbly Aug 14, 2017
f33477b
Renamed SendTeams to SendTeam
lkolbly Aug 17, 2017
e781c4e
{merge}
lkolbly Aug 19, 2017
40aa1fb
Tweaks
lkolbly Aug 19, 2017
9f19607
Added support for subcriterias for entity-based stats
lkolbly Aug 19, 2017
8df012d
Fixing precommit hooks
lkolbly Aug 19, 2017
8b275b5
Made ScoreboardSerializer track all display slots.
lkolbly Aug 20, 2017
099d8b1
{merge}
lkolbly Aug 22, 2017
06c646e
Added code to only broadcast displayed slots.
lkolbly Aug 23, 2017
a5349bc
Fixed lua warning
lkolbly Aug 23, 2017
c43af6e
Fixed StringToType EntityKilledBy processing
lkolbly Aug 23, 2017
286f39e
Removed semicolon
lkolbly Aug 23, 2017
b5dd7a7
Made cTeam::GetMembers not lua exported.
lkolbly Aug 24, 2017
e97eabb
Added documentation.
lkolbly Aug 24, 2017
451c0bc
Changed how team colors are handled
lkolbly Aug 24, 2017
84005d4
Added documentation for team colors.
lkolbly Aug 25, 2017
f9fbe3f
Merge branch 'master' into scoreboardImplementation
lkolbly Aug 25, 2017
b0234d1
Documented dsSidebarTeamOffset, removed dsTeam* descriptions.
lkolbly Aug 25, 2017
0ec602d
Renaming some methods.
lkolbly Aug 25, 2017
fdb586e
Use enumerated values in protocol layer more extensively.
lkolbly Aug 25, 2017
2f270a8
ScoreBoard => Scoreboard
lkolbly Aug 25, 2017
22dcb75
Updated docs to use key instead of player.
lkolbly Aug 25, 2017
0cfb2cc
Removed player tracking of teams.
lkolbly Aug 25, 2017
e0a6fe2
Pass cObjective into protocol layer, fixed friendly fire calculation.
lkolbly Aug 25, 2017
ea45d0f
Use const auto in loop in protocol
lkolbly Aug 25, 2017
f0f5c90
{merge}
lkolbly Aug 25, 2017
c1e7e18
Added a short tutorial
lkolbly Aug 26, 2017
f37345d
Added integer/hearts displays.
lkolbly Aug 26, 2017
8b06240
Added default case, documentation for integers/hearts
lkolbly Aug 26, 2017
804a507
Use auto
lkolbly Aug 26, 2017
ccb1f23
Lua fix
lkolbly Aug 26, 2017
19b428b
Removed default cases, added saving display type.
lkolbly Aug 26, 2017
950608a
Merge branch 'master' into scoreboardImplementation
lkolbly Aug 29, 2017
9d4c9f0
{merge}
lkolbly Sep 3, 2017
dfd393e
Fixed merge conflicts.
lkolbly Sep 4, 2017
bc0ab2d
Merge branch 'master' of https://github.com/cuberite/cuberite into sc…
lkolbly Sep 4, 2017
209a87d
Renamed eType to Criteria
lkolbly Sep 4, 2017
e0b4b3b
Moved StringToType and TypeToString methods into Criteria class.
lkolbly Sep 5, 2017
0112a66
Removed header declarations for removed methods.
lkolbly Sep 5, 2017
cc3f200
Updated scoreboard serializer to new criteria/string conversions.
lkolbly Sep 5, 2017
22f4f18
Revert "Updated scoreboard serializer to new criteria/string conversi…
lkolbly Sep 9, 2017
99517e0
Revert "Removed header declarations for removed methods."
lkolbly Sep 9, 2017
635dab5
Revert "Moved StringToType and TypeToString methods into Criteria cla…
lkolbly Sep 9, 2017
5b62474
Turned Criteria into an int bitfield.
lkolbly Sep 9, 2017
2b247be
Removed comment
lkolbly Sep 9, 2017
6d7a76d
Renamed StringToType to StringToCriteria and vice-versa.
lkolbly Sep 9, 2017
31ce44c
Switched order of Criteria, renamed enum to begin with cr.
lkolbly Sep 9, 2017
275b88d
Renamed ot to cr
lkolbly Sep 9, 2017
5258f35
Added comments, removed magic numbers.
lkolbly Sep 9, 2017
0203960
Merge branch 'master' into scoreboardImplementation
lkolbly Sep 9, 2017
d8f069e
Fixed compilation issues, removed bitmask constants from lua.
lkolbly Sep 9, 2017
b627f05
Added crClassCount to switch
lkolbly Sep 10, 2017
a6a9275
Fixed apicheck failure
lkolbly Sep 11, 2017
4e81c75
{merge}
lkolbly Sep 13, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
171 changes: 161 additions & 10 deletions Server/Plugins/APIDump/APIDesc.lua
Expand Up @@ -9086,7 +9086,7 @@ a_Player:OpenWindow(Window);
cObjective =
{
Desc = [[
This class represents a single scoreboard objective.
This class represents a single scoreboard objective. Note that the term "player" is used loosely here to mean "item that the objective is tracking," to match the Vanilla minecraft documentation, but a "player" does not need to be the username of an actual player.
]],
Functions =
{
Expand All @@ -9095,11 +9095,11 @@ a_Player:OpenWindow(Window);
Params =
{
{
Name = "string",
Name = "player",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Name or UUID or cPlayer? Use a descriptive param name: playerName, playerUuid

Type = "string",
},
{
Name = "number",
Name = "ScoreToAdd",
Type = "number",
},
},
Expand Down Expand Up @@ -9132,12 +9132,22 @@ a_Player:OpenWindow(Window);
},
Notes = "Returns the internal name of the objective.",
},
GetPlayers =
{
Returns =
{
{
Type = "table",
},
},
Notes = "Returns all of the players this objective is tracking",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Players, as in cPlayer instances, or playernames, or UUIDs? Array-table, or a map?

},
GetScore =
{
Params =
{
{
Name = "string",
Name = "player",
Type = "string",
},
},
Expand Down Expand Up @@ -9170,18 +9180,29 @@ a_Player:OpenWindow(Window);
Params =
{
{
Name = "string",
Name = "player",
Type = "string",
},
},
Notes = "Reset the score of the specified player.",
},
SetAllScores =
{
Params =
{
{
Name = "Score",
Type = "number",
},
},
Notes = "Sets the score of every player this objective tracks to the given score",
},
SetDisplayName =
{
Params =
{
{
Name = "string",
Name = "DisplayName",
Type = "string",
},
},
Expand All @@ -9192,7 +9213,7 @@ a_Player:OpenWindow(Window);
Params =
{
{
Name = "string",
Name = "player",
Type = "string",
},
{
Expand All @@ -9202,16 +9223,33 @@ a_Player:OpenWindow(Window);
},
Notes = "Sets the score of the specified player.",
},
StringToType =
{
Params =
{
{
Name = "TypeString",
Type = "string",
},
},
Returns =
{
{
Type = "<unknown>",
},
},
Notes = "(STATIC) Converts a Vanilla minecraft objective criteria string to an internal eType.",
},
SubScore =
{
Params =
{
{
Name = "string",
Name = "player",
Type = "string",
},
{
Name = "number",
Name = "ScoreToSubtract",
Type = "number",
},
},
Expand All @@ -9224,6 +9262,23 @@ a_Player:OpenWindow(Window);
},
Notes = "Subtracts a value from the score of the specified player and returns the new value.",
},
TypeToString =
{
Params =
{
{
Name = "Type",
Type = "<unknown>",
},
},
Returns =
{
{
Type = "string",
},
},
Notes = "(STATIC) Converts an internal objective eType to a Vanilla minecraft objective criteria string",
},
},
Constants =
{
Expand Down Expand Up @@ -11551,7 +11606,7 @@ end
},
{
Name = "Value",
Type = "<unknown>",
Type = "number",
},
},
Notes = "Adds a value to all player scores of the specified objective type.",
Expand Down Expand Up @@ -11793,6 +11848,10 @@ end
{
Notes = "",
},
dsSidebarTeamOffset =
{
Notes = "Add this to the team color (see cTeam::GetColor()) to get the appropriate display slot ID for the sidebar of that team. Note that the team must have been assigned a valid color using SetColor().",
},
},
},
cServer =
Expand Down Expand Up @@ -12072,6 +12131,16 @@ local CompressedString = cStringCompression.CompressStringGZIP("DataToCompress")
},
Notes = "Returns whether players can see invisible teammates.",
},
GetColor =
{
Returns =
{
{
Type = "number",
},
},
Notes = "Returns the color ID of the team",
},
GetDisplayName =
{
Returns =
Expand Down Expand Up @@ -12171,6 +12240,17 @@ local CompressedString = cStringCompression.CompressStringGZIP("DataToCompress")
},
Notes = "Set whether players can see invisible teammates.",
},
SetColor =
{
Params =
{
{
Name = "Color",
Type = "number",
},
},
Notes = "Sets the color ID of the team (0 to 15)",
},
SetDisplayName =
{
Params =
Expand Down Expand Up @@ -12216,6 +12296,77 @@ local CompressedString = cStringCompression.CompressStringGZIP("DataToCompress")
Notes = "Sets the suffix appended to the names of the members of this team.",
},
},
Constants =
{
teamInvalid =
{
Notes = "Placeholder for teams which are not associated with a color.",
},
teamBlack =
{
Notes = "",
},
teamDarkBlue =
{
Notes = "",
},
teamDarkGreen =
{
Notes = "",
},
teamDarkAqua =
{
Notes = "",
},
teamDarkRed =
{
Notes = "",
},
teamDarkPurple =
{
Notes = "",
},
teamGold =
{
Notes = "",
},
teamGray =
{
Notes = "",
},
teamDarkGray =
{
Notes = "",
},
teamBlue =
{
Notes = "",
},
teamGreen =
{
Notes = "",
},
teamAqua =
{
Notes = "",
},
teamRed =
{
Notes = "",
},
teamLightPurple =
{
Notes = "",
},
teamYellow =
{
Notes = "",
},
teamWhite =
{
Notes = "",
},
},
},
cTNTEntity =
{
Expand Down
28 changes: 28 additions & 0 deletions src/Bindings/ManualBindings.cpp
Expand Up @@ -3053,6 +3053,30 @@ static int tolua_cLuaWindow_new_local(lua_State * tolua_S)



static int tolua_cObjective_GetPlayers(lua_State * tolua_S)
{
cLuaState S(tolua_S);
if (
!S.CheckParamUserType(1, "cObjective") ||
!S.CheckParamEnd(2)
)
{
return 0;
}

// Get the groups:
cObjective * Objective = reinterpret_cast<cObjective *>(tolua_tousertype(tolua_S, 1, nullptr));
AStringVector Players = Objective->GetPlayers();

// Push the results:
S.Push(Players);
return 1;
}





static int tolua_cRoot_GetBuildCommitID(lua_State * tolua_S)
{
cLuaState L(tolua_S);
Expand Down Expand Up @@ -3890,6 +3914,10 @@ void cManualBindings::Bind(lua_State * tolua_S)
tolua_function(tolua_S, "MakeUUIDShort", tolua_cMojangAPI_MakeUUIDShort);
tolua_endmodule(tolua_S);

tolua_beginmodule(tolua_S, "cObjective");
tolua_function(tolua_S, "GetPlayers", tolua_cObjective_GetPlayers);
tolua_endmodule(tolua_S);

tolua_beginmodule(tolua_S, "cPlayer");
tolua_function(tolua_S, "GetPermissions", tolua_cPlayer_GetPermissions);
tolua_function(tolua_S, "GetRestrictions", tolua_cPlayer_GetRestrictions);
Expand Down
21 changes: 18 additions & 3 deletions src/ClientHandle.cpp
Expand Up @@ -446,9 +446,6 @@ void cClientHandle::Authenticate(const AString & a_Name, const AString & a_UUID,
// Query player team
m_Player->UpdateTeam();

// Send scoreboard data
World->GetScoreBoard().SendTo(*this);

// Send statistics
SendStatistics(m_Player->GetStatManager());

Expand Down Expand Up @@ -2928,6 +2925,24 @@ void cClientHandle::SendDisplayObjective(const AString & a_Objective, cScoreboar



void cClientHandle::SendTeam(const cTeam & a_Team, cTeam::eProtocolAction a_Mode)
{
m_Protocol->SendTeam(a_Team, a_Mode);
}





void cClientHandle::SendTeamChangeMembership(const AString & a_TeamName, bool a_IsAdding, const std::set<AString> & a_Delta)
{
m_Protocol->SendTeamChangeMembership(a_TeamName, a_IsAdding, a_Delta);
}





void cClientHandle::SendSetSubTitle(const cCompositeChat & a_SubTitle)
{
m_Protocol->SendSetSubTitle(a_SubTitle);
Expand Down
2 changes: 2 additions & 0 deletions src/ClientHandle.h
Expand Up @@ -213,6 +213,8 @@ class cClientHandle // tolua_export
void SendSpawnVehicle (const cEntity & a_Vehicle, char a_VehicleType, char a_VehicleSubType = 0);
void SendStatistics (const cStatManager & a_Manager);
void SendTabCompletionResults (const AStringVector & a_Results);
void SendTeam (const cTeam & a_Team, cTeam::eProtocolAction a_Mode);
void SendTeamChangeMembership (const AString & a_TeamName, bool a_IsAdding, const std::set<AString> & a_Delta);
void SendTeleportEntity (const cEntity & a_Entity);
void SendThunderbolt (int a_BlockX, int a_BlockY, int a_BlockZ);
void SendTitleTimes (int a_FadeInTicks, int a_DisplayTicks, int a_FadeOutTicks); // tolua_export
Expand Down
2 changes: 2 additions & 0 deletions src/Protocol/Protocol.h
Expand Up @@ -131,6 +131,8 @@ class cProtocol
virtual void SendSpawnVehicle (const cEntity & a_Vehicle, char a_VehicleType, char a_VehicleSubType) = 0;
virtual void SendStatistics (const cStatManager & a_Manager) = 0;
virtual void SendTabCompletionResults (const AStringVector & a_Results) = 0;
virtual void SendTeam (const cTeam & a_Team, Byte a_Mode) = 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the eProtocolAction enum here as well, only convert in the last moment before sending.

virtual void SendTeamChangeMembership (const AString & a_TeamName, bool a_IsAdding, const std::set<AString> & a_Delta) = 0;
virtual void SendTeleportEntity (const cEntity & a_Entity) = 0;
virtual void SendThunderbolt (int a_BlockX, int a_BlockY, int a_BlockZ) = 0;
virtual void SendTitleTimes (int a_FadeInTicks, int a_DisplayTicks, int a_FadeOutTicks) = 0;
Expand Down