mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2025-02-26 01:01:42 +01:00
Added protection.remove-infinite-stacks.
This commit is contained in:
parent
ad659cd32e
commit
ffc5281d59
@ -23,6 +23,7 @@ pumpkin-scuba: off
|
|||||||
|
|
||||||
protection:
|
protection:
|
||||||
item-durability: on
|
item-durability: on
|
||||||
|
remove-infinite-stacks: off
|
||||||
|
|
||||||
simulation:
|
simulation:
|
||||||
sponge:
|
sponge:
|
||||||
@ -82,6 +83,9 @@ iconomy:
|
|||||||
# Price per block for buying on claim
|
# Price per block for buying on claim
|
||||||
buy-on-claim-price: 2
|
buy-on-claim-price: 2
|
||||||
|
|
||||||
|
chest-protection:
|
||||||
|
enable: off
|
||||||
|
|
||||||
blacklist:
|
blacklist:
|
||||||
use-as-whitelist: off
|
use-as-whitelist: off
|
||||||
logging:
|
logging:
|
||||||
|
@ -101,6 +101,7 @@ public class WorldConfiguration {
|
|||||||
public int maxRegionCountPerPlayer;
|
public int maxRegionCountPerPlayer;
|
||||||
public boolean antiWolfDumbness;
|
public boolean antiWolfDumbness;
|
||||||
public boolean signChestProtection;
|
public boolean signChestProtection;
|
||||||
|
public boolean removeInfiniteStacks;
|
||||||
|
|
||||||
/* Configuration data end */
|
/* Configuration data end */
|
||||||
|
|
||||||
@ -135,6 +136,7 @@ private void loadConfiguration() {
|
|||||||
|
|
||||||
enforceOneSession = config.getBoolean("protection.enforce-single-session", true);
|
enforceOneSession = config.getBoolean("protection.enforce-single-session", true);
|
||||||
itemDurability = config.getBoolean("protection.item-durability", true);
|
itemDurability = config.getBoolean("protection.item-durability", true);
|
||||||
|
removeInfiniteStacks = config.getBoolean("protection.remove-infinite-stacks", false);
|
||||||
|
|
||||||
classicWater = config.getBoolean("simulation.classic-water", false);
|
classicWater = config.getBoolean("simulation.classic-water", false);
|
||||||
simulateSponge = config.getBoolean("simulation.sponge.enable", true);
|
simulateSponge = config.getBoolean("simulation.sponge.enable", true);
|
||||||
|
@ -77,6 +77,7 @@ public void registerEvents() {
|
|||||||
pm.registerEvent(Event.Type.PLAYER_BUCKET_FILL, this, Priority.High, plugin);
|
pm.registerEvent(Event.Type.PLAYER_BUCKET_FILL, this, Priority.High, plugin);
|
||||||
pm.registerEvent(Event.Type.PLAYER_BUCKET_EMPTY, this, Priority.High, plugin);
|
pm.registerEvent(Event.Type.PLAYER_BUCKET_EMPTY, this, Priority.High, plugin);
|
||||||
pm.registerEvent(Event.Type.PLAYER_RESPAWN, this, Priority.High, plugin);
|
pm.registerEvent(Event.Type.PLAYER_RESPAWN, this, Priority.High, plugin);
|
||||||
|
pm.registerEvent(Event.Type.PLAYER_ITEM_HELD, this, Priority.High, plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -582,4 +583,25 @@ public void onPlayerRespawn(PlayerRespawnEvent event) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a player changes their held item.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void onItemHeldChange(PlayerItemHeldEvent event) {
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
|
ConfigurationManager cfg = plugin.getGlobalConfiguration();
|
||||||
|
WorldConfiguration wcfg = cfg.get(player.getWorld());
|
||||||
|
|
||||||
|
if (wcfg.removeInfiniteStacks
|
||||||
|
&& !plugin.hasPermission(player, "worldguard.override.infinite-stack")) {
|
||||||
|
int newSlot = event.getNewSlot();
|
||||||
|
ItemStack heldItem = player.getInventory().getItem(newSlot);
|
||||||
|
if (heldItem.getAmount() < 0) {
|
||||||
|
player.getInventory().setItem(newSlot, null);
|
||||||
|
player.sendMessage(ChatColor.RED + "Infinite stack removed.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user