diff --git a/src/main/java/emu/grasscutter/DebugConstants.java b/src/main/java/emu/grasscutter/DebugConstants.java new file mode 100644 index 000000000..c496ab053 --- /dev/null +++ b/src/main/java/emu/grasscutter/DebugConstants.java @@ -0,0 +1,10 @@ +package emu.grasscutter; + +public final class DebugConstants { + public static boolean LOG_ABILITIES = false; + public static boolean LOG_LUA_SCRIPTS = false; + + private DebugConstants() { + // Prevent instantiation. + } +} diff --git a/src/main/java/emu/grasscutter/game/ability/AbilityManager.java b/src/main/java/emu/grasscutter/game/ability/AbilityManager.java index 5c2bc526f..5125285a2 100644 --- a/src/main/java/emu/grasscutter/game/ability/AbilityManager.java +++ b/src/main/java/emu/grasscutter/game/ability/AbilityManager.java @@ -1,7 +1,7 @@ package emu.grasscutter.game.ability; import com.google.protobuf.*; -import emu.grasscutter.Grasscutter; +import emu.grasscutter.*; import emu.grasscutter.data.GameData; import emu.grasscutter.data.binout.*; import emu.grasscutter.data.binout.AbilityModifier.AbilityModifierAction; @@ -19,13 +19,13 @@ import emu.grasscutter.net.proto.AbilityScalarTypeOuterClass.AbilityScalarType; import emu.grasscutter.net.proto.AbilityScalarValueEntryOuterClass.AbilityScalarValueEntry; import emu.grasscutter.net.proto.ModifierActionOuterClass.ModifierAction; import io.netty.util.concurrent.FastThreadLocalThread; -import java.util.HashMap; -import java.util.concurrent.*; import lombok.Getter; import org.reflections.Reflections; -public final class AbilityManager extends BasePlayerManager { +import java.util.HashMap; +import java.util.concurrent.*; +public final class AbilityManager extends BasePlayerManager { private static final HashMap actionHandlers = new HashMap<>(); private static final HashMap mixinHandlers = @@ -91,8 +91,11 @@ public final class AbilityManager extends BasePlayerManager { Ability ability, AbilityModifierAction action, ByteString abilityData, GameEntity target) { var handler = actionHandlers.get(action.type); if (handler == null || ability == null) { - Grasscutter.getLogger() + if (DebugConstants.LOG_ABILITIES) { + Grasscutter.getLogger() .debug("Could not execute ability action {} at {}", action.type, ability); + } + return; } @@ -148,7 +151,7 @@ public final class AbilityManager extends BasePlayerManager { invoke.getArgumentType(), invoke.getArgumentTypeValue(), entity.getId()); - } else { + } else if (DebugConstants.LOG_ABILITIES) { Grasscutter.getLogger() .debug( "Invoke type of {} ({}) has no entity. (referring to {})", @@ -375,7 +378,10 @@ public final class AbilityManager extends BasePlayerManager { var entity = this.player.getScene().getEntityById(invoke.getEntityId()); if (entity == null) { - Grasscutter.getLogger().debug("Entity not found: {}", invoke.getEntityId()); + if (DebugConstants.LOG_ABILITIES) { + Grasscutter.getLogger().debug("Entity not found: {}", invoke.getEntityId()); + } + return; } diff --git a/src/main/java/emu/grasscutter/scripts/data/controller/EntityController.java b/src/main/java/emu/grasscutter/scripts/data/controller/EntityController.java index 0435fe44f..4897910b9 100644 --- a/src/main/java/emu/grasscutter/scripts/data/controller/EntityController.java +++ b/src/main/java/emu/grasscutter/scripts/data/controller/EntityController.java @@ -1,14 +1,12 @@ package emu.grasscutter.scripts.data.controller; -import emu.grasscutter.Grasscutter; +import emu.grasscutter.*; import emu.grasscutter.game.entity.GameEntity; import emu.grasscutter.game.props.ElementType; -import emu.grasscutter.scripts.ScriptLib; -import emu.grasscutter.scripts.ScriptLoader; -import javax.script.Bindings; -import javax.script.CompiledScript; -import org.luaj.vm2.LuaError; -import org.luaj.vm2.LuaValue; +import emu.grasscutter.scripts.*; +import org.luaj.vm2.*; + +import javax.script.*; public class EntityController { private transient CompiledScript entityController; @@ -38,9 +36,11 @@ public class EntityController { } public int onClientExecuteRequest(GameEntity entity, int param1, int param2, int param3) { - Grasscutter.getLogger() + if (DebugConstants.LOG_LUA_SCRIPTS) { + Grasscutter.getLogger() .debug( - "Request on {}, {}: {}", entity.getGroupId(), param1, entity.getPosition().toString()); + "Request on {}, {}: {}", entity.getGroupId(), param1, entity.getPosition().toString()); + } LuaValue value = callControllerScriptFunc( entity,