@Override
  public boolean invoke(
      MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) {
    MOB target = CMLib.players().getLoadPlayer(CMParms.combine(commands, 0));
    if (target == null) target = getTargetAnywhere(mob, commands, givenTarget, false, true, false);
    if (target == null) return false;

    final Archon_Record A = (Archon_Record) target.fetchEffect(ID());
    if (A != null) {
      target.delEffect(A);
      if (target.playerStats() != null) target.playerStats().setLastUpdated(0);
      mob.tell(L("@x1 will no longer be recorded.", target.Name()));
      return true;
    }

    if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false;

    final boolean success = proficiencyCheck(mob, 0, auto);

    if (success) {
      final CMMsg msg =
          CMClass.getMsg(
              mob,
              target,
              this,
              CMMsg.MASK_MOVE | CMMsg.TYP_JUSTICE | (auto ? CMMsg.MASK_ALWAYS : 0),
              L("^F<S-NAME> begin(s) recording <T-NAMESELF>.^?"));
      CMLib.color().fixSourceFightColor(msg);
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        final String filename = "/" + target.Name() + System.currentTimeMillis() + ".log";
        final CMFile file = new CMFile(filename, null, CMFile.FLAG_LOGERRORS);
        if (!file.canWrite()) {
          if (!CMSecurity.isASysOp(mob) || (CMSecurity.isASysOp(target)))
            Log.sysOut("Record", mob.Name() + " failed to start recording " + target.name() + ".");
        } else {
          if (!CMSecurity.isASysOp(mob) || (CMSecurity.isASysOp(target)))
            Log.sysOut(
                "Record",
                mob.Name() + " started recording " + target.name() + " to /" + filename + ".");
          final Archon_Record A2 = (Archon_Record) copyOf();
          final Session F = (Session) CMClass.getCommon("FakeSession");
          F.initializeSession(null, Thread.currentThread().getThreadGroup().getName(), filename);
          if (target.session() == null) target.setSession(F);
          A2.sess = F;
          target.addNonUninvokableEffect(A2);
          mob.tell(L("Enter RECORD @x1 again to stop recording.", target.Name()));
        }
      }
    } else
      return beneficialVisualFizzle(
          mob, target, L("<S-NAME> attempt(s) to hush <T-NAMESELF>, but fail(s)."));
    return success;
  }
Beispiel #2
0
 public MOB getMobPossessingAnother(MOB mob) {
   if (mob == null) return null;
   Session S = null;
   MOB M = null;
   for (int s = 0; s < CMLib.sessions().size(); s++) {
     S = CMLib.sessions().elementAt(s);
     if (S != null) {
       M = S.mob();
       if ((M != null) && (M.soulMate() == mob)) return M;
     }
   }
   return null;
 }
