Stoping pvp all together

Discussion in 'Plugin Development' started by Twisted_Panda, Dec 18, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    Twisted_Panda

    Code:
    @EventHandler
        public void onEntityDamage(EntityDamageByEntityEvent e) {
            if (e.getDamager() instanceof Player && e.getEntity() instanceof Player) {
                Player attacker = (Player)e.getDamager();
                Player attacked = (Player)e.getEntity();
                List<String> guy1 = request.getConfig().getStringList("Truces." + attacker.getName());
                List<String> guy2 = request.getConfig().getStringList("Truces." + attacked.getName());
                if(guy1 == null || guy2 == null) {
                    return;
                }
               
                if(guy1.equals(guy2)) {
                  e.setCancelled(true);
                  return;
                }
            }
        }
    }
    It currently stops pvp all together, but I do not know the reason for it.

    Config for it:
    [​IMG]
     
  2. Offline

    Mitsugaru

    May or may not be related... but, I don't think list equality is what you want there. Instead, wouldn't you check that the attacker / receiver was in the other's list? Such as: guy1.contains(attacked.getName()); and vice versa? Although, I figure as long as one succeeds, then you can assume the other.
     
Thread Status:
Not open for further replies.

Share This Page