diff --git a/common/src/main/java/com/viaversion/viabackwards/api/entities/storage/EntityPositionHandler.java b/common/src/main/java/com/viaversion/viabackwards/api/entities/storage/EntityPositionHandler.java index 9880f19d..70741e84 100644 --- a/common/src/main/java/com/viaversion/viabackwards/api/entities/storage/EntityPositionHandler.java +++ b/common/src/main/java/com/viaversion/viabackwards/api/entities/storage/EntityPositionHandler.java @@ -17,13 +17,13 @@ */ package com.viaversion.viabackwards.api.entities.storage; -import com.viaversion.viabackwards.ViaBackwards; import com.viaversion.viabackwards.api.rewriters.EntityRewriterBase; import com.viaversion.viaversion.api.Via; import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.data.entity.StoredEntityData; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.type.Types; +import com.viaversion.viaversion.util.ProtocolLogger; import java.util.function.Supplier; public class EntityPositionHandler { @@ -51,12 +51,13 @@ public class EntityPositionHandler { StoredEntityData storedEntity = entityRewriter.tracker(wrapper.user()).entityData(entityId); if (storedEntity == null) { if (Via.getManager().isDebug()) { // There is too many plugins violating this out there, and reading seems to be hard! :> - ViaBackwards.getPlatform().getLogger().warning("Stored entity with id " + entityId + " missing at position: " + x + " - " + y + " - " + z + " in " + storageClass.getSimpleName()); + ProtocolLogger logger = entityRewriter.protocol().getLogger(); + logger.warning("Stored entity with id " + entityId + " missing at position: " + x + " - " + y + " - " + z + " in " + storageClass.getSimpleName()); if (entityId == -1 && x == 0 && y == 0 && z == 0) { - ViaBackwards.getPlatform().getLogger().warning("DO NOT REPORT THIS TO VIA, THIS IS A PLUGIN ISSUE"); + logger.warning("DO NOT REPORT THIS TO VIA, THIS IS A PLUGIN ISSUE"); } else if (!warnedForMissingEntity) { warnedForMissingEntity = true; - ViaBackwards.getPlatform().getLogger().warning("This is very likely caused by a plugin sending a teleport packet for an entity outside of the player's range."); + logger.warning("This is very likely caused by a plugin sending a teleport packet for an entity outside of the player's range."); } } return; @@ -69,7 +70,7 @@ public class EntityPositionHandler { } else { positionStorage = storedEntity.get(storageClass); if (positionStorage == null) { - ViaBackwards.getPlatform().getLogger().warning("Stored entity with id " + entityId + " missing " + storageClass.getSimpleName()); + entityRewriter.protocol().getLogger().warning("Stored entity with id " + entityId + " missing " + storageClass.getSimpleName()); return; } } @@ -81,7 +82,7 @@ public class EntityPositionHandler { StoredEntityData storedEntity = entityRewriter.tracker(user).entityData(entityId); EntityPositionStorage entityStorage; if (storedEntity == null || (entityStorage = storedEntity.get(EntityPositionStorage.class)) == null) { - ViaBackwards.getPlatform().getLogger().warning("Untracked entity with id " + entityId + " in " + storageClass.getSimpleName()); + entityRewriter.protocol().getLogger().warning("Untracked entity with id " + entityId + " in " + storageClass.getSimpleName()); return null; } return entityStorage; diff --git a/common/src/main/java/com/viaversion/viabackwards/api/rewriters/LegacyEntityRewriter.java b/common/src/main/java/com/viaversion/viabackwards/api/rewriters/LegacyEntityRewriter.java index bdaf60a3..0562411c 100644 --- a/common/src/main/java/com/viaversion/viabackwards/api/rewriters/LegacyEntityRewriter.java +++ b/common/src/main/java/com/viaversion/viabackwards/api/rewriters/LegacyEntityRewriter.java @@ -156,7 +156,7 @@ public abstract class LegacyEntityRewriter { ObjectType type = objectGetter.apply(wrapper.get(Types.BYTE, 0)); if (type == null) { - ViaBackwards.getPlatform().getLogger().warning("Could not find Entity Type" + wrapper.get(Types.BYTE, 0)); + protocol.getLogger().warning("Could not find Entity Type" + wrapper.get(Types.BYTE, 0)); return; } diff --git a/common/src/main/java/com/viaversion/viabackwards/api/rewriters/TranslatableRewriter.java b/common/src/main/java/com/viaversion/viabackwards/api/rewriters/TranslatableRewriter.java index d82bbd9f..1b3ad676 100644 --- a/common/src/main/java/com/viaversion/viabackwards/api/rewriters/TranslatableRewriter.java +++ b/common/src/main/java/com/viaversion/viabackwards/api/rewriters/TranslatableRewriter.java @@ -55,7 +55,7 @@ public class TranslatableRewriter extends Compo super(protocol, type); final Map translatableMappings = TRANSLATABLES.get(sectionIdentifier); if (translatableMappings == null) { - ViaBackwards.getPlatform().getLogger().warning("Missing " + sectionIdentifier + " translatables!"); + protocol.getLogger().warning("Missing " + sectionIdentifier + " translatables!"); this.translatables = new HashMap<>(); } else { this.translatables = translatableMappings; diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_13_1to1_13/rewriter/EntityPacketRewriter1_13_1.java b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_13_1to1_13/rewriter/EntityPacketRewriter1_13_1.java index b668e92e..f2839ae1 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_13_1to1_13/rewriter/EntityPacketRewriter1_13_1.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_13_1to1_13/rewriter/EntityPacketRewriter1_13_1.java @@ -17,7 +17,6 @@ */ package com.viaversion.viabackwards.protocol.v1_13_1to1_13.rewriter; -import com.viaversion.viabackwards.ViaBackwards; import com.viaversion.viabackwards.api.rewriters.LegacyEntityRewriter; import com.viaversion.viabackwards.protocol.v1_13_1to1_13.Protocol1_13_1To1_13; import com.viaversion.viaversion.api.minecraft.Particle; @@ -26,7 +25,6 @@ import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_13; import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.api.minecraft.metadata.Metadata; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; -import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.api.type.types.version.Types1_13; import com.viaversion.viaversion.libs.gson.JsonElement; @@ -59,7 +57,7 @@ public class EntityPacketRewriter1_13_1 extends LegacyEntityRewriter { public static final BackwardsMappingData1_13 MAPPINGS = new BackwardsMappingData1_13(); + public static final ProtocolLogger LOGGER = new ProtocolLogger(Protocol1_13To1_12_2.class); private final EntityPacketRewriter1_13 entityRewriter = new EntityPacketRewriter1_13(this); private final BlockItemPacketRewriter1_13 blockItemPackets = new BlockItemPacketRewriter1_13(this); private final TranslatableRewriter translatableRewriter = new TranslatableRewriter<>(this, ComponentRewriter.ReadType.JSON) { @@ -133,6 +135,11 @@ public class Protocol1_13To1_12_2 extends BackwardsProtocol> 2; tag.putInt("Base", 15 - color); } else { - ViaBackwards.getPlatform().getLogger().warning("Why does this block have the banner block entity? :(" + tag); + Protocol1_13To1_12_2.LOGGER.warning("Why does this block have the banner block entity? :(" + tag); } // Invert colors diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_13to1_12_2/rewriter/BlockItemPacketRewriter1_13.java b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_13to1_12_2/rewriter/BlockItemPacketRewriter1_13.java index 87d593f2..b6fb2d41 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_13to1_12_2/rewriter/BlockItemPacketRewriter1_13.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_13to1_12_2/rewriter/BlockItemPacketRewriter1_13.java @@ -512,8 +512,8 @@ public class BlockItemPacketRewriter1_13 extends BackwardsItemRewriter } else { String oldChannel = ItemPacketRewriter1_13.getOldPluginChannelId(channel); if (oldChannel == null) { - if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) { - ViaBackwards.getPlatform().getLogger().warning("Ignoring clientbound plugin message with channel: " + channel); + if (!Via.getConfig().isSuppressConversionWarnings()) { + protocol.getLogger().warning("Ignoring clientbound plugin message with channel: " + channel); } wrapper.cancel(); return; @@ -118,8 +118,8 @@ public class PlayerPacketRewriter1_13 extends RewriterBase String rewritten = ItemPacketRewriter1_13.getOldPluginChannelId(s); if (rewritten != null) { rewrittenChannels.add(rewritten); - } else if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) { - ViaBackwards.getPlatform().getLogger().warning("Ignoring plugin channel in clientbound " + oldChannel + ": " + s); + } else if (!Via.getConfig().isSuppressConversionWarnings()) { + protocol.getLogger().warning("Ignoring plugin channel in clientbound " + oldChannel + ": " + s); } } wrapper.write(Types.REMAINING_BYTES, Joiner.on('\0').join(rewrittenChannels).getBytes(StandardCharsets.UTF_8)); @@ -394,7 +394,7 @@ public class PlayerPacketRewriter1_13 extends RewriterBase //Maybe older versions used this and we need to implement this? The issue is that we would have to save the command block types wrapper.setPacketType(ServerboundPackets1_13.SET_COMMAND_BLOCK); wrapper.cancel(); - ViaBackwards.getPlatform().getLogger().warning("Client send MC|AdvCmd custom payload to update command block, weird!"); + protocol.getLogger().warning("Client send MC|AdvCmd custom payload to update command block, weird!"); } else if (type == 1) { wrapper.setPacketType(ServerboundPackets1_13.SET_COMMAND_MINECART); wrapper.write(Types.VAR_INT, wrapper.read(Types.INT)); //Entity Id @@ -482,8 +482,8 @@ public class PlayerPacketRewriter1_13 extends RewriterBase default -> { String newChannel = ItemPacketRewriter1_13.getNewPluginChannelId(channel); if (newChannel == null) { - if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) { - ViaBackwards.getPlatform().getLogger().warning("Ignoring serverbound plugin message with channel: " + channel); + if (!Via.getConfig().isSuppressConversionWarnings()) { + protocol.getLogger().warning("Ignoring serverbound plugin message with channel: " + channel); } wrapper.cancel(); return; @@ -497,8 +497,8 @@ public class PlayerPacketRewriter1_13 extends RewriterBase String rewritten = ItemPacketRewriter1_13.getNewPluginChannelId(s); if (rewritten != null) { rewrittenChannels.add(rewritten); - } else if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) { - ViaBackwards.getPlatform().getLogger().warning("Ignoring plugin channel in serverbound " + Key.stripMinecraftNamespace(newChannel).toUpperCase(Locale.ROOT) + ": " + s); + } else if (!Via.getConfig().isSuppressConversionWarnings()) { + protocol.getLogger().warning("Ignoring plugin channel in serverbound " + Key.stripMinecraftNamespace(newChannel).toUpperCase(Locale.ROOT) + ": " + s); } } if (!rewrittenChannels.isEmpty()) { diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_14to1_13_2/rewriter/BlockItemPacketRewriter1_14.java b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_14to1_13_2/rewriter/BlockItemPacketRewriter1_14.java index 93354c77..69dcd6f8 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_14to1_13_2/rewriter/BlockItemPacketRewriter1_14.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_14to1_13_2/rewriter/BlockItemPacketRewriter1_14.java @@ -125,7 +125,7 @@ public class BlockItemPacketRewriter1_14 extends BackwardsItemRewriter StoredEntityData storedEntity = wrapper.user().getEntityTracker(protocol.getClass()).entityData(entityId); EntityPositionStorage1_14 entityStorage; if (storedEntity == null || (entityStorage = storedEntity.get(EntityPositionStorage1_14.class)) == null) { - ViaBackwards.getPlatform().getLogger().warning("Untracked entity with id " + entityId); + protocol.getLogger().warning("Untracked entity with id " + entityId); return; } diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_16_2to1_16_1/Protocol1_16_2To1_16_1.java b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_16_2to1_16_1/Protocol1_16_2To1_16_1.java index 176b1ed4..4bc0c4ac 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_16_2to1_16_1/Protocol1_16_2To1_16_1.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_16_2to1_16_1/Protocol1_16_2To1_16_1.java @@ -21,7 +21,7 @@ import com.viaversion.viabackwards.api.BackwardsProtocol; import com.viaversion.viabackwards.api.data.BackwardsMappingData; import com.viaversion.viabackwards.api.rewriters.SoundRewriter; import com.viaversion.viabackwards.api.rewriters.TranslatableRewriter; -import com.viaversion.viabackwards.protocol.v1_16_2to1_16_1.data.CommandRewriter1_16_2; +import com.viaversion.viabackwards.protocol.v1_16_2to1_16_1.rewriter.CommandRewriter1_16_2; import com.viaversion.viabackwards.protocol.v1_16_2to1_16_1.rewriter.BlockItemPacketRewriter1_16_2; import com.viaversion.viabackwards.protocol.v1_16_2to1_16_1.rewriter.EntityPacketRewriter1_16_2; import com.viaversion.viabackwards.protocol.v1_16_2to1_16_1.storage.BiomeStorage; @@ -40,10 +40,12 @@ import com.viaversion.viaversion.protocols.v1_16_1to1_16_2.packet.ServerboundPac import com.viaversion.viaversion.rewriter.ComponentRewriter; import com.viaversion.viaversion.rewriter.StatisticsRewriter; import com.viaversion.viaversion.rewriter.TagRewriter; +import com.viaversion.viaversion.util.ProtocolLogger; public class Protocol1_16_2To1_16_1 extends BackwardsProtocol { public static final BackwardsMappingData MAPPINGS = new BackwardsMappingData("1.16.2", "1.16", Protocol1_16_1To1_16_2.class); + public static final ProtocolLogger LOGGER = new ProtocolLogger(Protocol1_16_2To1_16_1.class); private final EntityPacketRewriter1_16_2 entityRewriter = new EntityPacketRewriter1_16_2(this); private final BlockItemPacketRewriter1_16_2 blockItemPackets = new BlockItemPacketRewriter1_16_2(this); private final TranslatableRewriter translatableRewriter = new TranslatableRewriter<>(this, ComponentRewriter.ReadType.JSON); @@ -134,6 +136,11 @@ public class Protocol1_16_2To1_16_1 extends BackwardsProtocol MODERN_TO_LEGACY_ID = new Object2IntOpenHashMap<>(); private static final Object2IntMap LEGACY_BIOMES = new Object2IntOpenHashMap<>(); @@ -121,7 +122,7 @@ public final class BiomeMappings { for (final Map.Entry entry : mappings.entrySet()) { final int legacyBiome = LEGACY_BIOMES.getInt(entry.getValue().getAsString()); if (legacyBiome == -1) { - ViaBackwards.getPlatform().getLogger().warning("Unknown legacy biome: " + entry.getValue().getAsString()); + Protocol1_16_2To1_16_1.LOGGER.warning("Unknown legacy biome: " + entry.getValue().getAsString()); continue; } @@ -137,7 +138,7 @@ public final class BiomeMappings { final int legacyBiome = MODERN_TO_LEGACY_ID.getInt(Key.stripMinecraftNamespace(biome)); if (legacyBiome == -1) { if (!Via.getConfig().isSuppressConversionWarnings()) { - ViaBackwards.getPlatform().getLogger().warning("Biome with id " + biome + " has no legacy biome mapping (custom datapack?)"); + Protocol1_16_2To1_16_1.LOGGER.warning("Biome with id " + biome + " has no legacy biome mapping (custom datapack?)"); } return 1; // Plains } diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_16_2to1_16_1/data/CommandRewriter1_16_2.java b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_16_2to1_16_1/rewriter/CommandRewriter1_16_2.java similarity index 95% rename from common/src/main/java/com/viaversion/viabackwards/protocol/v1_16_2to1_16_1/data/CommandRewriter1_16_2.java rename to common/src/main/java/com/viaversion/viabackwards/protocol/v1_16_2to1_16_1/rewriter/CommandRewriter1_16_2.java index c98f4561..358b0079 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_16_2to1_16_1/data/CommandRewriter1_16_2.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_16_2to1_16_1/rewriter/CommandRewriter1_16_2.java @@ -15,7 +15,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package com.viaversion.viabackwards.protocol.v1_16_2to1_16_1.data; +package com.viaversion.viabackwards.protocol.v1_16_2to1_16_1.rewriter; import com.viaversion.viabackwards.protocol.v1_16_2to1_16_1.Protocol1_16_2To1_16_1; import com.viaversion.viaversion.api.type.Types; diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_16_2to1_16_1/rewriter/EntityPacketRewriter1_16_2.java b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_16_2to1_16_1/rewriter/EntityPacketRewriter1_16_2.java index a0487f83..f11b48f6 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_16_2to1_16_1/rewriter/EntityPacketRewriter1_16_2.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_16_2to1_16_1/rewriter/EntityPacketRewriter1_16_2.java @@ -85,7 +85,7 @@ public class EntityPacketRewriter1_16_2 extends EntityRewriter 256 || logicalHeight.asInt() > 256) { if (warn && !warned) { - ViaBackwards.getPlatform().getLogger().warning("Increased world height is NOT SUPPORTED for 1.16 players and below. They will see a void below y 0 and above 256"); + protocol.getLogger().warning("Increased world height is NOT SUPPORTED for 1.16 players and below. They will see a void below y 0 and above 256"); warned = true; } diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_18_2to1_18/Protocol1_18_2To1_18.java b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_18_2to1_18/Protocol1_18_2To1_18.java index 570505ed..0aecec32 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_18_2to1_18/Protocol1_18_2To1_18.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_18_2to1_18/Protocol1_18_2To1_18.java @@ -45,7 +45,7 @@ public final class Protocol1_18_2To1_18 extends BackwardsProtocol