@Override
 public void perform() {
   Factions.get()
       .getOuterCmdFactions()
       .cmdFactionsRank
       .execute(sender, MUtil.list(this.arg(0), this.rankName, this.arg(1)));
 }
Beispiel #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);
  }
  @Override
  public void perform() throws MassiveException {
    // Arguments
    Faction faction = this.readArg();

    // Apply
    CmdFactions.get()
        .cmdFactionsRelation
        .cmdFactionsRelationSet
        .execute(sender, MUtil.list(faction.getId(), this.relName));
  }
  public boolean ensureExists(String accountId) {
    Economy economy = this.getEconomy();

    if (economy.hasAccount(accountId)) return true;

    if (!economy.createPlayerAccount(accountId)) return false;

    if (MUtil.isValidPlayerName(accountId)) return true;

    double balance = economy.getBalance(accountId);
    economy.withdrawPlayer(accountId, balance);

    return true;
  }
Beispiel #5
0
public class UConf extends Entity<UConf> {
  // -------------------------------------------- //
  // META
  // -------------------------------------------- //

  public static UConf get(Object oid) {
    return UConfColls.get().get2(oid);
  }

  // -------------------------------------------- //
  // UNIVERSE ENABLE SWITCH
  // -------------------------------------------- //

  public boolean enabled = true;

  public static boolean isDisabled(Object universe) {
    return isDisabled(universe, null);
  }

  public static String getDisabledMessage(Object universe) {
    UConf uconf = UConf.get(universe);
    return Txt.parse("<i>Factions are disabled in the <h>%s <i>universe.", uconf.getUniverse());
  }

  public static boolean isDisabled(Object universe, Object inform) {
    UConf uconf = UConf.get(universe);
    if (uconf.enabled) return false;

    if (inform instanceof CommandSender) {
      ((CommandSender) inform).sendMessage(getDisabledMessage(universe));
    } else if (inform instanceof SenderEntity) {
      ((SenderEntity<?>) inform).sendMessage(getDisabledMessage(universe));
    }

    return true;
  }

  // -------------------------------------------- //
  // SPECIAL FACTION IDS
  // -------------------------------------------- //

  public String factionIdNone = UUID.randomUUID().toString();
  public String factionIdSafezone = UUID.randomUUID().toString();
  public String factionIdWarzone = UUID.randomUUID().toString();

  // -------------------------------------------- //
  // DEFAULTS
  // -------------------------------------------- //

  public String defaultPlayerFactionId = this.factionIdNone;
  public Rel defaultPlayerRole = Rel.RECRUIT;
  public double defaultPlayerPower = 0.0;

  public boolean defaultFactionOpen = false;
  public Map<FFlag, Boolean> defaultFactionFlags = FFlag.getDefaultDefaults();
  public Map<FPerm, Set<Rel>> defaultFactionPerms = FPerm.getDefaultDefaults();

  // -------------------------------------------- //
  // MESSAGES
  // -------------------------------------------- //

  public boolean broadcastNameChange = false;

  // -------------------------------------------- //
  // POWER
  // -------------------------------------------- //

  public double powerMax = 10.0;
  public double powerMin = 0.0;
  public double powerPerHour = 2.0;
  public double powerPerDeath = -2.0;

  public boolean canLeaveWithNegativePower = true;

  // -------------------------------------------- //
  // CORE
  // -------------------------------------------- //

  public int factionMemberLimit = 0;
  public double factionPowerMax = 0.0;

  public int factionNameLengthMin = 3;
  public int factionNameLengthMax = 16;
  public boolean factionNameForceUpperCase = false;

  // -------------------------------------------- //
  // CLAIMS
  // -------------------------------------------- //

  public boolean claimsMustBeConnected = true;
  public boolean claimingFromOthersAllowed = true;
  public boolean claimsCanBeUnconnectedIfOwnedByOtherFaction = false;
  public int claimsRequireMinFactionMembers = 1;
  public int claimedLandsMax = 0;

  // -------------------------------------------- //
  // HOMES
  // -------------------------------------------- //

  public boolean homesEnabled = true;
  public boolean homesMustBeInClaimedTerritory = true;
  public boolean homesTeleportCommandEnabled = true;
  public boolean homesTeleportAllowedFromEnemyTerritory = true;
  public boolean homesTeleportAllowedFromDifferentWorld = true;
  public double homesTeleportAllowedEnemyDistance = 32.0;
  public boolean homesTeleportIgnoreEnemiesIfInOwnTerritory = true;

  public boolean homesTeleportToOnDeathActive = false;
  public EventPriority homesTeleportToOnDeathPriority = EventPriority.NORMAL;

