|
66 | 66 | #include "mc/world/effect/MobEffectInstance.h" |
67 | 67 | #include "mc/world/item/ItemStack.h" |
68 | 68 | #include "mc/world/level/BlockSource.h" |
| 69 | +#include "mc/world/level/ChunkPos.h" |
69 | 70 | #include "mc/world/level/block/Block.h" |
70 | 71 | #include "mc/world/level/storage/AdventureSettings.h" |
71 | 72 | #include "mc/world/level/storage/DBStorage.h" |
72 | 73 | #include "mc/world/level/storage/db_helpers/Category.h" |
73 | 74 | #include "mc/world/phys/HitResult.h" |
| 75 | +#include "mc/world/scores/IdentityDefinition.h" |
74 | 76 | #include "mc/world/scores/PlayerScoreSetFunction.h" |
75 | 77 | #include "mc/world/scores/PlayerScoreboardId.h" |
76 | 78 | #include "mc/world/scores/ScoreInfo.h" |
|
92 | 94 | #include <mc/world/attribute/Attribute.h> |
93 | 95 | #include <mc/world/attribute/AttributeInstance.h> |
94 | 96 | #include <mc/world/attribute/SharedAttributes.h> |
95 | | -#include <mc/world/level/BlockSource.h> |
96 | 97 | #include <mc/world/level/biome/Biome.h> |
97 | 98 | #include <mc/world/level/material/Material.h> |
98 | 99 | #include <mc/world/scores/Objective.h> |
@@ -1514,16 +1515,14 @@ Local<Value> PlayerClass::runcmd(const Arguments& args) { |
1514 | 1515 | CHECK_ARG_TYPE(args[0], ValueKind::kString); |
1515 | 1516 |
|
1516 | 1517 | 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); |
1527 | 1526 | return Boolean::newBoolean(true); |
1528 | 1527 | } |
1529 | 1528 | CATCH("Fail in runcmd!"); |
@@ -2015,16 +2014,14 @@ Local<Value> PlayerClass::crash(const Arguments&) { |
2015 | 2014 | try { |
2016 | 2015 | Player* player = get(); |
2017 | 2016 | 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); |
2028 | 2025 | return Boolean::newBoolean(false); |
2029 | 2026 | } |
2030 | 2027 | CATCH("Fail in crashPlayer!"); |
@@ -2181,33 +2178,32 @@ Local<Value> PlayerClass::setSidebar(const Arguments& args) { |
2181 | 2178 | if (args.size() >= 3) CHECK_ARG_TYPE(args[2], ValueKind::kNumber); |
2182 | 2179 |
|
2183 | 2180 | try { |
2184 | | - // todo: fix this |
| 2181 | + Player* player = get(); |
| 2182 | + if (!player) return Local<Value>(); |
2185 | 2183 |
|
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 | + |
2203 | 2199 | // std::vector<ScorePacketInfo> info; |
2204 | 2200 | // for (auto& i : data) { |
2205 | 2201 | // 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; |
2211 | 2207 | // info.emplace_back(pktInfo); |
2212 | 2208 | // } |
2213 | 2209 | // SetScorePacket setPkt = SetScorePacket::change(info); |
|
0 commit comments