@Override public Set<PS> getChunks() { // Common Startup final PS chunk = PS.valueOf(me.getLocation()).getChunk(true); final Set<PS> chunks = new LinkedHashSet<PS>(); // What faction (aka color) resides there? // NOTE: Wilderness/None is valid. final Faction color = BoardColl.get().getFactionAt(chunk); // We start where we are! chunks.add(chunk); // Flood! int max = MConf.get().setFillMax; floodSearch(chunks, color, max); // Limit Reached? if (chunks.size() >= max) { msg("<b>Fill limit of <h>%d <b>reached.", max); return null; } // OK! return chunks; }
@Override public Set<PS> getChunks() throws MassiveException { // Common Startup final PS chunk = PS.valueOf(me.getLocation()).getChunk(true); final Set<PS> chunks = new LinkedHashSet<PS>(); chunks.add(chunk); // The center should come first for pretty messages Integer radiusZero = this.getRadiusZero(); if (radiusZero == null) return null; double radiusSquared = radiusZero * radiusZero; for (int dx = -radiusZero; dx <= radiusZero; dx++) { for (int dz = -radiusZero; dz <= radiusZero; dz++) { if (dx * dx + dz * dz > radiusSquared) continue; int x = chunk.getChunkX() + dx; int z = chunk.getChunkZ() + dz; chunks.add(chunk.withChunkX(x).withChunkZ(z)); } } return chunks; }
@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(); }