From 39419f4ca30914ce9fd5819d5eb26c21c423ff9c Mon Sep 17 00:00:00 2001 From: creeper123123321 Date: Fri, 22 Jun 2018 09:19:57 -0300 Subject: [PATCH] 1.13-pre3 --- bukkit/pom.xml | 2 +- bungee/pom.xml | 2 +- common/pom.xml | 2 +- .../api/protocol/ProtocolVersion.java | 2 +- .../protocols/base/BaseProtocol.java | 161 ++++++++++++------ .../ProtocolSnapshotTo1_12_2.java | 22 +++ .../packets/InventoryPackets.java | 31 ++-- .../assets/viaversion/data/mapping-1.13.json | 54 +++--- jar/pom.xml | 2 +- pom.xml | 2 +- sponge-legacy/pom.xml | 2 +- sponge/pom.xml | 2 +- 12 files changed, 186 insertions(+), 98 deletions(-) diff --git a/bukkit/pom.xml b/bukkit/pom.xml index 737d90a1f..fc72e208b 100644 --- a/bukkit/pom.xml +++ b/bukkit/pom.xml @@ -5,7 +5,7 @@ viaversion-parent us.myles - 1.4.0-1.13-pre2 + 1.4.0-1.13-pre3 4.0.0 diff --git a/bungee/pom.xml b/bungee/pom.xml index ed6470b3e..91907b3e3 100644 --- a/bungee/pom.xml +++ b/bungee/pom.xml @@ -5,7 +5,7 @@ viaversion-parent us.myles - 1.4.0-1.13-pre2 + 1.4.0-1.13-pre3 4.0.0 diff --git a/common/pom.xml b/common/pom.xml index ddb54a00f..9dd6a2f9f 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -5,7 +5,7 @@ viaversion-parent us.myles - 1.4.0-1.13-pre2 + 1.4.0-1.13-pre3 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 db89b29ce..8839ea023 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 @@ -62,7 +62,7 @@ public class ProtocolVersion { register(v1_12 = new ProtocolVersion(335, "1.12")); register(v1_12_1 = new ProtocolVersion(338, "1.12.1")); register(v1_12_2 = new ProtocolVersion(340, "1.12.2")); - register(v1_13 = new ProtocolVersion(384, "1.13-pre2")); + register(v1_13 = new ProtocolVersion(385, "1.13-pre3")); register(unknown = new ProtocolVersion(-1, "UNKNOWN")); } diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/base/BaseProtocol.java b/common/src/main/java/us/myles/ViaVersion/protocols/base/BaseProtocol.java index 519005b28..af5cf7b92 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/base/BaseProtocol.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/base/BaseProtocol.java @@ -16,6 +16,7 @@ import us.myles.ViaVersion.api.platform.providers.ViaProviders; import us.myles.ViaVersion.api.protocol.Protocol; import us.myles.ViaVersion.api.protocol.ProtocolPipeline; import us.myles.ViaVersion.api.protocol.ProtocolRegistry; +import us.myles.ViaVersion.api.protocol.ProtocolVersion; import us.myles.ViaVersion.api.remapper.PacketHandler; import us.myles.ViaVersion.api.remapper.PacketRemapper; import us.myles.ViaVersion.api.type.Type; @@ -107,50 +108,51 @@ public class BaseProtocol extends Protocol { registerOutgoing(State.STATUS, 0x01, 0x01); // Status Pong Packet - registerOutgoing(State.LOGIN, 0x00, 0x00); // Login Disconnect Packet - registerOutgoing(State.LOGIN, 0x01, 0x01); // Encryption Request Packet - // Login Success Packet + // Login Disconnect Packet (1.12.2) + // Plugin Message (1.13) + registerOutgoing(State.LOGIN, 0x00, 0x00); + + // Encryption Request Packet (1.12.2) + // Login Disconnect Packet (1.13) + registerOutgoing(State.LOGIN, 0x01, 0x01); + + // Login Success Packet (1.12.2) + // Encryption Request Packet (1.13) registerOutgoing(State.LOGIN, 0x02, 0x02, new PacketRemapper() { @Override public void registerMap() { - map(Type.STRING); // 0 - UUID as String - map(Type.STRING); // 1 - Player Username handler(new PacketHandler() { @Override public void handle(PacketWrapper wrapper) throws Exception { - ProtocolInfo info = wrapper.user().get(ProtocolInfo.class); - info.setState(State.PLAY); - // Save other info - String stringUUID = wrapper.get(Type.STRING, 0); - if (stringUUID.length() == 32) { // Trimmed UUIDs are 32 characters - // Trimmed - stringUUID = addDashes(stringUUID); - } - UUID uuid = UUID.fromString(stringUUID); - info.setUuid(uuid); - info.setUsername(wrapper.get(Type.STRING, 1)); - // Add to ported clients - Via.getManager().addPortedClient(wrapper.user()); - - if (info.getPipeline().pipes().size() == 1 && info.getPipeline().pipes().get(0).getClass() == BaseProtocol.class) // Only base protocol - wrapper.user().setActive(false); - - if (Via.getManager().isDebug()) { - // Print out the route to console - Via.getPlatform().getLogger().log(Level.INFO, "{0} logged in with protocol {1}, Route: {2}", - new Object[]{ - wrapper.get(Type.STRING, 1), - info.getProtocolVersion(), - Joiner.on(", ").join(info.getPipeline().pipes(), ", ") - }); - } + int protocol = wrapper.user().get(ProtocolInfo.class).getProtocolVersion(); + if (protocol < ProtocolVersion.v1_13.getId()) + handleLoginSuccess(wrapper); } }); } }); - registerOutgoing(State.LOGIN, 0x03, 0x03); // Login Set Compression Packet + // Login Set Compression Packet (1.12.2) + // Login Success Packet (1.13) + registerOutgoing(State.LOGIN, 0x03, 0x03, new PacketRemapper() { + @Override + public void registerMap() { + handler(new PacketHandler() { + @Override + public void handle(PacketWrapper wrapper) throws Exception { + int protocol = wrapper.user().get(ProtocolInfo.class).getProtocolVersion(); + if (protocol >= ProtocolVersion.v1_13.getId()) + handleLoginSuccess(wrapper); + } + }); + } + }); + + // Login Set Compression Packet (1.13) + registerOutgoing(State.LOGIN, 0x04, 0x04); + + /* Incoming Packets */ // Handshake Packet @@ -206,7 +208,8 @@ public class BaseProtocol extends Protocol { registerIncoming(State.STATUS, 0x00, 0x00); // Status Request Packet registerIncoming(State.STATUS, 0x01, 0x01); // Status Ping Packet - // Login Start Packet + // Login Start Packet (1.12.2) + // Plugin Message (1.13) registerIncoming(State.LOGIN, 0x00, 0x00, new PacketRemapper() { @Override public void registerMap() { @@ -214,27 +217,81 @@ public class BaseProtocol extends Protocol { @Override public void handle(final PacketWrapper wrapper) throws Exception { int protocol = wrapper.user().get(ProtocolInfo.class).getProtocolVersion(); - if (Via.getConfig().getBlockedProtocols().contains(protocol)) { - if (!wrapper.user().getChannel().isOpen()) return; - - PacketWrapper disconnectPacket = new PacketWrapper(0x00, null, wrapper.user()); // Disconnect Packet - Protocol1_9TO1_8.FIX_JSON.write(disconnectPacket, ChatColor.translateAlternateColorCodes('&', Via.getConfig().getBlockedDisconnectMsg())); - wrapper.cancel(); // cancel current - - // Send and close - ChannelFuture future = disconnectPacket.sendFuture(BaseProtocol.class); - future.addListener(new GenericFutureListener>() { - @Override - public void operationComplete(Future future) throws Exception { - wrapper.user().getChannel().close(); - } - }); - } + if (protocol < ProtocolVersion.v1_13.getId()) + handleLoginStart(wrapper); } }); } - }); // Login Start Packet - registerIncoming(State.LOGIN, 0x01, 0x01); // Encryption Response Packet + }); + + // Encryption Response Packet (1.12.2) + // Login Start Packet (1.13) + registerIncoming(State.LOGIN, 0x01, 0x01, new PacketRemapper() { + @Override + public void registerMap() { + handler(new PacketHandler() { + @Override + public void handle(PacketWrapper wrapper) throws Exception { + int protocol = wrapper.user().get(ProtocolInfo.class).getProtocolVersion(); + if (protocol >= ProtocolVersion.v1_13.getId()) + handleLoginStart(wrapper); + } + }); + } + }); + + // Encryption Response Packet (1.13) + registerIncoming(State.LOGIN, 0x02, 0x02); + } + + private void handleLoginStart(final PacketWrapper wrapper) throws Exception { + int protocol = wrapper.user().get(ProtocolInfo.class).getProtocolVersion(); + if (Via.getConfig().getBlockedProtocols().contains(protocol)) { + if (!wrapper.user().getChannel().isOpen()) return; + + PacketWrapper disconnectPacket = new PacketWrapper(0x00, null, wrapper.user()); // Disconnect Packet + Protocol1_9TO1_8.FIX_JSON.write(disconnectPacket, ChatColor.translateAlternateColorCodes('&', Via.getConfig().getBlockedDisconnectMsg())); + wrapper.cancel(); // cancel current + + // Send and close + ChannelFuture future = disconnectPacket.sendFuture(BaseProtocol.class); + future.addListener(new GenericFutureListener>() { + @Override + public void operationComplete(Future future) throws Exception { + wrapper.user().getChannel().close(); + } + }); + } + } + + private void handleLoginSuccess(final PacketWrapper wrapper) throws Exception { + ProtocolInfo info = wrapper.user().get(ProtocolInfo.class); + info.setState(State.PLAY); + // Save other info + String stringUUID = wrapper.passthrough(Type.STRING); + if (stringUUID.length() == 32) { // Trimmed UUIDs are 32 characters + // Trimmed + stringUUID = addDashes(stringUUID); + } + UUID uuid = UUID.fromString(stringUUID); + info.setUuid(uuid); + String username = wrapper.passthrough(Type.STRING); + info.setUsername(username); + // Add to ported clients + Via.getManager().addPortedClient(wrapper.user()); + + if (info.getPipeline().pipes().size() == 1 && info.getPipeline().pipes().get(0).getClass() == BaseProtocol.class) // Only base protocol + wrapper.user().setActive(false); + + if (Via.getManager().isDebug()) { + // Print out the route to console + Via.getPlatform().getLogger().log(Level.INFO, "{0} logged in with protocol {1}, Route: {2}", + new Object[]{ + username, + info.getProtocolVersion(), + Joiner.on(", ").join(info.getPipeline().pipes(), ", ") + }); + } } @Override @@ -259,7 +316,7 @@ public class BaseProtocol extends Protocol { } public static String addDashes(String trimmedUUID) { - StringBuffer idBuff = new StringBuffer(trimmedUUID); + StringBuilder idBuff = new StringBuilder(trimmedUUID); idBuff.insert(20, '-'); idBuff.insert(16, '-'); idBuff.insert(12, '-'); diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocolsnapshotto1_12_2/ProtocolSnapshotTo1_12_2.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocolsnapshotto1_12_2/ProtocolSnapshotTo1_12_2.java index 12d41049a..601b2d1a7 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocolsnapshotto1_12_2/ProtocolSnapshotTo1_12_2.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocolsnapshotto1_12_2/ProtocolSnapshotTo1_12_2.java @@ -54,6 +54,12 @@ public class ProtocolSnapshotTo1_12_2 extends Protocol { // Outgoing packets + // New packet 0x0 - Login Plugin Message + registerOutgoing(State.LOGIN, 0x0, 0x1); + registerOutgoing(State.LOGIN, 0x1, 0x2); + registerOutgoing(State.LOGIN, 0x2, 0x3); + registerOutgoing(State.LOGIN, 0x3, 0x4); + // Statistics registerOutgoing(State.PLAY, 0x07, 0x07, new PacketRemapper() { @Override @@ -406,6 +412,22 @@ public class ProtocolSnapshotTo1_12_2 extends Protocol { // New packet 0x53 - Tags // Incoming packets + + // New packet 0x0 - Login Plugin Message + registerIncoming(State.LOGIN, -1, 0x0, new PacketRemapper() { + @Override + public void registerMap() { + handler(new PacketHandler() { + @Override + public void handle(PacketWrapper wrapper) throws Exception { + wrapper.cancel(); + } + }); + } + }); + registerIncoming(State.LOGIN, 0x0, 0x1); + registerIncoming(State.LOGIN, 0x1, 0x2); + registerIncoming(State.PLAY, 0x2, 0x1); registerIncoming(State.PLAY, 0x3, 0x2); registerIncoming(State.PLAY, 0x4, 0x3); diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocolsnapshotto1_12_2/packets/InventoryPackets.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocolsnapshotto1_12_2/packets/InventoryPackets.java index dfd4c5e2c..b0c34450b 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocolsnapshotto1_12_2/packets/InventoryPackets.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocolsnapshotto1_12_2/packets/InventoryPackets.java @@ -100,34 +100,43 @@ public class InventoryPackets { } wrapper.set(Type.BYTE, 0, flags); // Update flags - } - if (channel.equalsIgnoreCase("MC|TrList")) { + return; + } else if (channel.equalsIgnoreCase("MC|TrList")) { + channel = "minecraft:trader_list"; wrapper.passthrough(Type.INT); // Passthrough Window ID int size = wrapper.passthrough(Type.UNSIGNED_BYTE); for (int i = 0; i < size; i++) { // Input Item - Item input = wrapper.read(Type.ITEM); - toClient(input); - wrapper.write(Type.ITEM, input); + Item input = wrapper.passthrough(Type.ITEM); + InventoryPackets.toClient(input); // Output Item - Item output = wrapper.read(Type.ITEM); - toClient(output); - wrapper.write(Type.ITEM, output); + Item output = wrapper.passthrough(Type.ITEM); + InventoryPackets.toClient(output); boolean secondItem = wrapper.passthrough(Type.BOOLEAN); // Has second item if (secondItem) { // Second Item - Item second = wrapper.read(Type.ITEM); - toClient(second); - wrapper.write(Type.ITEM, second); + Item second = wrapper.passthrough(Type.ITEM); + InventoryPackets.toClient(second); } wrapper.passthrough(Type.BOOLEAN); // Trade disabled wrapper.passthrough(Type.INT); // Number of tools uses wrapper.passthrough(Type.INT); // Maximum number of trade uses } + } else if (channel.equalsIgnoreCase("MC|Brand")) { + channel = "minecraft:brand"; + } else if (channel.equalsIgnoreCase("MC|BOpen")) { + channel = "minecraft:book_open"; + } else if (channel.equalsIgnoreCase("MC|DebugPath")) { + channel = "minecraft:debug/paths"; + } else if (channel.equalsIgnoreCase("MC|DebugNeighborsUpdate")) { + channel = "minecraft:debug/neighbors_update"; + } else { + wrapper.cancel(); // TODO REGISTER channel removed? } + wrapper.set(Type.STRING, 0, channel); } }); } diff --git a/common/src/main/resources/assets/viaversion/data/mapping-1.13.json b/common/src/main/resources/assets/viaversion/data/mapping-1.13.json index 08a67251c..a8b6d8583 100644 --- a/common/src/main/resources/assets/viaversion/data/mapping-1.13.json +++ b/common/src/main/resources/assets/viaversion/data/mapping-1.13.json @@ -8409,33 +8409,33 @@ "8406": "minecraft:green_concrete_powder", "8407": "minecraft:red_concrete_powder", "8408": "minecraft:black_concrete_powder", - "8409": "minecraft:kelp_plant", - "8410": "minecraft:kelp[age=0]", - "8411": "minecraft:kelp[age=1]", - "8412": "minecraft:kelp[age=2]", - "8413": "minecraft:kelp[age=3]", - "8414": "minecraft:kelp[age=4]", - "8415": "minecraft:kelp[age=5]", - "8416": "minecraft:kelp[age=6]", - "8417": "minecraft:kelp[age=7]", - "8418": "minecraft:kelp[age=8]", - "8419": "minecraft:kelp[age=9]", - "8420": "minecraft:kelp[age=10]", - "8421": "minecraft:kelp[age=11]", - "8422": "minecraft:kelp[age=12]", - "8423": "minecraft:kelp[age=13]", - "8424": "minecraft:kelp[age=14]", - "8425": "minecraft:kelp[age=15]", - "8426": "minecraft:kelp[age=16]", - "8427": "minecraft:kelp[age=17]", - "8428": "minecraft:kelp[age=18]", - "8429": "minecraft:kelp[age=19]", - "8430": "minecraft:kelp[age=20]", - "8431": "minecraft:kelp[age=21]", - "8432": "minecraft:kelp[age=22]", - "8433": "minecraft:kelp[age=23]", - "8434": "minecraft:kelp[age=24]", - "8435": "minecraft:kelp[age=25]", + "8409": "minecraft:kelp[age=0]", + "8410": "minecraft:kelp[age=1]", + "8411": "minecraft:kelp[age=2]", + "8412": "minecraft:kelp[age=3]", + "8413": "minecraft:kelp[age=4]", + "8414": "minecraft:kelp[age=5]", + "8415": "minecraft:kelp[age=6]", + "8416": "minecraft:kelp[age=7]", + "8417": "minecraft:kelp[age=8]", + "8418": "minecraft:kelp[age=9]", + "8419": "minecraft:kelp[age=10]", + "8420": "minecraft:kelp[age=11]", + "8421": "minecraft:kelp[age=12]", + "8422": "minecraft:kelp[age=13]", + "8423": "minecraft:kelp[age=14]", + "8424": "minecraft:kelp[age=15]", + "8425": "minecraft:kelp[age=16]", + "8426": "minecraft:kelp[age=17]", + "8427": "minecraft:kelp[age=18]", + "8428": "minecraft:kelp[age=19]", + "8429": "minecraft:kelp[age=20]", + "8430": "minecraft:kelp[age=21]", + "8431": "minecraft:kelp[age=22]", + "8432": "minecraft:kelp[age=23]", + "8433": "minecraft:kelp[age=24]", + "8434": "minecraft:kelp[age=25]", + "8435": "minecraft:kelp_plant", "8436": "minecraft:dried_kelp_block", "8437": "minecraft:turtle_egg[eggs=1,hatch=0]", "8438": "minecraft:turtle_egg[eggs=1,hatch=1]", diff --git a/jar/pom.xml b/jar/pom.xml index dacdd7bd1..2d4a5961b 100644 --- a/jar/pom.xml +++ b/jar/pom.xml @@ -5,7 +5,7 @@ viaversion-parent us.myles - 1.4.0-1.13-pre2 + 1.4.0-1.13-pre3 4.0.0 viaversion-jar diff --git a/pom.xml b/pom.xml index b2e5464f6..b5ebd6296 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ us.myles viaversion-parent - 1.4.0-1.13-pre2 + 1.4.0-1.13-pre3 pom viaversion-parent diff --git a/sponge-legacy/pom.xml b/sponge-legacy/pom.xml index 1dba5a1b8..ff8969f24 100644 --- a/sponge-legacy/pom.xml +++ b/sponge-legacy/pom.xml @@ -5,7 +5,7 @@ viaversion-parent us.myles - 1.4.0-1.13-pre2 + 1.4.0-1.13-pre3 4.0.0 diff --git a/sponge/pom.xml b/sponge/pom.xml index 83a4fb6e8..4a1cda815 100644 --- a/sponge/pom.xml +++ b/sponge/pom.xml @@ -5,7 +5,7 @@ viaversion-parent us.myles - 1.4.0-1.13-pre2 + 1.4.0-1.13-pre3 4.0.0