Skip to content

Instantly share code, notes, and snippets.

@aikar
Created September 20, 2013 02:26
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save aikar/6632586 to your computer and use it in GitHub Desktop.
Save aikar/6632586 to your computer and use it in GitHub Desktop.
diff --git a/src/main/java/net/minecraft/server/PendingConnection.java b/src/main/java/net/minecraft/server/PendingConnection.java
index 0b59471..3e7b746 100644
--- a/src/main/java/net/minecraft/server/PendingConnection.java
+++ b/src/main/java/net/minecraft/server/PendingConnection.java
@@ -78,7 +78,7 @@ public class PendingConnection extends Connection {
} else {
PublicKey publickey = this.server.H().getPublic();
- if (packet2handshake.d() != 78) {
+ if (packet2handshake.d() < 74) { // EMC
if (packet2handshake.d() > 78) {
this.disconnect(org.spigotmc.SpigotConfig.outdatedServerMessage); // Spigot
} else {
@@ -159,7 +159,7 @@ public class PendingConnection extends Connection {
s = pingEvent.getMotd() + "\u00A7" + playerlist.getPlayerCount() + "\u00A7" + pingEvent.getMaxPlayers();
} else {
// CraftBukkit start - Don't create a list from an array
- Object[] list = new Object[] { 1, 78, this.server.getVersion(), pingEvent.getMotd(), playerlist.getPlayerCount(), pingEvent.getMaxPlayers() };
+ Object[] list = new Object[] { 1, packet254getinfo.a > 73 && packet254getinfo.a < 79 ? packet254getinfo.a : 78, this.server.getVersion(), pingEvent.getMotd(), playerlist.
StringBuilder builder = new StringBuilder();
for (Object object : list) {
@wlritchi
Copy link

Note that this logic doesn't work if clients on a protocol version greater than 78 try to join (the code never reaches the inner if statement). In addition, you may want to limit it to 74, 77, and 78 to prevent people on the intermediate 13w36a, 13w37a, and 13w37b versions (protocol versions 75 and 76) from joining. I'm not sure if there were actually any protocol changes between the versions, but the snapshots might behave oddly since they expect new terrain, etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment