use of org.bukkit.entity.Egg in project Minigames by AddstarMC.
the class Events method playerShoot.
@EventHandler(ignoreCancelled = true)
private void playerShoot(ProjectileLaunchEvent event) {
if (event.getEntityType() == EntityType.SNOWBALL) {
Snowball snowball = (Snowball) event.getEntity();
if (snowball.getShooter() != null && snowball.getShooter() instanceof Player) {
MinigamePlayer ply = pdata.getMinigamePlayer((Player) snowball.getShooter());
if (ply == null)
return;
if (ply.isInMinigame() && ply.getMinigame().hasUnlimitedAmmo()) {
ItemStack mainhand = ply.getPlayer().getInventory().getItemInMainHand();
if (mainhand.getType() == Material.SNOW_BALL) {
mainhand.setAmount(16);
ply.getPlayer().updateInventory();
} else {
ply.getPlayer().getInventory().addItem(new ItemStack(Material.SNOW_BALL, 1));
}
}
}
} else if (event.getEntityType() == EntityType.EGG) {
Egg egg = (Egg) event.getEntity();
if (egg.getShooter() != null && egg.getShooter() instanceof Player) {
MinigamePlayer ply = pdata.getMinigamePlayer((Player) egg.getShooter());
if (ply == null)
return;
if (ply.isInMinigame() && ply.getMinigame().hasUnlimitedAmmo()) {
ply.getPlayer().getInventory().addItem(new ItemStack(Material.EGG));
}
}
}
}
Aggregations