mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2025-12-25 01:49:30 +00:00
补充处理退出玩家
This commit is contained in:
@@ -22,6 +22,7 @@ import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||
import org.bukkit.event.inventory.InventoryDragEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.inventory.InventoryView;
|
||||
import org.bukkit.inventory.MenuType;
|
||||
|
||||
@@ -143,6 +144,21 @@ public class BukkitGuiManager implements GuiManager, Listener {
|
||||
simpleStorageBlockEntity.onPlayerClose(this.plugin.adapt(player));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOW)
|
||||
public void onInventoryClose(PlayerQuitEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
org.bukkit.inventory.Inventory inventory = player.getInventory();
|
||||
if (!CraftBukkitReflections.clazz$MinecraftInventory.isInstance(FastNMS.INSTANCE.method$CraftInventory$getInventory(inventory))) {
|
||||
return;
|
||||
}
|
||||
if (!(inventory.getHolder() instanceof BlockEntityHolder holder)) {
|
||||
return;
|
||||
}
|
||||
if (holder.blockEntity() instanceof SimpleStorageBlockEntity simpleStorageBlockEntity) {
|
||||
simpleStorageBlockEntity.onPlayerClose(this.plugin.adapt(player));
|
||||
}
|
||||
}
|
||||
|
||||
public static BukkitGuiManager instance() {
|
||||
return instance;
|
||||
|
||||
Reference in New Issue
Block a user