diff --git a/all/pom.xml b/all/pom.xml index 72a0dddc..048785cf 100644 --- a/all/pom.xml +++ b/all/pom.xml @@ -15,7 +15,7 @@ viabackwards-parent nl.matsv - 2.2.0 + 2.3.0 4.0.0 diff --git a/bukkit/pom.xml b/bukkit/pom.xml index 0e893e8e..21e93bbe 100644 --- a/bukkit/pom.xml +++ b/bukkit/pom.xml @@ -15,7 +15,7 @@ viabackwards-parent nl.matsv - 2.2.0 + 2.3.0 4.0.0 diff --git a/bungee/pom.xml b/bungee/pom.xml index 9546d0c0..65987c68 100644 --- a/bungee/pom.xml +++ b/bungee/pom.xml @@ -15,7 +15,7 @@ viabackwards-parent nl.matsv - 2.2.0 + 2.3.0 4.0.0 diff --git a/core/pom.xml b/core/pom.xml index 50ec2188..e998b5ac 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -15,7 +15,7 @@ viabackwards-parent nl.matsv - 2.2.0 + 2.3.0 4.0.0 diff --git a/core/src/main/java/nl/matsv/viabackwards/api/ViaBackwardsPlatform.java b/core/src/main/java/nl/matsv/viabackwards/api/ViaBackwardsPlatform.java index 15584ee3..3bbddc28 100644 --- a/core/src/main/java/nl/matsv/viabackwards/api/ViaBackwardsPlatform.java +++ b/core/src/main/java/nl/matsv/viabackwards/api/ViaBackwardsPlatform.java @@ -13,6 +13,7 @@ package nl.matsv.viabackwards.api; import nl.matsv.viabackwards.ViaBackwards; import nl.matsv.viabackwards.protocol.protocol1_10to1_11.Protocol1_10To1_11; import nl.matsv.viabackwards.protocol.protocol1_11to1_11_1.Protocol1_11To1_11_1; +import nl.matsv.viabackwards.protocol.protocol1_12_1to1_12_2.Protocol1_12_1To1_12_2; import nl.matsv.viabackwards.protocol.protocol1_12to1_11_1.Protocol1_11_1To1_12; import nl.matsv.viabackwards.protocol.protocol1_12to1_12_1.Protocol1_12To1_12_1; import nl.matsv.viabackwards.protocol.protocol1_9_4to1_10.Protocol1_9_4To1_10; @@ -36,6 +37,7 @@ public interface ViaBackwardsPlatform { ProtocolRegistry.registerProtocol(new Protocol1_11To1_11_1(), Collections.singletonList(ProtocolVersion.v1_11.getId()), ProtocolVersion.v1_11_1.getId()); ProtocolRegistry.registerProtocol(new Protocol1_11_1To1_12(), Collections.singletonList(ProtocolVersion.v1_11_1.getId()), ProtocolVersion.v1_12.getId()); ProtocolRegistry.registerProtocol(new Protocol1_12To1_12_1(), Collections.singletonList(ProtocolVersion.v1_12.getId()), ProtocolVersion.v1_12_1.getId()); + ProtocolRegistry.registerProtocol(new Protocol1_12_1To1_12_2(), Collections.singletonList(ProtocolVersion.v1_12_1.getId()), ProtocolVersion.v1_12_2.getId()); } } @@ -51,9 +53,9 @@ public interface ViaBackwardsPlatform { boolean upToDate = false; try { Class clazz = Class.forName("us.myles.ViaVersion.api.protocol.ProtocolVersion"); - Field v1_12_1 = clazz.getField("v1_12_1"); + Field v1_12_2 = clazz.getField("v1_12_2"); - upToDate = (v1_12_1 != null); + upToDate = (v1_12_2 != null); } catch (ClassNotFoundException | NoSuchFieldException ignored) { } diff --git a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_1to1_12_2/Protocol1_12_1To1_12_2.java b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_1to1_12_2/Protocol1_12_1To1_12_2.java new file mode 100644 index 00000000..0a0f533d --- /dev/null +++ b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_1to1_12_2/Protocol1_12_1To1_12_2.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2016 Matsv + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package nl.matsv.viabackwards.protocol.protocol1_12_1to1_12_2; + +import nl.matsv.viabackwards.api.BackwardsProtocol; +import nl.matsv.viabackwards.protocol.protocol1_12to1_12_1.KeepAliveTracker; +import us.myles.ViaVersion.api.PacketWrapper; +import us.myles.ViaVersion.api.data.UserConnection; +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.packets.State; + +public class Protocol1_12_1To1_12_2 extends BackwardsProtocol { + @Override + protected void registerPackets() { + // Outgoing + // 0x1f - Keep alive + registerOutgoing(State.PLAY, 0x1f, 0x1f, new PacketRemapper() { + @Override + public void registerMap() { + handler(new PacketHandler() { + @Override + public void handle(PacketWrapper packetWrapper) throws Exception { + long keepAlive = packetWrapper.read(Type.LONG); + packetWrapper.user().get(KeepAliveTracker.class).setKeepAlive(keepAlive); + packetWrapper.write(Type.VAR_INT, (int) keepAlive); + } + }); + } + }); // Keep alive + // Incoming + // 0xb - Keep alive + registerIncoming(State.PLAY, 0xb, 0xb, new PacketRemapper() { + @Override + public void registerMap() { + handler(new PacketHandler() { + @Override + public void handle(PacketWrapper packetWrapper) throws Exception { + int keepAlive = packetWrapper.read(Type.VAR_INT); + long realKeepAlive = packetWrapper.user().get(KeepAliveTracker.class).getKeepAlive(); + if (keepAlive != (int) realKeepAlive) { + realKeepAlive = 0L; // Client sent wrong data, timeout + } + packetWrapper.write(Type.LONG, realKeepAlive); + } + }); + } + }); + } + + @Override + public void init(UserConnection userConnection) { + userConnection.put(new KeepAliveTracker(userConnection)); + } +} diff --git a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12to1_12_1/KeepAliveTracker.java b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12to1_12_1/KeepAliveTracker.java new file mode 100644 index 00000000..07b02154 --- /dev/null +++ b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12to1_12_1/KeepAliveTracker.java @@ -0,0 +1,18 @@ +package nl.matsv.viabackwards.protocol.protocol1_12to1_12_1; + +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; +import us.myles.ViaVersion.api.data.StoredObject; +import us.myles.ViaVersion.api.data.UserConnection; + +@Getter +@Setter +@ToString +public class KeepAliveTracker extends StoredObject { + private long keepAlive; + + public KeepAliveTracker(UserConnection user) { + super(user); + } +} diff --git a/pom.xml b/pom.xml index 1abb15ec..b7451bb2 100644 --- a/pom.xml +++ b/pom.xml @@ -16,7 +16,7 @@ nl.matsv viabackwards-parent - 2.2.0 + 2.3.0 pom Allow newer clients to join older server versions. @@ -61,11 +61,11 @@ guava 19.0 - + us.myles viaversion - 1.2.0-1_12_1-pre1 + 1.3.0 provided diff --git a/sponge/pom.xml b/sponge/pom.xml index e2c98161..23ce495f 100644 --- a/sponge/pom.xml +++ b/sponge/pom.xml @@ -15,7 +15,7 @@ viabackwards-parent nl.matsv - 2.2.0 + 2.3.0 4.0.0