Ejemplo n.º 1
0
 @EventHandler(priority = EventPriority.NORMAL)
 public void onEntityDamageByEntity(final EntityDamageByEntityEvent e) {
   Entity ent = e.getEntity();
   Entity entDamager = e.getDamager();
   if ((ent instanceof Player) && (entDamager instanceof Player)) {
     GamePlayer rmp = GamePlayer.getPlayerByName(((Player) ent).getName());
     GamePlayer rmpDamager = GamePlayer.getPlayerByName(((Player) entDamager).getName());
     if ((rmp != null) && (rmpDamager != null)) {
       if ((rmp.isIngame()) && (rmpDamager.isIngame())) {
         GameConfig config = rmp.getGame().getGameConfig();
         Timer pvpTimer = config.getPvpTimer();
         if (!config.getSettingBool(Setting.allowpvp)) {
           e.setCancelled(true);
         } else if (rmp.getTeam() == rmpDamager.getTeam()) {
           if (!config.getSettingBool(Setting.friendlyfire)) {
             e.setCancelled(true);
           }
         } else if ((rmp.isSafe()) || (rmpDamager.isSafe())) {
           e.setCancelled(true);
           rmpDamager.sendMessage(Text.getLabel("game.safezone.pvp"));
         } else if ((pvpTimer.isSet()) && (pvpTimer.isTicking())) {
           e.setCancelled(true);
           // rmpDamager.sendMessage(RMText.getLabelArgs("game.pvp.delay",
           // pvpTimer.getTextTimeRemaining()));
           rmpDamager.sendMessage(Text.getLabelArgs("game.pvp.disabled"));
         }
       }
     }
   }
 }
Ejemplo n.º 2
0
 @EventHandler(priority = EventPriority.NORMAL)
 public void onEntityDeath(final EntityDeathEvent e) {
   Entity ent = e.getEntity();
   if (ent instanceof Creature) {
     Creature creature = (Creature) e.getEntity();
     switch (creature.getType()) {
       case CHICKEN:
       case COW:
       case PIG:
       case SHEEP:
       case VILLAGER:
       case WOLF:
         Player p = creature.getKiller();
         if (p != null) {
           GamePlayer rmp = GamePlayer.getPlayerByName(p.getName());
           if (rmp != null) {
             if (rmp.isIngame()) {
               Game game = rmp.getGameInProgress();
               game.addLog(creature);
             }
           }
         }
         break;
     }
   }
 }