Improved blacklist support for the new hooks.

This commit is contained in:
sk89q 2010-11-30 21:54:36 -08:00
parent 8073089da4
commit 80df9c6aa4
2 changed files with 18 additions and 10 deletions

View File

@ -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)) {

View File

@ -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)) {