From 3b932bd6b3f59b0d4f31d0352d157d3e094065d0 Mon Sep 17 00:00:00 2001 From: Gerrygames Date: Tue, 7 May 2019 18:19:34 +0200 Subject: [PATCH 1/9] 1.14.1 pre1 --- bukkit/pom.xml | 2 +- bungee/pom.xml | 2 +- common/pom.xml | 2 +- .../api/protocol/ProtocolRegistry.java | 2 + .../api/protocol/ProtocolVersion.java | 2 + .../MetadataRewriter.java | 33 ++++++ .../Protocol1_14_1To1_14.java | 19 ++++ .../packets/EntityPackets.java | 101 ++++++++++++++++++ .../storage/EntityTracker.java | 45 ++++++++ jar/pom.xml | 2 +- pom.xml | 2 +- sponge-legacy/pom.xml | 2 +- sponge/pom.xml | 2 +- velocity/pom.xml | 2 +- 14 files changed, 210 insertions(+), 8 deletions(-) create mode 100644 common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14_1to1_14/MetadataRewriter.java create mode 100644 common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14_1to1_14/Protocol1_14_1To1_14.java create mode 100644 common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14_1to1_14/packets/EntityPackets.java create mode 100644 common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14_1to1_14/storage/EntityTracker.java diff --git a/bukkit/pom.xml b/bukkit/pom.xml index cfae64176..07f87bfb2 100644 --- a/bukkit/pom.xml +++ b/bukkit/pom.xml @@ -5,7 +5,7 @@ viaversion-parent us.myles - 2.0.2-SNAPSHOT + 2.1.0-1.14.1-pre1 4.0.0 diff --git a/bungee/pom.xml b/bungee/pom.xml index 5a9fdd1fd..d195808c6 100644 --- a/bungee/pom.xml +++ b/bungee/pom.xml @@ -5,7 +5,7 @@ viaversion-parent us.myles - 2.0.2-SNAPSHOT + 2.1.0-1.14.1-pre1 4.0.0 diff --git a/common/pom.xml b/common/pom.xml index d55c461bf..0d150ef17 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -5,7 +5,7 @@ viaversion-parent us.myles - 2.0.2-SNAPSHOT + 2.1.0-1.14.1-pre1 4.0.0 diff --git a/common/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolRegistry.java b/common/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolRegistry.java index c77885625..a56806bc3 100644 --- a/common/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolRegistry.java +++ b/common/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolRegistry.java @@ -15,6 +15,7 @@ import us.myles.ViaVersion.protocols.protocol1_12_2to1_12_1.Protocol1_12_2To1_12 import us.myles.ViaVersion.protocols.protocol1_12to1_11_1.Protocol1_12To1_11_1; import us.myles.ViaVersion.protocols.protocol1_13_2to1_13_1.Protocol1_13_2To1_13_1; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.Protocol1_13To1_12_2; +import us.myles.ViaVersion.protocols.protocol1_14_1to1_14.Protocol1_14_1To1_14; import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.Protocol1_14To1_13_2; import us.myles.ViaVersion.protocols.protocol1_9_1_2to1_9_3_4.Protocol1_9_1_2To1_9_3_4; import us.myles.ViaVersion.protocols.protocol1_9_1to1_9.Protocol1_9_1To1_9; @@ -62,6 +63,7 @@ public class ProtocolRegistry { registerProtocol(new Protocol1_13_2To1_13_1(), Arrays.asList(ProtocolVersion.v1_13_2.getId()), ProtocolVersion.v1_13_1.getId()); registerProtocol(new Protocol1_14To1_13_2(), Arrays.asList(ProtocolVersion.v1_14.getId()), ProtocolVersion.v1_13_2.getId()); + registerProtocol(new Protocol1_14_1To1_14(), Arrays.asList(ProtocolVersion.v1_14_1.getId()), ProtocolVersion.v1_14.getId()); } /** diff --git a/common/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolVersion.java b/common/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolVersion.java index e43721e4b..5242a42f4 100644 --- a/common/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolVersion.java +++ b/common/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolVersion.java @@ -36,6 +36,7 @@ public class ProtocolVersion { public static final ProtocolVersion v1_13_1; public static final ProtocolVersion v1_13_2; public static final ProtocolVersion v1_14; + public static final ProtocolVersion v1_14_1; public static final ProtocolVersion unknown; private final int id; @@ -68,6 +69,7 @@ public class ProtocolVersion { register(v1_13_1 = new ProtocolVersion(401, "1.13.1")); register(v1_13_2 = new ProtocolVersion(404, "1.13.2")); register(v1_14 = new ProtocolVersion(477, "1.14")); + register(v1_14_1 = new ProtocolVersion(478, "1.14.1")); register(unknown = new ProtocolVersion(-1, "UNKNOWN")); } diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14_1to1_14/MetadataRewriter.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14_1to1_14/MetadataRewriter.java new file mode 100644 index 000000000..f8724e2d5 --- /dev/null +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14_1to1_14/MetadataRewriter.java @@ -0,0 +1,33 @@ +package us.myles.ViaVersion.protocols.protocol1_14_1to1_14; + +import us.myles.ViaVersion.api.Via; +import us.myles.ViaVersion.api.data.UserConnection; +import us.myles.ViaVersion.api.entities.Entity1_14Types; +import us.myles.ViaVersion.api.minecraft.metadata.Metadata; + +import java.util.ArrayList; +import java.util.List; + +public class MetadataRewriter { + + public static void handleMetadata(int entityId, Entity1_14Types.EntityType type, List metadatas, UserConnection connection) { + if (type == null) return; + + for (Metadata metadata : new ArrayList<>(metadatas)) { + try { + if (type.is(Entity1_14Types.EntityType.VILLAGER) || type.is(Entity1_14Types.EntityType.WANDERING_TRADER)) { + if (metadata.getId() >= 15) { + metadata.setId(metadata.getId() + 1); + } + } + } catch (Exception e) { + metadatas.remove(metadata); + if (!Via.getConfig().isSuppressMetadataErrors() || Via.getManager().isDebug()) { + Via.getPlatform().getLogger().warning("An error occurred with entity metadata handler"); + Via.getPlatform().getLogger().warning("Metadata: " + metadata); + e.printStackTrace(); + } + } + } + } +} diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14_1to1_14/Protocol1_14_1To1_14.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14_1to1_14/Protocol1_14_1To1_14.java new file mode 100644 index 000000000..77b4182ef --- /dev/null +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14_1to1_14/Protocol1_14_1To1_14.java @@ -0,0 +1,19 @@ +package us.myles.ViaVersion.protocols.protocol1_14_1to1_14; + +import us.myles.ViaVersion.api.data.UserConnection; +import us.myles.ViaVersion.api.protocol.Protocol; +import us.myles.ViaVersion.protocols.protocol1_14_1to1_14.packets.EntityPackets; +import us.myles.ViaVersion.protocols.protocol1_14_1to1_14.storage.EntityTracker; + +public class Protocol1_14_1To1_14 extends Protocol { + + @Override + protected void registerPackets() { + EntityPackets.register(this); + } + + @Override + public void init(UserConnection userConnection) { + userConnection.put(new EntityTracker(userConnection)); + } +} diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14_1to1_14/packets/EntityPackets.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14_1to1_14/packets/EntityPackets.java new file mode 100644 index 000000000..7d7373909 --- /dev/null +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14_1to1_14/packets/EntityPackets.java @@ -0,0 +1,101 @@ +package us.myles.ViaVersion.protocols.protocol1_14_1to1_14.packets; + +import com.google.common.base.Optional; +import us.myles.ViaVersion.api.PacketWrapper; +import us.myles.ViaVersion.api.entities.Entity1_14Types; +import us.myles.ViaVersion.api.protocol.Protocol; +import us.myles.ViaVersion.api.remapper.PacketHandler; +import us.myles.ViaVersion.api.remapper.PacketRemapper; +import us.myles.ViaVersion.api.type.Type; +import us.myles.ViaVersion.api.type.types.version.Types1_14; +import us.myles.ViaVersion.packets.State; +import us.myles.ViaVersion.protocols.protocol1_14_1to1_14.MetadataRewriter; +import us.myles.ViaVersion.protocols.protocol1_14_1to1_14.storage.EntityTracker; + +public class EntityPackets { + + public static void register(Protocol protocol) { + + // Spawn Mob + protocol.registerOutgoing(State.PLAY, 0x03, 0x03, new PacketRemapper() { + @Override + public void registerMap() { + map(Type.VAR_INT); // 0 - Entity ID + map(Type.UUID); // 1 - Entity UUID + map(Type.VAR_INT); // 2 - Entity Type + map(Type.DOUBLE); // 3 - X + map(Type.DOUBLE); // 4 - Y + map(Type.DOUBLE); // 5 - Z + map(Type.BYTE); // 6 - Yaw + map(Type.BYTE); // 7 - Pitch + map(Type.BYTE); // 8 - Head Pitch + map(Type.SHORT); // 9 - Velocity X + map(Type.SHORT); // 10 - Velocity Y + map(Type.SHORT); // 11 - Velocity Z + map(Types1_14.METADATA_LIST); // 12 - Metadata + + handler(new PacketHandler() { + @Override + public void handle(PacketWrapper wrapper) throws Exception { + int entityId = wrapper.get(Type.VAR_INT, 0); + int type = wrapper.get(Type.VAR_INT, 1); + + Entity1_14Types.EntityType entType = Entity1_14Types.getTypeFromId(type); + + // Register Type ID + wrapper.user().get(EntityTracker.class).addEntity(entityId, entType); + + MetadataRewriter.handleMetadata(entityId, entType, wrapper.get(Types1_14.METADATA_LIST, 0), wrapper.user()); + } + }); + } + }); + + // Spawn Player + protocol.registerOutgoing(State.PLAY, 0x05, 0x05, new PacketRemapper() { + @Override + public void registerMap() { + map(Type.VAR_INT); // 0 - Entity ID + map(Type.UUID); // 1 - Player UUID + map(Type.DOUBLE); // 2 - X + map(Type.DOUBLE); // 3 - Y + map(Type.DOUBLE); // 4 - Z + map(Type.BYTE); // 5 - Yaw + map(Type.BYTE); // 6 - Pitch + map(Types1_14.METADATA_LIST); // 7 - Metadata + + handler(new PacketHandler() { + @Override + public void handle(PacketWrapper wrapper) throws Exception { + int entityId = wrapper.get(Type.VAR_INT, 0); + + Entity1_14Types.EntityType entType = Entity1_14Types.EntityType.PLAYER; + + // Register Type ID + wrapper.user().get(EntityTracker.class).addEntity(entityId, entType); + MetadataRewriter.handleMetadata(entityId, entType, wrapper.get(Types1_14.METADATA_LIST, 0), wrapper.user()); + } + }); + } + }); + + // Entity Metadata + protocol.registerOutgoing(State.PLAY, 0x43, 0x43, new PacketRemapper() { + @Override + public void registerMap() { + map(Type.VAR_INT); // 0 - Entity ID + map(Types1_14.METADATA_LIST); // 1 - Metadata list + + handler(new PacketHandler() { + @Override + public void handle(PacketWrapper wrapper) throws Exception { + int entityId = wrapper.get(Type.VAR_INT, 0); + + Optional type = wrapper.user().get(EntityTracker.class).get(entityId); + MetadataRewriter.handleMetadata(entityId, type.orNull(), wrapper.get(Types1_14.METADATA_LIST, 0), wrapper.user()); + } + }); + } + }); + } +} diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14_1to1_14/storage/EntityTracker.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14_1to1_14/storage/EntityTracker.java new file mode 100644 index 000000000..c28f14b49 --- /dev/null +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14_1to1_14/storage/EntityTracker.java @@ -0,0 +1,45 @@ +package us.myles.ViaVersion.protocols.protocol1_14_1to1_14.storage; + +import com.google.common.base.Optional; +import lombok.Getter; +import lombok.Setter; +import us.myles.ViaVersion.api.data.ExternalJoinGameListener; +import us.myles.ViaVersion.api.data.StoredObject; +import us.myles.ViaVersion.api.data.UserConnection; +import us.myles.ViaVersion.api.entities.Entity1_14Types; + +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +public class EntityTracker extends StoredObject implements ExternalJoinGameListener { + private final Map clientEntityTypes = new ConcurrentHashMap<>(); + @Getter + @Setter + private int clientEntityId; + + public EntityTracker(UserConnection user) { + super(user); + } + + public void removeEntity(int entityId) { + clientEntityTypes.remove(entityId); + } + + public void addEntity(int entityId, Entity1_14Types.EntityType type) { + clientEntityTypes.put(entityId, type); + } + + public boolean has(int entityId) { + return clientEntityTypes.containsKey(entityId); + } + + public Optional get(int id) { + return Optional.fromNullable(clientEntityTypes.get(id)); + } + + @Override + public void onExternalJoinGame(int playerEntityId) { + clientEntityId = playerEntityId; + clientEntityTypes.put(playerEntityId, Entity1_14Types.EntityType.PLAYER); + } +} diff --git a/jar/pom.xml b/jar/pom.xml index b81450cc3..92bb42d6e 100644 --- a/jar/pom.xml +++ b/jar/pom.xml @@ -5,7 +5,7 @@ viaversion-parent us.myles - 2.0.2-SNAPSHOT + 2.1.0-1.14.1-pre1 4.0.0 viaversion-jar diff --git a/pom.xml b/pom.xml index ee74971f7..4cc08776d 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ us.myles viaversion-parent - 2.0.2-SNAPSHOT + 2.1.0-1.14.1-pre1 pom viaversion-parent diff --git a/sponge-legacy/pom.xml b/sponge-legacy/pom.xml index d983cc973..e9088a97b 100644 --- a/sponge-legacy/pom.xml +++ b/sponge-legacy/pom.xml @@ -5,7 +5,7 @@ viaversion-parent us.myles - 2.0.2-SNAPSHOT + 2.1.0-1.14.1-pre1 4.0.0 diff --git a/sponge/pom.xml b/sponge/pom.xml index aad9f0855..30d56ba3d 100644 --- a/sponge/pom.xml +++ b/sponge/pom.xml @@ -5,7 +5,7 @@ viaversion-parent us.myles - 2.0.2-SNAPSHOT + 2.1.0-1.14.1-pre1 4.0.0 diff --git a/velocity/pom.xml b/velocity/pom.xml index cade95e88..431910fbe 100644 --- a/velocity/pom.xml +++ b/velocity/pom.xml @@ -5,7 +5,7 @@ viaversion-parent us.myles - 2.0.2-SNAPSHOT + 2.1.0-1.14.1-pre1 4.0.0 From 4d16dbf76fd611132d5bef2b9ea2c6d089fd0089 Mon Sep 17 00:00:00 2001 From: creeper123123321 Date: Wed, 8 May 2019 20:38:36 -0300 Subject: [PATCH 2/9] Not tested workaround for #1312 --- .../types/Chunk1_13Type.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/types/Chunk1_13Type.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/types/Chunk1_13Type.java index 804d69531..7c972abeb 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/types/Chunk1_13Type.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/types/Chunk1_13Type.java @@ -17,6 +17,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.BitSet; import java.util.List; +import java.util.logging.Level; public class Chunk1_13Type extends PartialType { public Chunk1_13Type(ClientWorld param) { @@ -30,7 +31,7 @@ public class Chunk1_13Type extends PartialType { boolean groundUp = input.readBoolean(); int primaryBitmask = Type.VAR_INT.read(input); - Type.VAR_INT.read(input); + ByteBuf data = input.readSlice(Type.VAR_INT.read(input)); BitSet usedSections = new BitSet(16); ChunkSection[] sections = new ChunkSection[16]; @@ -44,18 +45,23 @@ public class Chunk1_13Type extends PartialType { // Read sections for (int i = 0; i < 16; i++) { if (!usedSections.get(i)) continue; // Section not set - ChunkSection section = Types1_13.CHUNK_SECTION.read(input); + ChunkSection section = Types1_13.CHUNK_SECTION.read(data); sections[i] = section; - section.readBlockLight(input); + section.readBlockLight(data); if (world.getEnvironment() == Environment.NORMAL) { - section.readSkyLight(input); + section.readSkyLight(data); } } int[] biomeData = groundUp ? new int[256] : null; if (groundUp) { - for (int i = 0; i < 256; i++) { - biomeData[i] = input.readInt(); + try { + for (int i = 0; i < 256; i++) { + biomeData[i] = data.readInt(); + } + } catch (IndexOutOfBoundsException e) { + // Some plugin isn't sending biome data while groundUp is true, see #1312 + Via.getPlatform().getLogger().log(Level.WARNING, "IndexOutOfBoundsException while trying to read biome data", e); } } From 1fe3c337e1e74cab3b4fe69b26a2511d0fad5ac8 Mon Sep 17 00:00:00 2001 From: Gerrygames Date: Thu, 9 May 2019 17:26:56 +0200 Subject: [PATCH 3/9] 1.14-pre2 --- bukkit/pom.xml | 2 +- bungee/pom.xml | 2 +- common/pom.xml | 2 +- .../java/us/myles/ViaVersion/api/protocol/ProtocolVersion.java | 2 +- jar/pom.xml | 2 +- pom.xml | 2 +- sponge-legacy/pom.xml | 2 +- sponge/pom.xml | 2 +- velocity/pom.xml | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/bukkit/pom.xml b/bukkit/pom.xml index 07f87bfb2..e734e8b47 100644 --- a/bukkit/pom.xml +++ b/bukkit/pom.xml @@ -5,7 +5,7 @@ viaversion-parent us.myles - 2.1.0-1.14.1-pre1 + 2.1.0-1.14-pre2 4.0.0 diff --git a/bungee/pom.xml b/bungee/pom.xml index d195808c6..d5f6c1729 100644 --- a/bungee/pom.xml +++ b/bungee/pom.xml @@ -5,7 +5,7 @@ viaversion-parent us.myles - 2.1.0-1.14.1-pre1 + 2.1.0-1.14-pre2 4.0.0 diff --git a/common/pom.xml b/common/pom.xml index 0d150ef17..c173f24dd 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -5,7 +5,7 @@ viaversion-parent us.myles - 2.1.0-1.14.1-pre1 + 2.1.0-1.14-pre2 4.0.0 diff --git a/common/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolVersion.java b/common/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolVersion.java index 5242a42f4..dc0efa830 100644 --- a/common/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolVersion.java +++ b/common/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolVersion.java @@ -69,7 +69,7 @@ public class ProtocolVersion { register(v1_13_1 = new ProtocolVersion(401, "1.13.1")); register(v1_13_2 = new ProtocolVersion(404, "1.13.2")); register(v1_14 = new ProtocolVersion(477, "1.14")); - register(v1_14_1 = new ProtocolVersion(478, "1.14.1")); + register(v1_14_1 = new ProtocolVersion(479, "1.14.1")); register(unknown = new ProtocolVersion(-1, "UNKNOWN")); } diff --git a/jar/pom.xml b/jar/pom.xml index 92bb42d6e..21737cd75 100644 --- a/jar/pom.xml +++ b/jar/pom.xml @@ -5,7 +5,7 @@ viaversion-parent us.myles - 2.1.0-1.14.1-pre1 + 2.1.0-1.14-pre2 4.0.0 viaversion-jar diff --git a/pom.xml b/pom.xml index 4cc08776d..63e6e3f9c 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ us.myles viaversion-parent - 2.1.0-1.14.1-pre1 + 2.1.0-1.14-pre2 pom viaversion-parent diff --git a/sponge-legacy/pom.xml b/sponge-legacy/pom.xml index e9088a97b..bbe6ea9e3 100644 --- a/sponge-legacy/pom.xml +++ b/sponge-legacy/pom.xml @@ -5,7 +5,7 @@ viaversion-parent us.myles - 2.1.0-1.14.1-pre1 + 2.1.0-1.14-pre2 4.0.0 diff --git a/sponge/pom.xml b/sponge/pom.xml index 30d56ba3d..e98f3533e 100644 --- a/sponge/pom.xml +++ b/sponge/pom.xml @@ -5,7 +5,7 @@ viaversion-parent us.myles - 2.1.0-1.14.1-pre1 + 2.1.0-1.14-pre2 4.0.0 diff --git a/velocity/pom.xml b/velocity/pom.xml index 431910fbe..271ab145b 100644 --- a/velocity/pom.xml +++ b/velocity/pom.xml @@ -5,7 +5,7 @@ viaversion-parent us.myles - 2.1.0-1.14.1-pre1 + 2.1.0-1.14-pre2 4.0.0 From 56b48a803adbcc206c702ef97cb7ad473a98867d Mon Sep 17 00:00:00 2001 From: Gerrygames Date: Thu, 9 May 2019 18:32:53 +0200 Subject: [PATCH 4/9] 1.14.1-pre2 --- bukkit/pom.xml | 2 +- bungee/pom.xml | 2 +- common/pom.xml | 2 +- jar/pom.xml | 2 +- pom.xml | 2 +- sponge-legacy/pom.xml | 2 +- sponge/pom.xml | 2 +- velocity/pom.xml | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/bukkit/pom.xml b/bukkit/pom.xml index e734e8b47..c526cc598 100644 --- a/bukkit/pom.xml +++ b/bukkit/pom.xml @@ -5,7 +5,7 @@ viaversion-parent us.myles - 2.1.0-1.14-pre2 + 2.1.0-1.14.1-pre2 4.0.0 diff --git a/bungee/pom.xml b/bungee/pom.xml index d5f6c1729..51ada8b1b 100644 --- a/bungee/pom.xml +++ b/bungee/pom.xml @@ -5,7 +5,7 @@ viaversion-parent us.myles - 2.1.0-1.14-pre2 + 2.1.0-1.14.1-pre2 4.0.0 diff --git a/common/pom.xml b/common/pom.xml index c173f24dd..224c58434 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -5,7 +5,7 @@ viaversion-parent us.myles - 2.1.0-1.14-pre2 + 2.1.0-1.14.1-pre2 4.0.0 diff --git a/jar/pom.xml b/jar/pom.xml index 21737cd75..f97d1f3d4 100644 --- a/jar/pom.xml +++ b/jar/pom.xml @@ -5,7 +5,7 @@ viaversion-parent us.myles - 2.1.0-1.14-pre2 + 2.1.0-1.14.1-pre2 4.0.0 viaversion-jar diff --git a/pom.xml b/pom.xml index 63e6e3f9c..a98f29a9b 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ us.myles viaversion-parent - 2.1.0-1.14-pre2 + 2.1.0-1.14.1-pre2 pom viaversion-parent diff --git a/sponge-legacy/pom.xml b/sponge-legacy/pom.xml index bbe6ea9e3..ad7943632 100644 --- a/sponge-legacy/pom.xml +++ b/sponge-legacy/pom.xml @@ -5,7 +5,7 @@ viaversion-parent us.myles - 2.1.0-1.14-pre2 + 2.1.0-1.14.1-pre2 4.0.0 diff --git a/sponge/pom.xml b/sponge/pom.xml index e98f3533e..01c394237 100644 --- a/sponge/pom.xml +++ b/sponge/pom.xml @@ -5,7 +5,7 @@ viaversion-parent us.myles - 2.1.0-1.14-pre2 + 2.1.0-1.14.1-pre2 4.0.0 diff --git a/velocity/pom.xml b/velocity/pom.xml index 271ab145b..c889675f8 100644 --- a/velocity/pom.xml +++ b/velocity/pom.xml @@ -5,7 +5,7 @@ viaversion-parent us.myles - 2.1.0-1.14-pre2 + 2.1.0-1.14.1-pre2 4.0.0 From a51f3473715af0588566e7a91f46de5fc74f01e5 Mon Sep 17 00:00:00 2001 From: creeper123123321 Date: Fri, 10 May 2019 16:02:17 -0300 Subject: [PATCH 5/9] Use readableBytes --- .../protocol1_13to1_12_2/types/Chunk1_13Type.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/types/Chunk1_13Type.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/types/Chunk1_13Type.java index 7c972abeb..672fd1a34 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/types/Chunk1_13Type.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/types/Chunk1_13Type.java @@ -55,13 +55,12 @@ public class Chunk1_13Type extends PartialType { int[] biomeData = groundUp ? new int[256] : null; if (groundUp) { - try { + if (data.readableBytes() >= 256 * 4) { for (int i = 0; i < 256; i++) { biomeData[i] = data.readInt(); } - } catch (IndexOutOfBoundsException e) { - // Some plugin isn't sending biome data while groundUp is true, see #1312 - Via.getPlatform().getLogger().log(Level.WARNING, "IndexOutOfBoundsException while trying to read biome data", e); + } else { + Via.getPlatform().getLogger().log(Level.WARNING, "Chunk x="+ chunkX + " z=" + chunkZ + " doesn't have biome data!"); } } From fac7dafca5ad0592ba8be393e2af8457adaeb18b Mon Sep 17 00:00:00 2001 From: Myles Date: Sun, 12 May 2019 13:00:14 +0100 Subject: [PATCH 6/9] Use fixed locale for toUpperCase/toLower #1126 --- .../ViaVersion/bukkit/platform/BukkitViaLoader.java | 7 ++++--- .../myles/ViaVersion/commands/ViaCommandHandler.java | 8 ++++---- .../AbstractStempConnectionHandler.java | 3 ++- .../blockconnections/ChestConnectionHandler.java | 11 +++++++---- .../blockconnections/ConnectionData.java | 2 +- .../blockconnections/DoorConnectionHandler.java | 3 ++- .../blockconnections/StairConnectionHandler.java | 3 ++- .../blockconnections/TripwireConnectionHandler.java | 3 ++- .../protocol1_13to1_12_2/data/NamedSoundRewriter.java | 3 ++- .../providers/PaintingProvider.java | 3 ++- .../protocol1_9to1_8/sounds/SoundEffect.java | 3 ++- .../java/us/myles/ViaVersion/update/UpdateUtil.java | 3 ++- 12 files changed, 32 insertions(+), 20 deletions(-) diff --git a/bukkit/src/main/java/us/myles/ViaVersion/bukkit/platform/BukkitViaLoader.java b/bukkit/src/main/java/us/myles/ViaVersion/bukkit/platform/BukkitViaLoader.java index 14324fd02..ca5fc776f 100644 --- a/bukkit/src/main/java/us/myles/ViaVersion/bukkit/platform/BukkitViaLoader.java +++ b/bukkit/src/main/java/us/myles/ViaVersion/bukkit/platform/BukkitViaLoader.java @@ -30,6 +30,7 @@ import us.myles.ViaVersion.protocols.protocol1_9to1_8.providers.HandItemProvider import us.myles.ViaVersion.protocols.protocol1_9to1_8.providers.MovementTransmitterProvider; import java.util.HashSet; +import java.util.Locale; import java.util.Set; import java.util.UUID; import java.util.concurrent.Callable; @@ -85,9 +86,9 @@ public class BukkitViaLoader implements ViaPlatformLoader { } } - if ((Bukkit.getVersion().toLowerCase().contains("paper") - || Bukkit.getVersion().toLowerCase().contains("taco") - || Bukkit.getVersion().toLowerCase().contains("torch")) + if ((Bukkit.getVersion().toLowerCase(Locale.ROOT).contains("paper") + || Bukkit.getVersion().toLowerCase(Locale.ROOT).contains("taco") + || Bukkit.getVersion().toLowerCase(Locale.ROOT).contains("torch")) && ProtocolRegistry.SERVER_PROTOCOL < ProtocolVersion.v1_12.getId()) { plugin.getLogger().info("Enabling Paper/TacoSpigot/Torch patch: Fixes block placement."); storeListener(new PaperPatch(plugin)).register(); diff --git a/common/src/main/java/us/myles/ViaVersion/commands/ViaCommandHandler.java b/common/src/main/java/us/myles/ViaVersion/commands/ViaCommandHandler.java index 5610e2a50..a406835bb 100644 --- a/common/src/main/java/us/myles/ViaVersion/commands/ViaCommandHandler.java +++ b/common/src/main/java/us/myles/ViaVersion/commands/ViaCommandHandler.java @@ -28,17 +28,17 @@ public abstract class ViaCommandHandler implements ViaVersionCommand { Preconditions.checkArgument(command.name().matches("^[a-z0-9_-]{3,15}$"), command.name() + " is not a valid sub-command name."); if (hasSubCommand(command.name())) throw new Exception("ViaSubCommand " + command.name() + " does already exists!"); //Maybe another exception later. - commandMap.put(command.name().toLowerCase(), command); + commandMap.put(command.name().toLowerCase(Locale.ROOT), command); } @Override public boolean hasSubCommand(String name) { - return commandMap.containsKey(name.toLowerCase()); + return commandMap.containsKey(name.toLowerCase(Locale.ROOT)); } @Override public ViaSubCommand getSubCommand(String name) { - return commandMap.get(name.toLowerCase()); + return commandMap.get(name.toLowerCase(Locale.ROOT)); } @Override @@ -76,7 +76,7 @@ public abstract class ViaCommandHandler implements ViaVersionCommand { if (args.length == 1) { if (!args[0].isEmpty()) { for (ViaSubCommand sub : allowed) - if (sub.name().toLowerCase().startsWith(args[0].toLowerCase())) + if (sub.name().toLowerCase().startsWith(args[0].toLowerCase(Locale.ROOT))) output.add(sub.name()); } else { for (ViaSubCommand sub : allowed) diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/blockconnections/AbstractStempConnectionHandler.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/blockconnections/AbstractStempConnectionHandler.java index b949f129d..344ec1b60 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/blockconnections/AbstractStempConnectionHandler.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/blockconnections/AbstractStempConnectionHandler.java @@ -6,6 +6,7 @@ import us.myles.ViaVersion.api.minecraft.Position; import java.util.HashMap; import java.util.HashSet; +import java.util.Locale; import java.util.Map; import java.util.Set; @@ -33,7 +34,7 @@ public class AbstractStempConnectionHandler extends ConnectionHandler { ConnectionData.connectionHandlerMap.put(blockData.getSavedBlockStateId(), handler); } if (blockData.getMinecraftKey().equals(toKey)) { - String facing = blockData.getValue("facing").toUpperCase(); + String facing = blockData.getValue("facing").toUpperCase(Locale.ROOT); stemps.put(BlockFace.valueOf(facing), blockData.getSavedBlockStateId()); } } diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/blockconnections/ChestConnectionHandler.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/blockconnections/ChestConnectionHandler.java index 2cab89b9d..397ec5e97 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/blockconnections/ChestConnectionHandler.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/blockconnections/ChestConnectionHandler.java @@ -6,6 +6,7 @@ import us.myles.ViaVersion.api.minecraft.Position; import java.util.HashMap; import java.util.HashSet; +import java.util.Locale; import java.util.Map; import java.util.Set; @@ -19,10 +20,12 @@ class ChestConnectionHandler extends ConnectionHandler { return new ConnectionData.ConnectorInitAction() { @Override public void check(WrappedBlockData blockData) { - if (!blockData.getMinecraftKey().equals("minecraft:chest") && !blockData.getMinecraftKey().equals("minecraft:trapped_chest")) return; + if (!blockData.getMinecraftKey().equals("minecraft:chest") && !blockData.getMinecraftKey().equals("minecraft:trapped_chest")) + return; if (blockData.getValue("waterlogged").equals("true")) return; - chestFacings.put(blockData.getSavedBlockStateId(), BlockFace.valueOf(blockData.getValue("facing").toUpperCase())); - if (blockData.getMinecraftKey().equalsIgnoreCase("minecraft:trapped_chest")) trappedChests.add(blockData.getSavedBlockStateId()); + chestFacings.put(blockData.getSavedBlockStateId(), BlockFace.valueOf(blockData.getValue("facing").toUpperCase(Locale.ROOT))); + if (blockData.getMinecraftKey().equalsIgnoreCase("minecraft:trapped_chest")) + trappedChests.add(blockData.getSavedBlockStateId()); connectedStates.put(getStates(blockData), blockData.getSavedBlockStateId()); ConnectionData.connectionHandlerMap.put(blockData.getSavedBlockStateId(), connectionHandler); } @@ -34,7 +37,7 @@ class ChestConnectionHandler extends ConnectionHandler { String type = blockData.getValue("type"); if (type.equals("left")) states |= 1; if (type.equals("right")) states |= 2; - states |= (BlockFace.valueOf(blockData.getValue("facing").toUpperCase()).ordinal() << 2); + states |= (BlockFace.valueOf(blockData.getValue("facing").toUpperCase(Locale.ROOT)).ordinal() << 2); if (blockData.getMinecraftKey().equals("minecraft:trapped_chest")) states |= 16; return states; } diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/blockconnections/ConnectionData.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/blockconnections/ConnectionData.java index 574b071b6..8fc49d24f 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/blockconnections/ConnectionData.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/blockconnections/ConnectionData.java @@ -217,7 +217,7 @@ public class ConnectionData { JsonObject object = type.getValue().getAsJsonObject(); boolean[] data = new boolean[6]; for (BlockFace value : BlockFace.values()) { - String face = value.toString().toLowerCase(); + String face = value.toString().toLowerCase(Locale.ROOT); if (object.has(face)) { data[value.ordinal()] = object.getAsJsonPrimitive(face).getAsBoolean(); } diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/blockconnections/DoorConnectionHandler.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/blockconnections/DoorConnectionHandler.java index 655a008b7..a9675f2aa 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/blockconnections/DoorConnectionHandler.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/blockconnections/DoorConnectionHandler.java @@ -10,6 +10,7 @@ import us.myles.ViaVersion.api.minecraft.Position; import java.util.HashMap; import java.util.LinkedList; import java.util.List; +import java.util.Locale; import java.util.Map; public class DoorConnectionHandler extends ConnectionHandler { @@ -40,7 +41,7 @@ public class DoorConnectionHandler extends ConnectionHandler { blockData.getValue("hinge").equals("right"), blockData.getValue("powered").equals("true"), blockData.getValue("open").equals("true"), - BlockFace.valueOf(blockData.getValue("facing").toUpperCase()), + BlockFace.valueOf(blockData.getValue("facing").toUpperCase(Locale.ROOT)), type ); diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/blockconnections/StairConnectionHandler.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/blockconnections/StairConnectionHandler.java index dbe832671..ec032a24b 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/blockconnections/StairConnectionHandler.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/blockconnections/StairConnectionHandler.java @@ -10,6 +10,7 @@ import us.myles.ViaVersion.api.minecraft.Position; import java.util.HashMap; import java.util.LinkedList; import java.util.List; +import java.util.Locale; import java.util.Map; public class StairConnectionHandler extends ConnectionHandler { @@ -58,7 +59,7 @@ public class StairConnectionHandler extends ConnectionHandler { StairData stairData = new StairData( blockData.getValue("half").equals("bottom"), shape, (byte) type, - BlockFace.valueOf(blockData.getValue("facing").toUpperCase()) + BlockFace.valueOf(blockData.getValue("facing").toUpperCase(Locale.ROOT)) ); stairDataMap.put(blockData.getSavedBlockStateId(), stairData); diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/blockconnections/TripwireConnectionHandler.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/blockconnections/TripwireConnectionHandler.java index ac5cb83e3..ed0dd135e 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/blockconnections/TripwireConnectionHandler.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/blockconnections/TripwireConnectionHandler.java @@ -8,6 +8,7 @@ import us.myles.ViaVersion.api.minecraft.BlockFace; import us.myles.ViaVersion.api.minecraft.Position; import java.util.HashMap; +import java.util.Locale; import java.util.Map; public class TripwireConnectionHandler extends ConnectionHandler { @@ -21,7 +22,7 @@ public class TripwireConnectionHandler extends ConnectionHandler { @Override public void check(WrappedBlockData blockData) { if (blockData.getMinecraftKey().equals("minecraft:tripwire_hook")) { - tripwireHooks.put(blockData.getSavedBlockStateId(), BlockFace.valueOf(blockData.getValue("facing").toUpperCase())); + tripwireHooks.put(blockData.getSavedBlockStateId(), BlockFace.valueOf(blockData.getValue("facing").toUpperCase(Locale.ROOT))); } else if (blockData.getMinecraftKey().equals("minecraft:tripwire")) { TripwireData tripwireData = new TripwireData( blockData.getValue("attached").equals("true"), diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/data/NamedSoundRewriter.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/data/NamedSoundRewriter.java index 3c94345b9..64a75681a 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/data/NamedSoundRewriter.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/data/NamedSoundRewriter.java @@ -1,6 +1,7 @@ package us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data; import java.util.HashMap; +import java.util.Locale; import java.util.Map; public class NamedSoundRewriter { @@ -148,6 +149,6 @@ public class NamedSoundRewriter { public static String getNewId(String old) { String newId = oldToNew.get(old); - return newId != null ? newId : old.toLowerCase(); + return newId != null ? newId : old.toLowerCase(Locale.ROOT); } } diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/providers/PaintingProvider.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/providers/PaintingProvider.java index 819aa808c..f6c190cca 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/providers/PaintingProvider.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/providers/PaintingProvider.java @@ -3,6 +3,7 @@ package us.myles.ViaVersion.protocols.protocol1_13to1_12_2.providers; import com.google.common.base.Optional; import us.myles.ViaVersion.api.platform.providers.Provider; +import java.util.Locale; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; @@ -45,7 +46,7 @@ public class PaintingProvider implements Provider { public Optional getIntByIdentifier(String motive) { // Handle older versions if (!motive.startsWith("minecraft:")) - motive = "minecraft:" + motive.toLowerCase(); + motive = "minecraft:" + motive.toLowerCase(Locale.ROOT); return Optional.fromNullable(paintings.get(motive)); } } \ No newline at end of file diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/sounds/SoundEffect.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/sounds/SoundEffect.java index e5688fcde..85dffc247 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/sounds/SoundEffect.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/sounds/SoundEffect.java @@ -3,6 +3,7 @@ package us.myles.ViaVersion.protocols.protocol1_9to1_8.sounds; import lombok.Getter; import java.util.HashMap; +import java.util.Locale; import java.util.Map; @Getter @@ -284,7 +285,7 @@ public enum SoundEffect { } public static SoundEffect getByName(String name) { - name = name.toLowerCase(); + name = name.toLowerCase(Locale.ROOT); return effects.get(name); } diff --git a/common/src/main/java/us/myles/ViaVersion/update/UpdateUtil.java b/common/src/main/java/us/myles/ViaVersion/update/UpdateUtil.java index 1e88b4ce7..f5eb29076 100644 --- a/common/src/main/java/us/myles/ViaVersion/update/UpdateUtil.java +++ b/common/src/main/java/us/myles/ViaVersion/update/UpdateUtil.java @@ -12,6 +12,7 @@ import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.URL; +import java.util.Locale; import java.util.UUID; public class UpdateUtil { @@ -81,7 +82,7 @@ public class UpdateUtil { if (current.compareTo(newest) < 0) return "There is a newer version available: " + newest.toString() + ", you're on: " + current.toString(); else if (console && current.compareTo(newest) != 0) { - if (current.getTag().toLowerCase().startsWith("dev") || current.getTag().toLowerCase().startsWith("snapshot")) { + if (current.getTag().toLowerCase(Locale.ROOT).startsWith("dev") || current.getTag().toLowerCase(Locale.ROOT).startsWith("snapshot")) { return "You are running a development version, please report any bugs to GitHub."; } else { return "You are running a newer version than is released!"; From 77d572190eb77b1028c7ef41a8f25b721265269f Mon Sep 17 00:00:00 2001 From: Gerrygames Date: Mon, 13 May 2019 14:00:37 +0200 Subject: [PATCH 7/9] 1.14.1 --- bukkit/pom.xml | 2 +- bungee/pom.xml | 2 +- common/pom.xml | 2 +- .../java/us/myles/ViaVersion/api/protocol/ProtocolVersion.java | 2 +- jar/pom.xml | 2 +- pom.xml | 2 +- sponge-legacy/pom.xml | 2 +- sponge/pom.xml | 2 +- velocity/pom.xml | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/bukkit/pom.xml b/bukkit/pom.xml index c526cc598..1842c9d90 100644 --- a/bukkit/pom.xml +++ b/bukkit/pom.xml @@ -5,7 +5,7 @@ viaversion-parent us.myles - 2.1.0-1.14.1-pre2 + 2.1.0-SNAPSHOT 4.0.0 diff --git a/bungee/pom.xml b/bungee/pom.xml index 51ada8b1b..ac1ef5bd1 100644 --- a/bungee/pom.xml +++ b/bungee/pom.xml @@ -5,7 +5,7 @@ viaversion-parent us.myles - 2.1.0-1.14.1-pre2 + 2.1.0-SNAPSHOT 4.0.0 diff --git a/common/pom.xml b/common/pom.xml index 224c58434..25b5cd1ba 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -5,7 +5,7 @@ viaversion-parent us.myles - 2.1.0-1.14.1-pre2 + 2.1.0-SNAPSHOT 4.0.0 diff --git a/common/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolVersion.java b/common/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolVersion.java index dc0efa830..67be0178d 100644 --- a/common/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolVersion.java +++ b/common/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolVersion.java @@ -69,7 +69,7 @@ public class ProtocolVersion { register(v1_13_1 = new ProtocolVersion(401, "1.13.1")); register(v1_13_2 = new ProtocolVersion(404, "1.13.2")); register(v1_14 = new ProtocolVersion(477, "1.14")); - register(v1_14_1 = new ProtocolVersion(479, "1.14.1")); + register(v1_14_1 = new ProtocolVersion(480, "1.14.1")); register(unknown = new ProtocolVersion(-1, "UNKNOWN")); } diff --git a/jar/pom.xml b/jar/pom.xml index f97d1f3d4..a4d6c0b56 100644 --- a/jar/pom.xml +++ b/jar/pom.xml @@ -5,7 +5,7 @@ viaversion-parent us.myles - 2.1.0-1.14.1-pre2 + 2.1.0-SNAPSHOT 4.0.0 viaversion-jar diff --git a/pom.xml b/pom.xml index a98f29a9b..e3b074655 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ us.myles viaversion-parent - 2.1.0-1.14.1-pre2 + 2.1.0-SNAPSHOT pom viaversion-parent diff --git a/sponge-legacy/pom.xml b/sponge-legacy/pom.xml index ad7943632..5cc396d0f 100644 --- a/sponge-legacy/pom.xml +++ b/sponge-legacy/pom.xml @@ -5,7 +5,7 @@ viaversion-parent us.myles - 2.1.0-1.14.1-pre2 + 2.1.0-SNAPSHOT 4.0.0 diff --git a/sponge/pom.xml b/sponge/pom.xml index 01c394237..00a8043e9 100644 --- a/sponge/pom.xml +++ b/sponge/pom.xml @@ -5,7 +5,7 @@ viaversion-parent us.myles - 2.1.0-1.14.1-pre2 + 2.1.0-SNAPSHOT 4.0.0 diff --git a/velocity/pom.xml b/velocity/pom.xml index c889675f8..1209a673e 100644 --- a/velocity/pom.xml +++ b/velocity/pom.xml @@ -5,7 +5,7 @@ viaversion-parent us.myles - 2.1.0-1.14.1-pre2 + 2.1.0-SNAPSHOT 4.0.0 From 56a34ec2f803b6f4175073fe12cd0c3ae7456b62 Mon Sep 17 00:00:00 2001 From: Myles Date: Mon, 13 May 2019 13:15:14 +0100 Subject: [PATCH 8/9] Update to 2.1.0 --- bukkit/pom.xml | 2 +- bungee/pom.xml | 2 +- common/pom.xml | 2 +- jar/pom.xml | 2 +- pom.xml | 2 +- sponge-legacy/pom.xml | 2 +- sponge/pom.xml | 2 +- velocity/pom.xml | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/bukkit/pom.xml b/bukkit/pom.xml index 1842c9d90..87cf8bd2e 100644 --- a/bukkit/pom.xml +++ b/bukkit/pom.xml @@ -5,7 +5,7 @@ viaversion-parent us.myles - 2.1.0-SNAPSHOT + 2.1.0 4.0.0 diff --git a/bungee/pom.xml b/bungee/pom.xml index ac1ef5bd1..c653889a0 100644 --- a/bungee/pom.xml +++ b/bungee/pom.xml @@ -5,7 +5,7 @@ viaversion-parent us.myles - 2.1.0-SNAPSHOT + 2.1.0 4.0.0 diff --git a/common/pom.xml b/common/pom.xml index 25b5cd1ba..2ec21e778 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -5,7 +5,7 @@ viaversion-parent us.myles - 2.1.0-SNAPSHOT + 2.1.0 4.0.0 diff --git a/jar/pom.xml b/jar/pom.xml index a4d6c0b56..c2bd43181 100644 --- a/jar/pom.xml +++ b/jar/pom.xml @@ -5,7 +5,7 @@ viaversion-parent us.myles - 2.1.0-SNAPSHOT + 2.1.0 4.0.0 viaversion-jar diff --git a/pom.xml b/pom.xml index e3b074655..3a7506244 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ us.myles viaversion-parent - 2.1.0-SNAPSHOT + 2.1.0 pom viaversion-parent diff --git a/sponge-legacy/pom.xml b/sponge-legacy/pom.xml index 5cc396d0f..b63fd662b 100644 --- a/sponge-legacy/pom.xml +++ b/sponge-legacy/pom.xml @@ -5,7 +5,7 @@ viaversion-parent us.myles - 2.1.0-SNAPSHOT + 2.1.0 4.0.0 diff --git a/sponge/pom.xml b/sponge/pom.xml index 00a8043e9..4a12c8421 100644 --- a/sponge/pom.xml +++ b/sponge/pom.xml @@ -5,7 +5,7 @@ viaversion-parent us.myles - 2.1.0-SNAPSHOT + 2.1.0 4.0.0 diff --git a/velocity/pom.xml b/velocity/pom.xml index 1209a673e..a7060246f 100644 --- a/velocity/pom.xml +++ b/velocity/pom.xml @@ -5,7 +5,7 @@ viaversion-parent us.myles - 2.1.0-SNAPSHOT + 2.1.0 4.0.0 From 2e37175dc27765fcdfec2e8474483b6eabba8b00 Mon Sep 17 00:00:00 2001 From: Gerrygames Date: Tue, 14 May 2019 10:21:50 +0200 Subject: [PATCH 9/9] 1.14.1 abstraction --- .../MetadataRewriter.java | 33 -------------- .../Protocol1_14_1To1_14.java | 7 ++- .../MetadataRewriter1_14_1To1_14.java | 22 +++++++++ .../packets/EntityPackets.java | 16 +++---- .../storage/EntityTracker.java | 45 ------------------- .../storage/EntityTracker1_14_1.java | 13 ++++++ 6 files changed, 48 insertions(+), 88 deletions(-) delete mode 100644 common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14_1to1_14/MetadataRewriter.java create mode 100644 common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14_1to1_14/metadata/MetadataRewriter1_14_1To1_14.java delete mode 100644 common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14_1to1_14/storage/EntityTracker.java create mode 100644 common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14_1to1_14/storage/EntityTracker1_14_1.java diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14_1to1_14/MetadataRewriter.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14_1to1_14/MetadataRewriter.java deleted file mode 100644 index f8724e2d5..000000000 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14_1to1_14/MetadataRewriter.java +++ /dev/null @@ -1,33 +0,0 @@ -package us.myles.ViaVersion.protocols.protocol1_14_1to1_14; - -import us.myles.ViaVersion.api.Via; -import us.myles.ViaVersion.api.data.UserConnection; -import us.myles.ViaVersion.api.entities.Entity1_14Types; -import us.myles.ViaVersion.api.minecraft.metadata.Metadata; - -import java.util.ArrayList; -import java.util.List; - -public class MetadataRewriter { - - public static void handleMetadata(int entityId, Entity1_14Types.EntityType type, List metadatas, UserConnection connection) { - if (type == null) return; - - for (Metadata metadata : new ArrayList<>(metadatas)) { - try { - if (type.is(Entity1_14Types.EntityType.VILLAGER) || type.is(Entity1_14Types.EntityType.WANDERING_TRADER)) { - if (metadata.getId() >= 15) { - metadata.setId(metadata.getId() + 1); - } - } - } catch (Exception e) { - metadatas.remove(metadata); - if (!Via.getConfig().isSuppressMetadataErrors() || Via.getManager().isDebug()) { - Via.getPlatform().getLogger().warning("An error occurred with entity metadata handler"); - Via.getPlatform().getLogger().warning("Metadata: " + metadata); - e.printStackTrace(); - } - } - } - } -} diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14_1to1_14/Protocol1_14_1To1_14.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14_1to1_14/Protocol1_14_1To1_14.java index 77b4182ef..0758c64e1 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14_1to1_14/Protocol1_14_1To1_14.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14_1to1_14/Protocol1_14_1To1_14.java @@ -2,18 +2,21 @@ package us.myles.ViaVersion.protocols.protocol1_14_1to1_14; import us.myles.ViaVersion.api.data.UserConnection; import us.myles.ViaVersion.api.protocol.Protocol; +import us.myles.ViaVersion.protocols.protocol1_14_1to1_14.metadata.MetadataRewriter1_14_1To1_14; import us.myles.ViaVersion.protocols.protocol1_14_1to1_14.packets.EntityPackets; -import us.myles.ViaVersion.protocols.protocol1_14_1to1_14.storage.EntityTracker; +import us.myles.ViaVersion.protocols.protocol1_14_1to1_14.storage.EntityTracker1_14_1; public class Protocol1_14_1To1_14 extends Protocol { @Override protected void registerPackets() { + put(new MetadataRewriter1_14_1To1_14()); + EntityPackets.register(this); } @Override public void init(UserConnection userConnection) { - userConnection.put(new EntityTracker(userConnection)); + userConnection.put(new EntityTracker1_14_1(userConnection)); } } diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14_1to1_14/metadata/MetadataRewriter1_14_1To1_14.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14_1to1_14/metadata/MetadataRewriter1_14_1To1_14.java new file mode 100644 index 000000000..3fb76c9f2 --- /dev/null +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14_1to1_14/metadata/MetadataRewriter1_14_1To1_14.java @@ -0,0 +1,22 @@ +package us.myles.ViaVersion.protocols.protocol1_14_1to1_14.metadata; + +import us.myles.ViaVersion.api.data.UserConnection; +import us.myles.ViaVersion.api.entities.Entity1_14Types; +import us.myles.ViaVersion.api.entities.Entity1_14Types.EntityType; +import us.myles.ViaVersion.api.minecraft.metadata.Metadata; +import us.myles.ViaVersion.api.rewriters.MetadataRewriter; + +import java.util.List; + +public class MetadataRewriter1_14_1To1_14 extends MetadataRewriter { + + public void handleMetadata(int entityId, EntityType type, Metadata metadata, List metadatas, UserConnection connection) { + if (type == null) return; + + if (type.is(EntityType.VILLAGER) || type.is(EntityType.WANDERING_TRADER)) { + if (metadata.getId() >= 15) { + metadata.setId(metadata.getId() + 1); + } + } + } +} diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14_1to1_14/packets/EntityPackets.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14_1to1_14/packets/EntityPackets.java index 7d7373909..b19b2dcdc 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14_1to1_14/packets/EntityPackets.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14_1to1_14/packets/EntityPackets.java @@ -9,8 +9,8 @@ import us.myles.ViaVersion.api.remapper.PacketRemapper; import us.myles.ViaVersion.api.type.Type; import us.myles.ViaVersion.api.type.types.version.Types1_14; import us.myles.ViaVersion.packets.State; -import us.myles.ViaVersion.protocols.protocol1_14_1to1_14.MetadataRewriter; -import us.myles.ViaVersion.protocols.protocol1_14_1to1_14.storage.EntityTracker; +import us.myles.ViaVersion.protocols.protocol1_14_1to1_14.metadata.MetadataRewriter1_14_1To1_14; +import us.myles.ViaVersion.protocols.protocol1_14_1to1_14.storage.EntityTracker1_14_1; public class EntityPackets { @@ -43,9 +43,9 @@ public class EntityPackets { Entity1_14Types.EntityType entType = Entity1_14Types.getTypeFromId(type); // Register Type ID - wrapper.user().get(EntityTracker.class).addEntity(entityId, entType); + wrapper.user().get(EntityTracker1_14_1.class).addEntity(entityId, entType); - MetadataRewriter.handleMetadata(entityId, entType, wrapper.get(Types1_14.METADATA_LIST, 0), wrapper.user()); + protocol.get(MetadataRewriter1_14_1To1_14.class).handleMetadata(entityId, entType, wrapper.get(Types1_14.METADATA_LIST, 0), wrapper.user()); } }); } @@ -72,8 +72,8 @@ public class EntityPackets { Entity1_14Types.EntityType entType = Entity1_14Types.EntityType.PLAYER; // Register Type ID - wrapper.user().get(EntityTracker.class).addEntity(entityId, entType); - MetadataRewriter.handleMetadata(entityId, entType, wrapper.get(Types1_14.METADATA_LIST, 0), wrapper.user()); + wrapper.user().get(EntityTracker1_14_1.class).addEntity(entityId, entType); + protocol.get(MetadataRewriter1_14_1To1_14.class).handleMetadata(entityId, entType, wrapper.get(Types1_14.METADATA_LIST, 0), wrapper.user()); } }); } @@ -91,8 +91,8 @@ public class EntityPackets { public void handle(PacketWrapper wrapper) throws Exception { int entityId = wrapper.get(Type.VAR_INT, 0); - Optional type = wrapper.user().get(EntityTracker.class).get(entityId); - MetadataRewriter.handleMetadata(entityId, type.orNull(), wrapper.get(Types1_14.METADATA_LIST, 0), wrapper.user()); + Optional type = wrapper.user().get(EntityTracker1_14_1.class).getEntity(entityId); + protocol.get(MetadataRewriter1_14_1To1_14.class).handleMetadata(entityId, type.orNull(), wrapper.get(Types1_14.METADATA_LIST, 0), wrapper.user()); } }); } diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14_1to1_14/storage/EntityTracker.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14_1to1_14/storage/EntityTracker.java deleted file mode 100644 index c28f14b49..000000000 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14_1to1_14/storage/EntityTracker.java +++ /dev/null @@ -1,45 +0,0 @@ -package us.myles.ViaVersion.protocols.protocol1_14_1to1_14.storage; - -import com.google.common.base.Optional; -import lombok.Getter; -import lombok.Setter; -import us.myles.ViaVersion.api.data.ExternalJoinGameListener; -import us.myles.ViaVersion.api.data.StoredObject; -import us.myles.ViaVersion.api.data.UserConnection; -import us.myles.ViaVersion.api.entities.Entity1_14Types; - -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -public class EntityTracker extends StoredObject implements ExternalJoinGameListener { - private final Map clientEntityTypes = new ConcurrentHashMap<>(); - @Getter - @Setter - private int clientEntityId; - - public EntityTracker(UserConnection user) { - super(user); - } - - public void removeEntity(int entityId) { - clientEntityTypes.remove(entityId); - } - - public void addEntity(int entityId, Entity1_14Types.EntityType type) { - clientEntityTypes.put(entityId, type); - } - - public boolean has(int entityId) { - return clientEntityTypes.containsKey(entityId); - } - - public Optional get(int id) { - return Optional.fromNullable(clientEntityTypes.get(id)); - } - - @Override - public void onExternalJoinGame(int playerEntityId) { - clientEntityId = playerEntityId; - clientEntityTypes.put(playerEntityId, Entity1_14Types.EntityType.PLAYER); - } -} diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14_1to1_14/storage/EntityTracker1_14_1.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14_1to1_14/storage/EntityTracker1_14_1.java new file mode 100644 index 000000000..bff461a03 --- /dev/null +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14_1to1_14/storage/EntityTracker1_14_1.java @@ -0,0 +1,13 @@ +package us.myles.ViaVersion.protocols.protocol1_14_1to1_14.storage; + +import us.myles.ViaVersion.api.data.UserConnection; +import us.myles.ViaVersion.api.entities.Entity1_14Types; +import us.myles.ViaVersion.api.entities.Entity1_14Types.EntityType; +import us.myles.ViaVersion.api.storage.EntityTracker; + +public class EntityTracker1_14_1 extends EntityTracker { + + public EntityTracker1_14_1(UserConnection user) { + super(user, EntityType.PLAYER); + } +}