use of org.bukkit.entity.minecart.PoweredMinecart in project modules-extra by CubeEngine.
the class ListenerPlayerEntity method onPlayerInteractEntityEvent.
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerInteractEntityEvent(PlayerInteractEntityEvent event) {
if (!(event.getRightClicked() instanceof LivingEntity)) {
return;
}
Player player = event.getPlayer();
Entity entity = event.getRightClicked();
ActionPlayerEntity action;
if (player.getItemInHand().getType() == COAL && entity instanceof PoweredMinecart) {
action = this.newAction(UseFurnaceMinecart.class, entity.getWorld());
} else if (player.getItemInHand().getType() == INK_SACK && entity instanceof Sheep || entity instanceof Wolf) {
action = this.newAction(EntityDye.class, entity.getWorld());
if (action != null) {
((EntityDye) action).setColor(((Dye) player.getItemInHand().getData()).getColor());
}
} else if (player.getItemInHand().getType().equals(BOWL) && entity instanceof MushroomCow) {
action = this.newAction(EntityFillSoup.class, entity.getWorld());
} else {
return;
}
if (action != null) {
action.setEntity(entity);
action.setPlayer(player);
action.setLocation(entity.getLocation());
this.logAction(action);
}
}
use of org.bukkit.entity.minecart.PoweredMinecart in project Prism-Bukkit by prism.
the class PrismEntityEvents method onPlayerInteractEntityEvent.
/**
* PlayerInteractEntityEvent.
* @param event PlayerInteractEntityEvent
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerInteractEntityEvent(final PlayerInteractEntityEvent event) {
final Player p = event.getPlayer();
final Entity e = event.getRightClicked();
final ItemStack hand = p.getInventory().getItemInMainHand();
// Cancel the event if a wand is in use
if (WandUtils.playerUsesWandOnClick(p, e.getLocation())) {
event.setCancelled(true);
return;
}
if (e instanceof ItemFrame) {
final ItemFrame frame = (ItemFrame) e;
// If held item doesn't equal existing item frame object type
if (!frame.getItem().getType().equals(Material.AIR)) {
RecordingQueue.addToQueue(ActionFactory.createPlayer("item-rotate", event.getPlayer(), frame.getRotation().name().toLowerCase()));
}
// Frame is empty but an item is held
if (frame.getItem().getType().equals(Material.AIR) && hand != null) {
if (Prism.getIgnore().event("item-insert", p)) {
RecordingQueue.addToQueue(ActionFactory.createItemFrame("item-insert", hand, 1, frame.getAttachedFace(), null, e.getLocation(), p));
}
}
}
if (hand != null) {
// powered minecart
if (hand.getType() == Material.COAL && e instanceof PoweredMinecart) {
if (!Prism.getIgnore().event("item-insert", p)) {
return;
}
RecordingQueue.addToQueue(ActionFactory.createItemStack("item-insert", hand, 1, 0, null, e.getLocation(), p));
}
if (!Prism.getIgnore().event("entity-dye", p)) {
return;
}
// Only track the event on sheep, when player holds dye
if (MaterialTag.DYES.isTagged(hand.getType()) && e.getType() == EntityType.SHEEP) {
final String newColor = Prism.getItems().getAlias(hand.getType(), null);
RecordingQueue.addToQueue(ActionFactory.createEntity("entity-dye", event.getRightClicked(), event.getPlayer(), newColor));
}
}
}
Aggregations