88#include " magic_enum.hpp"
99#include " mc/deps/core/utility/typeid_t.h"
1010#include " mc/nbt/CompoundTag.h"
11- #include " mc/network/packet/AvailableCommandsPacket.h"
1211#include " mc/server/commands/BlockStateCommandParam.h"
1312#include " mc/server/commands/Command.h"
1413#include " mc/server/commands/CommandBlockName.h"
3130#include " mc/world/item/ItemInstance.h"
3231#include " mc/world/level/Level.h"
3332
34- #include < algorithm>
35- #include < cstddef>
3633#include < cstdint>
3734#include < ll/api/command/CommandRegistrar.h>
38- #include < ll/api/io/Logger.h>
3935#include < memory>
4036#include < sstream>
4137#include < stdexcept>
@@ -54,8 +50,6 @@ bool CommandRegistry::parse<std::pair<
5450 return true ;
5551}
5652
57- #define logger lse::getSelfPluginInstance ().getLogger()
58-
5953#define ForEachParameterType (func ) \
6054 func (Bool); \
6155 func (Int); \
@@ -133,9 +127,9 @@ auto const ParameterSizeMap = std::unordered_map<ParameterType, size_t>{
133127};
134128
135129inline void OutputError (const std::string& command, const std::string& func = __builtin_FUNCTION()) {
136- ll::error_utils::printCurrentException (logger );
137- logger .error (" In Function ({})" , func);
138- logger .error (" In Command <{}>" , command);
130+ ll::error_utils::printCurrentException (lse::getSelfPluginInstance (). getLogger () );
131+ lse::getSelfPluginInstance (). getLogger () .error (" In Function ({})" , func);
132+ lse::getSelfPluginInstance (). getLogger () .error (" In Command <{}>" , command);
139133}
140134
141135} // namespace
@@ -426,7 +420,7 @@ std::string DynamicCommand::Result::toDebugString() const {
426420 isSet ? getRaw<std::unique_ptr<Command>>()->getCommandName () : " Null"
427421 );
428422 default :
429- logger .error (" Unknown Parameter Type {}, name: {}" , typeName, name);
423+ lse::getSelfPluginInstance (). getLogger () .error (" Unknown Parameter Type {}, name: {}" , typeName, name);
430424 return " " ;
431425 }
432426}
@@ -446,7 +440,7 @@ DynamicCommandInstance*
446440DynamicCommand::preSetup (CommandRegistry& registry, std::unique_ptr<class DynamicCommandInstance > commandInstance) {
447441 std::string name = commandInstance->getCommandName ();
448442#if defined(LEGACYSCRIPTENGINE_DEBUG)
449- logger .debug (" Setting up command \" {}\" " , name);
443+ lse::getSelfPluginInstance (). getLogger () .debug (" Setting up command \" {}\" " , name);
450444#endif
451445 // Check if there is another command with the same name
452446 auto signature = registry.findCommand (name);
@@ -556,7 +550,10 @@ DynamicCommand::~DynamicCommand() {
556550 std::string commandName = getCommandName ();
557551 auto iter = dynamicCommandInstances.find (commandName);
558552 if (iter == dynamicCommandInstances.end ()) {
559- logger.error (" Error in DynamicCommand::~DynamicCommand(), command \" {}\" not found" , commandName);
553+ lse::getSelfPluginInstance ().getLogger ().error (
554+ " Error in DynamicCommand::~DynamicCommand(), command \" {}\" not found" ,
555+ commandName
556+ );
560557 return ;
561558 }
562559 auto & commandIns = *iter->second ;
@@ -604,7 +601,7 @@ DynamicCommandInstance const*
604601DynamicCommand::setup (CommandRegistry& registry, std::unique_ptr<class DynamicCommandInstance > commandInstance) {
605602 auto name = commandInstance->getCommandName ();
606603 auto ptr = preSetup (registry, std::move (commandInstance));
607- if (!ptr) logger .warn (" Registering command \" {}\" failed" , name);
604+ if (!ptr) lse::getSelfPluginInstance (). getLogger () .warn (" Registering command \" {}\" failed" , name);
608605 updateAvailableCommands (registry);
609606 return ptr;
610607}
0 commit comments