mirror of
https://github.com/EssentialsX/Essentials.git
synced 2025-01-18 06:02:54 +01:00
Fix invsee might cause items to disappear (#3065)
This commit is contained in:
parent
f1a5caf98e
commit
29c5b2c5b7
@ -36,10 +36,7 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||
import org.bukkit.event.inventory.InventoryType;
|
||||
import org.bukkit.event.inventory.*;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerBucketEmptyEvent;
|
||||
import org.bukkit.event.player.PlayerChangedWorldEvent;
|
||||
@ -960,6 +957,21 @@ public class EssentialsPlayerListener implements Listener, FakeAccessor {
|
||||
return false;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onInventoryDragEvent(final InventoryDragEvent event) {
|
||||
final Inventory top = ess.getInventoryViewProvider().getTopInventory(event.getView());
|
||||
if (top.getType() != InventoryType.PLAYER) {
|
||||
return;
|
||||
}
|
||||
final User user = ess.getUser((Player) event.getWhoClicked());
|
||||
if (!user.isInvSee()) {
|
||||
return;
|
||||
}
|
||||
if (event.getNewItems().keySet().stream().anyMatch(slot -> slot > 35)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onInventoryCloseEvent(final InventoryCloseEvent event) {
|
||||
Player refreshPlayer = null;
|
||||
|
Loading…
Reference in New Issue
Block a user