Stop clogging my console dawg

This commit is contained in:
Scald
2023-11-28 23:22:48 +05:30
parent 55ff4c18b1
commit f3df122170
3 changed files with 21 additions and 0 deletions

View File

@@ -130,6 +130,7 @@ public class Config {
public boolean commands = true;
public boolean connections = true;
public boolean packets = false;
public boolean loopPackets = false;
}
@Getter

View File

@@ -127,6 +127,10 @@ public class GameSession {
// Log packet
if (LunarCore.getConfig().getLogOptions().packets) {
if (LunarCore.getConfig().getLogOptions().loopPackets && CmdIdUtils.LOOP_PACKETS.contains(opcode)) {
return;
}
logPacket("RECV", opcode, data);
}
@@ -152,6 +156,10 @@ public class GameSession {
// Log
if (LunarCore.getConfig().getLogOptions().packets) {
if (LunarCore.getConfig().getLogOptions().loopPackets && CmdIdUtils.LOOP_PACKETS.contains(packet.getOpcode())) {
return;
}
logPacket("SEND", packet.getOpcode(), packet.getData());
}
}
@@ -167,6 +175,10 @@ public class GameSession {
// Log
if (LunarCore.getConfig().getLogOptions().packets) {
if (LunarCore.getConfig().getLogOptions().loopPackets && CmdIdUtils.LOOP_PACKETS.contains(cmdId)) {
return;
}
logPacket("SEND", cmdId, null);
}
}

View File

@@ -4,6 +4,7 @@ import java.io.FileWriter;
import java.io.IOException;
import java.lang.reflect.Field;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import java.util.stream.Collectors;
@@ -14,6 +15,13 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
public class CmdIdUtils {
public static final Set<Integer> LOOP_PACKETS = Set.of(
CmdId.PlayerHeartBeatCsReq,
CmdId.PlayerHeartBeatScRsp,
CmdId.SceneEntityMoveCsReq,
CmdId.SceneEntityMoveScRsp
);
private static Int2ObjectMap<String> opcodeMap;
static {