Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-18 04:20:08 +01:00
Make sure to catch extra interact packets from the client
Dieser Commit ist enthalten in:
Ursprung
cf5a502fd4
Commit
917e46a8d3
@ -1,5 +1,5 @@
|
||||
--- ../work/decompile-8eb82bde//net/minecraft/server/PlayerConnection.java 2014-12-09 09:37:59.263833851 +0000
|
||||
+++ src/main/java/net/minecraft/server/PlayerConnection.java 2014-12-09 09:37:19.499834734 +0000
|
||||
--- ../work/decompile-8eb82bde//net/minecraft/server/PlayerConnection.java 2014-12-09 12:20:29.531617451 +0000
|
||||
+++ src/main/java/net/minecraft/server/PlayerConnection.java 2014-12-09 12:20:21.823617622 +0000
|
||||
@@ -16,6 +16,48 @@
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
@ -390,7 +390,7 @@
|
||||
ItemStack itemstack = this.player.inventory.getItemInHand();
|
||||
boolean flag = false;
|
||||
BlockPosition blockposition = packetplayinblockplace.a();
|
||||
@@ -390,7 +627,42 @@
|
||||
@@ -390,7 +627,50 @@
|
||||
return;
|
||||
}
|
||||
|
||||
@ -416,15 +416,23 @@
|
||||
+ Vec3D vec3d1 = vec3d.add((double) f7 * d3, (double) f6 * d3, (double) f8 * d3);
|
||||
+ MovingObjectPosition movingobjectposition = this.player.world.rayTrace(vec3d, vec3d1, false);
|
||||
+
|
||||
+ org.bukkit.event.player.PlayerInteractEvent event = null;
|
||||
+ boolean cancelled = false;
|
||||
+ if (movingobjectposition == null || movingobjectposition.type != EnumMovingObjectType.BLOCK) {
|
||||
+ event = CraftEventFactory.callPlayerInteractEvent(this.player, Action.RIGHT_CLICK_AIR, itemstack);
|
||||
+ org.bukkit.event.player.PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(this.player, Action.RIGHT_CLICK_AIR, itemstack);
|
||||
+ cancelled = event.useItemInHand() == Event.Result.DENY;
|
||||
+ } else {
|
||||
+ if (player.playerInteractManager.firedInteract) {
|
||||
+ player.playerInteractManager.firedInteract = false;
|
||||
+ cancelled = player.playerInteractManager.interactResult;
|
||||
+ } else {
|
||||
+ org.bukkit.event.player.PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(player, Action.RIGHT_CLICK_BLOCK, movingobjectposition.a(), movingobjectposition.direction, itemstack, true);
|
||||
+ cancelled = event.useItemInHand() == Event.Result.DENY;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (player.playerInteractManager.interactResult && (event == null || event.useItemInHand() != Event.Result.DENY)) {
|
||||
+ if (!cancelled) {
|
||||
+ this.player.playerInteractManager.useItem(this.player, this.player.world, itemstack);
|
||||
+ }
|
||||
+ player.playerInteractManager.interactResult = true;
|
||||
+
|
||||
+ // CraftBukkit - notch decrements the counter by 1 in the above method with food,
|
||||
+ // snowballs and so forth, but he does it in a place that doesn't cause the
|
||||
@ -434,7 +442,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 +670,21 @@
|
||||
@@ -398,9 +678,21 @@
|
||||
this.player.playerConnection.sendPacket(new PacketPlayOutChat(chatmessage));
|
||||
flag = true;
|
||||
} else {
|
||||
@ -457,7 +465,7 @@
|
||||
|
||||
flag = true;
|
||||
}
|
||||
@@ -423,7 +707,8 @@
|
||||
@@ -423,7 +715,8 @@
|
||||
|
||||
this.player.activeContainer.b();
|
||||
this.player.g = false;
|
||||
@ -467,7 +475,7 @@
|
||||
this.sendPacket(new PacketPlayOutSetSlot(this.player.activeContainer.windowId, slot.rawSlotIndex, this.player.inventory.getItemInHand()));
|
||||
}
|
||||
}
|
||||
@@ -437,8 +722,8 @@
|
||||
@@ -437,8 +730,8 @@
|
||||
WorldServer[] aworldserver = this.minecraftServer.worldServer;
|
||||
int i = aworldserver.length;
|
||||
|
||||
@ -478,7 +486,7 @@
|
||||
|
||||
if (worldserver != null) {
|
||||
entity = packetplayinspectate.a(worldserver);
|
||||
@@ -455,6 +740,7 @@
|
||||
@@ -455,6 +748,7 @@
|
||||
WorldServer worldserver1 = this.player.u();
|
||||
WorldServer worldserver2 = (WorldServer) entity.world;
|
||||
|
||||
@ -486,7 +494,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 +758,9 @@
|
||||
@@ -472,6 +766,9 @@
|
||||
this.player.playerInteractManager.a(worldserver2);
|
||||
this.minecraftServer.getPlayerList().b(this.player, worldserver2);
|
||||
this.minecraftServer.getPlayerList().updateClient(this.player);
|
||||
@ -496,7 +504,7 @@
|
||||
} else {
|
||||
this.player.enderTeleportTo(entity.locX, entity.locY, entity.locZ);
|
||||
}
|
||||
@@ -483,14 +772,29 @@
|
||||
@@ -483,14 +780,29 @@
|
||||
public void a(PacketPlayInResourcePackStatus packetplayinresourcepackstatus) {}
|
||||
|
||||
public void a(IChatBaseComponent ichatbasecomponent) {
|
||||
@ -528,7 +536,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 +815,15 @@
|
||||
@@ -511,6 +823,15 @@
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -544,7 +552,7 @@
|
||||
|
||||
try {
|
||||
this.networkManager.handle(packet);
|
||||
@@ -524,18 +837,34 @@
|
||||
@@ -524,18 +845,34 @@
|
||||
}
|
||||
|
||||
public void a(PacketPlayInHeldItemSlot packetplayinhelditemslot) {
|
||||
@ -581,7 +589,7 @@
|
||||
ChatMessage chatmessage = new ChatMessage("chat.cannotSend", new Object[0]);
|
||||
|
||||
chatmessage.getChatModifier().setColor(EnumChatFormat.RED);
|
||||
@@ -548,39 +877,247 @@
|
||||
@@ -548,39 +885,247 @@
|
||||
|
||||
for (int i = 0; i < s.length(); ++i) {
|
||||
if (!SharedConstants.isAllowedChatCharacter(s.charAt(i))) {
|
||||
@ -837,7 +845,7 @@
|
||||
this.player.z();
|
||||
switch (SwitchHelperCommandActionType.b[packetplayinentityaction.b().ordinal()]) {
|
||||
case 1:
|
||||
@@ -601,7 +1138,7 @@
|
||||
@@ -601,7 +1146,7 @@
|
||||
|
||||
case 5:
|
||||
this.player.a(false, true, true);
|
||||
@ -846,7 +854,7 @@
|
||||
break;
|
||||
|
||||
case 6:
|
||||
@@ -623,6 +1160,7 @@
|
||||
@@ -623,6 +1168,7 @@
|
||||
}
|
||||
|
||||
public void a(PacketPlayInUseEntity packetplayinuseentity) {
|
||||
@ -854,7 +862,7 @@
|
||||
PlayerConnectionUtils.ensureMainThread(packetplayinuseentity, this, this.player.u());
|
||||
WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension);
|
||||
Entity entity = packetplayinuseentity.a((World) worldserver);
|
||||
@@ -637,18 +1175,72 @@
|
||||
@@ -637,18 +1183,72 @@
|
||||
}
|
||||
|
||||
if (this.player.h(entity) < d0) {
|
||||
@ -928,7 +936,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -663,7 +1255,8 @@
|
||||
@@ -663,7 +1263,8 @@
|
||||
switch (SwitchHelperCommandActionType.c[enumclientcommand.ordinal()]) {
|
||||
case 1:
|
||||
if (this.player.viewingCredits) {
|
||||
@ -938,7 +946,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 +1287,17 @@
|
||||
@@ -694,11 +1295,17 @@
|
||||
}
|
||||
|
||||
public void a(PacketPlayInCloseWindow packetplayinclosewindow) {
|
||||
@ -956,7 +964,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 +1310,269 @@
|
||||
@@ -711,7 +1318,269 @@
|
||||
|
||||
this.player.a(this.player.activeContainer, (List) arraylist);
|
||||
} else {
|
||||
@ -1227,7 +1235,7 @@
|
||||
|
||||
if (ItemStack.matches(packetplayinwindowclick.e(), itemstack)) {
|
||||
this.player.playerConnection.sendPacket(new PacketPlayOutTransaction(packetplayinwindowclick.a(), packetplayinwindowclick.d(), true));
|
||||
@@ -772,8 +1633,50 @@
|
||||
@@ -772,8 +1641,50 @@
|
||||
}
|
||||
|
||||
boolean flag1 = packetplayinsetcreativeslot.a() >= 1 && packetplayinsetcreativeslot.a() < 36 + PlayerInventory.getHotbarSize();
|
||||
@ -1279,7 +1287,7 @@
|
||||
|
||||
if (flag1 && flag2 && flag3) {
|
||||
if (itemstack == null) {
|
||||
@@ -796,6 +1699,7 @@
|
||||
@@ -796,6 +1707,7 @@
|
||||
}
|
||||
|
||||
public void a(PacketPlayInTransaction packetplayintransaction) {
|
||||
@ -1287,7 +1295,7 @@
|
||||
PlayerConnectionUtils.ensureMainThread(packetplayintransaction, this, this.player.u());
|
||||
Short oshort = (Short) this.n.get(this.player.activeContainer.windowId);
|
||||
|
||||
@@ -806,6 +1710,7 @@
|
||||
@@ -806,6 +1718,7 @@
|
||||
}
|
||||
|
||||
public void a(PacketPlayInUpdateSign packetplayinupdatesign) {
|
||||
@ -1295,7 +1303,7 @@
|
||||
PlayerConnectionUtils.ensureMainThread(packetplayinupdatesign, this, this.player.u());
|
||||
this.player.z();
|
||||
WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension);
|
||||
@@ -822,10 +1727,24 @@
|
||||
@@ -822,10 +1735,24 @@
|
||||
|
||||
if (!tileentitysign.b() || tileentitysign.c() != this.player) {
|
||||
this.minecraftServer.warning("Player " + this.player.getName() + " just tried to change non-editable sign");
|
||||
@ -1321,7 +1329,7 @@
|
||||
tileentitysign.update();
|
||||
worldserver.notify(blockposition);
|
||||
}
|
||||
@@ -847,11 +1766,28 @@
|
||||
@@ -847,11 +1774,28 @@
|
||||
|
||||
public void a(PacketPlayInAbilities packetplayinabilities) {
|
||||
PlayerConnectionUtils.ensureMainThread(packetplayinabilities, this, this.player.u());
|
||||
@ -1351,7 +1359,7 @@
|
||||
ArrayList arraylist = Lists.newArrayList();
|
||||
Iterator iterator = this.minecraftServer.tabCompleteCommand(this.player, packetplayintabcomplete.a(), packetplayintabcomplete.b()).iterator();
|
||||
|
||||
@@ -891,13 +1827,15 @@
|
||||
@@ -891,13 +1835,15 @@
|
||||
itemstack1 = this.player.inventory.getItemInHand();
|
||||
if (itemstack1 != null) {
|
||||
if (itemstack.getItem() == Items.WRITABLE_BOOK && itemstack.getItem() == itemstack1.getItem()) {
|
||||
@ -1368,7 +1376,7 @@
|
||||
return;
|
||||
} finally {
|
||||
packetdataserializer.release();
|
||||
@@ -909,27 +1847,31 @@
|
||||
@@ -909,27 +1855,31 @@
|
||||
|
||||
try {
|
||||
itemstack = packetdataserializer.i();
|
||||
@ -1412,7 +1420,7 @@
|
||||
return;
|
||||
} finally {
|
||||
packetdataserializer.release();
|
||||
@@ -946,6 +1888,7 @@
|
||||
@@ -946,6 +1896,7 @@
|
||||
}
|
||||
} catch (Exception exception2) {
|
||||
PlayerConnection.c.error("Couldn\'t select trade", exception2);
|
||||
@ -1420,7 +1428,7 @@
|
||||
}
|
||||
} else if ("MC|AdvCdm".equals(packetplayincustompayload.a())) {
|
||||
if (!this.minecraftServer.getEnableCommandBlock()) {
|
||||
@@ -986,6 +1929,7 @@
|
||||
@@ -986,6 +1937,7 @@
|
||||
}
|
||||
} catch (Exception exception3) {
|
||||
PlayerConnection.c.error("Couldn\'t set command block", exception3);
|
||||
@ -1428,7 +1436,7 @@
|
||||
} finally {
|
||||
packetdataserializer.release();
|
||||
}
|
||||
@@ -1011,6 +1955,7 @@
|
||||
@@ -1011,6 +1963,7 @@
|
||||
}
|
||||
} catch (Exception exception4) {
|
||||
PlayerConnection.c.error("Couldn\'t set beacon", exception4);
|
||||
@ -1436,7 +1444,7 @@
|
||||
}
|
||||
}
|
||||
} else if ("MC|ItemName".equals(packetplayincustompayload.a()) && this.player.activeContainer instanceof ContainerAnvil) {
|
||||
@@ -1026,6 +1971,27 @@
|
||||
@@ -1026,6 +1979,27 @@
|
||||
containeranvil.a("");
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
--- ../work/decompile-8eb82bde//net/minecraft/server/PlayerInteractManager.java 2014-12-09 09:38:37.363833006 +0000
|
||||
+++ src/main/java/net/minecraft/server/PlayerInteractManager.java 2014-12-09 09:38:31.515833135 +0000
|
||||
--- ../work/decompile-8eb82bde//net/minecraft/server/PlayerInteractManager.java 2014-12-09 12:19:57.555618161 +0000
|
||||
+++ src/main/java/net/minecraft/server/PlayerInteractManager.java 2014-12-09 12:16:26.307622849 +0000
|
||||
@@ -1,5 +1,13 @@
|
||||
package net.minecraft.server;
|
||||
|
||||
@ -202,19 +202,21 @@
|
||||
|
||||
return flag;
|
||||
}
|
||||
@@ -266,8 +392,11 @@
|
||||
@@ -267,7 +393,13 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
+
|
||||
+ public boolean interactResult = true; // CraftBukkit
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ public boolean interactResult = false;
|
||||
+ public boolean firedInteract = false;
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public boolean interact(EntityHuman entityhuman, World world, ItemStack itemstack, BlockPosition blockposition, EnumDirection enumdirection, float f, float f1, float f2) {
|
||||
+ /* CraftBukkit start - whole method
|
||||
if (this.gamemode == EnumGamemode.SPECTATOR) {
|
||||
TileEntity tileentity = world.getTileEntity(blockposition);
|
||||
|
||||
@@ -312,6 +441,67 @@
|
||||
@@ -312,6 +444,68 @@
|
||||
return itemstack.placeItem(entityhuman, world, blockposition, enumdirection, f, f1, f2);
|
||||
}
|
||||
}
|
||||
@ -230,6 +232,8 @@
|
||||
+ }
|
||||
+
|
||||
+ PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(entityhuman, Action.RIGHT_CLICK_BLOCK, blockposition, enumdirection, itemstack, cancelledBlock);
|
||||
+ firedInteract = true;
|
||||
+ interactResult = event.useItemInHand() == Event.Result.DENY;
|
||||
+
|
||||
+ if (event.useInteractedBlock() == Event.Result.DENY) {
|
||||
+ // If we denied a door from opening, we need to send a correcting update to the client, as it already opened the door.
|
||||
@ -263,7 +267,6 @@
|
||||
+ result = blockdata.getBlock().interact(world, blockposition, blockdata, entityhuman, enumdirection, f, f1, f2);
|
||||
+ }
|
||||
+
|
||||
+ interactResult = event.useItemInHand() != Event.Result.DENY;
|
||||
+ if (itemstack != null && !result) {
|
||||
+ int j1 = itemstack.getData();
|
||||
+ int k1 = itemstack.count;
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren