@EventHandler(priority = EventPriority.HIGHEST) public void onPlayerDamageByPlayer(final EntityDamageByEntityEvent e) { if (e.getEntity() instanceof Player == false || e.getDamager() instanceof Player == false) return; Player player = (Player) e.getEntity(); Player target = (Player) e.getDamager(); SCPlayer scp = getSCPlayer(player.getUniqueId()); SCPlayer sct = getSCPlayer(target.getUniqueId()); Faction faction = BoardColl.get().getFactionAt(PS.valueOf(target.getLocation().getChunk())); if (faction.getName().equalsIgnoreCase("Safezone")) { return; } final Faction pFaction = MPlayerColl.get().get(player).getFaction(); final Faction tFaction = MPlayerColl.get().get(target).getFaction(); if (pFaction.getRelationTo(tFaction) == Rel.MEMBER && !pFaction.isNone()) { return; } if (pFaction.getRelationTo(tFaction) == Rel.ALLY) { return; } scp.combatTag(); sct.combatTag(); }
@Override public Faction get(Object oid) { Faction ret = super.get(oid); // We should only trigger automatic clean if the whole database system is initialized. // A cleaning can only be successful if all data is available. // Example Reason: When creating the special factions for the first time "createSpecialFactions" // a clean would be triggered otherwise. if (ret == null && Factions.get().isDatabaseInitialized()) { String message = Txt.parse( "<b>Non existing factionId <h>%s <b>requested. <i>Cleaning all boards and mplayers.", this.fixId(oid)); Factions.get().log(message); BoardColl.get().clean(); MPlayerColl.get().clean(); } return ret; }