Esempio n. 1
0
  public boolean execute(MOB mob, Vector commands, int metaFlags) throws java.io.IOException {
    String memberStr = (commands.size() > 1) ? (String) commands.get(commands.size() - 1) : "";
    String clanName =
        (commands.size() > 2) ? CMParms.combine(commands, 1, commands.size() - 1) : "";

    Clan C = null;
    boolean skipChecks = mob.getClanRole(mob.Name()) != null;
    if (skipChecks) C = mob.getClanRole(mob.Name()).first;

    if (C == null)
      for (Pair<Clan, Integer> c : mob.clans())
        if ((clanName.length() == 0)
            || (CMLib.english().containsString(c.first.getName(), clanName))
                && (c.first.getAuthority(c.second.intValue(), Clan.Function.EXILE)
                    != Authority.CAN_NOT_DO)) {
          C = c.first;
          break;
        }

    commands.clear();
    commands.addElement(getAccessWords()[0]);
    commands.addElement(memberStr);

    StringBuffer msg = new StringBuffer("");
    boolean found = false;
    if (memberStr.length() > 0) {
      if (C == null) {
        mob.tell(
            "You aren't allowed to exile anyone from "
                + ((clanName.length() == 0) ? "anything" : clanName)
                + ".");
        return false;
      }
      if (skipChecks || CMLib.clans().goForward(mob, C, commands, Clan.Function.EXILE, false)) {
        List<MemberRecord> apps = C.getMemberList();
        if (apps.size() < 1) {
          mob.tell("There are no members in your " + C.getGovernmentName() + ".");
          return false;
        }
        for (MemberRecord member : apps) {
          if (member.name.equalsIgnoreCase(memberStr)) {
            found = true;
          }
        }
        if (found) {
          MOB M = CMLib.players().getLoadPlayer(memberStr);
          if (M == null) {
            mob.tell(
                memberStr + " was not found.  Could not exile from " + C.getGovernmentName() + ".");
            return false;
          }
          if (skipChecks || CMLib.clans().goForward(mob, C, commands, Clan.Function.EXILE, true)) {
            if (C.getGovernment().getExitScript().trim().length() > 0) {
              Pair<Clan, Integer> curClanRole = M.getClanRole(C.clanID());
              if (curClanRole != null) M.setClan(C.clanID(), curClanRole.second.intValue());
              ScriptingEngine S = (ScriptingEngine) CMClass.getCommon("DefaultScriptingEngine");
              S.setSavable(false);
              S.setVarScope("*");
              S.setScript(C.getGovernment().getExitScript());
              CMMsg msg2 = CMClass.getMsg(M, M, null, CMMsg.MSG_OK_VISUAL, null, null, "CLANEXIT");
              S.executeMsg(M, msg2);
              S.dequeResponses();
              S.tick(M, Tickable.TICKID_MOB);
            }
            CMLib.clans()
                .clanAnnounce(
                    mob,
                    "Member exiled from "
                        + C.getGovernmentName()
                        + " "
                        + C.name()
                        + ": "
                        + M.Name());
            mob.tell(
                M.Name()
                    + " has been exiled from "
                    + C.getGovernmentName()
                    + " '"
                    + C.clanID()
                    + "'.");
            if ((M.session() != null) && (M.session().mob() == M))
              M.tell(
                  "You have been exiled from " + C.getGovernmentName() + " '" + C.clanID() + "'.");
            C.delMember(M);
            return false;
          }
        } else {
          msg.append(memberStr + " isn't a member of your " + C.getGovernmentName() + ".");
        }
      } else {
        msg.append(
            "You aren't in the right position to exile anyone from your "
                + C.getGovernmentName()
                + ".");
      }
    } else {
      msg.append("You haven't specified which member you are exiling.");
    }
    mob.tell(msg.toString());
    return false;
  }