mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-01-09 03:42:57 +08:00
Add way to toggle certain spam logs
This commit is contained in:
parent
70e6d7f334
commit
afc5841596
10
src/main/java/emu/grasscutter/DebugConstants.java
Normal file
10
src/main/java/emu/grasscutter/DebugConstants.java
Normal 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.
|
||||||
|
}
|
||||||
|
}
|
@ -1,7 +1,7 @@
|
|||||||
package emu.grasscutter.game.ability;
|
package emu.grasscutter.game.ability;
|
||||||
|
|
||||||
import com.google.protobuf.*;
|
import com.google.protobuf.*;
|
||||||
import emu.grasscutter.Grasscutter;
|
import emu.grasscutter.*;
|
||||||
import emu.grasscutter.data.GameData;
|
import emu.grasscutter.data.GameData;
|
||||||
import emu.grasscutter.data.binout.*;
|
import emu.grasscutter.data.binout.*;
|
||||||
import emu.grasscutter.data.binout.AbilityModifier.AbilityModifierAction;
|
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.AbilityScalarValueEntryOuterClass.AbilityScalarValueEntry;
|
||||||
import emu.grasscutter.net.proto.ModifierActionOuterClass.ModifierAction;
|
import emu.grasscutter.net.proto.ModifierActionOuterClass.ModifierAction;
|
||||||
import io.netty.util.concurrent.FastThreadLocalThread;
|
import io.netty.util.concurrent.FastThreadLocalThread;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.concurrent.*;
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.reflections.Reflections;
|
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 =
|
private static final HashMap<AbilityModifierAction.Type, AbilityActionHandler> actionHandlers =
|
||||||
new HashMap<>();
|
new HashMap<>();
|
||||||
private static final HashMap<AbilityMixinData.Type, AbilityMixinHandler> mixinHandlers =
|
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) {
|
Ability ability, AbilityModifierAction action, ByteString abilityData, GameEntity target) {
|
||||||
var handler = actionHandlers.get(action.type);
|
var handler = actionHandlers.get(action.type);
|
||||||
if (handler == null || ability == null) {
|
if (handler == null || ability == null) {
|
||||||
Grasscutter.getLogger()
|
if (DebugConstants.LOG_ABILITIES) {
|
||||||
|
Grasscutter.getLogger()
|
||||||
.debug("Could not execute ability action {} at {}", action.type, ability);
|
.debug("Could not execute ability action {} at {}", action.type, ability);
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -148,7 +151,7 @@ public final class AbilityManager extends BasePlayerManager {
|
|||||||
invoke.getArgumentType(),
|
invoke.getArgumentType(),
|
||||||
invoke.getArgumentTypeValue(),
|
invoke.getArgumentTypeValue(),
|
||||||
entity.getId());
|
entity.getId());
|
||||||
} else {
|
} else if (DebugConstants.LOG_ABILITIES) {
|
||||||
Grasscutter.getLogger()
|
Grasscutter.getLogger()
|
||||||
.debug(
|
.debug(
|
||||||
"Invoke type of {} ({}) has no entity. (referring to {})",
|
"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());
|
var entity = this.player.getScene().getEntityById(invoke.getEntityId());
|
||||||
if (entity == null) {
|
if (entity == null) {
|
||||||
Grasscutter.getLogger().debug("Entity not found: {}", invoke.getEntityId());
|
if (DebugConstants.LOG_ABILITIES) {
|
||||||
|
Grasscutter.getLogger().debug("Entity not found: {}", invoke.getEntityId());
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,14 +1,12 @@
|
|||||||
package emu.grasscutter.scripts.data.controller;
|
package emu.grasscutter.scripts.data.controller;
|
||||||
|
|
||||||
import emu.grasscutter.Grasscutter;
|
import emu.grasscutter.*;
|
||||||
import emu.grasscutter.game.entity.GameEntity;
|
import emu.grasscutter.game.entity.GameEntity;
|
||||||
import emu.grasscutter.game.props.ElementType;
|
import emu.grasscutter.game.props.ElementType;
|
||||||
import emu.grasscutter.scripts.ScriptLib;
|
import emu.grasscutter.scripts.*;
|
||||||
import emu.grasscutter.scripts.ScriptLoader;
|
import org.luaj.vm2.*;
|
||||||
import javax.script.Bindings;
|
|
||||||
import javax.script.CompiledScript;
|
import javax.script.*;
|
||||||
import org.luaj.vm2.LuaError;
|
|
||||||
import org.luaj.vm2.LuaValue;
|
|
||||||
|
|
||||||
public class EntityController {
|
public class EntityController {
|
||||||
private transient CompiledScript entityController;
|
private transient CompiledScript entityController;
|
||||||
@ -38,9 +36,11 @@ public class EntityController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int onClientExecuteRequest(GameEntity entity, int param1, int param2, int param3) {
|
public int onClientExecuteRequest(GameEntity entity, int param1, int param2, int param3) {
|
||||||
Grasscutter.getLogger()
|
if (DebugConstants.LOG_LUA_SCRIPTS) {
|
||||||
|
Grasscutter.getLogger()
|
||||||
.debug(
|
.debug(
|
||||||
"Request on {}, {}: {}", entity.getGroupId(), param1, entity.getPosition().toString());
|
"Request on {}, {}: {}", entity.getGroupId(), param1, entity.getPosition().toString());
|
||||||
|
}
|
||||||
LuaValue value =
|
LuaValue value =
|
||||||
callControllerScriptFunc(
|
callControllerScriptFunc(
|
||||||
entity,
|
entity,
|
||||||
|
Loading…
Reference in New Issue
Block a user