mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-12-19 07:38:12 +01:00
Switched water/lava bucket block to use new onItemUse hook.
This commit is contained in:
parent
6d39ce7240
commit
cf31df35ec
@ -77,6 +77,9 @@ public void initialize() {
|
|||||||
registerHook("BLOCK_BROKEN", PluginListener.Priority.HIGH);
|
registerHook("BLOCK_BROKEN", PluginListener.Priority.HIGH);
|
||||||
registerHook("DISCONNECT", PluginListener.Priority.HIGH);
|
registerHook("DISCONNECT", PluginListener.Priority.HIGH);
|
||||||
registerHook("ITEM_DROP", PluginListener.Priority.HIGH);
|
registerHook("ITEM_DROP", PluginListener.Priority.HIGH);
|
||||||
|
if (!registerHook("ITEM_USE", PluginListener.Priority.HIGH)) {
|
||||||
|
missingFeatures.add("denying use of the lava or water buckets");
|
||||||
|
}
|
||||||
if (!registerHook("ITEM_PICK_UP", PluginListener.Priority.HIGH)) {
|
if (!registerHook("ITEM_PICK_UP", PluginListener.Priority.HIGH)) {
|
||||||
missingFeatures.add("denying item pickups");
|
missingFeatures.add("denying item pickups");
|
||||||
missingFeatures.add("the item durability fix");
|
missingFeatures.add("the item durability fix");
|
||||||
|
@ -521,6 +521,23 @@ public boolean onInventoryChange(Player player) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a player uses an item (rightclick with item in hand)
|
||||||
|
* @param player the player
|
||||||
|
* @param item the item being used (in hand)
|
||||||
|
* @return true to prevent using the item.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean onItemUse(Player player, Item item) {
|
||||||
|
if (blacklist != null) {
|
||||||
|
if (!blacklist.onCreate(item.getItemId(), player)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when someone presses right click. If they right clicked with a
|
* 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
|
* block you can return true to cancel that. You can intercept this to add
|
||||||
@ -537,23 +554,6 @@ public boolean onBlockCreate(Player player, Block blockPlaced, Block blockClicke
|
|||||||
int itemInHand) {
|
int itemInHand) {
|
||||||
if (blacklist != null) {
|
if (blacklist != null) {
|
||||||
if (!blacklist.onCreate(itemInHand, player)) {
|
if (!blacklist.onCreate(itemInHand, player)) {
|
||||||
// Water/lava bucket fix
|
|
||||||
if (itemInHand == 326 || itemInHand == 327) {
|
|
||||||
final int x = blockPlaced.getX();
|
|
||||||
final int y = blockPlaced.getY();
|
|
||||||
final int z = blockPlaced.getZ();
|
|
||||||
final int existingID = etc.getServer().getBlockIdAt(x, y, z);
|
|
||||||
|
|
||||||
// This is REALLY BAD, but there's no other choice
|
|
||||||
// at the moment that is as reliable
|
|
||||||
timer.schedule(new TimerTask() {
|
|
||||||
public void run() {
|
|
||||||
try {
|
|
||||||
etc.getServer().setBlockAt(existingID, x, y, z);
|
|
||||||
} catch (Throwable t) {}
|
|
||||||
}
|
|
||||||
}, 200); // Just in case
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user