mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-11-28 05:25:20 +01:00
Changed the proactive infinite stack check to occur on inventory open.
This commit is contained in:
parent
12779699e3
commit
24cc2d3b36
@ -77,6 +77,7 @@ public void registerEvents() {
|
|||||||
pm.registerEvent(Event.Type.PLAYER_ITEM_HELD, this, Priority.High, plugin);
|
pm.registerEvent(Event.Type.PLAYER_ITEM_HELD, this, Priority.High, plugin);
|
||||||
pm.registerEvent(Event.Type.PLAYER_BED_ENTER, this, Priority.High, plugin);
|
pm.registerEvent(Event.Type.PLAYER_BED_ENTER, this, Priority.High, plugin);
|
||||||
pm.registerEvent(Event.Type.PLAYER_MOVE, this, Priority.High, plugin);
|
pm.registerEvent(Event.Type.PLAYER_MOVE, this, Priority.High, plugin);
|
||||||
|
pm.registerEvent(Event.Type.PLAYER_INVENTORY, this, Priority.High, plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -122,17 +123,6 @@ public void onPlayerJoin(PlayerJoinEvent event) {
|
|||||||
if (plugin.inGroup(player, "wg-amphibious")) {
|
if (plugin.inGroup(player, "wg-amphibious")) {
|
||||||
cfg.enableAmphibiousMode(player);
|
cfg.enableAmphibiousMode(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wcfg.removeInfiniteStacks
|
|
||||||
&& !plugin.hasPermission(player, "worldguard.override.infinite-stack")) {
|
|
||||||
for (int slot = 0; slot < player.getInventory().getSize(); slot++) {
|
|
||||||
ItemStack heldItem = player.getInventory().getItem(slot);
|
|
||||||
if (heldItem.getAmount() < 0) {
|
|
||||||
player.getInventory().setItem(slot, null);
|
|
||||||
player.sendMessage(ChatColor.RED + "Infinite stack in slot #" + slot + " removed.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -837,4 +827,26 @@ public void onPlayerBedEnter(PlayerBedEnterEvent event) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a player opens an inventory.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void onInventoryOpen(PlayerInventoryEvent event) {
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
|
ConfigurationManager cfg = plugin.getGlobalStateManager();
|
||||||
|
WorldConfiguration wcfg = cfg.get(player.getWorld());
|
||||||
|
|
||||||
|
if (wcfg.removeInfiniteStacks
|
||||||
|
&& !plugin.hasPermission(player, "worldguard.override.infinite-stack")) {
|
||||||
|
for (int slot = 0; slot < player.getInventory().getSize(); slot++) {
|
||||||
|
ItemStack heldItem = player.getInventory().getItem(slot);
|
||||||
|
if (heldItem.getAmount() < 0) {
|
||||||
|
player.getInventory().setItem(slot, null);
|
||||||
|
player.sendMessage(ChatColor.RED + "Infinite stack in slot #" + slot + " removed.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user