3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-11-20 06:50:08 +01:00

1.13-pre9, RIP BaseProtocol1_13, use Type.VAR_INT_ARRAY

Dieser Commit ist enthalten in:
creeper123123321 2018-07-16 15:44:56 -03:00
Ursprung b83b7ee2bc
Commit ca85c9739a
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 0AC57D54786721D1
13 geänderte Dateien mit 24 neuen und 234 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-pre8</version> <version>1.4.0-1.13-pre9</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-pre8</version> <version>1.4.0-1.13-pre9</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-pre8</version> <version>1.4.0-1.13-pre9</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

Datei anzeigen

@ -6,7 +6,6 @@ import com.google.common.collect.Sets;
import us.myles.ViaVersion.api.Pair; import us.myles.ViaVersion.api.Pair;
import us.myles.ViaVersion.api.Via; import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.protocols.base.BaseProtocol; import us.myles.ViaVersion.protocols.base.BaseProtocol;
import us.myles.ViaVersion.protocols.base.BaseProtocol1_13;
import us.myles.ViaVersion.protocols.base.BaseProtocol1_7; import us.myles.ViaVersion.protocols.base.BaseProtocol1_7;
import us.myles.ViaVersion.protocols.protocol1_10to1_9_3.Protocol1_10To1_9_3_4; import us.myles.ViaVersion.protocols.protocol1_10to1_9_3.Protocol1_10To1_9_3_4;
import us.myles.ViaVersion.protocols.protocol1_11_1to1_11.Protocol1_11_1To1_11; import us.myles.ViaVersion.protocols.protocol1_11_1to1_11.Protocol1_11_1To1_11;
@ -37,8 +36,7 @@ public class ProtocolRegistry {
static { static {
// Base Protocol // Base Protocol
registerBaseProtocol(BASE_PROTOCOL, Range.lessThan(Integer.MIN_VALUE)); registerBaseProtocol(BASE_PROTOCOL, Range.lessThan(Integer.MIN_VALUE));
registerBaseProtocol(new BaseProtocol1_7(), Range.lessThan(ProtocolVersion.v1_13.getId())); registerBaseProtocol(new BaseProtocol1_7(), Range.<Integer>all());
registerBaseProtocol(new BaseProtocol1_13(), Range.atLeast(ProtocolVersion.v1_13.getId()));
// Register built in protocols // Register built in protocols
registerProtocol(new Protocol1_9TO1_8(), Collections.singletonList(ProtocolVersion.v1_9.getId()), ProtocolVersion.v1_8.getId()); registerProtocol(new Protocol1_9TO1_8(), Collections.singletonList(ProtocolVersion.v1_9.getId()), ProtocolVersion.v1_8.getId());

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(390, "1.13-pre8")); register(v1_13 = new ProtocolVersion(391, "1.13-pre9"));
register(unknown = new ProtocolVersion(-1, "UNKNOWN")); register(unknown = new ProtocolVersion(-1, "UNKNOWN"));
} }

Datei anzeigen

