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

1.13-pre5 + revert some changes

Dieser Commit ist enthalten in:
creeper123123321 2018-07-02 11:36:03 -03:00
Ursprung 7fda025c0d
Commit e3f71c26e7
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 0AC57D54786721D1
11 geänderte Dateien mit 105 neuen und 143 gelöschten Zeilen

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

@ -74,8 +74,6 @@ public class ProtocolPipeline extends Protocol {
// Apply protocols
packetWrapper.apply(direction, state, 0, protocols);
int transformedId = packetWrapper.getId();
super.transform(direction, state, packetWrapper);
if (Via.getManager().isDebug()) {
@ -88,10 +86,7 @@ public class ProtocolPipeline extends Protocol {
// For 1.8/1.9 server version, eventually we'll probably get an API for this...
if (serverProtocol >= ProtocolVersion.v1_8.getId() &&
serverProtocol <= ProtocolVersion.v1_9_3.getId()
|| clientProtocol >= ProtocolVersion.v1_8.getId() &&
clientProtocol <= ProtocolVersion.v1_9_3.getId()) {
serverProtocol <= ProtocolVersion.v1_9_3.getId()) {
PacketType type;
if (serverProtocol <= ProtocolVersion.v1_8.getId()) {
if (direction == Direction.INCOMING) {
@ -99,16 +94,8 @@ public class ProtocolPipeline extends Protocol {
} else {
type = PacketType.findOldPacket(state, direction, originalID);
}
} else if (serverProtocol <= ProtocolVersion.v1_9_3.getId()) {
} else {
type = PacketType.findNewPacket(state, direction, originalID);
} else if (clientProtocol <= ProtocolVersion.v1_8.getId()) {
if (direction == Direction.INCOMING) {
type = PacketType.findNewPacket(state, direction, transformedId);
} else {
type = PacketType.findOldPacket(state, direction, transformedId);
}
} else {
type = PacketType.findNewPacket(state, direction, transformedId);
}
if (type != null) {
// Filter :) This would be not hard coded too, sorry :(

Datei anzeigen

@ -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(386, "1.13-pre4"));
register(v1_13 = new ProtocolVersion(387, "1.13-pre5"));
register(unknown = new ProtocolVersion(-1, "UNKNOWN"));
}

Datei anzeigen

@ -16,7 +16,6 @@ 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;
@ -29,6 +28,7 @@ import java.util.List;
import java.util.UUID;
import java.util.logging.Level;
// TODO Make it work on 1.13 servers
public class BaseProtocol extends Protocol {
@Override
@ -108,51 +108,50 @@ 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 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)
// Login Success Packet
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 {
int protocol = wrapper.user().get(ProtocolInfo.class).getServerProtocolVersion();
if (protocol < ProtocolVersion.v1_13.getId())
handleLoginSuccess(wrapper);
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(), ", ")
});
}
}
});
}
});
// 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).getServerProtocolVersion();
if (protocol >= ProtocolVersion.v1_13.getId())
handleLoginSuccess(wrapper);
}
});
}
});
// Login Set Compression Packet (1.13)
registerOutgoing(State.LOGIN, 0x04, 0x04);
registerOutgoing(State.LOGIN, 0x03, 0x03); // Login Set Compression Packet
/* Incoming Packets */
// Handshake Packet
@ -209,43 +208,13 @@ public class BaseProtocol extends Protocol {
registerIncoming(State.STATUS, 0x00, 0x00); // Status Request Packet
registerIncoming(State.STATUS, 0x01, 0x01); // Status Ping Packet
// Login Start Packet (1.12.2)
// Plugin Message (1.13)
// Login Start Packet
registerIncoming(State.LOGIN, 0x00, 0x00, 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).getServerProtocolVersion();
if (protocol < ProtocolVersion.v1_13.getId())
handleLoginStart(wrapper);
}
});
}
});
// 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).getServerProtocolVersion();
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;
@ -264,35 +233,10 @@ public class BaseProtocol extends Protocol {
});
}
}
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(), ", ")
});
}
}); // Login Start Packet
registerIncoming(State.LOGIN, 0x01, 0x01); // Encryption Response Packet
}
@Override

Datei anzeigen

@ -1,6 +1,7 @@
package us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.packets;
import com.github.steveice10.opennbt.tag.builtin.*;
import com.google.common.base.Joiner;
import com.google.common.base.Optional;
import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.minecraft.item.Item;
@ -14,7 +15,9 @@ import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.data.MappingData;
import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.data.SoundSource;
import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.data.SpawnEggRewriter;
import java.util.Map;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
public class InventoryPackets {
private static String NBT_TAG_NAME;
@ -125,20 +128,29 @@ public class InventoryPackets {
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?
String originalChannel = channel;
channel = getNewPluginChannelId(channel).orNull();
if (channel == null) {
System.out.println("Plugin message cancelled " + originalChannel); // TODO remove this debug
wrapper.cancel();
return;
} else if (channel.equals("minecraft:register") || channel.equals("minecraft:unregister")) {
String[] channels = new String(wrapper.read(Type.REMAINING_BYTES), StandardCharsets.UTF_8).split("\0");
List<String> rewrittenChannels = new ArrayList<>();
for (int i = 0; i < channels.length; i++) {
String rewritten = getNewPluginChannelId(channels[i]).orNull();
if (rewritten != null)
rewrittenChannels.add(rewritten);
else
System.out.println("Ignoring plugin channel in REGISTER: " + channels[i]);
}
wrapper.write(Type.REMAINING_BYTES, Joiner.on('\0').join(rewrittenChannels).getBytes(StandardCharsets.UTF_8));
}
}
// TODO message channel to new packets rewriting
wrapper.set(Type.STRING, 0, channel);
}
// TODO Fix trading GUI
});
}
});
@ -208,6 +220,7 @@ public class InventoryPackets {
}
// TODO CLEANUP / SMARTER REWRITE SYSTEM
// TODO Rewrite identifiers
public static void toClient(Item item) {
if (item == null) return;
@ -430,4 +443,22 @@ public class InventoryPackets {
|| id == 442 // shield
|| id == 443; // elytra
}
public static Optional<String> getNewPluginChannelId(String old) {
if (old.equalsIgnoreCase("MC|TrList"))
return Optional.of("minecraft:trader_list");
if (old.equalsIgnoreCase("MC|Brand"))
return Optional.of("minecraft:brand");
if (old.equalsIgnoreCase("MC|BOpen"))
return Optional.of("minecraft:book_open");
if (old.equalsIgnoreCase("MC|DebugPath"))
return Optional.of("minecraft:debug/paths");
if (old.equalsIgnoreCase("MC|DebugNeighborsUpdate"))
return Optional.of("minecraft:debug/neighbors_update");
if (old.equalsIgnoreCase("REGISTER"))
return Optional.of("minecraft:register");
if (old.equalsIgnoreCase("UNREGISTER"))
return Optional.of("minecraft:unregister");
return Optional.absent();
}
}

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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