mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-12-18 23:27:35 +01:00
Improved blacklist support for the new hooks.
This commit is contained in:
parent
8073089da4
commit
80df9c6aa4
@ -75,6 +75,7 @@ public void initialize() {
|
||||
registerHook("BLOCK_CREATED", PluginListener.Priority.HIGH);
|
||||
registerHook("BLOCK_DESTROYED", PluginListener.Priority.CRITICAL);
|
||||
registerHook("BLOCK_BROKEN", PluginListener.Priority.HIGH);
|
||||
registerHook("BLOCK_PLACE", PluginListener.Priority.HIGH);
|
||||
registerHook("DISCONNECT", PluginListener.Priority.HIGH);
|
||||
registerHook("ITEM_DROP", PluginListener.Priority.HIGH);
|
||||
if (!registerHook("ITEM_USE", PluginListener.Priority.HIGH)) {
|
||||
|
@ -598,8 +598,12 @@ public boolean onInventoryChange(Player player) {
|
||||
@Override
|
||||
public boolean onItemUse(Player player, Item item) {
|
||||
if (blacklist != null) {
|
||||
if (!blacklist.onCreate(item.getItemId(), player)) {
|
||||
return true;
|
||||
int itemId = item.getItemId();
|
||||
|
||||
if (itemId >= 325 && itemId <= 327) {
|
||||
if (!blacklist.onCreate(itemId, player)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -607,22 +611,25 @@ public boolean onItemUse(Player player, Item item) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when someone presses right click. If they right clicked with a
|
||||
* block you can return true to cancel that. You can intercept this to add
|
||||
* your own right click actions to different item types (see itemInHand)
|
||||
* Called when someone places a block. Return true to prevent the placement.
|
||||
*
|
||||
* @param player
|
||||
* @param blockPlaced
|
||||
* @param blockClicked
|
||||
* @param itemInHand
|
||||
* @return false if you want the action to go through
|
||||
* @return true if you want to undo the block placement
|
||||
*/
|
||||
@Override
|
||||
public boolean onBlockCreate(Player player, Block blockPlaced, Block blockClicked,
|
||||
int itemInHand) {
|
||||
public boolean onBlockPlace(Player player, Block blockPlaced,
|
||||
Block blockClicked, Item itemInHand) {
|
||||
|
||||
int itemId = itemInHand.getItemId();
|
||||
|
||||
if (blacklist != null) {
|
||||
if (!blacklist.onCreate(itemInHand, player)) {
|
||||
return true;
|
||||
if (itemId < 325 || itemId > 327) {
|
||||
if (!blacklist.onCreate(itemId, player)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!blacklist.onUse(blockClicked, player)) {
|
||||
|
Loading…
Reference in New Issue
Block a user