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

SPIGOT-2639: Better state validation

Dieser Commit ist enthalten in:
md_5 2016-09-05 17:33:28 +10:00
Ursprung 48b88ed202
Commit 8788b79a48

Datei anzeigen

@ -228,7 +228,7 @@
+ double delta = Math.pow(this.lastPosX - to.getX(), 2) + Math.pow(this.lastPosY - to.getY(), 2) + Math.pow(this.lastPosZ - to.getZ(), 2); + double delta = Math.pow(this.lastPosX - to.getX(), 2) + Math.pow(this.lastPosY - to.getY(), 2) + Math.pow(this.lastPosZ - to.getZ(), 2);
+ float deltaAngle = Math.abs(this.lastYaw - to.getYaw()) + Math.abs(this.lastPitch - to.getPitch()); + float deltaAngle = Math.abs(this.lastYaw - to.getYaw()) + Math.abs(this.lastPitch - to.getPitch());
+ +
+ if ((delta > 1f / 256 || deltaAngle > 10f) && !this.player.dead) { + if ((delta > 1f / 256 || deltaAngle > 10f) && !this.player.cj()) {
+ this.lastPosX = to.getX(); + this.lastPosX = to.getX();
+ this.lastPosY = to.getY(); + this.lastPosY = to.getY();
+ this.lastPosZ = to.getZ(); + this.lastPosZ = to.getZ();
@ -273,7 +273,7 @@
WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension); WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension);
- if (!this.player.viewingCredits) { - if (!this.player.viewingCredits) {
+ if (!this.player.viewingCredits && !this.player.dead) { // CraftBukkit - Added ' && !this.player.dead' + if (!this.player.viewingCredits && !this.player.cj()) { // CraftBukkit // PAIL: rename
if (this.e == 0) { if (this.e == 0) {
this.d(); this.d();
} }
@ -366,7 +366,7 @@
+ double delta = Math.pow(this.lastPosX - to.getX(), 2) + Math.pow(this.lastPosY - to.getY(), 2) + Math.pow(this.lastPosZ - to.getZ(), 2); + double delta = Math.pow(this.lastPosX - to.getX(), 2) + Math.pow(this.lastPosY - to.getY(), 2) + Math.pow(this.lastPosZ - to.getZ(), 2);
+ float deltaAngle = Math.abs(this.lastYaw - to.getYaw()) + Math.abs(this.lastPitch - to.getPitch()); + float deltaAngle = Math.abs(this.lastYaw - to.getYaw()) + Math.abs(this.lastPitch - to.getPitch());
+ +
+ if ((delta > 1f / 256 || deltaAngle > 10f) && !this.player.dead) { + if ((delta > 1f / 256 || deltaAngle > 10f) && !this.player.cj()) {
+ this.lastPosX = to.getX(); + this.lastPosX = to.getX();
+ this.lastPosY = to.getY(); + this.lastPosY = to.getY();
+ this.lastPosZ = to.getZ(); + this.lastPosZ = to.getZ();
@ -511,7 +511,7 @@
public void a(PacketPlayInBlockDig packetplayinblockdig) { public void a(PacketPlayInBlockDig packetplayinblockdig) {
PlayerConnectionUtils.ensureMainThread(packetplayinblockdig, this, this.player.x()); PlayerConnectionUtils.ensureMainThread(packetplayinblockdig, this, this.player.x());
+ if (this.player.dead) return; // CraftBukkit + if (this.player.cj()) return; // CraftBukkit
WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension); WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension);
BlockPosition blockposition = packetplayinblockdig.a(); BlockPosition blockposition = packetplayinblockdig.a();
@ -613,7 +613,7 @@
public void a(PacketPlayInUseItem packetplayinuseitem) { public void a(PacketPlayInUseItem packetplayinuseitem) {
PlayerConnectionUtils.ensureMainThread(packetplayinuseitem, this, this.player.x()); PlayerConnectionUtils.ensureMainThread(packetplayinuseitem, this, this.player.x());
+ if (this.player.dead) return; // CraftBukkit + if (this.player.cj()) return; // CraftBukkit
WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension); WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension);
EnumHand enumhand = packetplayinuseitem.c(); EnumHand enumhand = packetplayinuseitem.c();
ItemStack itemstack = this.player.b(enumhand); ItemStack itemstack = this.player.b(enumhand);
@ -635,7 +635,7 @@
public void a(PacketPlayInBlockPlace packetplayinblockplace) { public void a(PacketPlayInBlockPlace packetplayinblockplace) {
PlayerConnectionUtils.ensureMainThread(packetplayinblockplace, this, this.player.x()); PlayerConnectionUtils.ensureMainThread(packetplayinblockplace, this, this.player.x());
+ if (this.player.dead) return; // CraftBukkit + if (this.player.cj()) return; // CraftBukkit
WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension); WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension);
EnumHand enumhand = packetplayinblockplace.a(); EnumHand enumhand = packetplayinblockplace.a();
ItemStack itemstack = this.player.b(enumhand); ItemStack itemstack = this.player.b(enumhand);
@ -785,7 +785,7 @@
public void a(PacketPlayInHeldItemSlot packetplayinhelditemslot) { public void a(PacketPlayInHeldItemSlot packetplayinhelditemslot) {
PlayerConnectionUtils.ensureMainThread(packetplayinhelditemslot, this, this.player.x()); PlayerConnectionUtils.ensureMainThread(packetplayinhelditemslot, this, this.player.x());
+ if (this.player.dead) return; // CraftBukkit + if (this.player.cj()) return; // CraftBukkit
if (packetplayinhelditemslot.a() >= 0 && packetplayinhelditemslot.a() < PlayerInventory.getHotbarSize()) { if (packetplayinhelditemslot.a() >= 0 && packetplayinhelditemslot.a() < PlayerInventory.getHotbarSize()) {
+ PlayerItemHeldEvent event = new PlayerItemHeldEvent(this.getPlayer(), this.player.inventory.itemInHandIndex, packetplayinhelditemslot.a()); + PlayerItemHeldEvent event = new PlayerItemHeldEvent(this.getPlayer(), this.player.inventory.itemInHandIndex, packetplayinhelditemslot.a());
+ this.server.getPluginManager().callEvent(event); + this.server.getPluginManager().callEvent(event);
@ -1013,7 +1013,7 @@
public void a(PacketPlayInArmAnimation packetplayinarmanimation) { public void a(PacketPlayInArmAnimation packetplayinarmanimation) {
PlayerConnectionUtils.ensureMainThread(packetplayinarmanimation, this, this.player.x()); PlayerConnectionUtils.ensureMainThread(packetplayinarmanimation, this, this.player.x());
+ if (this.player.dead) return; // CraftBukkit + if (this.player.cj()) return; // CraftBukkit
this.player.resetIdleTimer(); this.player.resetIdleTimer();
+ // CraftBukkit start - Raytrace to look for 'rogue armswings' + // CraftBukkit start - Raytrace to look for 'rogue armswings'
+ float f1 = this.player.pitch; + float f1 = this.player.pitch;
@ -1078,7 +1078,7 @@
public void a(PacketPlayInUseEntity packetplayinuseentity) { public void a(PacketPlayInUseEntity packetplayinuseentity) {
PlayerConnectionUtils.ensureMainThread(packetplayinuseentity, this, this.player.x()); PlayerConnectionUtils.ensureMainThread(packetplayinuseentity, this, this.player.x());
+ if (this.player.dead) return; // CraftBukkit + if (this.player.cj()) return; // CraftBukkit
WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension); WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension);
Entity entity = packetplayinuseentity.a((World) worldserver); Entity entity = packetplayinuseentity.a((World) worldserver);
@ -1171,7 +1171,7 @@
public void a(PacketPlayInCloseWindow packetplayinclosewindow) { public void a(PacketPlayInCloseWindow packetplayinclosewindow) {
PlayerConnectionUtils.ensureMainThread(packetplayinclosewindow, this, this.player.x()); PlayerConnectionUtils.ensureMainThread(packetplayinclosewindow, this, this.player.x());
+ +
+ if (this.player.dead) return; // CraftBukkit + if (this.player.cj()) return; // CraftBukkit
+ CraftEventFactory.handleInventoryCloseEvent(this.player); // CraftBukkit + CraftEventFactory.handleInventoryCloseEvent(this.player); // CraftBukkit
+ +
this.player.s(); this.player.s();
@ -1179,7 +1179,7 @@
public void a(PacketPlayInWindowClick packetplayinwindowclick) { public void a(PacketPlayInWindowClick packetplayinwindowclick) {
PlayerConnectionUtils.ensureMainThread(packetplayinwindowclick, this, this.player.x()); PlayerConnectionUtils.ensureMainThread(packetplayinwindowclick, this, this.player.x());
+ if (this.player.dead) return; // CraftBukkit + if (this.player.cj()) return; // CraftBukkit
this.player.resetIdleTimer(); this.player.resetIdleTimer();
if (this.player.activeContainer.windowId == packetplayinwindowclick.a() && this.player.activeContainer.c(this.player)) { if (this.player.activeContainer.windowId == packetplayinwindowclick.a() && this.player.activeContainer.c(this.player)) {
- if (this.player.isSpectator()) { - if (this.player.isSpectator()) {
@ -1473,7 +1473,7 @@
public void a(PacketPlayInEnchantItem packetplayinenchantitem) { public void a(PacketPlayInEnchantItem packetplayinenchantitem) {
PlayerConnectionUtils.ensureMainThread(packetplayinenchantitem, this, this.player.x()); PlayerConnectionUtils.ensureMainThread(packetplayinenchantitem, this, this.player.x());
+ if (this.player.dead) return; // CraftBukkit + if (this.player.cj()) return; // CraftBukkit
this.player.resetIdleTimer(); this.player.resetIdleTimer();
if (this.player.activeContainer.windowId == packetplayinenchantitem.a() && this.player.activeContainer.c(this.player) && !this.player.isSpectator()) { if (this.player.activeContainer.windowId == packetplayinenchantitem.a() && this.player.activeContainer.c(this.player) && !this.player.isSpectator()) {
this.player.activeContainer.a(this.player, packetplayinenchantitem.b()); this.player.activeContainer.a(this.player, packetplayinenchantitem.b());
@ -1531,7 +1531,7 @@
public void a(PacketPlayInTransaction packetplayintransaction) { public void a(PacketPlayInTransaction packetplayintransaction) {
PlayerConnectionUtils.ensureMainThread(packetplayintransaction, this, this.player.x()); PlayerConnectionUtils.ensureMainThread(packetplayintransaction, this, this.player.x());
+ if (this.player.dead) return; // CraftBukkit + if (this.player.cj()) return; // CraftBukkit
Short oshort = (Short) this.k.get(this.player.activeContainer.windowId); Short oshort = (Short) this.k.get(this.player.activeContainer.windowId);
if (oshort != null && packetplayintransaction.b() == oshort.shortValue() && this.player.activeContainer.windowId == packetplayintransaction.a() && !this.player.activeContainer.c(this.player) && !this.player.isSpectator()) { if (oshort != null && packetplayintransaction.b() == oshort.shortValue() && this.player.activeContainer.windowId == packetplayintransaction.a() && !this.player.activeContainer.c(this.player) && !this.player.isSpectator()) {
@ -1539,7 +1539,7 @@
public void a(PacketPlayInUpdateSign packetplayinupdatesign) { public void a(PacketPlayInUpdateSign packetplayinupdatesign) {
PlayerConnectionUtils.ensureMainThread(packetplayinupdatesign, this, this.player.x()); PlayerConnectionUtils.ensureMainThread(packetplayinupdatesign, this, this.player.x());
+ if (this.player.dead) return; // CraftBukkit + if (this.player.cj()) return; // CraftBukkit
this.player.resetIdleTimer(); this.player.resetIdleTimer();
WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension); WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension);
BlockPosition blockposition = packetplayinupdatesign.a(); BlockPosition blockposition = packetplayinupdatesign.a();