@Override
  public void perform() throws MassiveException {
    // Arg: Faction
    Faction faction = this.arg(0, ARFaction.get(), msenderFaction);

    List<MFlag> flags = new ArrayList<MFlag>();

    // Case: Show All
    if (!this.argIsSet(1) || "all".equalsIgnoreCase(this.arg(1))) {
      for (MFlag mflag : MFlag.getAll()) {
        if (!mflag.isVisible() && !msender.isUsingAdminMode()) continue;
        flags.add(mflag);
      }
    } else {
      // Arg: MFlag. Maybe we should use ARSet but that is currently buggy.
      List<MFlag> mflags = this.arg(this.argConcatFrom(1), ARList.get(ARMFlag.get()));
      flags.addAll(mflags);
    }

    // Create messages
    List<String> messages = new ArrayList<String>();
    messages.add(Txt.titleize("Flag for " + faction.describeTo(msender, true)));
    for (MFlag mflag : flags) {
      messages.add(mflag.getStateDesc(faction.getFlag(mflag), true, true, true, true, true));
    }

    // Send messages
    sendMessage(messages);
  }
Exemplo n.º 2
0
  public static MFlag getCreative(
      int priority,
      String id,
      String name,
      String desc,
      String descYes,
      String descNo,
      boolean standard,
      boolean editable,
      boolean visible) {
    MFlag ret = MFlagColl.get().get(id, false);
    if (ret != null) {
      ret.setRegistered(true);
      return ret;
    }

    ret = new MFlag(priority, name, desc, descYes, descNo, standard, editable, visible);
    MFlagColl.get().attach(ret, id);
    ret.setRegistered(true);
    ret.sync();

    return ret;
  }
  public void econLandRewardRoutine() {
    if (!Econ.isEnabled()) return;

    double econLandReward = MConf.get().econLandReward;
    if (econLandReward == 0.0) return;

    Factions.get().log("Running econLandRewardRoutine...");
    for (Faction faction : this.getAll()) {
      int landCount = faction.getLandCount();
      if (!faction.getFlag(MFlag.getFlagPeaceful()) && landCount > 0) {
        List<MPlayer> players = faction.getMPlayers();
        int playerCount = players.size();
        double reward = econLandReward * landCount / playerCount;
        for (MPlayer player : players) {
          Econ.modifyMoney(
              player,
              reward,
              "own " + landCount + " faction land divided among " + playerCount + " members");
        }
      }
    }
  }
 @Override
 public void invoke(long now) {
   MPerm.getAll();
   MFlag.getAll();
 }
  public Faction getNone() {
    String id = Factions.ID_NONE;
    Faction faction = this.get(id);
    if (faction != null) return faction;

    faction = this.create(id);

    faction.setName(Factions.NAME_NONE_DEFAULT);
    faction.setDescription(null);

    faction.setFlag(MFlag.getFlagOpen(), false);
    faction.setFlag(MFlag.getFlagPermanent(), true);
    faction.setFlag(MFlag.getFlagPeaceful(), false);
    faction.setFlag(MFlag.getFlagInfpower(), true);
    faction.setFlag(MFlag.getFlagPowerloss(), true);
    faction.setFlag(MFlag.getFlagPvp(), true);
    faction.setFlag(MFlag.getFlagFriendlyire(), false);
    faction.setFlag(MFlag.getFlagMonsters(), true);
    faction.setFlag(MFlag.getFlagExplosions(), true);
    faction.setFlag(MFlag.getFlagOfflineexplosions(), true);
    faction.setFlag(MFlag.getFlagFirespread(), true);
    faction.setFlag(MFlag.getFlagEndergrief(), true);

    faction.setPermittedRelations(
        MPerm.getPermBuild(),
        Rel.LEADER,
        Rel.OFFICER,
        Rel.MEMBER,
        Rel.RECRUIT,
        Rel.ALLY,
        Rel.TRUCE,
        Rel.NEUTRAL,
        Rel.ENEMY);
    faction.setPermittedRelations(
        MPerm.getPermDoor(),
        Rel.LEADER,
        Rel.OFFICER,
        Rel.MEMBER,
        Rel.RECRUIT,
        Rel.ALLY,
        Rel.TRUCE,
        Rel.NEUTRAL,
        Rel.ENEMY);
    faction.setPermittedRelations(
        MPerm.getPermContainer(),
        Rel.LEADER,
        Rel.OFFICER,
        Rel.MEMBER,
        Rel.RECRUIT,
        Rel.ALLY,
        Rel.TRUCE,
        Rel.NEUTRAL,
        Rel.ENEMY);
    faction.setPermittedRelations(
        MPerm.getPermButton(),
        Rel.LEADER,
        Rel.OFFICER,
        Rel.MEMBER,
        Rel.RECRUIT,
        Rel.ALLY,
        Rel.TRUCE,
        Rel.NEUTRAL,
        Rel.ENEMY);
    faction.setPermittedRelations(
        MPerm.getPermLever(),
        Rel.LEADER,
        Rel.OFFICER,
        Rel.MEMBER,
        Rel.RECRUIT,
        Rel.ALLY,
        Rel.TRUCE,
        Rel.NEUTRAL,
        Rel.ENEMY);
    faction.setPermittedRelations(
        MPerm.getPermDeposit(),
        Rel.LEADER,
        Rel.OFFICER); // Wilderness deposit should be limited as an anti spam meassure.

    return faction;
  }
  public Faction getWarzone() {
    String id = Factions.ID_WARZONE;
    Faction faction = this.get(id);
    if (faction != null) return faction;

    faction = this.create(id);

    faction.setName(Factions.NAME_WARZONE_DEFAULT);
    faction.setDescription("Not the safest place to be");

    faction.setFlag(MFlag.getFlagOpen(), false);
    faction.setFlag(MFlag.getFlagPermanent(), true);
    faction.setFlag(MFlag.getFlagPeaceful(), true);
    faction.setFlag(MFlag.getFlagInfpower(), true);
    faction.setFlag(MFlag.getFlagPowerloss(), true);
    faction.setFlag(MFlag.getFlagPvp(), true);
    faction.setFlag(MFlag.getFlagFriendlyire(), true);
    faction.setFlag(MFlag.getFlagMonsters(), true);
    faction.setFlag(MFlag.getFlagExplosions(), true);
    faction.setFlag(MFlag.getFlagOfflineexplosions(), true);
    faction.setFlag(MFlag.getFlagFirespread(), true);
    faction.setFlag(MFlag.getFlagEndergrief(), true);

    faction.setPermittedRelations(
        MPerm.getPermDoor(),
        Rel.LEADER,
        Rel.OFFICER,
        Rel.MEMBER,
        Rel.RECRUIT,
        Rel.ALLY,
        Rel.TRUCE,
        Rel.NEUTRAL,
        Rel.ENEMY);
    faction.setPermittedRelations(
        MPerm.getPermContainer(),
        Rel.LEADER,
        Rel.OFFICER,
        Rel.MEMBER,
        Rel.RECRUIT,
        Rel.ALLY,
        Rel.TRUCE,
        Rel.NEUTRAL,
        Rel.ENEMY);
    faction.setPermittedRelations(
        MPerm.getPermButton(),
        Rel.LEADER,
        Rel.OFFICER,
        Rel.MEMBER,
        Rel.RECRUIT,
        Rel.ALLY,
        Rel.TRUCE,
        Rel.NEUTRAL,
        Rel.ENEMY);
    faction.setPermittedRelations(
        MPerm.getPermLever(),
        Rel.LEADER,
        Rel.OFFICER,
        Rel.MEMBER,
        Rel.RECRUIT,
        Rel.ALLY,
        Rel.TRUCE,
        Rel.NEUTRAL,
        Rel.ENEMY);
    faction.setPermittedRelations(MPerm.getPermTerritory(), Rel.LEADER, Rel.OFFICER, Rel.MEMBER);

    return faction;
  }