Skip to content
Permalink
Browse files

Added PROJECTILE_LAUNCH CommandItems type.

  • Loading branch information...
me4502 committed Oct 16, 2016
1 parent 7e37e5c commit 65f321bee20c4ef53f4c79929d7403d127d2c74b
@@ -9,6 +9,7 @@
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.entity.ProjectileHitEvent;
import org.bukkit.event.entity.ProjectileLaunchEvent;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
@@ -22,7 +23,7 @@

CLICK_LEFT,CLICK_RIGHT,CLICK_EITHER,CLICK_LEFT_BLOCK,CLICK_RIGHT_BLOCK,CLICK_EITHER_BLOCK,CLICK_LEFT_AIR,CLICK_RIGHT_AIR,CLICK_EITHER_AIR,
ENTITY_RIGHT,ENTITY_LEFT,ENTITY_ARROW,ENTITY_PROJECTILE,ENTITY_EITHER,BLOCK_BREAK,BLOCK_PLACE,BLOCK_PROJECTILE_AIR,BLOCK_PROJECTILE_BLOCK,
BLOCK_PROJECTILE_EITHER,BLOCK_EITHER,ITEM_CONSUME,ITEM_DROP,ITEM_BREAK,ITEM_PICKUP,ITEM_CLICK_LEFT,ITEM_CLICK_RIGHT,ITEM_CLICK_EITHER,
BLOCK_PROJECTILE_EITHER,PROJECTILE_LAUNCH,BLOCK_EITHER,ITEM_CONSUME,ITEM_DROP,ITEM_BREAK,ITEM_PICKUP,ITEM_CLICK_LEFT,ITEM_CLICK_RIGHT,ITEM_CLICK_EITHER,
PLAYER_DEATH,PLAYER_CHAT,PASSIVE,ANY;

public boolean doesPassType(Event event) {
@@ -65,6 +66,8 @@ public boolean doesPassType(Event event) {
case ENTITY_ARROW:
case ENTITY_PROJECTILE:
return event instanceof EntityDamageByEntityEvent && ((EntityDamageByEntityEvent) event).getDamager() instanceof Projectile;
case PROJECTILE_LAUNCH:
return event instanceof ProjectileLaunchEvent;
case ENTITY_EITHER:
return event instanceof PlayerInteractEntityEvent || event instanceof EntityDamageByEntityEvent;
case ENTITY_LEFT:
@@ -22,10 +22,7 @@
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.entity.ProjectileHitEvent;
import org.bukkit.event.entity.*;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.*;
import org.bukkit.inventory.EquipmentSlot;
@@ -213,6 +210,22 @@ public void onBlockBreak(final BlockBreakEvent event) {
performCommandItems(event.getPlayer().getItemInHand(), event.getPlayer(), event);
}

@EventHandler(priority=EventPriority.HIGH)
public void onProjectileLaunch(final ProjectileLaunchEvent event) {
if(!(event.getEntity().getShooter() instanceof Player))
return;

if(((Player) event.getEntity().getShooter()).getItemInHand() == null)
return;

Bukkit.getScheduler().runTaskLater(CraftBookPlugin.inst(), new Runnable() {
@Override
public void run () {
performCommandItems(((Player) event.getEntity().getShooter()).getItemInHand(), (Player) event.getEntity().getShooter(), event);
}
}, 5L);
}

@EventHandler(priority=EventPriority.HIGH)
public void onProjectileHit(final ProjectileHitEvent event) {

0 comments on commit 65f321b

Please sign in to comment.
You can’t perform that action at this time.