Esempio n. 1
0
  @Override
  public void perform() throws MassiveException {
    // Args
    MPerm perm = this.readArg();
    Rel rel = this.readArg();
    Boolean value = this.readArg();
    Faction faction = this.readArg(msenderFaction);

    // Do the sender have the right to change perms for this faction?
    if (!MPerm.getPermPerms().has(msender, faction, true)) return;

    // Is this perm editable?
    if (!msender.isUsingAdminMode() && !perm.isEditable()) {
      msg("<b>The perm <h>%s <b>is not editable.", perm.getName());
      return;
    }

    // No change
    if (faction.getPermitted(perm).contains(rel) == value) {
      msg(
          "%s <i>already has %s <i>set to %s <i>for %s<i>.",
          faction.describeTo(msender),
          perm.getDesc(true, false),
          Txt.parse(value ? "<g>YES" : "<b>NOO"),
          rel.getColor() + rel.getDescPlayerMany());
      return;
    }

    // Apply
    faction.setRelationPermitted(perm, rel, value);

    // The following is to make sure the leader always has the right to change perms if that is our
    // goal.
    if (perm == MPerm.getPermPerms() && MPerm.getPermPerms().getStandard().contains(Rel.LEADER)) {
      faction.setRelationPermitted(MPerm.getPermPerms(), Rel.LEADER, true);
    }

    // Create messages
    List<String> messages = new ArrayList<String>();

    // Inform sender
    messages.add(Txt.titleize("Perm for " + faction.describeTo(msender, true)));
    messages.add(MPerm.getStateHeaders());
    messages.add(Txt.parse(perm.getStateInfo(faction.getPermitted(perm), true)));
    sendMessage(messages);

    // Inform faction (their message is slighly different)
    List<MPlayer> recipients = faction.getMPlayers();
    recipients.remove(msender);

    for (MPlayer recipient : recipients) {
      messages.add(
          0,
          Txt.parse(
              "<h>%s <i>set a perm for <h>%s<i>.",
              msender.describeTo(recipient, true), faction.describeTo(recipient, true)));
      recipient.sendMessage(messages);
    }
  }
  @Override
  public void perform() throws MassiveException {
    // Args
    MPlayer you = this.readArg();
    String newTitle = this.readArg("");

    newTitle = Txt.parse(newTitle);
    if (!Perm.TITLE_COLOR.has(sender, false)) {
      newTitle = ChatColor.stripColor(newTitle);
    }

    // MPerm
    if (!MPerm.getPermTitle().has(msender, you.getFaction(), true)) return;

    // Rank Check
    if (!msender.isUsingAdminMode() && you.getRole().isMoreThan(msender.getRole())) {
      msg("<b>You can not edit titles for higher ranks.");
      return;
    }

    // Event
    EventFactionsTitleChange event = new EventFactionsTitleChange(sender, you, newTitle);
    event.run();
    if (event.isCancelled()) return;
    newTitle = event.getNewTitle();

    // Apply
    you.setTitle(newTitle);

    // Inform
    msenderFaction.msg(
        "%s<i> changed a title: %s",
        msender.describeTo(msenderFaction, true), you.describeTo(msenderFaction, true));
  }
  @Override
  public void innerPerform() throws MassiveException {
    // Args
    MPlayer mplayer = this.readArg();
    boolean newValue = this.readArg(!ta.isPlayerIdGranted(mplayer.getId()));

    // MPerm
    if (!MPerm.getPermAccess().has(msender, hostFaction, true)) return;

    // Apply
    ta = ta.withPlayerId(mplayer.getId(), newValue);
    BoardColl.get().setTerritoryAccessAt(chunk, ta);

    // Inform
    this.sendAccessInfo();
  }
 @Override
 public void invoke(long now) {
   MPerm.getAll();
   MFlag.getAll();
 }