Beispiel #3
0
  @Override
  public boolean execute(MOB mob, List<String> commands, int metaFlags) throws java.io.IOException {
    if (!mob.isMonster()) {
      if ((commands != null)
          && (commands.size() > 1)
          && (commands.get(1).toUpperCase().equals("OFF"))) {
        final Command C = CMClass.getCommand("NoSounds");
        if (C != null) {
          return C.execute(mob, commands, metaFlags);
        }
      }

      boolean force = false;
      if (commands != null) {
        for (final Object o : commands) {
          if (o.toString().equalsIgnoreCase("force")) force = true;
        }
      }
      final Session session = mob.session();
      if ((!mob.isAttributeSet(MOB.Attrib.SOUND))
          || (!session.getClientTelnetMode(Session.TELNET_MSP))) {
        session.changeTelnetMode(Session.TELNET_MSP, true);
        for (int i = 0; ((i < 5) && (!session.getClientTelnetMode(Session.TELNET_MSP))); i++) {
          try {
            mob.session().prompt("", 500);
          } catch (final Exception e) {
          }
        }
        if (session.getClientTelnetMode(Session.TELNET_MSP)) {
          mob.setAttribute(MOB.Attrib.SOUND, true);
          mob.tell(L("MSP Sound/Music enabled.\n\r"));
        } else if (force) {
          session.setClientTelnetMode(Session.TELNET_MSP, true);
          session.setServerTelnetMode(Session.TELNET_MSP, true);
          mob.setAttribute(MOB.Attrib.SOUND, true);
          mob.tell(L("MSP Sound/Music has been forceably enabled.\n\r"));
        } else mob.tell(L("Your client does not appear to support MSP."));
      } else {
        mob.tell(L("MSP Sound/Music is already enabled.\n\r"));
      }
    }
    return false;
  }
  @Override
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    if (CMParms.combine(commands, 0).equalsIgnoreCase("auto")) {
      DATA.clear();
      IPS.clear();
      final Hashtable<String, List<MOB>> ipes = new Hashtable<String, List<MOB>>();
      for (final Session S : CMLib.sessions().localOnlineIterable()) {
        if ((S.getAddress().length() > 0) && (S.mob() != null)) {
          List V = ipes.get(S.getAddress());
          if (V == null) {
            V = new Vector();
            ipes.put(S.getAddress(), V);
          }
          if (!V.contains(S.mob())) V.add(S.mob());
        }
      }
      final StringBuffer rpt = new StringBuffer("");
      for (final Enumeration e = ipes.keys(); e.hasMoreElements(); ) {
        final String addr = (String) e.nextElement();
        final List<MOB> names = ipes.get(addr);
        if (names.size() > 1) {
          IPS.put(addr, names);
          rpt.append("Watch #" + (IPS.size()) + " added: ");
          for (int n = 0; n < names.size(); n++) {
            final MOB MN = names.get(n);
            if (MN.fetchEffect(ID()) == null) {
              final Ability A = (Ability) copyOf();
              MN.addNonUninvokableEffect(A);
              A.setSavable(false);
            }
            rpt.append(MN.Name() + " ");
          }
          rpt.append("\n\r");
        }
      }
      if (rpt.length() == 0)
        rpt.append("No users with duplicate IDs found.  Try MULTIWATCH ADD name1 name2 ... ");
      mob.tell(rpt.toString());
      return true;
    } else if (CMParms.combine(commands, 0).equalsIgnoreCase("stop")) {
      boolean foundLegacy = false;
      for (final Session S : CMLib.sessions().localOnlineIterable()) {
        if ((S != null) && (S.mob() != null) && (S.mob().fetchEffect(ID()) != null)) {
          foundLegacy = true;
          break;
        }
      }
      if ((DATA.size() == 0) && (IPS.size() == 0) && (!foundLegacy)) {
        mob.tell(L("Multiwatch is already off."));
        return false;
      }
      for (final Enumeration<List<MOB>> e = IPS.elements(); e.hasMoreElements(); ) {
        final List<MOB> V = e.nextElement();
        for (int v = 0; v < V.size(); v++) {
          final MOB M = V.get(v);
          final Ability A = M.fetchEffect(ID());
          if (A != null) M.delEffect(A);
        }
      }
      for (final Session S : CMLib.sessions().localOnlineIterable()) {
        if ((S != null) && (S.mob() != null)) {
          final MOB M = S.mob();
          final Ability A = M.fetchEffect(ID());
          if (A != null) M.delEffect(A);
        }
      }
      mob.tell(L("Multiplay watcher is now turned off."));
      DATA.clear();
      IPS.clear();
      return true;
    } else if ((commands.size() > 1)
        && ((String) commands.firstElement()).equalsIgnoreCase("add")) {
      final Vector V = new Vector();
      for (int i = 1; i < commands.size(); i++) {
        final String name = (String) commands.elementAt(i);
        final MOB M = CMLib.players().getPlayer(name);
        if ((M.session() != null) && (CMLib.flags().isInTheGame(M, true))) V.addElement(M);
        else mob.tell(L("'@x1' is not online.", name));
      }
      if (V.size() > 1) {
        for (int n = 0; n < V.size(); n++) {
          final MOB MN = (MOB) V.elementAt(n);
          if (MN.fetchEffect(ID()) == null) {
            final Ability A = (Ability) copyOf();
            MN.addNonUninvokableEffect(A);
            A.setSavable(false);
          }
        }
        IPS.put("MANUAL" + (IPS.size() + 1), V);
        mob.tell(L("Manual Watch #@x1 added.", "" + IPS.size()));
      }
      return true;
    } else if ((commands.size() == 0) && (DATA.size() > 0) && (IPS.size() > 0)) {
      final StringBuffer report = new StringBuffer("");
      for (final Enumeration<String> e = IPS.keys(); e.hasMoreElements(); ) {
        final String key = e.nextElement();
        int sync = 0;
        final List<MOB> V = IPS.get(key);
        for (int v = 0; v < V.size(); v++) {
          final MOB M = V.get(v);
          final int data[] = DATA.get(M);
          if (data != null) sync += data[DATA_SYNCHROFOUND];
        }
        report.append("^x" + key + "^?^., Syncs: " + sync + "\n\r");
        report.append(
            CMStrings.padRight(L("Name"), 25)
                + CMStrings.padRight(L("Speech"), 15)
                + CMStrings.padRight(L("Socials"), 15)
                + CMStrings.padRight(L("CMD"), 10)
                + CMStrings.padRight(L("ORDERS"), 10)
                + "\n\r");
        for (int v = 0; v < V.size(); v++) {
          final MOB M = V.get(v);
          int data[] = DATA.get(M);
          if (data == null) data = new int[DATA_TOTAL];
          report.append(CMStrings.padRight(M.Name(), 25));
          report.append(
              CMStrings.padRight(
                  data[DATA_GOODSPEECH] + "/" + data[DATA_DIRSPEECH] + "/" + data[DATA_ANYSPEECH],
                  15));
          report.append(
              CMStrings.padRight(
                  data[DATA_GOODSOCIAL] + "/" + data[DATA_DIRSOCIAL] + "/" + data[DATA_ANYSOCIAL],
                  15));
          report.append(CMStrings.padRight(data[DATA_TYPEDCOMMAND] + "", 10));
          report.append(CMStrings.padRight(data[DATA_ORDER] + "", 10));
          report.append("\n\r");
        }
        report.append("\n\r");
      }

      mob.tell(report.toString());
      return true;
    } else {
      mob.tell(L("Try MULTIWATCH AUTO, MULTIWATCH STOP, or MULTIWATCH ADD name1 name2.."));
      return false;
    }
  }
