mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-11-03 01:19:42 +01:00
Improved the infinite item stack remover by making it a bit more proactive.
This commit is contained in:
parent
2188690d20
commit
12779699e3
@ -122,6 +122,17 @@ 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.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -141,6 +152,9 @@ public void onPlayerQuit(PlayerQuitEvent event) {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
World world = player.getWorld();
|
||||||
|
|
||||||
if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||||
handleBlockRightClick(event);
|
handleBlockRightClick(event);
|
||||||
} else if (event.getAction() == Action.RIGHT_CLICK_AIR) {
|
} else if (event.getAction() == Action.RIGHT_CLICK_AIR) {
|
||||||
@ -152,6 +166,19 @@ public void onPlayerInteract(PlayerInteractEvent event) {
|
|||||||
} else if (event.getAction() == Action.PHYSICAL) {
|
} else if (event.getAction() == Action.PHYSICAL) {
|
||||||
handlePhysicalInteract(event);
|
handlePhysicalInteract(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ConfigurationManager cfg = plugin.getGlobalStateManager();
|
||||||
|
WorldConfiguration wcfg = cfg.get(world);
|
||||||
|
|
||||||
|
if (wcfg.removeInfiniteStacks
|
||||||
|
&& !plugin.hasPermission(player, "worldguard.override.infinite-stack")) {
|
||||||
|
int slot = player.getInventory().getHeldItemSlot();
|
||||||
|
ItemStack heldItem = player.getInventory().getItem(slot);
|
||||||
|
if (heldItem.getAmount() < 0) {
|
||||||
|
player.getInventory().setItem(slot, null);
|
||||||
|
player.sendMessage(ChatColor.RED + "Infinite stack removed.");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user