示例#1
0
 @EventHandler
 public void onEntityTarget(EntityTargetEvent event) {
   if (event.getTarget() instanceof Player) {
     Player p = (Player) event.getTarget();
     if (um.isSpectator(p.getName())) event.setCancelled(true);
   }
 }
示例#2
0
 @EventHandler
 public void onFoodLevelChange(FoodLevelChangeEvent event) {
   if (event.getEntity() instanceof Player) {
     Player p = (Player) event.getEntity();
     if (um.isSpectator(p.getName())) event.setCancelled(true);
   }
 }
示例#3
0
  @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);
    }
  }
示例#4
0
 @EventHandler
 public void onExpChangeEvent(PlayerExpChangeEvent event) {
   if (um.isSpectator(event.getPlayer().getName())) event.setAmount(0);
 }
示例#5
0
 @EventHandler
 public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
   if (um.isSpectator(event.getPlayer().getName())) event.setCancelled(true);
 }
示例#6
0
 @EventHandler
 public void onItemDrop(PlayerDropItemEvent event) {
   if (um.isSpectator(event.getPlayer().getName())) event.setCancelled(true);
 }
示例#7
0
 @EventHandler
 public void onBlockPlace(BlockPlaceEvent event) {
   if (um.isSpectator(event.getPlayer().getName())) event.setCancelled(true);
 }