Archiviert
13
0

SPIGOT-5263: Chests stay open after InventoryOpenEvent cancelled.

Dieser Commit ist enthalten in:
md_5 2019-08-24 20:02:14 +10:00
Ursprung 2439178eab
Commit 44d675ad8b

Datei anzeigen

@ -532,7 +532,7 @@
}
@Override
@@ -770,6 +1039,17 @@
@@ -770,6 +1039,21 @@
this.nextContainerCounter();
Container container = itileinventory.createMenu(this.containerCounter, this.inventory, this);
@ -543,6 +543,10 @@
+ boolean cancelled = false;
+ container = CraftEventFactory.callInventoryOpenEvent(this, container, cancelled);
+ if (container == null && !cancelled) { // Let pre-cancelled events fall through
+ // SPIGOT-5263 - close chest if cancelled
+ if (itileinventory instanceof IInventory) {
+ ((IInventory) itileinventory).closeContainer(this);
+ }
+ return OptionalInt.empty();
+ }
+ }
@ -550,7 +554,7 @@
if (container == null) {
if (this.isSpectator()) {
this.a((new ChatMessage("container.spectatorCantOpen", new Object[0])).a(EnumChatFormat.RED), true);
@@ -777,9 +1057,11 @@
@@ -777,9 +1061,11 @@
return OptionalInt.empty();
} else {
@ -564,7 +568,7 @@
return OptionalInt.of(this.containerCounter);
}
}
@@ -792,13 +1074,24 @@
@@ -792,13 +1078,24 @@
@Override
public void openHorseInventory(EntityHorseAbstract entityhorseabstract, IInventory iinventory) {
@ -591,7 +595,7 @@
this.activeContainer.addSlotListener(this);
}
@@ -843,6 +1136,11 @@
@@ -843,6 +1140,11 @@
public void a(Container container, NonNullList<ItemStack> nonnulllist) {
this.playerConnection.sendPacket(new PacketPlayOutWindowItems(container.windowId, nonnulllist));
this.playerConnection.sendPacket(new PacketPlayOutSetSlot(-1, -1, this.inventory.getCarried()));
@ -603,7 +607,7 @@
}
@Override
@@ -852,6 +1150,7 @@
@@ -852,6 +1154,7 @@
@Override
public void closeInventory() {
@ -611,7 +615,7 @@
this.playerConnection.sendPacket(new PacketPlayOutCloseWindow(this.activeContainer.windowId));
this.m();
}
@@ -886,7 +1185,7 @@
@@ -886,7 +1189,7 @@
@Override
public void a(Statistic<?> statistic, int i) {
this.serverStatisticManager.b(this, statistic, i);
@ -620,7 +624,7 @@
scoreboardscore.addScore(i);
});
}
@@ -894,7 +1193,7 @@
@@ -894,7 +1197,7 @@
@Override
public void a(Statistic<?> statistic) {
this.serverStatisticManager.setStatistic(this, statistic, 0);
@ -629,7 +633,7 @@
}
@Override
@@ -943,7 +1242,16 @@
@@ -943,7 +1246,16 @@
public void triggerHealthUpdate() {
this.lastHealthSent = -1.0E8F;
@ -646,7 +650,7 @@
@Override
public void a(IChatBaseComponent ichatbasecomponent, boolean flag) {
@@ -998,12 +1306,14 @@
@@ -998,12 +1310,14 @@
this.lastSentExp = -1;
this.lastHealthSent = -1.0F;
this.lastFoodSent = -1;
@ -662,7 +666,7 @@
}
@Override
@@ -1065,6 +1375,18 @@
@@ -1065,6 +1379,18 @@
@Override
public void a(EnumGamemode enumgamemode) {
@ -681,7 +685,7 @@
this.playerInteractManager.setGameMode(enumgamemode);
this.playerConnection.sendPacket(new PacketPlayOutGameStateChange(3, (float) enumgamemode.getId()));
if (enumgamemode == EnumGamemode.SPECTATOR) {
@@ -1115,6 +1437,17 @@
@@ -1115,6 +1441,17 @@
}
public void a(PacketPlayInSettings packetplayinsettings) {
@ -699,7 +703,7 @@
this.locale = packetplayinsettings.b();
this.ck = packetplayinsettings.d();
this.cl = packetplayinsettings.e();
@@ -1151,13 +1484,13 @@
@@ -1151,13 +1488,13 @@
if (entity instanceof EntityHuman) {
this.playerConnection.sendPacket(new PacketPlayOutEntityDestroy(new int[]{entity.getId()}));
} else {
@ -715,7 +719,7 @@
}
@Override
@@ -1181,7 +1514,7 @@
@@ -1181,7 +1518,7 @@
this.spectatedEntity = (Entity) (entity == null ? this : entity);
if (entity1 != this.spectatedEntity) {
this.playerConnection.sendPacket(new PacketPlayOutCamera(this.spectatedEntity));
@ -724,7 +728,7 @@
}
}
@@ -1210,7 +1543,7 @@
@@ -1210,7 +1547,7 @@
@Nullable
public IChatBaseComponent getPlayerListName() {
@ -733,7 +737,7 @@
}
@Override
@@ -1228,21 +1561,33 @@
@@ -1228,21 +1565,33 @@
}
public void J() {
@ -767,7 +771,7 @@
if (worldserver == this.world) {
this.playerConnection.a(d0, d1, d2, f, f1);
} else {
@@ -1265,6 +1610,9 @@
@@ -1265,6 +1614,9 @@
this.server.getPlayerList().a(this, worldserver);
this.server.getPlayerList().updateClient(this);
}
@ -777,7 +781,7 @@
}
@@ -1316,4 +1664,144 @@
@@ -1316,4 +1668,144 @@
return entityitem;
}
}