  // -------------------------------------------- //
  // ASSORTED
  // -------------------------------------------- //

  public boolean permanentFactionsDisableLeaderPromotion = false;
  public double actionDeniedPainAmount = 2.0D;
  public boolean disablePVPForFactionlessPlayers = false;
  public boolean enablePVPAgainstFactionlessInAttackersLand = false;
  public double territoryShieldFactor = 0.3D;

  // -------------------------------------------- //
  // DENY COMMANDS
  // -------------------------------------------- //

  // commands which will be prevented if the player is a member of a permanent faction
  public List<String> denyCommandsPermanentFactionMember = new ArrayList<String>();

  // commands which will be prevented when in claimed territory of another faction
  public Map<Rel, List<String>> denyCommandsTerritoryRelation =
      MUtil.map(
          Rel.ENEMY,
              MUtil.list(
                  // Essentials commands
                  "home",
                  "homes",
                  "sethome",
                  "createhome",
                  "tpahere",
                  "tpaccept",
                  "tpyes",
                  "tpa",
                  "call",
                  "tpask",
                  "warp",
                  "warps",
                  "spawn",
                  // Essentials e-alliases
                  "ehome",
                  "ehomes",
                  "esethome",
                  "ecreatehome",
                  "etpahere",
                  "etpaccept",
                  "etpyes",
                  "etpa",
                  "ecall",
                  "etpask",
                  "ewarp",
                  "ewarps",
                  "espawn",
                  // Essentials fallback alliases
                  "essentials:home",
                  "essentials:homes",
                  "essentials:sethome",
                  "essentials:createhome",
                  "essentials:tpahere",
                  "essentials:tpaccept",
                  "essentials:tpyes",
                  "essentials:tpa",
                  "essentials:call",
                  "essentials:tpask",
                  "essentials:warp",
                  "essentials:warps",
                  "essentials:spawn",
                  // Other plugins
                  "wtp",
                  "uspawn",
                  "utp",
                  "mspawn",
                  "mtp",
                  "fspawn",
                  "ftp",
                  "jspawn",
                  "jtp"),
          Rel.NEUTRAL, new ArrayList<String>(),
          Rel.TRUCE, new ArrayList<String>(),
          Rel.ALLY, new ArrayList<String>(),
          Rel.MEMBER, new ArrayList<String>());

  // -------------------------------------------- //
  // INTEGRATION: LWC
  // -------------------------------------------- //

  public Map<EventFactionsChunkChangeType, Boolean> lwcRemoveOnChange =
      MUtil.map(
          EventFactionsChunkChangeType.BUY, false,
          EventFactionsChunkChangeType.SELL, false,
          EventFactionsChunkChangeType.CONQUER, false,
          EventFactionsChunkChangeType.PILLAGE, false);

  // -------------------------------------------- //
  // INTEGRATION: ECONOMY
  // -------------------------------------------- //

  public boolean econEnabled = false;

  // TODO: Rename to include unit.
  public double econLandReward = 0.00;

  public String econUniverseAccount = "";

  public Map<EventFactionsChunkChangeType, Double> econChunkCost =
      MUtil.map(
          EventFactionsChunkChangeType.BUY, 30.0,
          EventFactionsChunkChangeType.SELL, -20.0,
          EventFactionsChunkChangeType.CONQUER, -10.0,
          EventFactionsChunkChangeType.PILLAGE, -10.0);

  public double econCostCreate = 200.0;
  public double econCostSethome = 0.0;
  public double econCostJoin = 0.0;
  public double econCostLeave = 0.0;
  public double econCostKick = 0.0;
  public double econCostInvite = 0.0;
  public double econCostDeinvite = 0.0;
  public double econCostHome = 0.0;
  public double econCostName = 0.0;
  public double econCostDescription = 0.0;
  public double econCostTitle = 0.0;
  public double econCostOpen = 0.0;

  public Map<Rel, Double> econRelCost =
      MUtil.map(
          Rel.ENEMY, 0.0,
          Rel.ALLY, 0.0,
          Rel.TRUCE, 0.0,
          Rel.NEUTRAL, 0.0);

  // Faction banks, to pay for land claiming and other costs instead of individuals paying for them
  public boolean bankEnabled = true;
  // public static boolean bankMembersCanWithdraw = false; //Have to be at least moderator to
  // withdraw or pay money to another faction
  public boolean bankFactionPaysCosts =
      true; // The faction pays for faction command costs, such as sethome
  public boolean bankFactionPaysLandCosts = true; // The faction pays for land claiming costs.
}