InventoryCloseEvent Reason API
Allows you to determine why an inventory was closed, enabling plugin developers to "confirm" things based on if it was player triggered close or not.
This commit is contained in:
@@ -617,7 +617,7 @@
|
||||
+ for (net.minecraft.world.level.block.entity.BlockEntity tileentity : chunk.getBlockEntities().values()) {
|
||||
+ if (tileentity instanceof net.minecraft.world.Container) {
|
||||
+ for (org.bukkit.entity.HumanEntity h : Lists.newArrayList(((net.minecraft.world.Container) tileentity).getViewers())) {
|
||||
+ h.closeInventory();
|
||||
+ h.closeInventory(org.bukkit.event.inventory.InventoryCloseEvent.Reason.UNLOADED); // Paper - Inventory close reason
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
@@ -976,7 +976,7 @@
|
||||
+ // Spigot Start
|
||||
+ if (entity.getBukkitEntity() instanceof org.bukkit.inventory.InventoryHolder && (!(entity instanceof ServerPlayer) || entity.getRemovalReason() != Entity.RemovalReason.KILLED)) { // SPIGOT-6876: closeInventory clears death message
|
||||
+ for (org.bukkit.entity.HumanEntity h : Lists.newArrayList(((org.bukkit.inventory.InventoryHolder) entity.getBukkitEntity()).getInventory().getViewers())) {
|
||||
+ h.closeInventory();
|
||||
+ h.closeInventory(org.bukkit.event.inventory.InventoryCloseEvent.Reason.UNLOADED); // Paper - Inventory close reason
|
||||
+ }
|
||||
+ }
|
||||
+ // Spigot End
|
||||
|
||||
@@ -175,8 +175,8 @@
|
||||
+ this.adventure$displayName = net.kyori.adventure.text.Component.text(this.getScoreboardName()); // Paper
|
||||
+ this.bukkitPickUpLoot = true;
|
||||
+ this.maxHealthCache = this.getMaxHealth();
|
||||
+ }
|
||||
+
|
||||
}
|
||||
|
||||
+ // Use method to resend items in hands in case of client desync, because the item use got cancelled.
|
||||
+ // For example, when cancelling the leash event
|
||||
+ public void resendItemInHands() {
|
||||
@@ -222,9 +222,9 @@
|
||||
+ }
|
||||
+
|
||||
+ return blockposition;
|
||||
}
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
+
|
||||
@Override
|
||||
public BlockPos adjustSpawnLocation(ServerLevel world, BlockPos basePos) {
|
||||
AABB axisalignedbb = this.getDimensions(Pose.STANDING).makeBoundingBox(Vec3.ZERO);
|
||||
@@ -418,7 +418,7 @@
|
||||
this.tickClientLoadTimeout();
|
||||
this.gameMode.tick();
|
||||
this.wardenSpawnTracker.tick();
|
||||
@@ -751,7 +924,11 @@
|
||||
@@ -751,9 +924,13 @@
|
||||
--this.invulnerableTime;
|
||||
}
|
||||
|
||||
@@ -429,8 +429,11 @@
|
||||
+ }
|
||||
+ // Paper end - Configurable container update tick rate
|
||||
if (!this.containerMenu.stillValid(this)) {
|
||||
this.closeContainer();
|
||||
- this.closeContainer();
|
||||
+ this.closeContainer(org.bukkit.event.inventory.InventoryCloseEvent.Reason.CANT_USE); // Paper - Inventory close reason
|
||||
this.containerMenu = this.inventoryMenu;
|
||||
}
|
||||
|
||||
@@ -820,7 +997,7 @@
|
||||
}
|
||||
|
||||
@@ -528,11 +531,11 @@
|
||||
+
|
||||
+ // SPIGOT-943 - only call if they have an inventory open
|
||||
+ if (this.containerMenu != this.inventoryMenu) {
|
||||
+ this.closeContainer();
|
||||
+ this.closeContainer(org.bukkit.event.inventory.InventoryCloseEvent.Reason.DEATH); // Paper - Inventory close reason
|
||||
+ }
|
||||
|
||||
+ net.kyori.adventure.text.Component deathMessage = event.deathMessage() != null ? event.deathMessage() : net.kyori.adventure.text.Component.empty(); // Paper - Adventure
|
||||
+
|
||||
+ net.kyori.adventure.text.Component deathMessage = event.deathMessage() != null ? event.deathMessage() : net.kyori.adventure.text.Component.empty(); // Paper - Adventure
|
||||
|
||||
+ if (deathMessage != null && deathMessage != net.kyori.adventure.text.Component.empty() && flag) { // Paper - Adventure // TODO: allow plugins to override?
|
||||
+ Component ichatbasecomponent = PaperAdventure.asVanilla(deathMessage); // Paper - Adventure
|
||||
+
|
||||
@@ -799,7 +802,7 @@
|
||||
this.connection.resetPosition();
|
||||
worldserver.addDuringTeleport(this);
|
||||
gameprofilerfiller.pop();
|
||||
@@ -1215,10 +1525,28 @@
|
||||
@@ -1215,12 +1525,30 @@
|
||||
this.lastSentExp = -1;
|
||||
this.lastSentHealth = -1.0F;
|
||||
this.lastSentFood = -1;
|
||||
@@ -810,24 +813,26 @@
|
||||
+ // CraftBukkit end
|
||||
return this;
|
||||
}
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
}
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ @Override
|
||||
@Override
|
||||
+ public CraftPortalEvent callPortalEvent(Entity entity, Location exit, TeleportCause cause, int searchRadius, int creationRadius) {
|
||||
+ Location enter = this.getBukkitEntity().getLocation();
|
||||
+ PlayerPortalEvent event = new PlayerPortalEvent(this.getBukkitEntity(), enter, exit, cause, searchRadius, true, creationRadius);
|
||||
+ Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
+ if (event.isCancelled() || event.getTo() == null || event.getTo().getWorld() == null) {
|
||||
+ return null;
|
||||
}
|
||||
+ }
|
||||
+ return new CraftPortalEvent(event);
|
||||
}
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
@Override
|
||||
+
|
||||
+ @Override
|
||||
public void forceSetRotation(float yaw, float pitch) {
|
||||
this.connection.send(new ClientboundPlayerRotationPacket(yaw, pitch));
|
||||
}
|
||||
@@ -1228,13 +1556,21 @@
|
||||
public void triggerDimensionChangeTriggers(ServerLevel origin) {
|
||||
ResourceKey<Level> resourcekey = origin.dimension();
|
||||
@@ -1053,7 +1058,8 @@
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
if (this.containerMenu != this.inventoryMenu) {
|
||||
this.closeContainer();
|
||||
- this.closeContainer();
|
||||
+ this.closeContainer(org.bukkit.event.inventory.InventoryCloseEvent.Reason.OPEN_NEW); // Paper - Inventory close reason
|
||||
}
|
||||
|
||||
- this.nextContainerCounter();
|
||||
@@ -1066,15 +1072,21 @@
|
||||
this.initMenu(this.containerMenu);
|
||||
}
|
||||
|
||||
@@ -1456,6 +1872,7 @@
|
||||
@@ -1456,6 +1872,13 @@
|
||||
|
||||
@Override
|
||||
public void closeContainer() {
|
||||
+ CraftEventFactory.handleInventoryCloseEvent(this); // CraftBukkit
|
||||
+ // Paper start - Inventory close reason
|
||||
+ this.closeContainer(org.bukkit.event.inventory.InventoryCloseEvent.Reason.UNKNOWN);
|
||||
+ }
|
||||
+ @Override
|
||||
+ public void closeContainer(org.bukkit.event.inventory.InventoryCloseEvent.Reason reason) {
|
||||
+ CraftEventFactory.handleInventoryCloseEvent(this, reason); // CraftBukkit
|
||||
+ // Paper end - Inventory close reason
|
||||
this.connection.send(new ClientboundContainerClosePacket(this.containerMenu.containerId));
|
||||
this.doCloseContainer();
|
||||
}
|
||||
@@ -1485,19 +1902,19 @@
|
||||
@@ -1485,19 +1908,19 @@
|
||||
i = Math.round((float) Math.sqrt(deltaX * deltaX + deltaY * deltaY + deltaZ * deltaZ) * 100.0F);
|
||||
if (i > 0) {
|
||||
this.awardStat(Stats.SWIM_ONE_CM, i);
|
||||
@@ -1097,7 +1109,7 @@
|
||||
}
|
||||
} else if (this.onClimbable()) {
|
||||
if (deltaY > 0.0D) {
|
||||
@@ -1508,13 +1925,13 @@
|
||||
@@ -1508,13 +1931,13 @@
|
||||
if (i > 0) {
|
||||
if (this.isSprinting()) {
|
||||
this.awardStat(Stats.SPRINT_ONE_CM, i);
|
||||
@@ -1114,7 +1126,7 @@
|
||||
}
|
||||
}
|
||||
} else if (this.isFallFlying()) {
|
||||
@@ -1557,7 +1974,7 @@
|
||||
@@ -1557,7 +1980,7 @@
|
||||
@Override
|
||||
public void awardStat(Stat<?> stat, int amount) {
|
||||
this.stats.increment(this, stat, amount);
|
||||
@@ -1123,7 +1135,7 @@
|
||||
scoreaccess.add(amount);
|
||||
});
|
||||
}
|
||||
@@ -1565,7 +1982,7 @@
|
||||
@@ -1565,7 +1988,7 @@
|
||||
@Override
|
||||
public void resetStat(Stat<?> stat) {
|
||||
this.stats.setValue(this, stat, 0);
|
||||
@@ -1132,7 +1144,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1597,9 +2014,9 @@
|
||||
@@ -1597,9 +2020,9 @@
|
||||
super.jumpFromGround();
|
||||
this.awardStat(Stats.JUMP);
|
||||
if (this.isSprinting()) {
|
||||
@@ -1144,7 +1156,7 @@
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1625,6 +2042,7 @@
|
||||
@@ -1625,6 +2048,7 @@
|
||||
|
||||
public void resetSentInfo() {
|
||||
this.lastSentHealth = -1.0E8F;
|
||||
@@ -1152,7 +1164,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1661,7 +2079,7 @@
|
||||
@@ -1661,7 +2085,7 @@
|
||||
this.onUpdateAbilities();
|
||||
if (alive) {
|
||||
this.getAttributes().assignBaseValues(oldPlayer.getAttributes());
|
||||
@@ -1161,7 +1173,7 @@
|
||||
this.setHealth(oldPlayer.getHealth());
|
||||
this.foodData = oldPlayer.foodData;
|
||||
Iterator iterator = oldPlayer.getActiveEffects().iterator();
|
||||
@@ -1669,7 +2087,7 @@
|
||||
@@ -1669,7 +2093,7 @@
|
||||
while (iterator.hasNext()) {
|
||||
MobEffectInstance mobeffect = (MobEffectInstance) iterator.next();
|
||||
|
||||
@@ -1170,7 +1182,7 @@
|
||||
}
|
||||
|
||||
this.getInventory().replaceWith(oldPlayer.getInventory());
|
||||
@@ -1680,7 +2098,7 @@
|
||||
@@ -1680,7 +2104,7 @@
|
||||
this.portalProcess = oldPlayer.portalProcess;
|
||||
} else {
|
||||
this.getAttributes().assignBaseValues(oldPlayer.getAttributes());
|
||||
@@ -1179,7 +1191,7 @@
|
||||
if (this.serverLevel().getGameRules().getBoolean(GameRules.RULE_KEEPINVENTORY) || oldPlayer.isSpectator()) {
|
||||
this.getInventory().replaceWith(oldPlayer.getInventory());
|
||||
this.experienceLevel = oldPlayer.experienceLevel;
|
||||
@@ -1696,7 +2114,7 @@
|
||||
@@ -1696,7 +2120,7 @@
|
||||
this.lastSentExp = -1;
|
||||
this.lastSentHealth = -1.0F;
|
||||
this.lastSentFood = -1;
|
||||
@@ -1188,7 +1200,7 @@
|
||||
this.seenCredits = oldPlayer.seenCredits;
|
||||
this.enteredNetherPosition = oldPlayer.enteredNetherPosition;
|
||||
this.chunkTrackingView = oldPlayer.chunkTrackingView;
|
||||
@@ -1752,19 +2170,19 @@
|
||||
@@ -1752,19 +2176,19 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1212,7 +1224,7 @@
|
||||
}
|
||||
|
||||
return flag1;
|
||||
@@ -1861,8 +2279,13 @@
|
||||
@@ -1861,8 +2285,13 @@
|
||||
}
|
||||
|
||||
public void sendChatMessage(OutgoingChatMessage message, boolean filterMaskEnabled, ChatType.Bound params) {
|
||||
@@ -1227,7 +1239,7 @@
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1878,7 +2301,18 @@
|
||||
@@ -1878,7 +2307,18 @@
|
||||
}
|
||||
|
||||
public void updateOptions(ClientInformation clientOptions) {
|
||||
@@ -1246,7 +1258,7 @@
|
||||
this.requestedViewDistance = clientOptions.viewDistance();
|
||||
this.chatVisibility = clientOptions.chatVisibility();
|
||||
this.canChatColor = clientOptions.chatColors();
|
||||
@@ -1962,7 +2396,7 @@
|
||||
@@ -1962,7 +2402,7 @@
|
||||
if (world instanceof ServerLevel) {
|
||||
ServerLevel worldserver = (ServerLevel) world;
|
||||
|
||||
@@ -1255,7 +1267,7 @@
|
||||
}
|
||||
|
||||
if (entity != null) {
|
||||
@@ -1999,11 +2433,11 @@
|
||||
@@ -1999,11 +2439,11 @@
|
||||
|
||||
@Nullable
|
||||
public Component getTabListDisplayName() {
|
||||
@@ -1269,7 +1281,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -2046,17 +2480,43 @@
|
||||
@@ -2046,17 +2486,43 @@
|
||||
}
|
||||
|
||||
public void setRespawnPosition(ResourceKey<Level> dimension, @Nullable BlockPos pos, float angle, boolean forced, boolean sendMessage) {
|
||||
@@ -1320,7 +1332,7 @@
|
||||
} else {
|
||||
this.respawnPosition = null;
|
||||
this.respawnDimension = Level.OVERWORLD;
|
||||
@@ -2088,18 +2548,44 @@
|
||||
@@ -2088,18 +2554,44 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1369,7 +1381,7 @@
|
||||
}
|
||||
|
||||
this.awardStat(Stats.DROP);
|
||||
@@ -2375,16 +2861,160 @@
|
||||
@@ -2375,16 +2867,160 @@
|
||||
return TicketType.ENDER_PEARL.timeout();
|
||||
}
|
||||
|
||||
|
||||
@@ -129,14 +129,14 @@
|
||||
this.chunkSender = new PlayerChunkSender(connection.isMemoryConnection());
|
||||
this.player = player;
|
||||
player.connection = this;
|
||||
@@ -256,8 +320,24 @@
|
||||
@@ -256,9 +320,25 @@
|
||||
|
||||
Objects.requireNonNull(server);
|
||||
this.signedMessageDecoder = SignedMessageChain.Decoder.unsigned(uuid, server::enforceSecureProfile);
|
||||
- this.chatMessageChain = new FutureChain(server);
|
||||
+ this.chatMessageChain = new FutureChain(server.chatExecutor); // CraftBukkit - async chat
|
||||
}
|
||||
+
|
||||
|
||||
+ // CraftBukkit start - add fields and methods
|
||||
+ private int lastTick = MinecraftServer.currentTick;
|
||||
+ private int allowedPlayerTicks = 1;
|
||||
@@ -152,9 +152,10 @@
|
||||
+ private float lastYaw = Float.MAX_VALUE;
|
||||
+ private boolean justTeleported = false;
|
||||
+ // CraftBukkit end
|
||||
|
||||
+
|
||||
@Override
|
||||
public void tick() {
|
||||
if (this.ackBlockChangesUpTo > -1) {
|
||||
@@ -277,7 +357,7 @@
|
||||
if (this.clientIsFloating && !this.player.isSleeping() && !this.player.isPassenger() && !this.player.isDeadOrDying()) {
|
||||
if (++this.aboveGroundTickCount > this.getMaximumFlyingTicks(this.player)) {
|
||||
@@ -243,7 +244,7 @@
|
||||
ServerGamePacketListenerImpl.LOGGER.warn("{} (vehicle of {}) moved too quickly! {},{},{}", new Object[]{entity.getName().getString(), this.player.getName().getString(), d6, d7, d8});
|
||||
this.send(ClientboundMoveVehiclePacket.fromEntity(entity));
|
||||
return;
|
||||
@@ -449,20 +569,73 @@
|
||||
@@ -449,19 +569,72 @@
|
||||
d10 = d6 * d6 + d7 * d7 + d8 * d8;
|
||||
boolean flag2 = false;
|
||||
|
||||
@@ -262,8 +263,8 @@
|
||||
+ this.player.absMoveTo(d0, d1, d2, this.player.getYRot(), this.player.getXRot()); // CraftBukkit
|
||||
this.send(ClientboundMoveVehiclePacket.fromEntity(entity));
|
||||
return;
|
||||
}
|
||||
|
||||
+ }
|
||||
+
|
||||
+ // CraftBukkit start - fire PlayerMoveEvent
|
||||
+ Player player = this.getCraftPlayer();
|
||||
+ if (!this.hasMoved) {
|
||||
@@ -312,12 +313,11 @@
|
||||
+ this.justTeleported = false;
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
}
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
|
||||
this.player.serverLevel().getChunkSource().move(this.player);
|
||||
entity.recordMovementThroughBlocks(new Vec3(d0, d1, d2), entity.position());
|
||||
Vec3 vec3d = new Vec3(entity.getX() - d0, entity.getY() - d1, entity.getZ() - d2);
|
||||
@@ -499,6 +672,7 @@
|
||||
this.lastGoodZ = this.awaitingPositionFromClient.z;
|
||||
this.player.hasChangedDimension();
|
||||
@@ -800,10 +800,12 @@
|
||||
this.player.drop(false);
|
||||
}
|
||||
|
||||
@@ -1218,9 +1669,31 @@
|
||||
}
|
||||
}
|
||||
@@ -1216,11 +1667,33 @@
|
||||
|
||||
return (item instanceof BlockItem || item instanceof BucketItem) && !player.getCooldowns().isOnCooldown(stack);
|
||||
}
|
||||
+ }
|
||||
+
|
||||
+ // Spigot start - limit place/interactions
|
||||
+ private int limitedPackets;
|
||||
+ private long lastLimitedPacket = -1;
|
||||
@@ -821,9 +823,9 @@
|
||||
+ }
|
||||
+
|
||||
+ return true;
|
||||
+ }
|
||||
}
|
||||
+ // Spigot end
|
||||
+
|
||||
|
||||
@Override
|
||||
public void handleUseItemOn(ServerboundUseItemOnPacket packet) {
|
||||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
|
||||
@@ -1111,12 +1113,10 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1564,8 +2155,129 @@
|
||||
}
|
||||
|
||||
@@ -1566,6 +2157,127 @@
|
||||
return false;
|
||||
+ }
|
||||
+
|
||||
}
|
||||
|
||||
+ // CraftBukkit start - add method
|
||||
+ public void chat(String s, PlayerChatMessage original, boolean async) {
|
||||
+ if (s.isEmpty() || this.player.getChatVisibility() == ChatVisiblity.HIDDEN) {
|
||||
@@ -1209,8 +1209,8 @@
|
||||
+ this.server.console.sendMessage(s);
|
||||
+ }
|
||||
+ }
|
||||
}
|
||||
|
||||
+ }
|
||||
+
|
||||
+ private void handleCommand(String s) {
|
||||
+ org.spigotmc.AsyncCatcher.catchOp("Command Dispatched Async: " + s); // Paper - Add async catcher
|
||||
+ if ( org.spigotmc.SpigotConfig.logCommands ) // Spigot
|
||||
@@ -1426,7 +1426,7 @@
|
||||
+ ItemStack itemInHand = ServerGamePacketListenerImpl.this.player.getItemInHand(enumhand);
|
||||
+ boolean triggerLeashUpdate = itemInHand != null && itemInHand.getItem() == Items.LEAD && entity instanceof Mob;
|
||||
+ Item origItem = ServerGamePacketListenerImpl.this.player.getInventory().getSelected() == null ? null : ServerGamePacketListenerImpl.this.player.getInventory().getSelected().getItem();
|
||||
|
||||
+
|
||||
+ ServerGamePacketListenerImpl.this.cserver.getPluginManager().callEvent(event);
|
||||
+
|
||||
+ // Entity in bucket - SPIGOT-4048 and SPIGOT-6859a
|
||||
@@ -1449,7 +1449,7 @@
|
||||
+ ServerGamePacketListenerImpl.this.player.containerMenu.sendAllDataToRemote();
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
|
||||
+ if (event.isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
@@ -1559,13 +1559,19 @@
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -1834,15 +2713,21 @@
|
||||
@@ -1833,16 +2712,27 @@
|
||||
|
||||
@Override
|
||||
public void handleContainerClose(ServerboundContainerClosePacket packet) {
|
||||
+ // Paper start - Inventory close reason
|
||||
+ this.handleContainerClose(packet, org.bukkit.event.inventory.InventoryCloseEvent.Reason.PLAYER);
|
||||
+ }
|
||||
+ public void handleContainerClose(ServerboundContainerClosePacket packet, org.bukkit.event.inventory.InventoryCloseEvent.Reason reason) {
|
||||
+ // Paper end - Inventory close reason
|
||||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
|
||||
+
|
||||
+ if (this.player.isImmobile()) return; // CraftBukkit
|
||||
+ CraftEventFactory.handleInventoryCloseEvent(this.player); // CraftBukkit
|
||||
+ CraftEventFactory.handleInventoryCloseEvent(this.player, reason); // CraftBukkit // Paper
|
||||
+
|
||||
this.player.doCloseContainer();
|
||||
}
|
||||
@@ -1583,7 +1589,7 @@
|
||||
this.player.containerMenu.sendAllDataToRemote();
|
||||
} else if (!this.player.containerMenu.stillValid(this.player)) {
|
||||
ServerGamePacketListenerImpl.LOGGER.debug("Player {} interacted with invalid menu {}", this.player, this.player.containerMenu);
|
||||
@@ -1855,7 +2740,284 @@
|
||||
@@ -1855,7 +2745,284 @@
|
||||
boolean flag = packet.getStateId() != this.player.containerMenu.getStateId();
|
||||
|
||||
this.player.containerMenu.suppressRemoteUpdates();
|
||||
@@ -1869,7 +1875,7 @@
|
||||
ObjectIterator objectiterator = Int2ObjectMaps.fastIterable(packet.getChangedSlots()).iterator();
|
||||
|
||||
while (objectiterator.hasNext()) {
|
||||
@@ -1901,8 +3063,22 @@
|
||||
@@ -1901,8 +3068,22 @@
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1893,7 +1899,7 @@
|
||||
if (containerrecipebook_a == RecipeBookMenu.PostPlaceAction.PLACE_GHOST_RECIPE) {
|
||||
this.player.connection.send(new ClientboundPlaceGhostRecipePacket(this.player.containerMenu.containerId, craftingmanager_d.display().display()));
|
||||
}
|
||||
@@ -1917,6 +3093,7 @@
|
||||
@@ -1917,6 +3098,7 @@
|
||||
@Override
|
||||
public void handleContainerButtonClick(ServerboundContainerButtonClickPacket packet) {
|
||||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
|
||||
@@ -1901,7 +1907,7 @@
|
||||
this.player.resetLastActionTime();
|
||||
if (this.player.containerMenu.containerId == packet.containerId() && !this.player.isSpectator()) {
|
||||
if (!this.player.containerMenu.stillValid(this.player)) {
|
||||
@@ -1945,7 +3122,44 @@
|
||||
@@ -1945,7 +3127,44 @@
|
||||
|
||||
boolean flag1 = packet.slotNum() >= 1 && packet.slotNum() <= 45;
|
||||
boolean flag2 = itemstack.isEmpty() || itemstack.getCount() <= itemstack.getMaxStackSize();
|
||||
@@ -1946,7 +1952,7 @@
|
||||
if (flag1 && flag2) {
|
||||
this.player.inventoryMenu.getSlot(packet.slotNum()).setByPlayer(itemstack);
|
||||
this.player.inventoryMenu.setRemoteSlot(packet.slotNum(), itemstack);
|
||||
@@ -1972,6 +3186,7 @@
|
||||
@@ -1972,6 +3191,7 @@
|
||||
}
|
||||
|
||||
private void updateSignText(ServerboundSignUpdatePacket packet, List<FilteredText> signText) {
|
||||
@@ -1954,7 +1960,7 @@
|
||||
this.player.resetLastActionTime();
|
||||
ServerLevel worldserver = this.player.serverLevel();
|
||||
BlockPos blockposition = packet.getPos();
|
||||
@@ -1993,7 +3208,17 @@
|
||||
@@ -1993,7 +3213,17 @@
|
||||
@Override
|
||||
public void handlePlayerAbilities(ServerboundPlayerAbilitiesPacket packet) {
|
||||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
|
||||
@@ -1973,7 +1979,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -2002,6 +3227,7 @@
|
||||
@@ -2002,6 +3232,7 @@
|
||||
boolean flag = this.player.isModelPartShown(PlayerModelPart.HAT);
|
||||
|
||||
this.player.updateOptions(packet.information());
|
||||
@@ -1981,7 +1987,7 @@
|
||||
if (this.player.isModelPartShown(PlayerModelPart.HAT) != flag) {
|
||||
this.server.getPlayerList().broadcastAll(new ClientboundPlayerInfoUpdatePacket(ClientboundPlayerInfoUpdatePacket.Action.UPDATE_HAT, this.player));
|
||||
}
|
||||
@@ -2058,7 +3284,7 @@
|
||||
@@ -2058,7 +3289,7 @@
|
||||
if (!this.waitingForSwitchToConfig) {
|
||||
throw new IllegalStateException("Client acknowledged config, but none was requested");
|
||||
} else {
|
||||
@@ -1990,7 +1996,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2083,8 +3309,10 @@
|
||||
@@ -2083,8 +3314,10 @@
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -341,7 +341,7 @@
|
||||
+ // CraftBukkit start - Quitting must be before we do final save of data, in case plugins need to modify it
|
||||
+ // See SPIGOT-5799, SPIGOT-6145
|
||||
+ if (entityplayer.containerMenu != entityplayer.inventoryMenu) {
|
||||
+ entityplayer.closeContainer();
|
||||
+ entityplayer.closeContainer(org.bukkit.event.inventory.InventoryCloseEvent.Reason.DISCONNECT); // Paper - Inventory close reason
|
||||
+ }
|
||||
+
|
||||
+ PlayerQuitEvent playerQuitEvent = new PlayerQuitEvent(entityplayer.getBukkitEntity(), net.kyori.adventure.text.Component.translatable("multiplayer.player.left", net.kyori.adventure.text.format.NamedTextColor.YELLOW, io.papermc.paper.configuration.GlobalConfiguration.get().messages.useDisplayNameInQuitMessage ? entityplayer.getBukkitEntity().displayName() : io.papermc.paper.adventure.PaperAdventure.asAdventure(entityplayer.getDisplayName()))); // Paper - Adventure
|
||||
|
||||
Reference in New Issue
Block a user