3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-18 04:20:08 +01:00

Add 1.9.1 support.

Dieser Commit ist enthalten in:
md_5 2016-03-16 16:49:50 +11:00 committet von Thinkofname
Ursprung 44216f12ed
Commit 23ce4d1b96
5 geänderte Dateien mit 71 neuen und 11 gelöschten Zeilen

Datei anzeigen

@ -18,10 +18,17 @@
private final MinecraftServer a;
private final NetworkManager b;
@@ -16,6 +26,41 @@
@@ -11,12 +21,48 @@
}
public void a(PacketHandshakingInSetProtocol packethandshakinginsetprotocol) {
+ this.b.channel.pipeline().get(PacketEncoder.class).version = packethandshakinginsetprotocol.b(); // CraftBukkit
switch (HandshakeListener.SyntheticClass_1.a[packethandshakinginsetprotocol.a().ordinal()]) {
case 1:
this.b.setProtocol(EnumProtocol.LOGIN);
ChatComponentText chatcomponenttext;
- if (packethandshakinginsetprotocol.b() > 107) {
+ // CraftBukkit start - Connection throttle
+ try {
+ long currentTime = System.currentTimeMillis();
@ -57,10 +64,11 @@
+ }
+ // CraftBukkit end
+
if (packethandshakinginsetprotocol.b() > 107) {
+ if (packethandshakinginsetprotocol.b() > 108) {
chatcomponenttext = new ChatComponentText("Outdated server! I\'m still on 1.9");
this.b.sendPacket(new PacketLoginOutDisconnect(chatcomponenttext));
@@ -26,6 +71,7 @@
this.b.close(chatcomponenttext);
@@ -26,6 +72,7 @@
this.b.close(chatcomponenttext);
} else {
this.b.setPacketListener(new LoginListener(this.a, this.b));

Datei anzeigen

@ -1,6 +1,6 @@
--- a/net/minecraft/server/PacketDataSerializer.java
+++ b/net/minecraft/server/PacketDataSerializer.java
@@ -20,6 +20,8 @@
@@ -20,9 +20,12 @@
import java.nio.charset.Charset;
import java.util.UUID;
@ -9,7 +9,11 @@
public class PacketDataSerializer extends ByteBuf {
private final ByteBuf a;
@@ -44,8 +46,16 @@
+ int version = 107; // CraftBukkkit
public PacketDataSerializer(ByteBuf bytebuf) {
this.a = bytebuf;
@@ -44,8 +47,16 @@
return this;
}
@ -27,7 +31,7 @@
this.readBytes(abyte);
return abyte;
@@ -99,7 +109,7 @@
@@ -99,7 +110,7 @@
}
public <T extends Enum<T>> T a(Class<T> oclass) {
@ -36,7 +40,7 @@
}
public PacketDataSerializer a(Enum<?> oenum) {
@@ -176,7 +186,7 @@
@@ -176,7 +187,7 @@
} else {
try {
NBTCompressedStreamTools.a(nbttagcompound, (DataOutput) (new ByteBufOutputStream(this)));
@ -45,7 +49,7 @@
throw new EncoderException(ioexception);
}
}
@@ -202,7 +212,7 @@
@@ -202,7 +213,7 @@
}
public PacketDataSerializer a(ItemStack itemstack) {
@ -54,7 +58,7 @@
this.writeShort(-1);
} else {
this.writeShort(Item.getId(itemstack.getItem()));
@@ -230,6 +240,11 @@
@@ -230,6 +241,11 @@
itemstack = new ItemStack(Item.getById(short0), b0, short1);
itemstack.setTag(this.j());

Datei anzeigen

@ -0,0 +1,27 @@
--- a/net/minecraft/server/PacketEncoder.java
+++ b/net/minecraft/server/PacketEncoder.java
@@ -14,6 +14,7 @@
private static final Logger a = LogManager.getLogger();
private static final Marker b = MarkerManager.getMarker("PACKET_SENT", NetworkManager.b);
private final EnumProtocolDirection c;
+ int version; // CraftBukkit
public PacketEncoder(EnumProtocolDirection enumprotocoldirection) {
this.c = enumprotocoldirection;
@@ -30,6 +31,7 @@
throw new IOException("Can\'t serialize unregistered packet");
} else {
PacketDataSerializer packetdataserializer = new PacketDataSerializer(bytebuf);
+ packetdataserializer.version = version; // CraftBukkit
packetdataserializer.b(integer.intValue());
@@ -42,7 +44,7 @@
}
}
- protected void encode(ChannelHandlerContext channelhandlercontext, Object object, ByteBuf bytebuf) throws Exception {
+ protected void encode(ChannelHandlerContext channelhandlercontext, Packet object, ByteBuf bytebuf) throws Exception {
this.a(channelhandlercontext, (Packet) object, bytebuf);
}
}

Datei anzeigen

@ -0,0 +1,17 @@
--- a/net/minecraft/server/PacketPlayOutLogin.java
+++ b/net/minecraft/server/PacketPlayOutLogin.java
@@ -54,7 +54,13 @@
}
packetdataserializer.writeByte(i);
- packetdataserializer.writeByte(this.d);
+ // CraftBukkit start
+ if (packetdataserializer.version < 108) {
+ packetdataserializer.writeByte(this.d);
+ } else {
+ packetdataserializer.writeInt(this.d);
+ }
+ // CraftBukkit end
packetdataserializer.writeByte(this.e.a());
packetdataserializer.writeByte(this.f);
packetdataserializer.a(this.g.name());

Datei anzeigen

@ -17,7 +17,7 @@
public class PacketStatusListener implements PacketStatusInListener {
private static final IChatBaseComponent a = new ChatComponentText("Status request has been handled.");
@@ -19,8 +30,95 @@
@@ -19,8 +30,99 @@
this.networkManager.close(PacketStatusListener.a);
} else {
this.d = true;
@ -106,7 +106,11 @@
+ ping.setFavicon(event.icon.value);
+ ping.setMOTD(new ChatComponentText(event.getMotd()));
+ ping.setPlayerSample(playerSample);
+ ping.setServerInfo(new ServerPing.ServerData(minecraftServer.getServerModName() + " " + minecraftServer.getVersion(), minecraftServer.getServerPing().getServerData().getProtocolVersion()));
+ int version = minecraftServer.getServerPing().getServerData().getProtocolVersion();
+ if (this.networkManager.channel.pipeline().get(PacketEncoder.class).version == 108) {
+ version = 108;
+ }
+ ping.setServerInfo(new ServerPing.ServerData(minecraftServer.getServerModName() + " " + minecraftServer.getVersion(), version));
+
+ this.networkManager.sendPacket(new PacketStatusOutServerInfo(ping));
}