-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from zzz-mimimi/master
Implement SetScore packet and set-score scripting event
- Loading branch information
Showing
8 changed files
with
98 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#include "pch.h" | ||
#include "SetScorePacket.h" | ||
|
||
std::wstring SDK::SetScorePacket::serialize() const { | ||
nlohmann::json serialized; | ||
|
||
serialized["type"] = static_cast<int>(type); | ||
|
||
for (const auto& info : scoreInfo) { | ||
nlohmann::json score; | ||
score["scoreboardId"] = info.scoreboardId.rawId; | ||
score["objectiveName"] = info.objectiveName; | ||
score["scoreValue"] = info.scoreValue; | ||
score["identityType"] = static_cast<unsigned char>(info.identityType); | ||
score["playerId"] = info.playerId; | ||
score["entityId"] = info.entityId; | ||
score["fakePlayerName"] = info.fakePlayerName; | ||
|
||
serialized["scoreInfo"].push_back(score); | ||
} | ||
|
||
return util::StrToWStr(serialized.dump()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#pragma once | ||
#include "../Packet.h" | ||
#include "sdk/String.h" | ||
|
||
namespace SDK { | ||
|
||
class SetScorePacket : public Packet { | ||
private: | ||
enum class PacketType : uint8_t { | ||
Change = 0x0, | ||
Remove = 0x1 | ||
}; | ||
|
||
enum class IdentityType : unsigned char { | ||
Invalid = 0x0, | ||
Player = 0x1, | ||
Entity = 0x2, | ||
FakePlayer = 0x3 | ||
}; | ||
|
||
enum class DefinitionType : unsigned char { | ||
Invalid = 0x0, | ||
Player = 0x1, | ||
Entity = 0x2, | ||
FakePlayer = 0x3 | ||
}; | ||
|
||
class IdentityDef; | ||
|
||
struct ScoreboardId { | ||
int64_t rawId; | ||
IdentityDef* identityDef; | ||
}; | ||
|
||
class IdentityDef { | ||
ScoreboardId scoreboardId; | ||
bool isHiddenFakePlayer; | ||
int64_t playerId; | ||
int64_t entityId; | ||
std::string playerName; | ||
DefinitionType identityType; | ||
}; | ||
|
||
struct ScoreInfo { | ||
ScoreboardId scoreboardId; | ||
std::string objectiveName; | ||
int scoreValue; | ||
DefinitionType identityType; | ||
int64_t playerId; | ||
int64_t entityId; | ||
std::string fakePlayerName; | ||
}; | ||
|
||
public: | ||
PacketType type; | ||
std::vector<ScoreInfo> scoreInfo; | ||
std::wstring serialize() const; | ||
}; | ||
} |