3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-11-20 06:50:08 +01:00
Dieser Commit ist enthalten in:
creeper123123321 2018-06-22 09:19:57 -03:00
Ursprung e26b6d08e1
Commit 39419f4ca3
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 0AC57D54786721D1
12 geänderte Dateien mit 186 neuen und 98 gelöschten Zeilen

Datei anzeigen

@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>viaversion-parent</artifactId> <artifactId>viaversion-parent</artifactId>
<groupId>us.myles</groupId> <groupId>us.myles</groupId>
<version>1.4.0-1.13-pre2</version> <version>1.4.0-1.13-pre3</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

Datei anzeigen

@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>viaversion-parent</artifactId> <artifactId>viaversion-parent</artifactId>
<groupId>us.myles</groupId> <groupId>us.myles</groupId>
<version>1.4.0-1.13-pre2</version> <version>1.4.0-1.13-pre3</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

Datei anzeigen

@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>viaversion-parent</artifactId> <artifactId>viaversion-parent</artifactId>
<groupId>us.myles</groupId> <groupId>us.myles</groupId>
<version>1.4.0-1.13-pre2</version> <version>1.4.0-1.13-pre3</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

Datei anzeigen

@ -62,7 +62,7 @@ public class ProtocolVersion {
register(v1_12 = new ProtocolVersion(335, "1.12")); register(v1_12 = new ProtocolVersion(335, "1.12"));
register(v1_12_1 = new ProtocolVersion(338, "1.12.1")); register(v1_12_1 = new ProtocolVersion(338, "1.12.1"));
register(v1_12_2 = new ProtocolVersion(340, "1.12.2")); 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")); register(unknown = new ProtocolVersion(-1, "UNKNOWN"));
} }

Datei anzeigen

