Skip to content

Commit a2f8298

Browse files
committed
refactor: remove some annotation
1 parent c32f5ea commit a2f8298

File tree

1 file changed

+40
-44
lines changed

1 file changed

+40
-44
lines changed

src/legacy/api/PlayerAPI.cpp

Lines changed: 40 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,13 @@
6666
#include "mc/world/effect/MobEffectInstance.h"
6767
#include "mc/world/item/ItemStack.h"
6868
#include "mc/world/level/BlockSource.h"
69+
#include "mc/world/level/ChunkPos.h"
6970
#include "mc/world/level/block/Block.h"
7071
#include "mc/world/level/storage/AdventureSettings.h"
7172
#include "mc/world/level/storage/DBStorage.h"
7273
#include "mc/world/level/storage/db_helpers/Category.h"
7374
#include "mc/world/phys/HitResult.h"
75+
#include "mc/world/scores/IdentityDefinition.h"
7476
#include "mc/world/scores/PlayerScoreSetFunction.h"
7577
#include "mc/world/scores/PlayerScoreboardId.h"
7678
#include "mc/world/scores/ScoreInfo.h"
@@ -92,7 +94,6 @@
9294
#include <mc/world/attribute/Attribute.h>
9395
#include <mc/world/attribute/AttributeInstance.h>
9496
#include <mc/world/attribute/SharedAttributes.h>
95-
#include <mc/world/level/BlockSource.h>
9697
#include <mc/world/level/biome/Biome.h>
9798
#include <mc/world/level/material/Material.h>
9899
#include <mc/world/scores/Objective.h>
@@ -1514,16 +1515,14 @@ Local<Value> PlayerClass::runcmd(const Arguments& args) {
15141515
CHECK_ARG_TYPE(args[0], ValueKind::kString);
15151516

15161517
try {
1517-
// todo: fix this
1518-
1519-
// Player* player = get();
1520-
// if (!player) return Local<Value>();
1521-
// CommandContext context = CommandContext(
1522-
// args[0].asString().toString(),
1523-
// std::make_unique<PlayerCommandOrigin>(*get()),
1524-
// CommandVersion::CurrentVersion()
1525-
// );
1526-
// ll::service::getMinecraft()->getCommands().executeCommand(context, false);
1518+
Player* player = get();
1519+
if (!player) return Local<Value>();
1520+
CommandContext context = CommandContext(
1521+
args[0].asString().toString(),
1522+
std::make_unique<PlayerCommandOrigin>(*get()),
1523+
CommandVersion::CurrentVersion()
1524+
);
1525+
ll::service::getMinecraft()->getCommands().executeCommand(context, false);
15271526
return Boolean::newBoolean(true);
15281527
}
15291528
CATCH("Fail in runcmd!");
@@ -2015,16 +2014,14 @@ Local<Value> PlayerClass::crash(const Arguments&) {
20152014
try {
20162015
Player* player = get();
20172016
if (!player) return Local<Value>();
2018-
// todo: fix this
2019-
2020-
// RecordOperation(
2021-
// getEngineOwnData()->pluginName,
2022-
// "Crash Player",
2023-
// "Execute player.crash() to crash player <" + player->getRealName() + ">"
2024-
// );
2025-
// LevelChunkPacket pkt;
2026-
// pkt.mCacheEnabled = true;
2027-
// player->sendNetworkPacket(pkt);
2017+
RecordOperation(
2018+
getEngineOwnData()->pluginName,
2019+
"Crash Player",
2020+
"Execute player.crash() to crash player <" + player->getRealName() + ">"
2021+
);
2022+
LevelChunkPacket pkt;
2023+
pkt.mCacheEnabled = true;
2024+
player->sendNetworkPacket(pkt);
20282025
return Boolean::newBoolean(false);
20292026
}
20302027
CATCH("Fail in crashPlayer!");
@@ -2181,33 +2178,32 @@ Local<Value> PlayerClass::setSidebar(const Arguments& args) {
21812178
if (args.size() >= 3) CHECK_ARG_TYPE(args[2], ValueKind::kNumber);
21822179

21832180
try {
2184-
// todo: fix this
2181+
Player* player = get();
2182+
if (!player) return Local<Value>();
21852183

2186-
// Player* player = get();
2187-
// if (!player) return Local<Value>();
2188-
//
2189-
// std::vector<std::pair<std::string, int>> data;
2190-
// auto source = args[1].asObject();
2191-
// auto keys = source.getKeyNames();
2192-
// for (auto& key : keys) {
2193-
// data.push_back(make_pair(key, source.get(key).asNumber().toInt32()));
2194-
// }
2195-
//
2196-
// int sortOrder = 1;
2197-
// if (args.size() >= 3) sortOrder = args[2].asNumber().toInt32();
2198-
//
2199-
// SetDisplayObjectivePacket
2200-
// disObjPkt("sidebar", "FakeScoreObj", args[0].asString().toString(), "dummy",
2201-
// (ObjectiveSortOrder)sortOrder);
2202-
// disObjPkt.sendTo(*player);
2184+
std::vector<std::pair<std::string, int>> data;
2185+
auto source = args[1].asObject();
2186+
auto keys = source.getKeyNames();
2187+
for (auto& key : keys) {
2188+
data.push_back(make_pair(key, source.get(key).asNumber().toInt32()));
2189+
}
2190+
2191+
int sortOrder = 1;
2192+
if (args.size() >= 3) sortOrder = args[2].asNumber().toInt32();
2193+
2194+
SetDisplayObjectivePacket
2195+
disObjPkt("sidebar", "FakeScoreObj", args[0].asString().toString(), "dummy", (ObjectiveSortOrder)sortOrder);
2196+
disObjPkt.sendTo(*player);
2197+
// todo: fix it
2198+
22032199
// std::vector<ScorePacketInfo> info;
22042200
// for (auto& i : data) {
22052201
// ScorePacketInfo pktInfo;
2206-
// pktInfo.mScoreboardId = i.second;
2207-
// pktInfo.mObjectiveName = "FakeScoreObj";
2208-
// pktInfo.mIdentityType = IdentityDefinition::Type::FakePlayer;
2209-
// pktInfo.mScoreValue = i.second;
2210-
// pktInfo.mFakePlayerName = i.first;
2202+
// pktInfo.mScoreboardId->mRawID = i.second;
2203+
// pktInfo.mObjectiveName = "FakeScoreObj";
2204+
// pktInfo.mIdentityType = IdentityDefinition::Type::FakePlayer;
2205+
// pktInfo.mScoreValue = i.second;
2206+
// pktInfo.mFakePlayerName = i.first;
22112207
// info.emplace_back(pktInfo);
22122208
// }
22132209
// SetScorePacket setPkt = SetScorePacket::change(info);

0 commit comments

Comments
 (0)