Skip to content

Commit 04514fd

Browse files
committed
fix: fix command api
1 parent b45ba10 commit 04514fd

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/legacy/api/CommandAPI.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "main/Configs.h"
2020
#include "mc/_HeaderOutputPredefine.h"
2121
#include "mc/codebuilder/MCRESULT.h"
22+
#include "mc/common/wrapper/GenerateMessageResult.h"
2223
#include "mc/deps/json/JsonHelpers.h"
2324
#include "mc/enums/CurrentCmdVersion.h"
2425
#include "mc/locale/I18n.h"
@@ -113,7 +114,9 @@ Local<Value> convertResult(DynamicCommand::Result const& result) {
113114
return FloatPos::newPos(result.get<Vec3>(), dim ? (int)dim->getDimensionId() : -1);
114115
}
115116
case DynamicCommand::ParameterType::Message:
116-
return String::newString(result.getRaw<CommandMessage>().getMessage(*result.origin));
117+
return String::newString(
118+
result.getRaw<CommandMessage>().generateMessage(*result.origin, CommandVersion::CurrentVersion).string
119+
);
117120
case DynamicCommand::ParameterType::RawText:
118121
return String::newString(result.getRaw<std::string>());
119122
case DynamicCommand::ParameterType::JsonValue:
@@ -470,7 +473,10 @@ void onExecute(
470473
auto cmd = CommandClass::newCommand(const_cast<DynamicCommandInstance*>(instance));
471474
auto ori = CommandOriginClass::newCommandOrigin(&origin);
472475
auto outp = CommandOutputClass::newCommandOutput(&output);
473-
for (auto& [name, param] : results) args.set(name, convertResult(param));
476+
for (auto& [name, param] : results) {
477+
lse::getSelfPluginInstance().getLogger().info(param.toDebugString());
478+
args.set(name, convertResult(param));
479+
}
474480
localShareData->commandCallbacks[commandName].func.get().call({}, cmd, ori, outp, args);
475481
}
476482
CATCH_WITHOUT_RETURN("Fail in executing command \"" + commandName + "\"!")

src/legacy/legacyapi/command/DynamicCommand.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include "ll/api/utils/ErrorUtils.h"
99
#include "lse/Entry.h"
1010
#include "magic_enum.hpp"
11+
#include "mc/common/wrapper/GenerateMessageResult.h"
1112
#include "mc/deps/core/common/bedrock/typeid_t.h"
1213
#include "mc/enums/SoftEnumUpdateType.h"
1314
#include "mc/network/packet/AvailableCommandsPacket.h"
@@ -25,6 +26,7 @@
2526
#include "mc/server/commands/CommandSelector.h"
2627
#include "mc/server/commands/CommandSoftEnumRegistry.h"
2728
#include "mc/server/commands/CommandUtils.h"
29+
#include "mc/server/commands/CommandVersion.h"
2830
#include "mc/server/commands/WildcardCommandSelector.h"
2931
#include "mc/world/actor/ActorDefinitionIdentifier.h"
3032
#include "mc/world/effect/MobEffect.h"
@@ -350,7 +352,7 @@ std::string DynamicCommand::Result::toDebugString() const {
350352
name,
351353
typeName,
352354
isSet,
353-
getRaw<CommandMessage>().getMessage(*origin)
355+
getRaw<CommandMessage>().generateMessage(*origin, CommandVersion::CurrentVersion).string
354356
);
355357
case ParameterType::JsonValue:
356358
return fmt::format(

0 commit comments

Comments
 (0)