@EventHandler public void onEntityTarget(EntityTargetEvent event) { if (event.getTarget() instanceof Player) { Player p = (Player) event.getTarget(); if (um.isSpectator(p.getName())) event.setCancelled(true); } }
@EventHandler public void onFoodLevelChange(FoodLevelChangeEvent event) { if (event.getEntity() instanceof Player) { Player p = (Player) event.getEntity(); if (um.isSpectator(p.getName())) event.setCancelled(true); } }
@SuppressWarnings("deprecation") @EventHandler public void onEntityDamage(EntityDamageByEntityEvent event) { Player damager = null; if (event.getDamager() instanceof Player) { damager = (Player) event.getDamager(); } else if (event.getDamager() instanceof Projectile) { Projectile pro = (Projectile) event.getDamager(); if (pro.getShooter() instanceof Player) { damager = (Player) pro.getShooter(); } } if (damager != null) { if (um.isSpectator(damager.getName())) event.setCancelled(true); } }
@EventHandler public void onExpChangeEvent(PlayerExpChangeEvent event) { if (um.isSpectator(event.getPlayer().getName())) event.setAmount(0); }
@EventHandler public void onPlayerInteractEntity(PlayerInteractEntityEvent event) { if (um.isSpectator(event.getPlayer().getName())) event.setCancelled(true); }
@EventHandler public void onItemDrop(PlayerDropItemEvent event) { if (um.isSpectator(event.getPlayer().getName())) event.setCancelled(true); }
@EventHandler public void onBlockPlace(BlockPlaceEvent event) { if (um.isSpectator(event.getPlayer().getName())) event.setCancelled(true); }