refactor enum to String (in messages do not use name())

This commit is contained in:
Bixilon 2020-07-21 20:52:48 +02:00
parent 3a009d5ee1
commit 4d6db77986
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
53 changed files with 79 additions and 73 deletions

View File

@ -55,7 +55,7 @@ public class Minosoft {
Log.info(String.format("Loaded config file (version=%s)", config.getInteger(GameConfiguration.CONFIG_VERSION)));
// set log level from config
Log.setLevel(LogLevel.byName(config.getString(GameConfiguration.GENERAL_LOG_LEVEL)));
Log.info(String.format("Logging info with level: %s", Log.getLevel().name()));
Log.info(String.format("Logging info with level: %s", Log.getLevel()));
Log.info("Checking assets...");
checkAssets();
Log.info("Assets checking done");

View File

@ -69,7 +69,7 @@ public class Block {
if (rotation != BlockRotation.NONE) {
out.append(" (");
out.append("rotation=");
out.append(getRotation().name());
out.append(getRotation());
}
if (properties.length > 0) {
if (out.length() > 0) {
@ -79,7 +79,7 @@ public class Block {
}
out.append("properties={");
for (BlockProperties property : properties) {
out.append(property.name());
out.append(property);
out.append(",");
}
// remove last ,
@ -89,6 +89,6 @@ public class Block {
if (out.length() > 0) {
out.append(")");
}
return String.format("%s:%s%s", getMod(), getIdentifier(), out.toString());
return String.format("%s:%s%s", getMod(), getIdentifier(), out);
}
}

View File

@ -578,7 +578,7 @@ public class Blocks {
} else {
blockIdString = String.valueOf(blockId);
}
throw new RuntimeException(String.format("Block Id %s is already present for %s! (identifier=%s, version=%s)", blockIdString, versionMapping.get(blockId), identifierName, version.name()));
throw new RuntimeException(String.format("Block Id %s is already present for %s! (identifier=%s, version=%s)", blockIdString, versionMapping.get(blockId), identifierName, version));
}
}

View File

@ -24,7 +24,7 @@ public class NoteBlockAction implements BlockAction {
@Override
public String toString() {
return String.format("NOTEBLOCK_%s:%d", instrument.name(), pitch);
return String.format("NOTEBLOCK_%s:%d", instrument, pitch);
}
public enum Instruments {

View File

@ -26,7 +26,7 @@ public class PistonAction implements BlockAction {
@Override
public String toString() {
return String.format("PISTON_%s:%s", status.name(), direction.name());
return String.format("PISTON_%s:%s", status, direction);
}
public enum PistonStates {

View File

@ -38,6 +38,6 @@ public class StatusEffect {
@Override
public String toString() {
return String.format("%s (amplifier: %d, duration: %d)", effect.name(), amplifier, duration);
return String.format("%s (amplifier: %d, duration: %d)", effect, amplifier, duration);
}
}

View File

@ -60,7 +60,7 @@ public class Slot {
public String getDisplayName() {
if (nbt != null && nbt.containsKey("display") && nbt.getCompoundTag("display").containsKey("Name")) { // check if object has nbt data, and a custom display name
return String.format("%s (%s)", new TextComponent(nbt.getCompoundTag("display").getStringTag("Name").getValue()).getColoredMessage(), item.toString());
return String.format("%s (%s)", new TextComponent(nbt.getCompoundTag("display").getStringTag("Name").getValue()).getColoredMessage(), item);
}
return item.toString(); // ToDo display name per Item (from language file)
}
@ -76,4 +76,9 @@ public class Slot {
return their.getItem().equals(getItem()) && their.getItemCount() == getItemCount() && their.getItemMetadata() == getItemMetadata();
}
@Override
public String toString() {
return getDisplayName();
}
}

View File

@ -92,7 +92,7 @@ public class Connection {
if (this.state == state) {
return;
}
Log.verbose("ConnectionStatus changed: " + state.name());
Log.verbose("ConnectionStatus changed: " + state);
this.state = state;
switch (state) {
case HANDSHAKING:

View File

@ -164,7 +164,7 @@ public class Network {
Class<? extends ClientboundPacket> clazz = Protocol.getPacketByPacket(p);
if (clazz == null) {
Log.warn(String.format("[IN] Received unknown packet (id=0x%x, name=%s, length=%d, dataLength=%d, version=%s, state=%s)", inPacketBuffer.getCommand(), ((p != null) ? p.name() : "UNKNOWN"), inPacketBuffer.getLength(), inPacketBuffer.getBytesLeft(), connection.getVersion().name(), connection.getConnectionState().name()));
Log.warn(String.format("[IN] Received unknown packet (id=0x%x, name=%s, length=%d, dataLength=%d, version=%s, state=%s)", inPacketBuffer.getCommand(), p, inPacketBuffer.getLength(), inPacketBuffer.getBytesLeft(), connection.getVersion(), connection.getConnectionState()));
continue;
}
try {
@ -178,7 +178,7 @@ public class Network {
}
if (inPacketBuffer.getBytesLeft() > 0 || !success) {
// warn not all data used
Log.warn(String.format("[IN] Could not parse packet %s (used=%d, available=%d, total=%d, success=%s)", ((p != null) ? p.name() : "null"), inPacketBuffer.getPosition(), inPacketBuffer.getBytesLeft(), inPacketBuffer.getLength(), success));
Log.warn(String.format("[IN] Could not parse packet %s (used=%d, available=%d, total=%d, success=%s)", p, inPacketBuffer.getPosition(), inPacketBuffer.getBytesLeft(), inPacketBuffer.getLength(), success));
continue;
}

View File

@ -33,7 +33,7 @@ public class PacketLoginSuccess implements ClientboundPacket {
@Override
public void log() {
Log.protocol(String.format("Receiving login success packet (username: %s, UUID: %s)", username, uuid.toString()));
Log.protocol(String.format("Receiving login success packet (username: %s, UUID: %s)", username, uuid));
}
@Override

View File

@ -54,7 +54,7 @@ public class PacketBlockEntityMetadata implements ClientboundPacket {
@Override
public void log() {
Log.protocol(String.format("Receiving blockEntityMeta (position=%s, action=%s)", position.toString(), action.name()));
Log.protocol(String.format("Receiving blockEntityMeta (position=%s, action=%s)", position, action));
}
@Override

View File

@ -78,22 +78,22 @@ public class PacketBossBar implements ClientboundPacket {
public void log() {
switch (action) {
case ADD:
Log.protocol(String.format("Received boss bar (action=%s, uuid=%s, title=\"%s\", health=%s, color=%s, divisions=%s, dragonBar=%s, darkenSky=%s)", action.name(), uuid.toString(), title.getColoredMessage(), health, color.name(), divisions.name(), isDragonBar(), shouldDarkenSky()));
Log.protocol(String.format("Received boss bar (action=%s, uuid=%s, title=\"%s\", health=%s, color=%s, divisions=%s, dragonBar=%s, darkenSky=%s)", action, uuid.toString(), title.getColoredMessage(), health, color, divisions, isDragonBar(), shouldDarkenSky()));
break;
case REMOVE:
Log.protocol(String.format("Received boss bar (action=%s, uuid=%s)", action.name(), uuid.toString()));
Log.protocol(String.format("Received boss bar (action=%s, uuid=%s)", action, uuid.toString()));
break;
case UPDATE_HEALTH:
Log.protocol(String.format("Received boss bar (action=%s, uuid=%s, health=%s)", action.name(), uuid.toString(), health));
Log.protocol(String.format("Received boss bar (action=%s, uuid=%s, health=%s)", action, uuid.toString(), health));
break;
case UPDATE_TITLE:
Log.protocol(String.format("Received boss bar (action=%s, uuid=%s, title=\"%s\")", action.name(), uuid.toString(), title.getColoredMessage()));
Log.protocol(String.format("Received boss bar (action=%s, uuid=%s, title=\"%s\")", action, uuid.toString(), title.getColoredMessage()));
break;
case UPDATE_STYLE:
Log.protocol(String.format("Received boss bar (action=%s, uuid=%s, color=%s, divisions=%s)", action.name(), uuid.toString(), color.name(), divisions.name()));
Log.protocol(String.format("Received boss bar (action=%s, uuid=%s, color=%s, divisions=%s)", action, uuid.toString(), color, divisions));
break;
case UPDATE_FLAGS:
Log.protocol(String.format("Received boss bar (action=%s, uuid=%s, dragonBar=%s, darkenSky=%s)", action.name(), uuid.toString(), isDragonBar(), shouldDarkenSky()));
Log.protocol(String.format("Received boss bar (action=%s, uuid=%s, dragonBar=%s, darkenSky=%s)", action, uuid.toString(), isDragonBar(), shouldDarkenSky()));
break;
}
}

View File

@ -55,10 +55,10 @@ public class PacketChangeGameState implements ClientboundPacket {
Log.game("Received weather packet: Stopping rain...");
break;
case CHANGE_GAMEMODE:
Log.game(String.format("Received game mode change: Now in %s", GameMode.byId(getValue().intValue()).name()));
Log.game(String.format("Received game mode change: Now in %s", GameMode.byId(getValue().intValue())));
break;
default:
Log.protocol(String.format("Received game status change (%s)", getReason().name()));
Log.protocol(String.format("Received game status change (%s)", getReason()));
break;
}
}

View File

@ -58,13 +58,13 @@ public class PacketCombatEvent implements ClientboundPacket {
public void log() {
switch (action) {
case ENTER_COMBAT:
Log.protocol(String.format("Received combat packet (action=%s)", action.name()));
Log.protocol(String.format("Received combat packet (action=%s)", action));
break;
case END_COMBAT:
Log.protocol(String.format("Received combat packet (action=%s, duration=%d, entityId=%d)", action.name(), duration, entityId));
Log.protocol(String.format("Received combat packet (action=%s, duration=%d, entityId=%d)", action, duration, entityId));
break;
case ENTITY_DEAD:
Log.protocol(String.format("Received combat packet (action=%s, playerId=%d, entityId=%d, message=\"%s\")", action.name(), playerId, entityId, message));
Log.protocol(String.format("Received combat packet (action=%s, playerId=%d, entityId=%d, message=\"%s\")", action, playerId, entityId, message));
break;
}

View File

@ -55,7 +55,7 @@ public class PacketEffect implements ClientboundPacket {
@Override
public void log() {
Log.protocol(String.format("Received effect packet at %s (effect=%s, data=%d, disableRelativeVolume=%s)", position.toString(), effect.name(), data, disableRelativeVolume));
Log.protocol(String.format("Received effect packet at %s (effect=%s, data=%d, disableRelativeVolume=%s)", position.toString(), effect, data, disableRelativeVolume));
}
@Override

View File

@ -45,7 +45,7 @@ public class PacketEntityAnimation implements ClientboundPacket {
@Override
public void log() {
Log.protocol(String.format("Play entity animation (entityId=%d, animation=%s)", entityId, animation.name()));
Log.protocol(String.format("Play entity animation (entityId=%d, animation=%s)", entityId, animation));
}
@Override

View File

@ -56,10 +56,10 @@ public class PacketEntityEquipment implements ClientboundPacket {
@Override
public void log() {
if (data != null) {
Log.protocol(String.format("Entity equipment changed (entityId=%d, slot=%s): %dx %s", entityId, slot.name(), data.getItemCount(), data.getDisplayName()));
Log.protocol(String.format("Entity equipment changed (entityId=%d, slot=%s): %dx %s", entityId, slot, data.getItemCount(), data.getDisplayName()));
} else {
// null means nothing, means air
Log.protocol(String.format("Entity equipment changed (entityId=%d, slot=%s): AIR", entityId, slot.name()));
Log.protocol(String.format("Entity equipment changed (entityId=%d, slot=%s): AIR", entityId, slot));
}
}

View File

@ -42,7 +42,7 @@ public class PacketEntityStatus implements ClientboundPacket {
@Override
public void log() {
Log.protocol(String.format("Entity status: (entityId=%d, animation=%s)", entityId, status.name()));
Log.protocol(String.format("Entity status: (entityId=%d, animation=%s)", entityId, status));
}
@Override

View File

@ -45,7 +45,7 @@ public class PacketFacePlayer implements ClientboundPacket {
@Override
public void log() {
Log.protocol(String.format("Received face player packet (face=%s, location=%s, entityId=%d, entityFace=%s)", face.name(), location.toString(), entityId, ((entityFace != null) ? entityFace.name() : null)));
Log.protocol(String.format("Received face player packet (face=%s, location=%s, entityId=%d, entityFace=%s)", face, location.toString(), entityId, entityFace));
}
@Override

View File

@ -100,7 +100,7 @@ public class PacketJoinGame implements ClientboundPacket {
@Override
public void log() {
Log.protocol(String.format("Receiving join game packet (entityId=%s, gameMode=%s, dimension=%s, difficulty=%s, hardcore=%s, viewDistance=%d)", entityId, gameMode.name(), dimension.name(), difficulty.name(), hardcore, viewDistance));
Log.protocol(String.format("Receiving join game packet (entityId=%s, gameMode=%s, dimension=%s, difficulty=%s, hardcore=%s, viewDistance=%d)", entityId, gameMode, dimension, difficulty, hardcore, viewDistance));
}
@Override

View File

@ -72,7 +72,7 @@ public class PacketMultiBlockChange implements ClientboundPacket {
@Override
public void log() {
Log.protocol(String.format("Multi block change received at %s (size=%d)", location.toString(), blocks.size()));
Log.protocol(String.format("Multi block change received at %s (size=%d)", location, blocks.size()));
}
@Override

View File

@ -64,7 +64,7 @@ public class PacketOpenWindow implements ClientboundPacket {
@Override
public void log() {
Log.protocol(String.format("Received inventory open packet (windowId=%d, type=%s, title=%s, entityId=%d, slotCount=%d)", windowId, type.name(), ((title == null) ? "null" : title), entityId, slotCount));
Log.protocol(String.format("Received inventory open packet (windowId=%d, type=%s, title=%s, entityId=%d, slotCount=%d)", windowId, type, title, entityId, slotCount));
}
@Override

View File

@ -93,7 +93,7 @@ public class PacketParticle implements ClientboundPacket {
@Override
public void log() {
Log.protocol(String.format("Received particle spawn at %s %s %s (particle=%s, data=%s, count=%d, dataClass=%s)", x, y, z, particle.name(), particleData, count, particleDataClass));
Log.protocol(String.format("Received particle spawn at %s %s %s (particle=%s, data=%s, count=%d, dataClass=%s)", x, y, z, particle, particleData, count, particleDataClass));
}
@Override

View File

@ -94,7 +94,7 @@ public class PacketPlayerInfo implements ClientboundPacket {
if (property.isLegacy()) {
Log.game(String.format("[TAB] Player info bulk (uuid=%s, name=%s, ping=%d)", property.getUUID(), property.getName(), property.getPing()));
} else {
Log.game(String.format("[TAB] Player info bulk (uuid=%s, action=%s, name=%s, gameMode=%s, ping=%d, displayName=%s)", property.getUUID(), property.getAction(), property.getName(), ((property.getGameMode() == null) ? "null" : property.getGameMode().name()), property.getPing(), ((property.getDisplayName() == null) ? "null" : property.getDisplayName().getColoredMessage())));
Log.game(String.format("[TAB] Player info 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()));
}
}

View File

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

View File

@ -56,7 +56,7 @@ public class PacketRespawn implements ClientboundPacket {
@Override
public void log() {
Log.protocol(String.format("Respawn packet received (dimension=%s, difficulty=%s, gamemode=%s, levelType=%s)", dimension.name(), difficulty.name(), gameMode.name(), levelType.name()));
Log.protocol(String.format("Respawn packet received (dimension=%s, difficulty=%s, gamemode=%s, levelType=%s)", dimension, difficulty, gameMode, levelType));
}
public Dimension getDimension() {

View File

@ -44,7 +44,7 @@ public class PacketScoreboardDisplayScoreboard implements ClientboundPacket {
@Override
public void log() {
Log.protocol(String.format("Received display scoreboard packet (position=%s, scoreName=\"%s\"", action.name(), scoreName));
Log.protocol(String.format("Received display scoreboard packet (position=%s, scoreName=\"%s\"", action, scoreName));
}
@Override

View File

@ -62,9 +62,9 @@ public class PacketScoreboardObjective implements ClientboundPacket {
@Override
public void log() {
if (action == ScoreboardObjectiveAction.CREATE || action == ScoreboardObjectiveAction.UPDATE) {
Log.protocol(String.format("Received scoreboard objective action (action=%s, name=\"%s\", value=\"%s\", type=%s", action.name(), name, value.getColoredMessage(), type.name));
Log.protocol(String.format("Received scoreboard objective action (action=%s, name=\"%s\", value=\"%s\", type=%s", action, name, value.getColoredMessage(), type.name));
} else {
Log.protocol(String.format("Received scoreboard objective action (action=%s, name=\"%s\")", action.name(), name));
Log.protocol(String.format("Received scoreboard objective action (action=%s, name=\"%s\")", action, name));
}
}

View File

@ -61,7 +61,7 @@ public class PacketScoreboardUpdateScore implements ClientboundPacket {
@Override
public void log() {
Log.protocol(String.format("Received scoreboard score update (itemName=\"%s\", action=%s, scoreName=\"%s\", scoreValue=%d", itemName, action.name(), scoreName, scoreValue));
Log.protocol(String.format("Received scoreboard score update (itemName=\"%s\", action=%s, scoreName=\"%s\", scoreValue=%d", itemName, action, scoreName, scoreValue));
}
@Override

View File

@ -40,7 +40,7 @@ public class PacketSelectAdvancementTab implements ClientboundPacket {
@Override
public void log() {
Log.protocol(String.format("Received select advancement tab (tab=%s)", ((tab == null) ? null : tab.name())));
Log.protocol(String.format("Received select advancement tab (tab=%s)", tab));
}
@Override

View File

@ -46,7 +46,7 @@ public class PacketServerDifficulty implements ClientboundPacket {
@Override
public void log() {
Log.protocol(String.format("Received server difficulty (difficulty=%s)", difficulty.name()));
Log.protocol(String.format("Received server difficulty (difficulty=%s)", difficulty));
}
@Override

View File

@ -101,7 +101,7 @@ public class PacketSpawnMob implements ClientboundPacket {
@Override
public void log() {
Log.protocol(String.format("Mob spawned at %s (entityId=%d, type=%s)", entity.getLocation().toString(), entity.getEntityId(), entity.getEntityType().name()));
Log.protocol(String.format("Mob spawned at %s (entityId=%d, type=%s)", entity.getLocation().toString(), entity.getEntityId(), entity.getEntityType()));
}
public Entity getMob() {

View File

@ -38,7 +38,7 @@ public class PacketSpawnObject implements ClientboundPacket {
@Override
public void log() {
Log.protocol(String.format("Object spawned at %s (entityId=%d, type=%s)", object.getLocation().toString(), object.getEntityId(), object.getEntityType().name()));
Log.protocol(String.format("Object spawned at %s (entityId=%d, type=%s)", object.getLocation().toString(), object.getEntityId(), object.getEntityType()));
}
public Entity getObject() {

View File

@ -68,7 +68,7 @@ public class PacketSpawnPainting implements ClientboundPacket {
@Override
public void log() {
Log.protocol(String.format("Spawning painting at %s (entityId=%d, painting=%s, direction=%d)", position.toString(), entityId, painting.name(), direction));
Log.protocol(String.format("Spawning painting at %s (entityId=%d, painting=%s, direction=%d)", position.toString(), entityId, painting, direction));
}
@Override

View File

@ -128,7 +128,7 @@ public class PacketTeams implements ClientboundPacket {
@Override
public void log() {
Log.protocol(String.format("Received scoreboard Team update (name=\"%s\", action=%s, displayName=\"%s\", prefix=\"%s\", suffix=\"%s\", friendlyFire=%s, seeFriendlyInvisibiles=%s, playerCount=%s)", name, action.name(), ((displayName == null) ? null : displayName.getColoredMessage()), prefix, suffix, friendlyFire, seeFriendlyInvisibles, ((playerNames == null) ? "null" : playerNames.length)));
Log.protocol(String.format("Received scoreboard Team update (name=\"%s\", action=%s, displayName=\"%s\", prefix=\"%s\", suffix=\"%s\", friendlyFire=%s, seeFriendlyInvisibiles=%s, playerCount=%s)", name, action, displayName, prefix, suffix, friendlyFire, seeFriendlyInvisibles, ((playerNames == null) ? null : playerNames.length)));
}
@Override

View File

@ -66,17 +66,17 @@ public class PacketTitle implements ClientboundPacket {
public void log() {
switch (action) {
case SET_TITLE:
Log.protocol(String.format("Received title (action=%s, text=%s)", action.name(), text.getColoredMessage()));
Log.protocol(String.format("Received title (action=%s, text=%s)", action, text.getColoredMessage()));
break;
case SET_SUBTITLE:
Log.protocol(String.format("Received title (action=%s, subText=%s)", action.name(), subText.getColoredMessage()));
Log.protocol(String.format("Received title (action=%s, subText=%s)", action, subText.getColoredMessage()));
break;
case SET_TIMES_AND_DISPLAY:
Log.protocol(String.format("Received title (action=%s, fadeInTime=%d, stayTime=%d, fadeOutTime=%d)", action.name(), fadeInTime, stayTime, fadeOutTime));
Log.protocol(String.format("Received title (action=%s, fadeInTime=%d, stayTime=%d, fadeOutTime=%d)", action, fadeInTime, stayTime, fadeOutTime));
break;
case HIDE:
case RESET:
Log.protocol(String.format("Received title (action=%s)", action.name()));
Log.protocol(String.format("Received title (action=%s)", action));
break;
}
}

View File

@ -71,7 +71,7 @@ public class PacketUnlockRecipes implements ClientboundPacket {
@Override
public void log() {
Log.protocol(String.format("Received unlock crafting recipe packet (action=%s, isCraftingBookOpen=%s, isFilteringActive=%s, isSmeltingBookOpen=%s, isSmeltingFilteringActive=%s listedLength=%d, taggedLength=%s)", action.name(), isCraftingBookOpen, isCraftingFilteringActive, isSmeltingBookOpen, isSmeltingFilteringActive, listed.length, ((tagged == null) ? 0 : tagged.length)));
Log.protocol(String.format("Received unlock crafting recipe packet (action=%s, isCraftingBookOpen=%s, isFilteringActive=%s, isSmeltingBookOpen=%s, isSmeltingFilteringActive=%s listedLength=%d, taggedLength=%s)", action, isCraftingBookOpen, isCraftingFilteringActive, isSmeltingBookOpen, isSmeltingFilteringActive, listed.length, ((tagged == null) ? 0 : tagged.length)));
}
@Override

View File

@ -49,7 +49,7 @@ public class PacketAdvancementTab implements ServerboundPacket {
@Override
public void log() {
Log.protocol(String.format("Sending advancement tab packet (action=%s, tabToOpen=%s)", action.name(), tabToOpen));
Log.protocol(String.format("Sending advancement tab packet (action=%s, tabToOpen=%s)", action, tabToOpen));
}

View File

@ -47,6 +47,6 @@ public class PacketAnimation implements ServerboundPacket {
@Override
public void log() {
Log.protocol(String.format("Sending hand animation (hand=%s)", hand.name()));
Log.protocol(String.format("Sending hand animation (hand=%s)", hand));
}
}

View File

@ -61,7 +61,7 @@ public class PacketClickWindow implements ServerboundPacket {
@Override
public void log() {
Log.protocol(String.format("Clicking in window (windowId=%d, slot=%d, action=%s)", windowId, slot, action.name()));
Log.protocol(String.format("Clicking in window (windowId=%d, slot=%d, action=%s)", windowId, slot, action));
}
}

View File

@ -49,7 +49,7 @@ public class PacketClientStatus implements ServerboundPacket {
@Override
public void log() {
Log.protocol(String.format("Sending client status packet (status=%s)", status.name()));
Log.protocol(String.format("Sending client status packet (status=%s)", status));
}
public enum ClientStatus {

View File

@ -65,10 +65,10 @@ public class PacketCraftingBookData implements ServerboundPacket {
public void log() {
switch (action) {
case DISPLAY_RECIPE:
Log.protocol(String.format("Sending crafting book status (action=%s, recipeId=%d)", action.name(), recipeId));
Log.protocol(String.format("Sending crafting book status (action=%s, recipeId=%d)", action, recipeId));
break;
case CRAFTING_BOOK_STATUS:
Log.protocol(String.format("Sending crafting book status (action=%s, craftingBookOpen=%s, craftingFilter=%s)", action.name(), craftingBookOpen, craftingFilter));
Log.protocol(String.format("Sending crafting book status (action=%s, craftingBookOpen=%s, craftingFilter=%s)", action, craftingBookOpen, craftingFilter));
break;
}
}

View File

@ -65,7 +65,7 @@ public class PacketEntityAction implements ServerboundPacket {
@Override
public void log() {
Log.protocol(String.format("Sending entity action packet (entityId=%d, action=%s, parameter=%d)", entityId, action.name(), parameter));
Log.protocol(String.format("Sending entity action packet (entityId=%d, action=%s, parameter=%d)", entityId, action, parameter));
}
public enum EntityActions {

View File

@ -97,7 +97,7 @@ public class PacketInteractEntity implements ServerboundPacket {
@Override
public void log() {
Log.protocol(String.format("Interacting with entity (entityId=%d, click=%s)", entityId, click.name()));
Log.protocol(String.format("Interacting with entity (entityId=%d, click=%s)", entityId, click));
}
public enum Click {

View File

@ -103,6 +103,6 @@ public class PacketPlayerBlockPlacement implements ServerboundPacket {
@Override
public void log() {
Log.protocol(String.format("Send player block placement(position=%s, direction=%d, item=%s, cursor=%d %d %d)", position.toString(), direction, ((item == null) ? "AIR" : item.getDisplayName()), cursorX, cursorY, cursorZ));
Log.protocol(String.format("Send player block placement(position=%s, direction=%d, item=%s, cursor=%s %s %s)", position.toString(), direction, item, cursorX, cursorY, cursorZ));
}
}

View File

@ -76,7 +76,7 @@ public class PacketPlayerDigging implements ServerboundPacket {
@Override
public void log() {
Log.protocol(String.format("Send player digging packet (status=%s, position=%s, face=%s)", status.name(), position.toString(), face.name()));
Log.protocol(String.format("Send player digging packet (status=%s, position=%s, face=%s)", status, position.toString(), face));
}
public enum DiggingStatus {

View File

@ -50,7 +50,7 @@ public class PacketResourcePackStatus implements ServerboundPacket {
@Override
public void log() {
Log.protocol(String.format("Sending resource pack status (status=%s, hash=%s)", status.name(), hash));
Log.protocol(String.format("Sending resource pack status (status=%s, hash=%s)", status, hash));
}
public enum ResourcePackStatus {

View File

@ -67,7 +67,7 @@ public class PacketUpdateCommandBlock implements ServerboundPacket {
@Override
public void log() {
Log.protocol(String.format("Sending update command block packet at %s (command=\"%s\", type=%s, trackOutput=%s, isConditional=%s, isAutomatic=%s)", position.toString(), command, type.name(), trackOutput, isConditional, isAutomatic));
Log.protocol(String.format("Sending update command block packet at %s (command=\"%s\", type=%s, trackOutput=%s, isConditional=%s, isAutomatic=%s)", position.toString(), command, type, trackOutput, isConditional, isAutomatic));
}
public enum CommandBlockType {

View File

@ -45,6 +45,6 @@ public class PacketUseItem implements ServerboundPacket {
@Override
public void log() {
Log.protocol(String.format("Use hand (hand=%s)", hand.name()));
Log.protocol(String.format("Use hand (hand=%s)", hand));
}
}

View File

@ -20,8 +20,7 @@ public enum ConnectionState {
LOGIN(2),
PLAY(3),
DISCONNECTING(5),
DISCONNECTED(6),
UNKNOWN(7);
DISCONNECTED(6);
final int id;
@ -33,12 +32,12 @@ public enum ConnectionState {
return this.id;
}
public static ConnectionState getById(int id) {
public static ConnectionState byId(int id) {
for (ConnectionState state : values()) {
if (state.getId() == id) {
return state;
}
}
return ConnectionState.UNKNOWN;
return null;
}
}

View File

@ -72,7 +72,6 @@ public class Packets {
Serverbound() {
this.state = ConnectionState.valueOf(name().split("_")[0]);
}
public ConnectionState getState() {
@ -191,7 +190,6 @@ public class Packets {
Clientbound() {
this.state = ConnectionState.valueOf(name().split("_")[0]);
}
public ConnectionState getState() {

View File

@ -80,4 +80,8 @@ public enum ProtocolVersion {
return protocol.getReleaseName();
}
@Override
public String toString() {
return getVersionString();
}
}

View File

@ -50,7 +50,7 @@ public class Protocol_1_14_4 extends Protocol {
registerPacket(Packets.Clientbound.PLAY_SET_COOLDOWN, 0x17);
registerPacket(Packets.Clientbound.PLAY_PLUGIN_MESSAGE, 0x18);
registerPacket(Packets.Clientbound.PLAY_NAMED_SOUND_EFFECT, 0x19);
registerPacket(Packets.Clientbound.PLAY_DISCONNECT, 0x1AA);
registerPacket(Packets.Clientbound.PLAY_DISCONNECT, 0x1A);
registerPacket(Packets.Clientbound.PLAY_ENTITY_STATUS, 0x1B);
registerPacket(Packets.Clientbound.PLAY_EXPLOSION, 0x1C);
registerPacket(Packets.Clientbound.PLAY_UNLOAD_CHUNK, 0x1D);