Add way to toggle certain spam logs

This commit is contained in:
KingRainbow44 2023-08-12 22:12:48 -04:00
parent 70e6d7f334
commit afc5841596
No known key found for this signature in database
GPG Key ID: FC2CB64B00D257BE
3 changed files with 32 additions and 16 deletions

View File

@ -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.
}
}

View File

@ -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<AbilityModifierAction.Type, AbilityActionHandler> actionHandlers =
new HashMap<>();
private static final HashMap<AbilityMixinData.Type, AbilityMixinHandler> 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;
}

View File

@ -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,