Beispiel #5
0
  @Override
  public boolean execute(final MOB mob, List<String> commands, int metaFlags)
      throws java.io.IOException {
    final PlayerStats pstats = mob.playerStats();
    if (pstats == null) return false;
    if (mob.isMonster()) return false;
    final Session sess = mob.session();
    if (sess != null) {
      sess.prompt(
          new InputCallback(InputCallback.Type.PROMPT) {
            @Override
            public void showPrompt() {
              sess.promptPrint(L("Enter your old password : "******"Enter a new password    : "******"Enter new password again: "));
                            }

                            @Override
                            public void timedOut() {}

                            @Override
                            public void callBack() {
                              final String ne2 = this.input;
                              if (!pstats.matchesPassword(old))
                                mob.tell(L("Your old password was not entered correctly."));
                              else if (!nep.equals(ne2))
                                mob.tell(
                                    L("Your new password was not entered the same way twice!"));
                              else {
                                pstats.setPassword(nep);
                                mob.tell(L("Your password has been changed."));
                                if (pstats.getAccount() != null)
                                  CMLib.database().DBUpdateAccount(pstats.getAccount());
                                CMLib.database()
                                    .DBUpdatePassword(mob.Name(), pstats.getPasswordStr());
                              }
                            }
                          });
                    }
                  });
            }
          });
    }
    return false;
  }
