コード例 #1
0
  @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;
  }
コード例 #2
0
  public static void floodSearch(Set<PS> set, Faction color, int max) {
    // Clean
    if (set == null) throw new NullPointerException("set");
    if (color == null) throw new NullPointerException("color");

    // Expand
    Set<PS> expansion = new LinkedHashSet<PS>();
    for (PS chunk : set) {
      Set<PS> neighbours =
          MUtil.set(
              chunk.withChunkX(chunk.getChunkX() + 1),
              chunk.withChunkX(chunk.getChunkX() - 1),
              chunk.withChunkZ(chunk.getChunkZ() + 1),
              chunk.withChunkZ(chunk.getChunkZ() - 1));

      for (PS neighbour : neighbours) {
        if (set.contains(neighbour)) continue;
        Faction faction = BoardColl.get().getFactionAt(neighbour);
        if (faction == null) continue;
        if (faction != color) continue;
        expansion.add(neighbour);
      }
    }
    set.addAll(expansion);

    // No Expansion?
    if (expansion.isEmpty()) return;

    // Reached Max?
    if (set.size() >= max) return;

    // Recurse
    floodSearch(set, color, max);
  }
コード例 #3
0
ファイル: Fx.java プロジェクト: MassiveCraft/MassiveGates
  public static void perform(Fx fx, String dataString, Gate gate) {
    Collection<Location> locations;
    if (fx.hasSound) {
      locations = Arrays.asList(gate.calcGateCenter());
    } else {
      locations = new ArrayList<Location>(gate.getContent().size());
      for (PS coord : gate.getContent()) {
        try {
          locations.add(coord.asBukkitLocation(true));
        } catch (Exception e) {

        }
      }
    }
    perform(fx, dataString, locations);
  }
コード例 #4
0
  @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;
  }
コード例 #5
0
ファイル: SCPlayerManager.java プロジェクト: xAnml/SCCore
  @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();
  }