Remove Log::game references on protocol level (in packet classes)

This commit is contained in:
Bixilon 2020-10-30 14:38:50 +01:00
parent ddd33e4132
commit 1a6fed4b52
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
9 changed files with 21 additions and 16 deletions

View File

@ -94,4 +94,9 @@ public class PlayerListItemBulk {
public PacketPlayerListItem.PlayerListItemActions getAction() {
return action;
}
@Override
public String toString() {
return String.format("uuid=%s, action=%s, name=%s, gameMode=%s, ping=%d, displayName=%s", getUUID(), getAction(), getName(), getGameMode(), getPing(), getDisplayName());
}
}

View File

@ -59,6 +59,9 @@ public class Log {
}
public static void log(LogLevels level, String prefix, String message, RGBColor color) {
if (message.isBlank()) {
return;
}
if (level.ordinal() > Log.level.ordinal()) {
// log level too low
return;

View File

@ -13,7 +13,6 @@
package de.bixilon.minosoft.protocol.packets.clientbound.play;
import de.bixilon.minosoft.data.GameModes;
import de.bixilon.minosoft.data.MapSet;
import de.bixilon.minosoft.data.VersionValueMap;
import de.bixilon.minosoft.logging.Log;
@ -39,12 +38,7 @@ public class PacketChangeGameState implements ClientboundPacket {
@Override
public void log() {
switch (getReason()) {
case START_RAIN -> Log.game("Received weather packet: Starting rain...");
case END_RAIN -> Log.game("Received weather packet: Stopping rain...");
case CHANGE_GAMEMODE -> Log.game(String.format("Received game mode change: Now in %s", GameModes.byId(getValue().intValue())));
default -> Log.protocol(String.format("Received game status change (%s)", getReason()));
}
Log.protocol(String.format("Received game status change (%s)", getReason()));
}
public Reason getReason() {

View File

@ -35,7 +35,7 @@ public class PacketDisconnect implements ClientboundPacket {
@Override
public void log() {
Log.game(String.format("Disconnected: %s", reason.getANSIColoredMessage()));
Log.protocol(String.format("Received disconnect packet (reason=\"%s\")", reason.getANSIColoredMessage()));
}
public ChatComponent getReason() {

View File

@ -57,7 +57,7 @@ public class PacketEntityEffect implements ClientboundPacket {
@Override
public void log() {
Log.game(String.format("Entity effect added: %d %s", entityId, effect.toString()));
Log.protocol(String.format("Entity effect added: %d %s", entityId, effect.toString()));
}
public int getEntityId() {

View File

@ -83,11 +83,7 @@ public class PacketPlayerListItem implements ClientboundPacket {
@Override
public void log() {
for (PlayerListItemBulk property : playerList) {
if (property.isLegacy()) {
Log.game(String.format("[TAB] Player list item bulk (uuid=%s, name=%s, ping=%d)", property.getUUID(), property.getName(), property.getPing()));
} else {
Log.game(String.format("[TAB] Player list item bulk (uuid=%s, action=%s, name=%s, gameMode=%s, ping=%d, displayName=%s)", property.getUUID(), property.getAction(), property.getName(), property.getGameMode(), property.getPing(), property.getDisplayName()));
}
Log.protocol(String.format("Received player list item bulk (%s)", property));
}
}

View File

@ -38,7 +38,7 @@ public class PacketRemoveEntityEffect implements ClientboundPacket {
@Override
public void log() {
Log.game(String.format("Entity effect removed (entityId=%d, effect=%s)", entityId, effect));
Log.protocol(String.format("Entity effect removed (entityId=%d, effect=%s)", entityId, effect));
}
public int getEntityId() {

View File

@ -44,7 +44,7 @@ public class PacketUpdateSignReceiving implements ClientboundPacket {
@Override
public void log() {
Log.game(String.format("Sign data received at: %s", position));
Log.protocol(String.format("Sign data received at: %s", position));
}
public BlockPosition getPosition() {

View File

@ -266,6 +266,13 @@ public class PacketHandler {
return;
}
Log.game(switch (pkg.getReason()) {
case START_RAIN -> "Received weather packet: Starting rain...";
case END_RAIN -> "Received weather packet: Stopping rain...";
case CHANGE_GAMEMODE -> String.format("Received game mode change: Now in %s", GameModes.byId(pkg.getValue().intValue()));
default -> "";
});
switch (pkg.getReason()) {
case START_RAIN -> connection.getPlayer().getWorld().setRaining(true);
case END_RAIN -> connection.getPlayer().getWorld().setRaining(false);