mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-30 14:33:56 +01:00
Better way of doing this without making plugins angry
This commit is contained in:
parent
f3d31bfdff
commit
9049cf8101
339
CraftBukkit-Patches/0073-Snapshot-Protocol.patch
Normal file
339
CraftBukkit-Patches/0073-Snapshot-Protocol.patch
Normal file
@ -0,0 +1,339 @@
|
|||||||
|
From 69614650662d3da7f61f0399a01094ad6ed16ad9 Mon Sep 17 00:00:00 2001
|
||||||
|
From: md_5 <md_5@live.com.au>
|
||||||
|
Date: Sat, 28 Sep 2013 18:35:51 +1000
|
||||||
|
Subject: [PATCH] Snapshot Protocol
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/server/EntityHuman.java b/src/main/java/net/minecraft/server/EntityHuman.java
|
||||||
|
index 36eca0f..c90c65e 100644
|
||||||
|
--- a/src/main/java/net/minecraft/server/EntityHuman.java
|
||||||
|
+++ b/src/main/java/net/minecraft/server/EntityHuman.java
|
||||||
|
@@ -63,6 +63,7 @@ public abstract class EntityHuman extends EntityLiving implements ICommandListen
|
||||||
|
protected float bL = 0.02F;
|
||||||
|
private int h;
|
||||||
|
public EntityFishingHook hookedFish;
|
||||||
|
+ public String playerUUID; // Spigot
|
||||||
|
|
||||||
|
public EntityHuman(World world, String s) {
|
||||||
|
super(world);
|
||||||
|
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||||
|
index fb8bc87..5651bd0 100644
|
||||||
|
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||||
|
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||||
|
@@ -764,7 +764,7 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getVersion() {
|
||||||
|
- return "1.6.4";
|
||||||
|
+ return org.spigotmc.SpigotConfig.gameVersion; // Spigot
|
||||||
|
}
|
||||||
|
|
||||||
|
public int A() {
|
||||||
|
diff --git a/src/main/java/net/minecraft/server/Packet200Statistic.java b/src/main/java/net/minecraft/server/Packet200Statistic.java
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000..a850473
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/main/java/net/minecraft/server/Packet200Statistic.java
|
||||||
|
@@ -0,0 +1,49 @@
|
||||||
|
+package net.minecraft.server;
|
||||||
|
+
|
||||||
|
+import java.io.DataInput;
|
||||||
|
+import java.io.DataOutput;
|
||||||
|
+import java.io.IOException;
|
||||||
|
+
|
||||||
|
+public class Packet200Statistic extends Packet {
|
||||||
|
+
|
||||||
|
+ public int a;
|
||||||
|
+ public int b;
|
||||||
|
+
|
||||||
|
+ public Packet200Statistic() {}
|
||||||
|
+
|
||||||
|
+ public Packet200Statistic(int i, int j) {
|
||||||
|
+ this.a = i;
|
||||||
|
+ this.b = j;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public void handle(Connection connection) {
|
||||||
|
+ connection.a(this);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public void a(DataInput datainput) throws IOException {
|
||||||
|
+ this.a = datainput.readInt();
|
||||||
|
+ this.b = datainput.readInt();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public void a(DataOutput dataoutput) throws IOException {
|
||||||
|
+ // Spigot Start
|
||||||
|
+ if ( org.spigotmc.SpigotConfig.snapshotProtocol )
|
||||||
|
+ {
|
||||||
|
+ dataoutput.writeInt( 1 );
|
||||||
|
+ a( ( (Statistic) StatisticList.a.get( this.a ) ).g, dataoutput );
|
||||||
|
+ dataoutput.writeInt( this.b );
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
+ // Spigot End
|
||||||
|
+ dataoutput.writeInt(this.a);
|
||||||
|
+ dataoutput.writeInt(this.b);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public int a() {
|
||||||
|
+ return 6;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public boolean a_() {
|
||||||
|
+ return true;
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
diff --git a/src/main/java/net/minecraft/server/Packet20NamedEntitySpawn.java b/src/main/java/net/minecraft/server/Packet20NamedEntitySpawn.java
|
||||||
|
index 1843d9c..aeb42bb 100644
|
||||||
|
--- a/src/main/java/net/minecraft/server/Packet20NamedEntitySpawn.java
|
||||||
|
+++ b/src/main/java/net/minecraft/server/Packet20NamedEntitySpawn.java
|
||||||
|
@@ -8,6 +8,7 @@ import java.io.IOException; // CraftBukkit
|
||||||
|
|
||||||
|
public class Packet20NamedEntitySpawn extends Packet {
|
||||||
|
|
||||||
|
+ public String playerUUID; // Spigot
|
||||||
|
public int a;
|
||||||
|
public String b;
|
||||||
|
public int c;
|
||||||
|
@@ -23,6 +24,7 @@ public class Packet20NamedEntitySpawn extends Packet {
|
||||||
|
|
||||||
|
public Packet20NamedEntitySpawn(EntityHuman entityhuman) {
|
||||||
|
this.a = entityhuman.id;
|
||||||
|
+ this.playerUUID = entityhuman.playerUUID; // Spigot
|
||||||
|
|
||||||
|
// CraftBukkit start - Limit name length to 16 characters
|
||||||
|
if (entityhuman.name.length() > 16) {
|
||||||
|
@@ -58,6 +60,7 @@ public class Packet20NamedEntitySpawn extends Packet {
|
||||||
|
|
||||||
|
public void a(DataOutput dataoutput) throws IOException { // CraftBukkit
|
||||||
|
dataoutput.writeInt(this.a);
|
||||||
|
+ if ( this.playerUUID != null ) a( playerUUID, dataoutput ); // Spigot
|
||||||
|
a(this.b, dataoutput);
|
||||||
|
dataoutput.writeInt(this.c);
|
||||||
|
dataoutput.writeInt(this.d);
|
||||||
|
diff --git a/src/main/java/net/minecraft/server/Packet62NamedSoundEffect.java b/src/main/java/net/minecraft/server/Packet62NamedSoundEffect.java
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000..9b64483
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/main/java/net/minecraft/server/Packet62NamedSoundEffect.java
|
||||||
|
@@ -0,0 +1,60 @@
|
||||||
|
+package net.minecraft.server;
|
||||||
|
+
|
||||||
|
+import java.io.DataInput;
|
||||||
|
+import java.io.DataOutput;
|
||||||
|
+import java.io.IOException;
|
||||||
|
+
|
||||||
|
+public class Packet62NamedSoundEffect extends Packet {
|
||||||
|
+
|
||||||
|
+ private String a;
|
||||||
|
+ private int b;
|
||||||
|
+ private int c = Integer.MAX_VALUE;
|
||||||
|
+ private int d;
|
||||||
|
+ private float e;
|
||||||
|
+ private int f;
|
||||||
|
+
|
||||||
|
+ public Packet62NamedSoundEffect() {}
|
||||||
|
+
|
||||||
|
+ public Packet62NamedSoundEffect(String s, double d0, double d1, double d2, float f, float f1) {
|
||||||
|
+ this.a = s;
|
||||||
|
+ this.b = (int) (d0 * 8.0D);
|
||||||
|
+ this.c = (int) (d1 * 8.0D);
|
||||||
|
+ this.d = (int) (d2 * 8.0D);
|
||||||
|
+ this.e = f;
|
||||||
|
+ this.f = (int) (f1 * 63.0F);
|
||||||
|
+ if (this.f < 0) {
|
||||||
|
+ this.f = 0;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if (this.f > 255) {
|
||||||
|
+ this.f = 255;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public void a(DataInput datainput) throws IOException {
|
||||||
|
+ this.a = a(datainput, 256);
|
||||||
|
+ this.b = datainput.readInt();
|
||||||
|
+ this.c = datainput.readInt();
|
||||||
|
+ this.d = datainput.readInt();
|
||||||
|
+ this.e = datainput.readFloat();
|
||||||
|
+ this.f = datainput.readUnsignedByte();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public void a(DataOutput dataoutput) throws IOException {
|
||||||
|
+ a(this.a, dataoutput);
|
||||||
|
+ dataoutput.writeInt(this.b);
|
||||||
|
+ dataoutput.writeInt(this.c);
|
||||||
|
+ dataoutput.writeInt(this.d);
|
||||||
|
+ dataoutput.writeFloat(this.e);
|
||||||
|
+ dataoutput.writeByte(this.f);
|
||||||
|
+ if ( org.spigotmc.SpigotConfig.snapshotProtocol ) dataoutput.writeByte( 0 ); // Spigot
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public void handle(Connection connection) {
|
||||||
|
+ connection.a(this);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public int a() {
|
||||||
|
+ return 24;
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
diff --git a/src/main/java/net/minecraft/server/Packet70Bed.java b/src/main/java/net/minecraft/server/Packet70Bed.java
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000..ff89531
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/main/java/net/minecraft/server/Packet70Bed.java
|
||||||
|
@@ -0,0 +1,37 @@
|
||||||
|
+package net.minecraft.server;
|
||||||
|
+
|
||||||
|
+import java.io.DataInput;
|
||||||
|
+import java.io.DataOutput;
|
||||||
|
+import java.io.IOException;
|
||||||
|
+
|
||||||
|
+public class Packet70Bed extends Packet {
|
||||||
|
+
|
||||||
|
+ public static final String[] a = new String[] { "tile.bed.notValid", null, null, "gameMode.changed"};
|
||||||
|
+ public int b;
|
||||||
|
+ public int c;
|
||||||
|
+
|
||||||
|
+ public Packet70Bed() {}
|
||||||
|
+
|
||||||
|
+ public Packet70Bed(int i, int j) {
|
||||||
|
+ this.b = i;
|
||||||
|
+ this.c = j;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public void a(DataInput datainput) throws IOException {
|
||||||
|
+ this.b = datainput.readByte();
|
||||||
|
+ this.c = datainput.readByte();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public void a(DataOutput dataoutput) throws IOException {
|
||||||
|
+ dataoutput.writeByte(this.b);
|
||||||
|
+ if ( org.spigotmc.SpigotConfig.snapshotProtocol ) dataoutput.writeFloat(this.c); else dataoutput.writeByte(this.c); // Spigot
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public void handle(Connection connection) {
|
||||||
|
+ connection.a(this);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public int a() {
|
||||||
|
+ return 2;
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
diff --git a/src/main/java/net/minecraft/server/PendingConnection.java b/src/main/java/net/minecraft/server/PendingConnection.java
|
||||||
|
index 358cba4..a86fbbc 100644
|
||||||
|
--- a/src/main/java/net/minecraft/server/PendingConnection.java
|
||||||
|
+++ b/src/main/java/net/minecraft/server/PendingConnection.java
|
||||||
|
@@ -25,6 +25,7 @@ public class PendingConnection extends Connection {
|
||||||
|
private boolean j;
|
||||||
|
private SecretKey k;
|
||||||
|
public String hostname = ""; // CraftBukkit - add field
|
||||||
|
+ public String playerUUID;
|
||||||
|
|
||||||
|
public PendingConnection(MinecraftServer minecraftserver, org.spigotmc.netty.NettyNetworkManager networkManager) {
|
||||||
|
this.server = minecraftserver;
|
||||||
|
@@ -78,8 +79,8 @@ public class PendingConnection extends Connection {
|
||||||
|
} else {
|
||||||
|
PublicKey publickey = this.server.H().getPublic();
|
||||||
|
|
||||||
|
- if (packet2handshake.d() != 78) {
|
||||||
|
- if (packet2handshake.d() > 78) {
|
||||||
|
+ if (packet2handshake.d() != org.spigotmc.SpigotConfig.protocolVersion) { // Spigot
|
||||||
|
+ if (packet2handshake.d() > org.spigotmc.SpigotConfig.protocolVersion) { // Spigot
|
||||||
|
this.disconnect(org.spigotmc.SpigotConfig.outdatedServerMessage); // Spigot
|
||||||
|
} else {
|
||||||
|
this.disconnect(org.spigotmc.SpigotConfig.outdatedClientMessage); // Spigot
|
||||||
|
@@ -133,6 +134,7 @@ public class PendingConnection extends Connection {
|
||||||
|
// CraftBukkit end
|
||||||
|
} else {
|
||||||
|
EntityPlayer entityplayer = this.server.getPlayerList().processLogin(s); // CraftBukkit - this.g -> s
|
||||||
|
+ entityplayer.playerUUID = this.playerUUID; // Spigot
|
||||||
|
|
||||||
|
if (entityplayer != null) {
|
||||||
|
this.server.getPlayerList().a((INetworkManager) this.networkManager, entityplayer);
|
||||||
|
@@ -159,7 +161,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, org.spigotmc.SpigotConfig.protocolVersion, this.server.getVersion(), pingEvent.getMotd(), playerlist.getPlayerCount(), pingEvent.getMaxPlayers() }; // Spigot
|
||||||
|
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
for (Object object : list) {
|
||||||
|
diff --git a/src/main/java/net/minecraft/server/ThreadLoginVerifier.java b/src/main/java/net/minecraft/server/ThreadLoginVerifier.java
|
||||||
|
index 70f9fea..2d0c1f9 100644
|
||||||
|
--- a/src/main/java/net/minecraft/server/ThreadLoginVerifier.java
|
||||||
|
+++ b/src/main/java/net/minecraft/server/ThreadLoginVerifier.java
|
||||||
|
@@ -26,9 +26,39 @@ class ThreadLoginVerifier extends Thread {
|
||||||
|
// CraftBukkit end
|
||||||
|
this.pendingConnection = pendingconnection;
|
||||||
|
}
|
||||||
|
+
|
||||||
|
+ // Spigot Start
|
||||||
|
+ public static class NewResponse
|
||||||
|
+ {
|
||||||
|
|
||||||
|
- private boolean auth() throws java.io.IOException {
|
||||||
|
- String s = (new BigInteger(MinecraftEncryption.a(PendingConnection.a(this.pendingConnection), PendingConnection.b(this.pendingConnection).H().getPublic(), PendingConnection.c(this.pendingConnection)))).toString(16);
|
||||||
|
+ private String id;
|
||||||
|
+ }
|
||||||
|
+ // Spigot End
|
||||||
|
+
|
||||||
|
+ private boolean auth() throws java.io.IOException
|
||||||
|
+ {
|
||||||
|
+ // Spigot Start
|
||||||
|
+ if ( org.spigotmc.SpigotConfig.snapshotProtocol )
|
||||||
|
+ {
|
||||||
|
+ String url = "https://sessionserver.mojang.com/session/minecraft/hasJoined?username=" + URLEncoder.encode( PendingConnection.d( this.pendingConnection ), "UTF-8" ) + "&serverId=" + URLEncoder.encode( PendingConnection.a( pendingConnection ), "UTF-8" );
|
||||||
|
+ BufferedReader br = new BufferedReader( new InputStreamReader( new URL( url ).openConnection( PendingConnection.b( this.pendingConnection ).ap() ).getInputStream() ) );
|
||||||
|
+ String s = br.readLine();
|
||||||
|
+ br.close();
|
||||||
|
+ NewResponse response = new com.google.gson.Gson().fromJson( s, NewResponse.class );
|
||||||
|
+ if ( response != null )
|
||||||
|
+ {
|
||||||
|
+ if ( response.id != null )
|
||||||
|
+ {
|
||||||
|
+ this.pendingConnection.playerUUID = response.id;
|
||||||
|
+ return true;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ this.pendingConnection.disconnect( "Failed to verify username!" );
|
||||||
|
+ return false;
|
||||||
|
+ }
|
||||||
|
+ // Spigot End
|
||||||
|
+
|
||||||
|
+ String s = ( new BigInteger( MinecraftEncryption.a( PendingConnection.a(this.pendingConnection), PendingConnection.b(this.pendingConnection).H().getPublic(), PendingConnection.c(this.pendingConnection)))).toString(16);
|
||||||
|
URL url = new URL("http://session.minecraft.net/game/checkserver.jsp?user=" + URLEncoder.encode(PendingConnection.d(this.pendingConnection), "UTF-8") + "&serverId=" + URLEncoder.encode(s, "UTF-8"));
|
||||||
|
BufferedReader bufferedreader = new BufferedReader(new InputStreamReader(url.openConnection(PendingConnection.b(this.pendingConnection).ap()).getInputStream()));
|
||||||
|
String s1 = bufferedreader.readLine();
|
||||||
|
diff --git a/src/main/java/org/spigotmc/SpigotConfig.java b/src/main/java/org/spigotmc/SpigotConfig.java
|
||||||
|
index 296c581..a49b275 100644
|
||||||
|
--- a/src/main/java/org/spigotmc/SpigotConfig.java
|
||||||
|
+++ b/src/main/java/org/spigotmc/SpigotConfig.java
|
||||||
|
@@ -290,4 +290,22 @@ public class SpigotConfig
|
||||||
|
|
||||||
|
Bukkit.getLogger().setFilter( new LogFilter() );
|
||||||
|
}
|
||||||
|
+
|
||||||
|
+ public static boolean snapshotProtocol;
|
||||||
|
+ public static String gameVersion;
|
||||||
|
+ public static byte protocolVersion;
|
||||||
|
+ private static void snapshotProtocol()
|
||||||
|
+ {
|
||||||
|
+ snapshotProtocol = getBoolean( "settings.snapshot-protocol", false );
|
||||||
|
+
|
||||||
|
+ gameVersion = ( snapshotProtocol ) ? "13w39b" : "1.6.4";
|
||||||
|
+ protocolVersion = (byte) ( ( snapshotProtocol ) ? 80 : 78 );
|
||||||
|
+ if ( snapshotProtocol )
|
||||||
|
+ {
|
||||||
|
+ Bukkit.getLogger().severe( "================ [Snapshot Protocol] ================" );
|
||||||
|
+ Bukkit.getLogger().severe( "Initialised Snapshot Protocol for " + gameVersion + " (" + protocolVersion + ")" );
|
||||||
|
+ Bukkit.getLogger().severe( "Features may NOT be implemented! Use at your own risk!" );
|
||||||
|
+ Bukkit.getLogger().severe( "================ ====================================" );
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
}
|
||||||
|
--
|
||||||
|
1.8.1.2
|
||||||
|
|
@ -1,22 +1,39 @@
|
|||||||
From 89f9c8f06dbe1b36214500b30a2db3b5383f03c5 Mon Sep 17 00:00:00 2001
|
From 84cf8a6a6899e1915dbbd49ec862018ed4749871 Mon Sep 17 00:00:00 2001
|
||||||
From: md_5 <md_5@live.com.au>
|
From: md_5 <md_5@live.com.au>
|
||||||
Date: Sun, 6 Oct 2013 17:36:28 +1100
|
Date: Sun, 6 Oct 2013 17:36:28 +1100
|
||||||
Subject: [PATCH] Don't Special Case X Move Value
|
Subject: [PATCH] Don't Special Case X Move Value
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
|
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
|
||||||
index 10d853b..4117942 100644
|
index 10d853b..fbba359 100644
|
||||||
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
|
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
|
||||||
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
|
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
|
||||||
@@ -222,7 +222,7 @@ public class PlayerConnection extends Connection {
|
@@ -96,6 +96,7 @@ public class PlayerConnection extends Connection {
|
||||||
|
private float lastPitch = Float.MAX_VALUE;
|
||||||
|
private float lastYaw = Float.MAX_VALUE;
|
||||||
|
private boolean justTeleported = false;
|
||||||
|
+ private boolean hasMoved; // Spigot
|
||||||
|
|
||||||
|
// For the packet15 hack :(
|
||||||
|
Long lastPacket;
|
||||||
|
@@ -222,7 +223,7 @@ public class PlayerConnection extends Connection {
|
||||||
this.lastPitch = to.getPitch();
|
this.lastPitch = to.getPitch();
|
||||||
|
|
||||||
// Skip the first time we do this
|
// Skip the first time we do this
|
||||||
- if (from.getX() != Double.MAX_VALUE) {
|
- if (from.getX() != Double.MAX_VALUE) {
|
||||||
+ if (true) { // Spigot - no special cases!
|
+ if (hasMoved) { // Spigot - Better Check!
|
||||||
PlayerMoveEvent event = new PlayerMoveEvent(player, from, to);
|
PlayerMoveEvent event = new PlayerMoveEvent(player, from, to);
|
||||||
this.server.getPluginManager().callEvent(event);
|
this.server.getPluginManager().callEvent(event);
|
||||||
|
|
||||||
|
@@ -246,7 +247,7 @@ public class PlayerConnection extends Connection {
|
||||||
|
this.justTeleported = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
- }
|
||||||
|
+ } else { hasMoved = true; } // Spigot - Better Check!
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Double.isNaN(packet10flying.x) || Double.isNaN(packet10flying.y) || Double.isNaN(packet10flying.z) || Double.isNaN(packet10flying.stance)) {
|
||||||
--
|
--
|
||||||
1.8.1.2
|
1.8.1.2
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user