Beispiel #6
0
  public String systemReport(String itemCode) {
    long totalMOBMillis = 0;
    long totalMOBTicks = 0;
    long topMOBMillis = 0;
    long topMOBTicks = 0;
    MOB topMOBClient = null;
    for (int s = 0; s < CMLib.sessions().size(); s++) {
      Session S = CMLib.sessions().elementAt(s);
      totalMOBMillis += S.getTotalMillis();
      totalMOBTicks += S.getTotalTicks();
      if (S.getTotalMillis() > topMOBMillis) {
        topMOBMillis = S.getTotalMillis();
        topMOBTicks = S.getTotalTicks();
        topMOBClient = S.mob();
      }
    }

    if (itemCode.equalsIgnoreCase("totalMOBMillis")) return "" + totalMOBMillis;
    else if (itemCode.equalsIgnoreCase("totalMOBMillisTime"))
      return CMLib.english().returnTime(totalMOBMillis, 0);
    else if (itemCode.equalsIgnoreCase("totalMOBMillisTimePlusAverage"))
      return CMLib.english().returnTime(totalMOBMillis, totalMOBTicks);
    else if (itemCode.equalsIgnoreCase("totalMOBTicks")) return "" + totalMOBTicks;
    else if (itemCode.equalsIgnoreCase("topMOBMillis")) return "" + topMOBMillis;
    else if (itemCode.equalsIgnoreCase("topMOBMillisTime"))
      return CMLib.english().returnTime(topMOBMillis, 0);
    else if (itemCode.equalsIgnoreCase("topMOBMillisTimePlusAverage"))
      return CMLib.english().returnTime(topMOBMillis, topMOBTicks);
    else if (itemCode.equalsIgnoreCase("topMOBTicks")) return "" + topMOBTicks;
    else if (itemCode.equalsIgnoreCase("topMOBClient")) {
      if (topMOBClient != null) return topMOBClient.Name();
      return "";
    }

    int totalTickers = 0;
    long totalMillis = 0;
    long totalTicks = 0;
    int topGroupNumber = -1;
    long topGroupMillis = -1;
    long topGroupTicks = 0;
    long topObjectMillis = -1;
    long topObjectTicks = 0;
    int topObjectGroup = 0;
    Tickable topObjectClient = null;
    int num = 0;
    Tick almostTock = null;
    for (Iterator<Tick> e = tickGroups(); e.hasNext(); ) {
      almostTock = e.next();
      totalTickers += almostTock.numTickers();
      totalMillis += almostTock.milliTotal;
      totalTicks += almostTock.tickTotal;
      if (almostTock.milliTotal > topGroupMillis) {
        topGroupMillis = almostTock.milliTotal;
        topGroupTicks = almostTock.tickTotal;
        topGroupNumber = num;
      }
      try {
        for (Iterator et = almostTock.tickers(); et.hasNext(); ) {
          TockClient C = (TockClient) et.next();
          if (C.milliTotal > topObjectMillis) {
            topObjectMillis = C.milliTotal;
            topObjectTicks = C.tickTotal;
            topObjectClient = C.clientObject;
            topObjectGroup = num;
          }
        }
      } catch (NoSuchElementException ex) {
      }
      num++;
    }
    if (itemCode.equalsIgnoreCase("freeMemory"))
      return "" + (Runtime.getRuntime().freeMemory() / 1000);
    else if (itemCode.equalsIgnoreCase("totalMemory"))
      return "" + (Runtime.getRuntime().totalMemory() / 1000);
    else if (itemCode.equalsIgnoreCase("totalTime"))
      return ""
          + CMLib.english().returnTime(System.currentTimeMillis() - CMSecurity.getStartTime(), 0);
    else if (itemCode.equalsIgnoreCase("startTime"))
      return CMLib.time().date2String(CMSecurity.getStartTime());
    else if (itemCode.equalsIgnoreCase("currentTime"))
      return CMLib.time().date2String(System.currentTimeMillis());
    else if (itemCode.equalsIgnoreCase("totalTickers")) return "" + totalTickers;
    else if (itemCode.equalsIgnoreCase("totalMillis")) return "" + totalMillis;
    else if (itemCode.equalsIgnoreCase("totalMillisTime"))
      return CMLib.english().returnTime(totalMillis, 0);
    else if (itemCode.equalsIgnoreCase("totalMillisTimePlusAverage"))
      return CMLib.english().returnTime(totalMillis, totalTicks);
    else if (itemCode.equalsIgnoreCase("totalTicks")) return "" + totalTicks;
    else if (itemCode.equalsIgnoreCase("tickgroupsize")) return "" + ticks.size();
    else if (itemCode.equalsIgnoreCase("topGroupNumber")) return "" + topGroupNumber;
    else if (itemCode.equalsIgnoreCase("topGroupMillis")) return "" + topGroupMillis;
    else if (itemCode.equalsIgnoreCase("topGroupMillisTime"))
      return CMLib.english().returnTime(topGroupMillis, 0);
    else if (itemCode.equalsIgnoreCase("topGroupMillisTimePlusAverage"))
      return CMLib.english().returnTime(topGroupMillis, topGroupTicks);
    else if (itemCode.equalsIgnoreCase("topGroupTicks")) return "" + topGroupTicks;
    else if (itemCode.equalsIgnoreCase("topObjectMillis")) return "" + topObjectMillis;
    else if (itemCode.equalsIgnoreCase("topObjectMillisTime"))
      return CMLib.english().returnTime(topObjectMillis, 0);
    else if (itemCode.equalsIgnoreCase("topObjectMillisTimePlusAverage"))
      return CMLib.english().returnTime(topObjectMillis, topObjectTicks);
    else if (itemCode.equalsIgnoreCase("topObjectTicks")) return "" + topObjectTicks;
    else if (itemCode.equalsIgnoreCase("topObjectGroup")) return "" + topObjectGroup;
    else if (itemCode.toLowerCase().startsWith("thread")) {
      int xstart = "thread".length();
      int xend = xstart;
      while ((xend < itemCode.length()) && (Character.isDigit(itemCode.charAt(xend)))) xend++;
      int threadNum = CMath.s_int(itemCode.substring(xstart, xend));
      int curThreadNum = 0;
      for (Enumeration e = CMLib.libraries(); e.hasMoreElements(); ) {
        CMLibrary lib = (CMLibrary) e.nextElement();
        ThreadEngine.SupportThread thread = lib.getSupportThread();
        if (thread != null) {
          if (curThreadNum == threadNum) {
            String instrCode = itemCode.substring(xend);
            if (instrCode.equalsIgnoreCase("miliTotal")) return "" + thread.milliTotal;
            if (instrCode.equalsIgnoreCase("milliTotal")) return "" + thread.milliTotal;
            if (instrCode.equalsIgnoreCase("status")) return "" + thread.status;
            if (instrCode.equalsIgnoreCase("name")) return "" + thread.getName();
            if (instrCode.equalsIgnoreCase("MilliTotalTime"))
              return CMLib.english().returnTime(thread.milliTotal, 0);
            if (instrCode.equalsIgnoreCase("MiliTotalTime"))
              return CMLib.english().returnTime(thread.milliTotal, 0);
            if (instrCode.equalsIgnoreCase("MilliTotalTimePlusAverage"))
              return CMLib.english().returnTime(thread.milliTotal, thread.tickTotal);
            if (instrCode.equalsIgnoreCase("MiliTotalTimePlusAverage"))
              return CMLib.english().returnTime(thread.milliTotal, thread.tickTotal);
            if (instrCode.equalsIgnoreCase("TickTotal")) return "" + thread.tickTotal;
            break;
          }
          curThreadNum++;
        }
      }
    }
    if (itemCode.equalsIgnoreCase("topObjectClient")) {
      if (topObjectClient != null) return topObjectClient.name();
      return "";
    }

    return "";
  }