@ -1,195 +0,0 @@
package us.myles.ViaVersion.protocols.base;
import com.google.common.base.Joiner;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import io.netty.channel.ChannelFuture;
import io.netty.util.concurrent.Future;
import io.netty.util.concurrent.GenericFutureListener;
import net.md_5.bungee.api.ChatColor;
import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.Pair;
import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.protocol.Protocol;
import us.myles.ViaVersion.api.protocol.ProtocolRegistry;
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;
import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9TO1_8;
import us.myles.ViaVersion.util.GsonUtil;
import java.util.List;
import java.util.UUID;
import java.util.logging.Level;
public class BaseProtocol1_13 extends Protocol {
@Override
protected void registerPackets() {
/* Outgoing Packets */
// Status Response Packet
registerOutgoing(State.STATUS, 0x00, 0x00, new PacketRemapper() { // Status Response Packet
@Override
public void registerMap() {
map(Type.STRING);
handler(new PacketHandler() {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
ProtocolInfo info = wrapper.user().get(ProtocolInfo.class);
String originalStatus = wrapper.get(Type.STRING, 0);
try {
JsonElement json = GsonUtil.getGson().fromJson(originalStatus, JsonElement.class);
JsonObject version;
int protocolVersion = 0; // Unknown!
if (json.isJsonObject()) {
if (json.getAsJsonObject().has("version")) {
version = json.getAsJsonObject().get("version").getAsJsonObject();
if (version.has("protocol")) {
protocolVersion = ((Long) version.get("protocol").getAsLong()).intValue();
}
} else {
version = new JsonObject();
json.getAsJsonObject().add("version", version);
}
} else {
// Format properly
json = new JsonObject();
version = new JsonObject();
json.getAsJsonObject().add("version", version);
}
if (Via.getConfig().isSendSupportedVersions()) //Send supported versions
version.add("supportedVersions", GsonUtil.getGson().toJsonTree(Via.getAPI().getSupportedVersions()));
if (ProtocolRegistry.SERVER_PROTOCOL == -1) // Set the Server protocol if the detection on startup failed
ProtocolRegistry.SERVER_PROTOCOL = protocolVersion;
// Ensure the server has a version provider
if (Via.getManager().getProviders().get(VersionProvider.class) == null) {
wrapper.user().setActive(false);
return;
}
int protocol = Via.getManager().getProviders().get(VersionProvider.class).getServerProtocol(wrapper.user());
List<Pair<Integer, Protocol>> protocols = null;
// Only allow newer clients or (1.9.2 on 1.9.4 server if the server supports it)
if (info.getProtocolVersion() >= protocol || Via.getPlatform().isOldClientsAllowed()) {
protocols = ProtocolRegistry.getProtocolPath(info.getProtocolVersion(), protocol);
}
if (protocols != null) {
if (protocolVersion != 9999) {
//Fix ServerListPlus
version.addProperty("protocol", info.getProtocolVersion());
}
} else {
// not compatible :(, *plays very sad violin*
wrapper.user().setActive(false);
}
if (Via.getConfig().getBlockedProtocols().contains(info.getProtocolVersion()))
version.addProperty("protocol", -1); // Show blocked versions as outdated
wrapper.set(Type.STRING, 0, GsonUtil.getGson().toJson(json)); // Update value
} catch (JsonParseException e) {
e.printStackTrace();
}
}
});
}
});
registerOutgoing(State.STATUS, 0x01, 0x01); // Status Pong Packet
registerOutgoing(State.LOGIN, 0x00, 0x00); // Login Plugin Message
registerOutgoing(State.LOGIN, 0x01, 0x01); // Login Disconnect Packet
registerOutgoing(State.LOGIN, 0x02, 0x02); // Encryption Request Packet
// Login Success Packet
registerOutgoing(State.LOGIN, 0x03, 0x03, 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() == 2
&& info.getPipeline().pipes().get(1).getClass() == BaseProtocol1_13.class
&& 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, 0x04, 0x04); // Login Set Compression Packet
/* Incoming Packets */
registerIncoming(State.STATUS, 0x00, 0x00); // Status Request Packet
registerIncoming(State.STATUS, 0x01, 0x01); // Status Ping Packet
registerIncoming(State.LOGIN, 0x00, 0x00); // Login Plugin Message
// Login Start Packet
registerIncoming(State.LOGIN, 0x01, 0x01, new PacketRemapper() {
@Override
public void registerMap() {
handler(new PacketHandler() {
@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<Future<? super Void>>() {
@Override
public void operationComplete(Future<? super Void> future) throws Exception {
wrapper.user().getChannel().close();
}
});
}
}
});
}
}); // Login Start Packet
registerIncoming(State.LOGIN, 0x02, 0x02); // Encryption Response Packet
}
@Override
public void init(UserConnection userConnection) {
}
}

Datei anzeigen

@ -150,6 +150,7 @@ public class BaseProtocol1_7 extends Protocol {
}); });
registerOutgoing(State.LOGIN, 0x03, 0x03); // Login Set Compression Packet registerOutgoing(State.LOGIN, 0x03, 0x03); // Login Set Compression Packet
registerIncoming(State.LOGIN, 0x04, 0x04); // Plugin Request (1.13)
/* Incoming Packets */ /* Incoming Packets */
@ -185,6 +186,7 @@ public class BaseProtocol1_7 extends Protocol {
} }
}); // Login Start Packet }); // Login Start Packet
registerIncoming(State.LOGIN, 0x01, 0x01); // Encryption Response Packet registerIncoming(State.LOGIN, 0x01, 0x01); // Encryption Response Packet
registerIncoming(State.LOGIN, 0x02, 0x02); // Plugin Response (1.13)
} }
@Override @Override

Datei anzeigen

@ -66,11 +66,7 @@ public class ProtocolSnapshotTo1_12_2 extends Protocol {
// Outgoing packets // Outgoing packets
// New packet 0x0 - Login Plugin Message // New packet 0x04 - 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() {
@ -198,28 +194,19 @@ public class ProtocolSnapshotTo1_12_2 extends Protocol {
@Override @Override
public void write(PacketWrapper wrapper) throws Exception { public void write(PacketWrapper wrapper) throws Exception {
wrapper.write(Type.VAR_INT, MappingData.blockTags.size()); // block tags wrapper.write(Type.VAR_INT, MappingData.blockTags.size()); // block tags
for (Map.Entry<String, int[]> tag : MappingData.blockTags.entrySet()) { for (Map.Entry<String, Integer[]> tag : MappingData.blockTags.entrySet()) {
wrapper.write(Type.STRING, tag.getKey()); wrapper.write(Type.STRING, tag.getKey());
wrapper.write(Type.VAR_INT, tag.getValue().length); wrapper.write(Type.VAR_INT_ARRAY, tag.getValue().clone());
for (int id : tag.getValue()) {
wrapper.write(Type.VAR_INT, id);
}
} }
wrapper.write(Type.VAR_INT, MappingData.itemTags.size()); // item tags wrapper.write(Type.VAR_INT, MappingData.itemTags.size()); // item tags
for (Map.Entry<String, int[]> tag : MappingData.itemTags.entrySet()) { for (Map.Entry<String, Integer[]> tag : MappingData.itemTags.entrySet()) {
wrapper.write(Type.STRING, tag.getKey()); wrapper.write(Type.STRING, tag.getKey());
wrapper.write(Type.VAR_INT, tag.getValue().length); wrapper.write(Type.VAR_INT_ARRAY, tag.getValue().clone());
for (int id : tag.getValue()) {
wrapper.write(Type.VAR_INT, id);
}
} }
wrapper.write(Type.VAR_INT, MappingData.fluidTags.size()); // fluid tags wrapper.write(Type.VAR_INT, MappingData.fluidTags.size()); // fluid tags
for (Map.Entry<String, int[]> tag : MappingData.fluidTags.entrySet()) { for (Map.Entry<String, Integer[]> tag : MappingData.fluidTags.entrySet()) {
wrapper.write(Type.STRING, tag.getKey()); wrapper.write(Type.STRING, tag.getKey());
wrapper.write(Type.VAR_INT, tag.getValue().length); wrapper.write(Type.VAR_INT_ARRAY, tag.getValue().clone());
for (int id : tag.getValue()) {
wrapper.write(Type.VAR_INT, id);
}
} }
} }
}).send(ProtocolSnapshotTo1_12_2.class); }).send(ProtocolSnapshotTo1_12_2.class);
@ -436,7 +423,7 @@ public class ProtocolSnapshotTo1_12_2 extends Protocol {
// Incoming packets // Incoming packets
// New packet 0x0 - Login Plugin Message // New packet 0x0 - Login Plugin Message
registerIncoming(State.LOGIN, -1, 0x0, new PacketRemapper() { registerIncoming(State.LOGIN, -1, 0x02, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
handler(new PacketHandler() { handler(new PacketHandler() {
@ -447,8 +434,6 @@ public class ProtocolSnapshotTo1_12_2 extends Protocol {
}); });
} }
}); });
registerIncoming(State.LOGIN, 0x0, 0x1);
registerIncoming(State.LOGIN, 0x1, 0x2);
// New 0x01 - Query Block NBT // New 0x01 - Query Block NBT
registerIncoming(State.PLAY, -1, 0x01, new PacketRemapper() { registerIncoming(State.PLAY, -1, 0x01, new PacketRemapper() {

Datei anzeigen

@ -17,9 +17,9 @@ public class MappingData {
public static Map<Integer, Integer> oldToNewBlocks = new HashMap<>(); public static Map<Integer, Integer> oldToNewBlocks = new HashMap<>();
public static Map<Integer, Integer> oldToNewItems = new HashMap<>(); public static Map<Integer, Integer> oldToNewItems = new HashMap<>();
public static Map<Integer, Integer> newToOldItems = new HashMap<>(); public static Map<Integer, Integer> newToOldItems = new HashMap<>();
public static Map<String, int[]> blockTags = new HashMap<>(); public static Map<String, Integer[]> blockTags = new HashMap<>();
public static Map<String, int[]> itemTags = new HashMap<>(); public static Map<String, Integer[]> itemTags = new HashMap<>();
public static Map<String, int[]> fluidTags = new HashMap<>(); public static Map<String, Integer[]> fluidTags = new HashMap<>();
public static BiMap<Short, String> oldEnchantmentsIds = HashBiMap.create(); public static BiMap<Short, String> oldEnchantmentsIds = HashBiMap.create();
public static Map<Integer, Integer> oldToNewSounds = new HashMap<>(); public static Map<Integer, Integer> oldToNewSounds = new HashMap<>();
@ -87,10 +87,10 @@ public class MappingData {
return null; return null;
} }
private static void loadTags(Map<String, int[]> output, JsonObject newTags) { private static void loadTags(Map<String, Integer[]> output, JsonObject newTags) {
for (Map.Entry<String, JsonElement> entry : newTags.entrySet()) { for (Map.Entry<String, JsonElement> entry : newTags.entrySet()) {
JsonArray ids = entry.getValue().getAsJsonArray(); JsonArray ids = entry.getValue().getAsJsonArray();
int[] idsArray = new int[ids.size()]; Integer[] idsArray = new Integer[ids.size()];
for (int i = 0; i < ids.size(); i++) { for (int i = 0; i < ids.size(); i++) {
idsArray[i] = ids.get(i).getAsInt(); idsArray[i] = ids.get(i).getAsInt();
} }

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-pre8</version> <version>1.4.0-1.13-pre9</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-pre8</version> <version>1.4.0-1.13-pre9</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-pre8</version> <version>1.4.0-1.13-pre9</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-pre8</version> <version>1.4.0-1.13-pre9</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>