@ -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.Protocol;
import us.myles.ViaVersion.api.protocol.ProtocolPipeline; import us.myles.ViaVersion.api.protocol.ProtocolPipeline;
import us.myles.ViaVersion.api.protocol.ProtocolRegistry; 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.PacketHandler;
import us.myles.ViaVersion.api.remapper.PacketRemapper; import us.myles.ViaVersion.api.remapper.PacketRemapper;
import us.myles.ViaVersion.api.type.Type; 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.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() { registerOutgoing(State.LOGIN, 0x02, 0x02, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.STRING); // 0 - UUID as String
map(Type.STRING); // 1 - Player Username
handler(new PacketHandler() { handler(new PacketHandler() {
@Override @Override
public void handle(PacketWrapper wrapper) throws Exception { public void handle(PacketWrapper wrapper) throws Exception {
ProtocolInfo info = wrapper.user().get(ProtocolInfo.class); int protocol = wrapper.user().get(ProtocolInfo.class).getProtocolVersion();
info.setState(State.PLAY); if (protocol < ProtocolVersion.v1_13.getId())
// Save other info handleLoginSuccess(wrapper);
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(), ", ")
});
}
} }
}); });
} }
}); });
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 */ /* Incoming Packets */
// Handshake Packet // Handshake Packet
@ -206,7 +208,8 @@ public class BaseProtocol extends Protocol {
registerIncoming(State.STATUS, 0x00, 0x00); // Status Request Packet registerIncoming(State.STATUS, 0x00, 0x00); // Status Request Packet
registerIncoming(State.STATUS, 0x01, 0x01); // Status Ping 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() { registerIncoming(State.LOGIN, 0x00, 0x00, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
@ -214,27 +217,81 @@ public class BaseProtocol extends Protocol {
@Override @Override
public void handle(final PacketWrapper wrapper) throws Exception { public void handle(final PacketWrapper wrapper) throws Exception {
int protocol = wrapper.user().get(ProtocolInfo.class).getProtocolVersion(); int protocol = wrapper.user().get(ProtocolInfo.class).getProtocolVersion();
if (Via.getConfig().getBlockedProtocols().contains(protocol)) { if (protocol < ProtocolVersion.v1_13.getId())
if (!wrapper.user().getChannel().isOpen()) return; handleLoginStart(wrapper);
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<Future<? super Void>>() {
@Override
public void operationComplete(Future<? super Void> future) throws Exception {
wrapper.user().getChannel().close();
}
});
}
} }
}); });
} }
}); // 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<Future<? super Void>>() {
@Override
public void operationComplete(Future<? super Void> 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 @Override
@ -259,7 +316,7 @@ public class BaseProtocol extends Protocol {
} }
public static String addDashes(String trimmedUUID) { public static String addDashes(String trimmedUUID) {
StringBuffer idBuff = new StringBuffer(trimmedUUID); StringBuilder idBuff = new StringBuilder(trimmedUUID);
idBuff.insert(20, '-'); idBuff.insert(20, '-');
idBuff.insert(16, '-'); idBuff.insert(16, '-');
idBuff.insert(12, '-'); idBuff.insert(12, '-');

Datei anzeigen

@ -54,6 +54,12 @@ public class ProtocolSnapshotTo1_12_2 extends Protocol {
// Outgoing packets // 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 // Statistics
registerOutgoing(State.PLAY, 0x07, 0x07, new PacketRemapper() { registerOutgoing(State.PLAY, 0x07, 0x07, new PacketRemapper() {
@Override @Override
@ -406,6 +412,22 @@ public class ProtocolSnapshotTo1_12_2 extends Protocol {
// New packet 0x53 - Tags // New packet 0x53 - Tags
// Incoming packets // 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, 0x2, 0x1);
registerIncoming(State.PLAY, 0x3, 0x2); registerIncoming(State.PLAY, 0x3, 0x2);
registerIncoming(State.PLAY, 0x4, 0x3); registerIncoming(State.PLAY, 0x4, 0x3);

Datei anzeigen

@ -100,34 +100,43 @@ public class InventoryPackets {
} }
wrapper.set(Type.BYTE, 0, flags); // Update flags wrapper.set(Type.BYTE, 0, flags); // Update flags
} return;
if (channel.equalsIgnoreCase("MC|TrList")) { } else if (channel.equalsIgnoreCase("MC|TrList")) {
channel = "minecraft:trader_list";
wrapper.passthrough(Type.INT); // Passthrough Window ID wrapper.passthrough(Type.INT); // Passthrough Window ID
int size = wrapper.passthrough(Type.UNSIGNED_BYTE); int size = wrapper.passthrough(Type.UNSIGNED_BYTE);
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {
// Input Item // Input Item
Item input = wrapper.read(Type.ITEM); Item input = wrapper.passthrough(Type.ITEM);
toClient(input); InventoryPackets.toClient(input);
wrapper.write(Type.ITEM, input);
// Output Item // Output Item
Item output = wrapper.read(Type.ITEM); Item output = wrapper.passthrough(Type.ITEM);
toClient(output); InventoryPackets.toClient(output);
wrapper.write(Type.ITEM, output);
boolean secondItem = wrapper.passthrough(Type.BOOLEAN); // Has second item boolean secondItem = wrapper.passthrough(Type.BOOLEAN); // Has second item
if (secondItem) { if (secondItem) {
// Second Item // Second Item
Item second = wrapper.read(Type.ITEM); Item second = wrapper.passthrough(Type.ITEM);
toClient(second); InventoryPackets.toClient(second);
wrapper.write(Type.ITEM, second);
} }
wrapper.passthrough(Type.BOOLEAN); // Trade disabled wrapper.passthrough(Type.BOOLEAN); // Trade disabled
wrapper.passthrough(Type.INT); // Number of tools uses wrapper.passthrough(Type.INT); // Number of tools uses
wrapper.passthrough(Type.INT); // Maximum number of trade 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);
} }
}); });
} }

Datei anzeigen

@ -8409,33 +8409,33 @@
"8406": "minecraft:green_concrete_powder", "8406": "minecraft:green_concrete_powder",
"8407": "minecraft:red_concrete_powder", "8407": "minecraft:red_concrete_powder",
"8408": "minecraft:black_concrete_powder", "8408": "minecraft:black_concrete_powder",
"8409": "minecraft:kelp_plant", "8409": "minecraft:kelp[age=0]",
"8410": "minecraft:kelp[age=0]", "8410": "minecraft:kelp[age=1]",
"8411": "minecraft:kelp[age=1]", "8411": "minecraft:kelp[age=2]",
"8412": "minecraft:kelp[age=2]", "8412": "minecraft:kelp[age=3]",
"8413": "minecraft:kelp[age=3]", "8413": "minecraft:kelp[age=4]",
"8414": "minecraft:kelp[age=4]", "8414": "minecraft:kelp[age=5]",
"8415": "minecraft:kelp[age=5]", "8415": "minecraft:kelp[age=6]",
"8416": "minecraft:kelp[age=6]", "8416": "minecraft:kelp[age=7]",
"8417": "minecraft:kelp[age=7]", "8417": "minecraft:kelp[age=8]",
"8418": "minecraft:kelp[age=8]", "8418": "minecraft:kelp[age=9]",
"8419": "minecraft:kelp[age=9]", "8419": "minecraft:kelp[age=10]",
"8420": "minecraft:kelp[age=10]", "8420": "minecraft:kelp[age=11]",
"8421": "minecraft:kelp[age=11]", "8421": "minecraft:kelp[age=12]",
"8422": "minecraft:kelp[age=12]", "8422": "minecraft:kelp[age=13]",
"8423": "minecraft:kelp[age=13]", "8423": "minecraft:kelp[age=14]",
"8424": "minecraft:kelp[age=14]", "8424": "minecraft:kelp[age=15]",
"8425": "minecraft:kelp[age=15]", "8425": "minecraft:kelp[age=16]",
"8426": "minecraft:kelp[age=16]", "8426": "minecraft:kelp[age=17]",
"8427": "minecraft:kelp[age=17]", "8427": "minecraft:kelp[age=18]",
"8428": "minecraft:kelp[age=18]", "8428": "minecraft:kelp[age=19]",
"8429": "minecraft:kelp[age=19]", "8429": "minecraft:kelp[age=20]",
"8430": "minecraft:kelp[age=20]", "8430": "minecraft:kelp[age=21]",
"8431": "minecraft:kelp[age=21]", "8431": "minecraft:kelp[age=22]",
"8432": "minecraft:kelp[age=22]", "8432": "minecraft:kelp[age=23]",
"8433": "minecraft:kelp[age=23]", "8433": "minecraft:kelp[age=24]",
"8434": "minecraft:kelp[age=24]", "8434": "minecraft:kelp[age=25]",
"8435": "minecraft:kelp[age=25]", "8435": "minecraft:kelp_plant",
"8436": "minecraft:dried_kelp_block", "8436": "minecraft:dried_kelp_block",
"8437": "minecraft:turtle_egg[eggs=1,hatch=0]", "8437": "minecraft:turtle_egg[eggs=1,hatch=0]",
"8438": "minecraft:turtle_egg[eggs=1,hatch=1]", "8438": "minecraft:turtle_egg[eggs=1,hatch=1]",

Datei anzeigen

@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>viaversion-parent</artifactId> <artifactId>viaversion-parent</artifactId>
<groupId>us.myles</groupId> <groupId>us.myles</groupId>
<version>1.4.0-1.13-pre2</version> <version>1.4.0-1.13-pre3</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<name>viaversion-jar</name> <name>viaversion-jar</name>

Datei anzeigen

@ -6,7 +6,7 @@
<groupId>us.myles</groupId> <groupId>us.myles</groupId>
<artifactId>viaversion-parent</artifactId> <artifactId>viaversion-parent</artifactId>
<version>1.4.0-1.13-pre2</version> <version>1.4.0-1.13-pre3</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<name>viaversion-parent</name> <name>viaversion-parent</name>

Datei anzeigen

@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>viaversion-parent</artifactId> <artifactId>viaversion-parent</artifactId>
<groupId>us.myles</groupId> <groupId>us.myles</groupId>
<version>1.4.0-1.13-pre2</version> <version>1.4.0-1.13-pre3</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

Datei anzeigen

@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>viaversion-parent</artifactId> <artifactId>viaversion-parent</artifactId>
<groupId>us.myles</groupId> <groupId>us.myles</groupId>
<version>1.4.0-1.13-pre2</version> <version>1.4.0-1.13-pre3</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>