Send item-use blacklist event when right-clicking entities.

This commit is contained in:
wizjany 2013-08-16 13:17:28 -04:00
parent 0a54779fc4
commit c0f95bebf0

View File

@ -47,6 +47,7 @@
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerFishEvent;
import org.bukkit.event.player.PlayerGameModeChangeEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerItemHeldEvent;
import org.bukkit.event.player.PlayerJoinEvent;
@ -462,6 +463,27 @@ public void onPlayerQuit(PlayerQuitEvent event) {
plugin.forgetPlayer(player);
}
@EventHandler(priority = EventPriority.HIGH)
public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
// TODO reduce duplication with right-click-air
Player player = event.getPlayer();
World world = player.getWorld();
ItemStack item = player.getItemInHand();
ConfigurationManager cfg = plugin.getGlobalStateManager();
WorldConfiguration wcfg = cfg.get(world);
if (wcfg.getBlacklist() != null) {
if (!wcfg.getBlacklist().check(
new ItemUseBlacklistEvent(plugin.wrapPlayer(player),
toVector(player.getLocation()),
item.getTypeId()), false, false)) {
event.setCancelled(true);
return;
}
}
}
@EventHandler(priority = EventPriority.HIGH)
public void onPlayerInteract(PlayerInteractEvent event) {
Player player = event.getPlayer();