summaryrefslogtreecommitdiffstats
path: root/nms-patches
diff options
context:
space:
mode:
authorThinkofdeath <thinkofdeath@spigotmc.org>2014-12-06 20:53:57 +0000
committerThinkofdeath <thinkofdeath@spigotmc.org>2014-12-06 20:53:57 +0000
commitc4129c259b5913333efed76975c345d2afff6acd (patch)
treeef96497c1564a3a7bf3660bdcc1a692b22020e49 /nms-patches
parentd04430e09b0a7067595640d16ed55299d20135ee (diff)
downloadcraftbukkit-c4129c259b5913333efed76975c345d2afff6acd.tar
craftbukkit-c4129c259b5913333efed76975c345d2afff6acd.tar.gz
craftbukkit-c4129c259b5913333efed76975c345d2afff6acd.tar.lz
craftbukkit-c4129c259b5913333efed76975c345d2afff6acd.tar.xz
craftbukkit-c4129c259b5913333efed76975c345d2afff6acd.zip
Disconnect old players before firing PlayerLoginEvent and fire a
PlayerQuitEvent straight after a PlayerKickEvent
Diffstat (limited to 'nms-patches')
-rw-r--r--nms-patches/PlayerConnection.patch75
-rw-r--r--nms-patches/PlayerList.patch69
2 files changed, 84 insertions, 60 deletions
diff --git a/nms-patches/PlayerConnection.patch b/nms-patches/PlayerConnection.patch
index 624d4f58..5f84678f 100644
--- a/nms-patches/PlayerConnection.patch
+++ b/nms-patches/PlayerConnection.patch
@@ -1,5 +1,5 @@
---- ../work/decompile-8eb82bde//net/minecraft/server/PlayerConnection.java 2014-12-05 15:03:49.462262206 +0000
-+++ src/main/java/net/minecraft/server/PlayerConnection.java 2014-12-05 15:03:44.490262316 +0000
+--- ../work/decompile-8eb82bde//net/minecraft/server/PlayerConnection.java 2014-12-06 20:53:31.195313494 +0000
++++ src/main/java/net/minecraft/server/PlayerConnection.java 2014-12-06 20:50:54.967316961 +0000
@@ -16,6 +16,48 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -115,7 +115,7 @@
if (this.m > 0) {
--this.m;
-@@ -76,11 +151,27 @@
+@@ -76,11 +151,28 @@
}
public void disconnect(String s) {
@@ -137,6 +137,7 @@
+ // CraftBukkit end
ChatComponentText chatcomponenttext = new ChatComponentText(s);
++ this.a(chatcomponenttext); // CraftBukkit - fire quit instantly
this.networkManager.a(new PacketPlayOutKickDisconnect(chatcomponenttext), new PlayerConnectionFuture(this, chatcomponenttext), new GenericFutureListener[0]);
this.networkManager.k();
- Futures.getUnchecked(this.minecraftServer.postToMainThread(new PlayerConnectionDisconnector(this)));
@@ -144,7 +145,7 @@
}
public void a(PacketPlayInSteerVehicle packetplayinsteervehicle) {
-@@ -90,6 +181,13 @@
+@@ -90,6 +182,13 @@
public void a(PacketPlayInFlying packetplayinflying) {
PlayerConnectionUtils.ensureMainThread(packetplayinflying, this, this.player.u());
@@ -158,7 +159,7 @@
WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension);
this.h = true;
-@@ -108,8 +206,65 @@
+@@ -108,8 +207,65 @@
this.checkMovement = true;
}
}
@@ -225,7 +226,7 @@
this.f = this.e;
double d7;
double d8;
-@@ -203,12 +358,14 @@
+@@ -203,12 +359,14 @@
double d11 = d7 - this.player.locX;
double d12 = d8 - this.player.locY;
double d13 = d9 - this.player.locZ;
@@ -244,7 +245,7 @@
PlayerConnection.c.warn(this.player.getName() + " moved too quickly! " + d11 + "," + d12 + "," + d13 + " (" + d14 + ", " + d15 + ", " + d16 + ")");
this.a(this.o, this.p, this.q, this.player.yaw, this.player.pitch);
return;
-@@ -281,6 +438,49 @@
+@@ -281,6 +439,49 @@
}
public void a(double d0, double d1, double d2, float f, float f1, Set set) {
@@ -294,7 +295,7 @@
this.checkMovement = false;
this.o = d0;
this.p = d1;
-@@ -314,32 +514,49 @@
+@@ -314,32 +515,49 @@
public void a(PacketPlayInBlockDig packetplayinblockdig) {
PlayerConnectionUtils.ensureMainThread(packetplayinblockdig, this, this.player.u());
@@ -350,7 +351,7 @@
double d0 = this.player.locX - ((double) blockposition.getX() + 0.5D);
double d1 = this.player.locY - ((double) blockposition.getY() + 0.5D) + 1.5D;
double d2 = this.player.locZ - ((double) blockposition.getZ() + 0.5D);
-@@ -354,7 +571,15 @@
+@@ -354,7 +572,15 @@
if (!this.minecraftServer.a(worldserver, blockposition, this.player) && worldserver.af().a(blockposition)) {
this.player.playerInteractManager.a(blockposition, packetplayinblockdig.b());
} else {
@@ -366,7 +367,7 @@
}
} else {
if (packetplayinblockdig.c() == EnumPlayerDigType.STOP_DESTROY_BLOCK) {
-@@ -374,11 +599,22 @@
+@@ -374,11 +600,22 @@
default:
throw new IllegalArgumentException("Invalid player action");
}
@@ -389,7 +390,7 @@
ItemStack itemstack = this.player.inventory.getItemInHand();
boolean flag = false;
BlockPosition blockposition = packetplayinblockplace.a();
-@@ -390,7 +626,18 @@
+@@ -390,7 +627,18 @@
return;
}
@@ -409,7 +410,7 @@
} else if (blockposition.getY() >= this.minecraftServer.getMaxBuildHeight() - 1 && (enumdirection == EnumDirection.UP || blockposition.getY() >= this.minecraftServer.getMaxBuildHeight())) {
ChatMessage chatmessage = new ChatMessage("build.tooHigh", new Object[] { Integer.valueOf(this.minecraftServer.getMaxBuildHeight())});
-@@ -398,9 +645,21 @@
+@@ -398,9 +646,21 @@
this.player.playerConnection.sendPacket(new PacketPlayOutChat(chatmessage));
flag = true;
} else {
@@ -432,7 +433,7 @@
flag = true;
}
-@@ -423,7 +682,8 @@
+@@ -423,7 +683,8 @@
this.player.activeContainer.b();
this.player.g = false;
@@ -442,7 +443,7 @@
this.sendPacket(new PacketPlayOutSetSlot(this.player.activeContainer.windowId, slot.rawSlotIndex, this.player.inventory.getItemInHand()));
}
}
-@@ -437,8 +697,8 @@
+@@ -437,8 +698,8 @@
WorldServer[] aworldserver = this.minecraftServer.worldServer;
int i = aworldserver.length;
@@ -453,7 +454,7 @@
if (worldserver != null) {
entity = packetplayinspectate.a(worldserver);
-@@ -455,6 +715,7 @@
+@@ -455,6 +716,7 @@
WorldServer worldserver1 = this.player.u();
WorldServer worldserver2 = (WorldServer) entity.world;
@@ -461,7 +462,7 @@
this.player.dimension = entity.dimension;
this.sendPacket(new PacketPlayOutRespawn(this.player.dimension, worldserver1.getDifficulty(), worldserver1.getWorldData().getType(), this.player.playerInteractManager.getGameMode()));
worldserver1.removeEntity(this.player);
-@@ -472,6 +733,9 @@
+@@ -472,6 +734,9 @@
this.player.playerInteractManager.a(worldserver2);
this.minecraftServer.getPlayerList().b(this.player, worldserver2);
this.minecraftServer.getPlayerList().updateClient(this.player);
@@ -471,7 +472,7 @@
} else {
this.player.enderTeleportTo(entity.locX, entity.locY, entity.locZ);
}
-@@ -483,14 +747,29 @@
+@@ -483,14 +748,29 @@
public void a(PacketPlayInResourcePackStatus packetplayinresourcepackstatus) {}
public void a(IChatBaseComponent ichatbasecomponent) {
@@ -503,7 +504,7 @@
if (this.minecraftServer.S() && this.player.getName().equals(this.minecraftServer.R())) {
PlayerConnection.c.info("Stopping singleplayer server as player logged out");
this.minecraftServer.safeShutdown();
-@@ -511,6 +790,15 @@
+@@ -511,6 +791,15 @@
return;
}
}
@@ -519,7 +520,7 @@
try {
this.networkManager.handle(packet);
-@@ -524,18 +812,34 @@
+@@ -524,18 +813,34 @@
}
public void a(PacketPlayInHeldItemSlot packetplayinhelditemslot) {
@@ -556,7 +557,7 @@
ChatMessage chatmessage = new ChatMessage("chat.cannotSend", new Object[0]);
chatmessage.getChatModifier().setColor(EnumChatFormat.RED);
-@@ -548,39 +852,247 @@
+@@ -548,39 +853,247 @@
for (int i = 0; i < s.length(); ++i) {
if (!SharedConstants.isAllowedChatCharacter(s.charAt(i))) {
@@ -812,7 +813,7 @@
this.player.z();
switch (SwitchHelperCommandActionType.b[packetplayinentityaction.b().ordinal()]) {
case 1:
-@@ -601,7 +1113,7 @@
+@@ -601,7 +1114,7 @@
case 5:
this.player.a(false, true, true);
@@ -821,7 +822,7 @@
break;
case 6:
-@@ -623,6 +1135,7 @@
+@@ -623,6 +1136,7 @@
}
public void a(PacketPlayInUseEntity packetplayinuseentity) {
@@ -829,7 +830,7 @@
PlayerConnectionUtils.ensureMainThread(packetplayinuseentity, this, this.player.u());
WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension);
Entity entity = packetplayinuseentity.a((World) worldserver);
-@@ -637,18 +1150,72 @@
+@@ -637,18 +1151,72 @@
}
if (this.player.h(entity) < d0) {
@@ -903,7 +904,7 @@
}
}
}
-@@ -663,7 +1230,8 @@
+@@ -663,7 +1231,8 @@
switch (SwitchHelperCommandActionType.c[enumclientcommand.ordinal()]) {
case 1:
if (this.player.viewingCredits) {
@@ -913,7 +914,7 @@
} else if (this.player.u().getWorldData().isHardcore()) {
if (this.minecraftServer.S() && this.player.getName().equals(this.minecraftServer.R())) {
this.player.playerConnection.disconnect("You have died. Game over, man, it\'s game over!");
-@@ -694,11 +1262,17 @@
+@@ -694,11 +1263,17 @@
}
public void a(PacketPlayInCloseWindow packetplayinclosewindow) {
@@ -931,7 +932,7 @@
PlayerConnectionUtils.ensureMainThread(packetplayinwindowclick, this, this.player.u());
this.player.z();
if (this.player.activeContainer.windowId == packetplayinwindowclick.a() && this.player.activeContainer.c(this.player)) {
-@@ -711,7 +1285,269 @@
+@@ -711,7 +1286,269 @@
this.player.a(this.player.activeContainer, (List) arraylist);
} else {
@@ -1202,7 +1203,7 @@
if (ItemStack.matches(packetplayinwindowclick.e(), itemstack)) {
this.player.playerConnection.sendPacket(new PacketPlayOutTransaction(packetplayinwindowclick.a(), packetplayinwindowclick.d(), true));
-@@ -772,8 +1608,50 @@
+@@ -772,8 +1609,50 @@
}
boolean flag1 = packetplayinsetcreativeslot.a() >= 1 && packetplayinsetcreativeslot.a() < 36 + PlayerInventory.getHotbarSize();
@@ -1254,7 +1255,7 @@
if (flag1 && flag2 && flag3) {
if (itemstack == null) {
-@@ -796,6 +1674,7 @@
+@@ -796,6 +1675,7 @@
}
public void a(PacketPlayInTransaction packetplayintransaction) {
@@ -1262,7 +1263,7 @@
PlayerConnectionUtils.ensureMainThread(packetplayintransaction, this, this.player.u());
Short oshort = (Short) this.n.get(this.player.activeContainer.windowId);
-@@ -806,6 +1685,7 @@
+@@ -806,6 +1686,7 @@
}
public void a(PacketPlayInUpdateSign packetplayinupdatesign) {
@@ -1270,7 +1271,7 @@
PlayerConnectionUtils.ensureMainThread(packetplayinupdatesign, this, this.player.u());
this.player.z();
WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension);
-@@ -822,10 +1702,24 @@
+@@ -822,10 +1703,24 @@
if (!tileentitysign.b() || tileentitysign.c() != this.player) {
this.minecraftServer.warning("Player " + this.player.getName() + " just tried to change non-editable sign");
@@ -1296,7 +1297,7 @@
tileentitysign.update();
worldserver.notify(blockposition);
}
-@@ -847,11 +1741,28 @@
+@@ -847,11 +1742,28 @@
public void a(PacketPlayInAbilities packetplayinabilities) {
PlayerConnectionUtils.ensureMainThread(packetplayinabilities, this, this.player.u());
@@ -1326,7 +1327,7 @@
ArrayList arraylist = Lists.newArrayList();
Iterator iterator = this.minecraftServer.tabCompleteCommand(this.player, packetplayintabcomplete.a(), packetplayintabcomplete.b()).iterator();
-@@ -891,13 +1802,15 @@
+@@ -891,13 +1803,15 @@
itemstack1 = this.player.inventory.getItemInHand();
if (itemstack1 != null) {
if (itemstack.getItem() == Items.WRITABLE_BOOK && itemstack.getItem() == itemstack1.getItem()) {
@@ -1343,7 +1344,7 @@
return;
} finally {
packetdataserializer.release();
-@@ -909,27 +1822,31 @@
+@@ -909,27 +1823,31 @@
try {
itemstack = packetdataserializer.i();
@@ -1387,7 +1388,7 @@
return;
} finally {
packetdataserializer.release();
-@@ -946,6 +1863,7 @@
+@@ -946,6 +1864,7 @@
}
} catch (Exception exception2) {
PlayerConnection.c.error("Couldn\'t select trade", exception2);
@@ -1395,7 +1396,7 @@
}
} else if ("MC|AdvCdm".equals(packetplayincustompayload.a())) {
if (!this.minecraftServer.getEnableCommandBlock()) {
-@@ -986,6 +1904,7 @@
+@@ -986,6 +1905,7 @@
}
} catch (Exception exception3) {
PlayerConnection.c.error("Couldn\'t set command block", exception3);
@@ -1403,7 +1404,7 @@
} finally {
packetdataserializer.release();
}
-@@ -1011,6 +1930,7 @@
+@@ -1011,6 +1931,7 @@
}
} catch (Exception exception4) {
PlayerConnection.c.error("Couldn\'t set beacon", exception4);
@@ -1411,7 +1412,7 @@
}
}
} else if ("MC|ItemName".equals(packetplayincustompayload.a()) && this.player.activeContainer instanceof ContainerAnvil) {
-@@ -1026,6 +1946,27 @@
+@@ -1026,6 +1947,27 @@
containeranvil.a("");
}
}
diff --git a/nms-patches/PlayerList.patch b/nms-patches/PlayerList.patch
index 9595b1a5..5a8d02a1 100644
--- a/nms-patches/PlayerList.patch
+++ b/nms-patches/PlayerList.patch
@@ -1,5 +1,5 @@
---- ../work/decompile-8eb82bde//net/minecraft/server/PlayerList.java 2014-12-06 11:15:54.648082670 +0000
-+++ src/main/java/net/minecraft/server/PlayerList.java 2014-12-06 11:13:59.976085215 +0000
+--- ../work/decompile-8eb82bde//net/minecraft/server/PlayerList.java 2014-12-06 20:53:31.255313492 +0000
++++ src/main/java/net/minecraft/server/PlayerList.java 2014-12-06 20:41:55.959328924 +0000
@@ -18,6 +18,25 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -188,7 +188,7 @@
worldserver.removeEntity(entityplayer.vehicle);
PlayerList.h.debug("removing player mount");
}
-@@ -238,13 +312,40 @@
+@@ -238,13 +312,61 @@
this.players.remove(entityplayer);
this.f.remove(entityplayer.getUniqueID());
this.o.remove(entityplayer.getUniqueID());
@@ -217,6 +217,27 @@
- public String attemptLogin(SocketAddress socketaddress, GameProfile gameprofile) {
+ // CraftBukkit start - Whole method, SocketAddress to LoginListener, added hostname to signature, return EntityPlayer
+ public EntityPlayer attemptLogin(LoginListener loginlistener, GameProfile gameprofile, String hostname) {
++ // Moved from processLogin
++ UUID uuid = EntityHuman.a(gameprofile);
++ ArrayList arraylist = Lists.newArrayList();
++
++ EntityPlayer entityplayer;
++
++ for (int i = 0; i < this.players.size(); ++i) {
++ entityplayer = (EntityPlayer) this.players.get(i);
++ if (entityplayer.getUniqueID().equals(uuid)) {
++ arraylist.add(entityplayer);
++ }
++ }
++
++ Iterator iterator = arraylist.iterator();
++
++ while (iterator.hasNext()) {
++ entityplayer = (EntityPlayer) iterator.next();
++ savePlayerFile(entityplayer); // CraftBukkit - Force the player's inventory to be saved
++ entityplayer.playerConnection.disconnect("You logged in from another location");
++ }
++
+ // Instead of kicking then returning, we need to store the kick reason
+ // in the event, check with plugins to see if it's ok, and THEN kick
+ // depending on the outcome.
@@ -232,7 +253,7 @@
GameProfileBanEntry gameprofilebanentry = (GameProfileBanEntry) this.k.get(gameprofile);
s = "You are banned from this server!\nReason: " + gameprofilebanentry.getReason();
-@@ -252,10 +353,12 @@
+@@ -252,10 +374,12 @@
s = s + "\nYour ban will be removed on " + PlayerList.i.format(gameprofilebanentry.getExpires());
}
@@ -248,7 +269,7 @@
IpBanEntry ipbanentry = this.l.get(socketaddress);
s = "Your IP address is banned from this server!\nReason: " + ipbanentry.getReason();
-@@ -263,13 +366,24 @@
+@@ -263,13 +387,25 @@
s = s + "\nYour ban will be removed on " + PlayerList.i.format(ipbanentry.getExpires());
}
@@ -273,22 +294,24 @@
- public EntityPlayer processLogin(GameProfile gameprofile) {
+ public EntityPlayer processLogin(GameProfile gameprofile, EntityPlayer player) { // CraftBukkit - added EntityPlayer
++ /* CraftBukkit startMoved up
UUID uuid = EntityHuman.a(gameprofile);
ArrayList arraylist = Lists.newArrayList();
-@@ -286,9 +400,11 @@
+@@ -286,9 +422,12 @@
while (iterator.hasNext()) {
entityplayer = (EntityPlayer) iterator.next();
+ savePlayerFile(entityplayer); // CraftBukkit - Force the player's inventory to be saved
entityplayer.playerConnection.disconnect("You logged in from another location");
}
++ // CraftBukkit end */
+ /* CraftBukkit start
Object object;
if (this.server.W()) {
-@@ -298,17 +414,25 @@
+@@ -298,17 +437,25 @@
}
return new EntityPlayer(this.server, this.server.getWorldServer(0), gameprofile, (PlayerInteractManager) object);
@@ -315,7 +338,7 @@
entityplayer.dimension = i;
Object object;
-@@ -319,80 +443,270 @@
+@@ -319,80 +466,270 @@
}
EntityPlayer entityplayer1 = new EntityPlayer(this.server, this.server.getWorldServer(entityplayer.dimension), entityplayer.getProfile(), (PlayerInteractManager) object);
@@ -557,7 +580,8 @@
+ */
+ } else {
+ BlockPosition blockposition;
-+
+
+- entityplayer.playerConnection.sendPacket(new PacketPlayOutEntityEffect(entityplayer.getId(), mobeffect));
+ if (i == 1) {
+ // use default NORMAL world spawn instead of target
+ worldserver1 = this.server.worlds.get(0);
@@ -575,9 +599,8 @@
+ worldserver.entityJoinedWorld(entity, false);
+ }
+ */
-+ }
+ }
-- entityplayer.playerConnection.sendPacket(new PacketPlayOutEntityEffect(entityplayer.getId(), mobeffect));
+ // worldserver.methodProfiler.b();
+ if (i != 1) {
+ worldserver.methodProfiler.a("placing");
@@ -593,8 +616,8 @@
+
+ worldserver.methodProfiler.b();
+ */
- }
-
++ }
++
+ // entity.spawnIn(worldserver1);
+ return new Location(worldserver1.getWorld(), d0, y, d1, yaw, pitch);
}
@@ -622,7 +645,7 @@
if (entity.dimension == -1) {
d0 = MathHelper.a(d0 / d2, worldserver1.af().b() + 16.0D, worldserver1.af().d() - 16.0D);
d1 = MathHelper.a(d1 / d2, worldserver1.af().c() + 16.0D, worldserver1.af().e() - 16.0D);
-@@ -411,6 +725,8 @@
+@@ -411,6 +748,8 @@
BlockPosition blockposition;
if (i == 1) {
@@ -631,7 +654,7 @@
blockposition = worldserver1.getSpawn();
} else {
blockposition = worldserver1.getDimensionSpawn();
-@@ -424,15 +740,26 @@
+@@ -424,15 +763,26 @@
worldserver.entityJoinedWorld(entity, false);
}
}
@@ -660,7 +683,7 @@
worldserver1.addEntity(entity);
worldserver1.entityJoinedWorld(entity, false);
}
-@@ -441,6 +768,7 @@
+@@ -441,6 +791,7 @@
}
entity.spawnIn(worldserver1);
@@ -668,7 +691,7 @@
}
public void tick() {
-@@ -549,10 +877,24 @@
+@@ -549,10 +900,24 @@
public void addOp(GameProfile gameprofile) {
this.operators.add(new OpListEntry(gameprofile, this.server.p()));
@@ -693,7 +716,7 @@
}
public boolean isWhitelisted(GameProfile gameprofile) {
-@@ -560,7 +902,7 @@
+@@ -560,7 +925,7 @@
}
public boolean isOp(GameProfile gameprofile) {
@@ -702,7 +725,7 @@
}
public EntityPlayer getPlayer(String s) {
-@@ -587,6 +929,12 @@
+@@ -587,6 +952,12 @@
for (int j = 0; j < this.players.size(); ++j) {
EntityPlayer entityplayer = (EntityPlayer) this.players.get(j);
@@ -715,7 +738,7 @@
if (entityplayer != entityhuman && entityplayer.dimension == i) {
double d4 = d0 - entityplayer.locX;
double d5 = d1 - entityplayer.locY;
-@@ -634,21 +982,26 @@
+@@ -634,21 +1005,26 @@
public void reloadWhitelist() {}
public void b(EntityPlayer entityplayer, WorldServer worldserver) {
@@ -747,7 +770,7 @@
entityplayer.playerConnection.sendPacket(new PacketPlayOutHeldItemSlot(entityplayer.inventory.itemInHandIndex));
}
-@@ -661,7 +1014,7 @@
+@@ -661,7 +1037,7 @@
}
public String[] getSeenPlayers() {
@@ -756,7 +779,7 @@
}
public boolean getHasWhitelist() {
-@@ -711,10 +1064,17 @@
+@@ -711,10 +1087,17 @@
public void v() {
for (int i = 0; i < this.players.size(); ++i) {
@@ -775,7 +798,7 @@
public void sendMessage(IChatBaseComponent ichatbasecomponent, boolean flag) {
this.server.sendMessage(ichatbasecomponent);
-@@ -754,11 +1114,10 @@
+@@ -754,11 +1137,10 @@
public void a(int i) {
this.r = i;
if (this.server.worldServer != null) {