Archiviert
13
0

Expand the isFinite checks to yaw and pitch

Dieser Commit ist enthalten in:
Thinkofdeath 2015-04-03 01:36:47 +01:00
Ursprung 63e28b1c3d
Commit 7d020a7041

Datei anzeigen

@ -1,5 +1,5 @@
--- /home/matt/mc-dev-private//net/minecraft/server/PlayerConnection.java 2015-03-19 21:25:54.882142154 +0000
+++ src/main/java/net/minecraft/server/PlayerConnection.java 2015-03-19 21:25:54.886142154 +0000
--- /home/matt/mc-dev-private//net/minecraft/server/PlayerConnection.java 2015-04-03 01:35:20.157517546 +0100
+++ src/main/java/net/minecraft/server/PlayerConnection.java 2015-04-03 01:35:20.177517546 +0100
@@ -17,6 +17,48 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@ -157,12 +157,16 @@
}
public void a(PacketPlayInSteerVehicle packetplayinsteervehicle) {
@@ -99,6 +192,13 @@
@@ -99,6 +192,17 @@
public void a(PacketPlayInFlying packetplayinflying) {
PlayerConnectionUtils.ensureMainThread(packetplayinflying, this, this.player.u());
+ // CraftBukkit start - Check for NaN
+ if (!NumberConversions.isFinite(packetplayinflying.x) || !NumberConversions.isFinite(packetplayinflying.y) || !NumberConversions.isFinite(packetplayinflying.z)) {
+ if (!NumberConversions.isFinite(packetplayinflying.x)
+ || !NumberConversions.isFinite(packetplayinflying.y)
+ || !NumberConversions.isFinite(packetplayinflying.z)
+ || !NumberConversions.isFinite(packetplayinflying.yaw)
+ || !NumberConversions.isFinite(packetplayinflying.pitch)) {
+ c.warn(player.getName() + " was caught trying to crash the server with an invalid position.");
+ getPlayer().kickPlayer("Nope!");
+ return;
@ -171,7 +175,7 @@
WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension);
this.h = true;
@@ -117,8 +217,65 @@
@@ -117,8 +221,65 @@
this.checkMovement = true;
}
}
@ -238,7 +242,7 @@
this.f = this.e;
double d7;
double d8;
@@ -212,12 +369,14 @@
@@ -212,12 +373,14 @@
double d11 = d7 - this.player.locX;
double d12 = d8 - this.player.locY;
double d13 = d9 - this.player.locZ;
@ -257,7 +261,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;
@@ -286,10 +445,53 @@
@@ -286,10 +449,53 @@
}
public void a(double d0, double d1, double d2, float f, float f1) {
@ -312,7 +316,7 @@
this.checkMovement = false;
this.o = d0;
this.p = d1;
@@ -323,32 +525,49 @@
@@ -323,32 +529,49 @@
public void a(PacketPlayInBlockDig packetplayinblockdig) {
PlayerConnectionUtils.ensureMainThread(packetplayinblockdig, this, this.player.u());
@ -368,7 +372,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);
@@ -363,7 +582,15 @@
@@ -363,7 +586,15 @@
if (!this.minecraftServer.a(worldserver, blockposition, this.player) && worldserver.getWorldBorder().a(blockposition)) {
this.player.playerInteractManager.a(blockposition, packetplayinblockdig.b());
} else {
@ -384,7 +388,7 @@
}
} else {
if (packetplayinblockdig.c() == PacketPlayInBlockDig.EnumPlayerDigType.STOP_DESTROY_BLOCK) {
@@ -383,11 +610,22 @@
@@ -383,11 +614,22 @@
default:
throw new IllegalArgumentException("Invalid player action");
}
@ -407,7 +411,7 @@
ItemStack itemstack = this.player.inventory.getItemInHand();
boolean flag = false;
BlockPosition blockposition = packetplayinblockplace.a();
@@ -399,7 +637,50 @@
@@ -399,7 +641,50 @@
return;
}
@ -459,7 +463,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())});
@@ -407,8 +688,19 @@
@@ -407,8 +692,19 @@
this.player.playerConnection.sendPacket(new PacketPlayOutChat(chatmessage));
flag = true;
} else {
@ -480,7 +484,7 @@
}
flag = true;
@@ -432,7 +724,8 @@
@@ -432,7 +728,8 @@
this.player.activeContainer.b();
this.player.g = false;
@ -490,7 +494,7 @@
this.sendPacket(new PacketPlayOutSetSlot(this.player.activeContainer.windowId, slot.rawSlotIndex, this.player.inventory.getItemInHand()));
}
}
@@ -446,8 +739,8 @@
@@ -446,8 +743,8 @@
WorldServer[] aworldserver = this.minecraftServer.worldServer;
int i = aworldserver.length;
@ -501,7 +505,7 @@
if (worldserver != null) {
entity = packetplayinspectate.a(worldserver);
@@ -460,6 +753,8 @@
@@ -460,6 +757,8 @@
if (entity != null) {
this.player.e((Entity) this.player);
this.player.mount((Entity) null);
@ -510,7 +514,7 @@
if (entity.world != this.player.world) {
WorldServer worldserver1 = this.player.u();
WorldServer worldserver2 = (WorldServer) entity.world;
@@ -484,6 +779,9 @@
@@ -484,6 +783,9 @@
} else {
this.player.enderTeleportTo(entity.locX, entity.locY, entity.locZ);
}
@ -520,7 +524,7 @@
}
}
@@ -492,14 +790,29 @@
@@ -492,14 +794,29 @@
public void a(PacketPlayInResourcePackStatus packetplayinresourcepackstatus) {}
public void a(IChatBaseComponent ichatbasecomponent) {
@ -552,7 +556,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();
@@ -521,6 +834,15 @@
@@ -521,6 +838,15 @@
}
}
@ -568,7 +572,7 @@
try {
this.networkManager.handle(packet);
} catch (Throwable throwable) {
@@ -541,18 +863,34 @@
@@ -541,18 +867,34 @@
}
public void a(PacketPlayInHeldItemSlot packetplayinhelditemslot) {
@ -605,7 +609,7 @@
ChatMessage chatmessage = new ChatMessage("chat.cannotSend", new Object[0]);
chatmessage.getChatModifier().setColor(EnumChatFormat.RED);
@@ -565,39 +903,249 @@
@@ -565,39 +907,249 @@
for (int i = 0; i < s.length(); ++i) {
if (!SharedConstants.isAllowedChatCharacter(s.charAt(i))) {
@ -863,7 +867,7 @@
this.player.z();
switch (PlayerConnection.SyntheticClass_1.b[packetplayinentityaction.b().ordinal()]) {
case 1:
@@ -618,7 +1166,7 @@
@@ -618,7 +1170,7 @@
case 5:
this.player.a(false, true, true);
@ -872,7 +876,7 @@
break;
case 6:
@@ -640,6 +1188,7 @@
@@ -640,6 +1192,7 @@
}
public void a(PacketPlayInUseEntity packetplayinuseentity) {
@ -880,7 +884,7 @@
PlayerConnectionUtils.ensureMainThread(packetplayinuseentity, this, this.player.u());
WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension);
Entity entity = packetplayinuseentity.a((World) worldserver);
@@ -654,18 +1203,71 @@
@@ -654,18 +1207,71 @@
}
if (this.player.h(entity) < d0) {
@ -953,7 +957,7 @@
}
}
}
@@ -680,7 +1282,8 @@
@@ -680,7 +1286,8 @@
switch (PlayerConnection.SyntheticClass_1.c[packetplayinclientcommand_enumclientcommand.ordinal()]) {
case 1:
if (this.player.viewingCredits) {
@ -963,7 +967,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!");
@@ -711,15 +1314,21 @@
@@ -711,15 +1318,21 @@
}
public void a(PacketPlayInCloseWindow packetplayinclosewindow) {
@ -986,7 +990,7 @@
ArrayList arraylist = Lists.newArrayList();
for (int i = 0; i < this.player.activeContainer.c.size(); ++i) {
@@ -728,7 +1337,270 @@
@@ -728,7 +1341,270 @@
this.player.a(this.player.activeContainer, (List) arraylist);
} else {
@ -1258,7 +1262,7 @@
if (ItemStack.matches(packetplayinwindowclick.e(), itemstack)) {
this.player.playerConnection.sendPacket(new PacketPlayOutTransaction(packetplayinwindowclick.a(), packetplayinwindowclick.d(), true));
@@ -789,8 +1661,48 @@
@@ -789,8 +1665,48 @@
}
boolean flag1 = packetplayinsetcreativeslot.a() >= 1 && packetplayinsetcreativeslot.a() < 36 + PlayerInventory.getHotbarSize();
@ -1308,7 +1312,7 @@
if (flag1 && flag2 && flag3) {
if (itemstack == null) {
@@ -813,6 +1725,7 @@
@@ -813,6 +1729,7 @@
}
public void a(PacketPlayInTransaction packetplayintransaction) {
@ -1316,7 +1320,7 @@
PlayerConnectionUtils.ensureMainThread(packetplayintransaction, this, this.player.u());
Short oshort = (Short) this.n.get(this.player.activeContainer.windowId);
@@ -823,6 +1736,7 @@
@@ -823,6 +1740,7 @@
}
public void a(PacketPlayInUpdateSign packetplayinupdatesign) {
@ -1324,7 +1328,7 @@
PlayerConnectionUtils.ensureMainThread(packetplayinupdatesign, this, this.player.u());
this.player.z();
WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension);
@@ -839,14 +1753,30 @@
@@ -839,14 +1757,30 @@
if (!tileentitysign.b() || tileentitysign.c() != this.player) {
this.minecraftServer.warning("Player " + this.player.getName() + " just tried to change non-editable sign");
@ -1356,7 +1360,7 @@
tileentitysign.update();
worldserver.notify(blockposition);
@@ -869,11 +1799,27 @@
@@ -869,11 +1803,27 @@
public void a(PacketPlayInAbilities packetplayinabilities) {
PlayerConnectionUtils.ensureMainThread(packetplayinabilities, this, this.player.u());
@ -1385,7 +1389,7 @@
ArrayList arraylist = Lists.newArrayList();
Iterator iterator = this.minecraftServer.tabCompleteCommand(this.player, packetplayintabcomplete.a(), packetplayintabcomplete.b()).iterator();
@@ -913,13 +1859,15 @@
@@ -913,13 +1863,15 @@
itemstack1 = this.player.inventory.getItemInHand();
if (itemstack1 != null) {
if (itemstack.getItem() == Items.WRITABLE_BOOK && itemstack.getItem() == itemstack1.getItem()) {
@ -1402,7 +1406,7 @@
return;
} finally {
packetdataserializer.release();
@@ -942,16 +1890,20 @@
@@ -942,16 +1894,20 @@
itemstack1 = this.player.inventory.getItemInHand();
if (itemstack1 != null) {
if (itemstack.getItem() == Items.WRITTEN_BOOK && itemstack1.getItem() == Items.WRITABLE_BOOK) {
@ -1427,7 +1431,7 @@
return;
} finally {
packetdataserializer.release();
@@ -968,11 +1920,12 @@
@@ -968,11 +1924,12 @@
}
} catch (Exception exception2) {
PlayerConnection.c.error("Couldn\'t select trade", exception2);
@ -1441,7 +1445,7 @@
packetdataserializer = packetplayincustompayload.b();
try {
@@ -1008,6 +1961,7 @@
@@ -1008,6 +1965,7 @@
}
} catch (Exception exception3) {
PlayerConnection.c.error("Couldn\'t set command block", exception3);
@ -1449,7 +1453,7 @@
} finally {
packetdataserializer.release();
}
@@ -1033,6 +1987,7 @@
@@ -1033,6 +1991,7 @@
}
} catch (Exception exception4) {
PlayerConnection.c.error("Couldn\'t set beacon", exception4);
@ -1457,7 +1461,7 @@
}
}
} else if ("MC|ItemName".equals(packetplayincustompayload.a()) && this.player.activeContainer instanceof ContainerAnvil) {
@@ -1048,7 +2003,28 @@
@@ -1048,7 +2007,28 @@
containeranvil.a("");
}
}