// update title, since it may affect clusters, worries about ALL involved
 @Override
 public void updateTitle() {
   if (affected instanceof Room) CMLib.database().DBUpdateRoom((Room) affected);
   else {
     final Room R = CMLib.map().getRoom(landPropertyID());
     if (R != null) CMLib.database().DBUpdateRoom(R);
   }
 }
 @Override
 public void executeMsg(final Environmental myHost, final CMMsg msg) {
   super.executeMsg(myHost, msg);
   if (((msg.sourceMinor() == CMMsg.TYP_SHUTDOWN)
           || ((msg.targetMinor() == CMMsg.TYP_EXPIRE) && (msg.target() == affected))
           || (msg.sourceMinor() == CMMsg.TYP_ROOMRESET))
       && (affected instanceof Room)) {
     updateLot(null);
     final Vector mobs = new Vector();
     Room R = (Room) affected;
     if (R != null) {
       synchronized (("SYNC" + R.roomID()).intern()) {
         R = CMLib.map().getRoom(R);
         for (int m = 0; m < R.numInhabitants(); m++) {
           final MOB M = R.fetchInhabitant(m);
           if ((M != null)
               && (M.isSavable())
               && (M.getStartRoom() == R)
               && ((M.basePhyStats().rejuv() == 0)
                   || (M.basePhyStats().rejuv() == PhyStats.NO_REJUV))) {
             CMLib.catalog().updateCatalogIntegrity(M);
             mobs.addElement(M);
           }
         }
         if (!CMSecurity.isSaveFlag(CMSecurity.SaveFlag.NOPROPERTYMOBS))
           CMLib.database().DBUpdateTheseMOBs(R, mobs);
       }
     }
   }
 }
 public static void colorForSale(Room R, boolean rental, boolean reset) {
   synchronized (("SYNC" + R.roomID()).intern()) {
     R = CMLib.map().getRoom(R);
     final String theStr = rental ? RENTSTR : SALESTR;
     final String otherStr = rental ? SALESTR : RENTSTR;
     int x = R.description().indexOf(otherStr);
     while (x >= 0) {
       R.setDescription(R.description().substring(0, x));
       CMLib.database().DBUpdateRoom(R);
       x = R.description().indexOf(otherStr);
     }
     final String oldDescription = R.description();
     x = R.description().indexOf(theStr.trim());
     if ((x < 0)
         || (reset
             && (!R.displayText()
                 .equals(CMath.bset(R.domainType(), Room.INDOORS) ? INDOORSTR : OUTDOORSTR)))) {
       if (reset) {
         R.setDescription("");
         R.setDisplayText(CMath.bset(R.domainType(), Room.INDOORS) ? INDOORSTR : OUTDOORSTR);
         x = -1;
       }
       if (x < 0) R.setDescription(R.description() + theStr);
       else if (!reset) R.setDescription(R.description().substring(0, x + theStr.trim().length()));
       if (!R.description().equals(oldDescription)) CMLib.database().DBUpdateRoom(R);
     } else {
       R.setDescription(R.description().substring(0, x + theStr.trim().length()));
       if (!R.description().equals(oldDescription)) CMLib.database().DBUpdateRoom(R);
     }
     Item I = R.findItem(null, "$id$");
     if ((I == null) || (!I.ID().equals("GenWallpaper"))) {
       I = CMClass.getItem("GenWallpaper");
       CMLib.flags().setReadable(I, true);
       I.setName(("id"));
       I.setReadableText(CMLib.lang().L("This room is " + CMLib.map().getExtendedRoomID(R)));
       I.setDescription(CMLib.lang().L("This room is @x1", CMLib.map().getExtendedRoomID(R)));
       R.addItem(I);
       CMLib.database().DBUpdateItems(R);
     }
   }
 }
  @Override
  public boolean invoke(
      MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) {
    Physical target = null;
    if (commands.size() > 0) {
      final String s = CMParms.combine(commands, 0);
      if (s.equalsIgnoreCase("room")) target = mob.location();
      else if (s.equalsIgnoreCase("here")) target = mob.location();
      else if (CMLib.english().containsString(mob.location().ID(), s)
          || CMLib.english().containsString(mob.location().name(), s)
          || CMLib.english().containsString(mob.location().displayText(), s))
        target = mob.location();
    }
    if (target == null) target = getTarget(mob, commands, givenTarget);
    if (target == null) return false;
    if ((target instanceof Room) && (target.fetchEffect(ID()) != null)) {
      mob.tell(L("This place is already under a teleportation ward."));
      return false;
    }

    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,
              verbalCastCode(mob, target, auto),
              auto
                  ? L("<T-NAME> seem(s) magically protected.")
                  : L("^S<S-NAME> invoke(s) a teleportation ward upon <T-NAMESELF>.^?"));
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        if ((target instanceof Room) && (CMLib.law().doesOwnThisLand(mob, ((Room) target)))) {
          target.addNonUninvokableEffect((Ability) this.copyOf());
          CMLib.database().DBUpdateRoom((Room) target);
        } else beneficialAffect(mob, target, asLevel, 0);
      }
    } else
      beneficialWordsFizzle(
          mob, target, L("<S-NAME> attempt(s) to invoke a teleportation ward, but fail(s)."));

    return success;
  }
Exemple #5
0
 @Override
 public boolean execute(MOB mob, List<String> commands, int metaFlags) throws java.io.IOException {
   final StringBuffer head = new StringBuffer("");
   final boolean isArchonLooker = CMSecurity.isASysOp(mob);
   head.append("^x[");
   head.append(CMStrings.padRight(L("Class"), 16) + " ");
   head.append(CMStrings.padRight(L("Race"), 8) + " ");
   head.append(CMStrings.padRight(L("Lvl"), 4) + " ");
   if (isArchonLooker) head.append(CMStrings.padRight(L("Last"), 18) + " ");
   head.append("] Character Name^.^?\n\r");
   mob.tell(
       "^x["
           + CMStrings.centerPreserve(
               L("The Administrators of @x1", CMProps.getVar(CMProps.Str.MUDNAME)),
               head.length() - 10)
           + "]^.^?");
   final java.util.List<PlayerLibrary.ThinPlayer> allUsers =
       CMLib.database().getExtendedUserList();
   String mask = CMProps.getVar(CMProps.Str.WIZLISTMASK);
   if (mask.length() == 0) mask = "-ANYCLASS +Archon";
   final MaskingLibrary.CompiledZMask compiledMask = CMLib.masking().maskCompile(mask);
   for (final PlayerLibrary.ThinPlayer U : allUsers) {
     CharClass C;
     final MOB player = CMLib.players().getPlayer(U.name());
     if (player != null) C = player.charStats().getCurrentClass();
     else C = CMClass.getCharClass(U.charClass());
     if (C == null) C = CMClass.findCharClass(U.charClass());
     if (((player != null) && (CMLib.masking().maskCheck(compiledMask, player, true)))
         || (CMLib.masking().maskCheck(compiledMask, U))) {
       head.append("[");
       if (C != null) head.append(CMStrings.padRight(C.name(), 16) + " ");
       else head.append(CMStrings.padRight(L("Unknown"), 16) + " ");
       head.append(CMStrings.padRight(U.race(), 8) + " ");
       if ((C == null) || (!C.leveless()))
         head.append(CMStrings.padRight("" + U.level(), 4) + " ");
       else head.append(CMStrings.padRight("    ", 4) + " ");
       if (isArchonLooker)
         head.append(CMStrings.padRight(CMLib.time().date2String(U.last()), 18) + " ");
       head.append("] " + U.name());
       head.append("\n\r");
     }
   }
   mob.tell(head.toString());
   return false;
 }
  @Override
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    final Physical target = mob.location();
    if (target == null) return false;
    if (target.fetchEffect(ID()) != null) {
      mob.tell(L("This place is already consecrated."));
      return false;
    }

    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,
              verbalCastCode(mob, target, auto),
              auto ? "" : L("^S<S-NAME> @x1 to consecrate this place.^?", prayForWord(mob)));
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        setMiscText(mob.Name());
        if ((target instanceof Room) && (CMLib.law().doesOwnThisLand(mob, ((Room) target)))) {
          target.addNonUninvokableEffect((Ability) this.copyOf());
          CMLib.database().DBUpdateRoom((Room) target);
        } else beneficialAffect(mob, target, asLevel, 0);
      }
    } else
      beneficialWordsFizzle(
          mob,
          target,
          L(
              "<S-NAME> @x1 to consecrate this place, but <S-IS-ARE> not answered.",
              prayForWord(mob)));

    return success;
  }
 // update lot, since its called by the savethread, ONLY worries about itself
 @Override
 public void updateLot(List optPlayerList) {
   if (affected instanceof Room) {
     Room R = (Room) affected;
     synchronized (("SYNC" + R.roomID()).intern()) {
       R = CMLib.map().getRoom(R);
       lastItemNums =
           updateLotWithThisData(R, this, false, scheduleReset, optPlayerList, lastItemNums);
       if ((lastDayDone != R.getArea().getTimeObj().getDayOfMonth())
           && (CMProps.getBoolVar(CMProps.Bool.MUDSTARTED))) {
         lastDayDone = R.getArea().getTimeObj().getDayOfMonth();
         if ((getOwnerName().length() > 0) && rentalProperty() && (R.roomID().length() > 0))
           if (doRentalProperty(R.getArea(), R.roomID(), getOwnerName(), getPrice())) {
             setOwnerName("");
             CMLib.database().DBUpdateRoom(R);
             lastItemNums =
                 updateLotWithThisData(R, this, false, scheduleReset, optPlayerList, lastItemNums);
           }
       }
       scheduleReset = false;
     }
   }
 }
Exemple #8
0
  public boolean invoke(
      MOB mob, Vector commands, Environmental givenTarget, boolean auto, int asLevel) {
    if ((commands.size() < 1) && (givenTarget == null)) {
      mob.tell("Wizard Lock what?.");
      return false;
    }
    String targetName = CMParms.combine(commands, 0);

    Environmental target = null;
    int dirCode = Directions.getGoodDirectionCode(targetName);
    if (dirCode >= 0) target = mob.location().getExitInDir(dirCode);
    if (target == null)
      target = getTarget(mob, mob.location(), givenTarget, commands, Wearable.FILTER_ANY);
    if (target == null) return false;

    if ((!(target instanceof Container)) && (!(target instanceof Exit))) {
      mob.tell("You can't lock that.");
      return false;
    }

    if (target instanceof Container) {
      Container container = (Container) target;
      if ((!container.hasALid()) || (!container.hasALock())) {
        mob.tell("You can't lock that!");
        return false;
      }
    } else if (target instanceof Exit) {
      Exit exit = (Exit) target;
      if (!exit.hasADoor()) {
        mob.tell("You can't lock that!");
        return false;
      }
    }

    if (target.fetchEffect(this.ID()) != null) {
      mob.tell(target.name() + " is already magically locked!");
      return false;
    }

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

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

    if (success) {
      CMMsg msg =
          CMClass.getMsg(
              mob,
              target,
              this,
              verbalCastCode(mob, target, auto),
              auto ? "" : "^S<S-NAME> point(s) <S-HIS-HER> finger at <T-NAMESELF>, incanting.^?");
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        if (target instanceof Exit) {
          Exit exit = (Exit) target;
          exit.setDoorsNLocks(
              exit.hasADoor(),
              false,
              exit.defaultsClosed(),
              exit.hasALock(),
              true,
              exit.defaultsLocked());
          Room R = mob.location();
          Room R2 = null;
          for (int d = Directions.NUM_DIRECTIONS() - 1; d >= 0; d--)
            if (R.getExitInDir(d) == target) {
              R2 = R.getRoomInDir(d);
              break;
            }
          if ((CMLib.law().doesOwnThisProperty(mob, R))
              || ((R2 != null) && (CMLib.law().doesOwnThisProperty(mob, R2)))) {
            target.addNonUninvokableEffect((Ability) copyOf());
            CMLib.database().DBUpdateExits(R);
          } else beneficialAffect(mob, target, asLevel, Integer.MAX_VALUE / 2);
          mob.location().show(mob, target, CMMsg.MSG_OK_VISUAL, "<T-NAME> look(s) shut tight!");
        } else if (target instanceof Container) {
          beneficialAffect(mob, target, asLevel, Integer.MAX_VALUE / 2);
          Container container = (Container) target;
          container.setLidsNLocks(container.hasALid(), false, container.hasALock(), true);
          mob.location().show(mob, target, CMMsg.MSG_OK_VISUAL, "<T-NAME> look(s) shut tight!");
        }
        Ability lock = target.fetchEffect(ID());
        if (lock != null) {
          lock.setMiscText(Integer.toString(mob.envStats().level()));
          if (target instanceof Exit) {
            Room R = mob.location();
            if (!CMLib.law().doesHavePriviledgesHere(mob, R))
              for (int a = 0; a < R.numEffects(); a++)
                if ((R.fetchEffect(a) instanceof LandTitle)
                    && (((LandTitle) R.fetchEffect(a)).landOwner().length() > 0))
                  lock.setMiscText(lock.text() + " MALICIOUS");
          }
        }
      }

    } else
      beneficialWordsFizzle(
          mob, target, "<S-NAME> point(s) at <T-NAMESELF>, incanting, but nothing happens.");

    // return whether it worked
    return success;
  }
Exemple #9
0
  public boolean doArchonDBCompare(MOB mob, String scope, String firstWord, Vector commands)
      throws java.io.IOException {
    CMClass.CMObjectType doType = OBJECT_TYPES.get(firstWord.toUpperCase());
    if (doType == null) doType = OBJECT_TYPES.get(firstWord.toUpperCase() + "S");
    if (doType != null) commands.remove(0);
    else doType = CMClass.CMObjectType.LOCALE;

    final String theRest = CMParms.combineQuoted(commands, 0);
    DBConnector dbConnector = null;
    final String dbClass = CMParms.getParmStr(theRest, "DBCLASS", "");
    final String dbService = CMParms.getParmStr(theRest, "DBSERVICE", "");
    final String dbUser = CMParms.getParmStr(theRest, "DBUSER", "");
    final String dbPass = CMParms.getParmStr(theRest, "DBPASS", "");
    final int dbConns = CMParms.getParmInt(theRest, "DBCONNECTIONS", 3);
    final int dbPingIntMins = CMParms.getParmInt(theRest, "DBPINGINTERVALMINS", 30);
    final boolean dbReuse = CMParms.getParmBool(theRest, "DBREUSE", true);
    final String ignore = CMParms.getParmStr(theRest, "IGNORE", "");
    final String maskStr = CMParms.getParmStr(theRest, "MASK", "");
    final Set<String> ignores = new SHashSet(CMParms.parseCommas(ignore.toUpperCase(), true));
    final MaskingLibrary.CompiledZapperMask mask = CMLib.masking().maskCompile(maskStr);
    if (dbClass.length() == 0) {
      mob.tell(L("This command requires DBCLASS= to be set."));
      return false;
    }
    if (dbService.length() == 0) {
      mob.tell(L("This command requires DBSERVICE= to be set."));
      return false;
    }
    if (dbUser.length() == 0) {
      mob.tell(L("This command requires DBUSER= to be set."));
      return false;
    }
    if (dbPass.length() == 0) {
      mob.tell(L("This command requires DBPASS= to be set."));
      return false;
    }

    dbConnector =
        new DBConnector(
            dbClass, dbService, dbUser, dbPass, dbConns, dbPingIntMins, dbReuse, false, false);
    dbConnector.reconnect();
    final DBInterface dbInterface = new DBInterface(dbConnector, null);

    final DBConnection DBTEST = dbConnector.DBFetch();
    if (DBTEST != null) dbConnector.DBDone(DBTEST);
    mob.tell(L("Loading database rooms..."));
    final List<Room> rooms = new LinkedList<Room>();
    if ((!dbConnector.amIOk()) || (!dbInterface.isConnected())) {
      mob.tell(L("Failed to connect to database."));
      return false;
    }
    if (scope.equalsIgnoreCase("AREA"))
      rooms.addAll(
          Arrays.asList(dbInterface.DBReadRoomObjects(mob.location().getArea().Name(), false)));
    else if (scope.equalsIgnoreCase("ROOM")) {
      final Room R = dbInterface.DBReadRoomObject(mob.location().roomID(), false);
      if (R != null) rooms.add(R);
    } else
      for (final Enumeration<Area> e = CMLib.map().areas(); e.hasMoreElements(); )
        rooms.addAll(Arrays.asList(dbInterface.DBReadRoomObjects(e.nextElement().Name(), false)));
    if (rooms.size() == 0) {
      mob.tell(L("No rooms found."));
      return false;
    }
    for (final Room R : rooms) dbInterface.DBReadContent(R.roomID(), R, false);
    mob.tell(L("Data loaded, starting scan."));
    final Comparator<MOB> convM =
        new Comparator<MOB>() {
          @Override
          public int compare(MOB arg0, MOB arg1) {
            final int x = arg0.ID().compareTo(arg1.ID());
            return (x != 0) ? x : arg0.Name().compareTo(arg1.Name());
          }
        };
    final Comparator<Item> convI =
        new Comparator<Item>() {
          @Override
          public int compare(Item arg0, Item arg1) {
            final int x = arg0.ID().compareTo(arg1.ID());
            return (x != 0) ? x : arg0.Name().compareTo(arg1.Name());
          }
        };
    try {
      for (final Room dbR : rooms) {
        Room R = CMLib.map().getRoom(dbR.roomID());
        if (R == null) {
          if (doType == CMClass.CMObjectType.LOCALE)
            Log.sysOut("Merge", dbR.roomID() + " not in database");
          // import, including exits!
          continue;
        }
        synchronized (("SYNC" + dbR.roomID()).intern()) {
          final Area.State oldFlags = R.getArea().getAreaState();
          R.getArea().setAreaState(Area.State.FROZEN);

          boolean updateMobs = false;
          boolean updateItems = false;
          final boolean updateRoom = false;
          R = CMLib.map().getRoom(R);
          CMLib.map().resetRoom(R);
          final List<MOB> mobSetL = new Vector<MOB>();
          for (final Enumeration<MOB> e = dbR.inhabitants(); e.hasMoreElements(); )
            mobSetL.add(e.nextElement());
          final MOB[] mobSet = mobSetL.toArray(new MOB[0]);
          Arrays.sort(mobSet, convM);
          String lastName = "";
          int ct = 1;
          final HashSet<MOB> doneM = new HashSet<MOB>();
          for (final MOB dbM : mobSet) {
            if (!lastName.equals(dbM.Name())) ct = 1;
            else ct++;
            final String rName = dbM.Name() + "." + ct;
            MOB M = null;
            int ctr = ct;
            for (final Enumeration<MOB> m = R.inhabitants(); m.hasMoreElements(); ) {
              final MOB M1 = m.nextElement();
              if (M1.Name().equalsIgnoreCase(dbM.Name()) && ((--ctr) <= 0)) {
                M = M1;
                break;
              }
            }
            if (M == null) {
              if (amMerging(doType, mask, dbM) && (!ignore.contains("MISSING"))) {
                if (mob.session()
                    .confirm(
                        L(
                            "MOB: @x1.@x2 not in local room.\n\rWould you like to add it (y/N)?",
                            dbR.roomID(),
                            rName),
                        L("N"))) {
                  M = (MOB) dbM.copyOf();
                  M.bringToLife(R, true);
                  doneM.add(M);
                  updateMobs = true;
                  Log.sysOut("Merge", mob.Name() + " added mob " + dbR.roomID() + "." + rName);
                }
              }
            } else {
              doneM.add(M);
              if (amMerging(doType, mask, dbM)) {
                if (!dbM.sameAs(M)) {
                  final MOB oldM = (MOB) M.copyOf();
                  if ((dbMerge(mob, "^MMOB " + dbR.roomID() + "." + rName + "^N", dbM, M, ignores))
                      && (!oldM.sameAs(M))) {
                    Log.sysOut("Merge", mob.Name() + " modified mob " + dbR.roomID() + "." + rName);
                    updateMobs = true;
                  }
                }
              }
              final STreeSet<Item> itemSetL = new STreeSet<Item>(convI);
              for (final Enumeration<Item> e = dbM.items(); e.hasMoreElements(); )
                itemSetL.add(e.nextElement());
              final Item[] itemSet = itemSetL.toArray(new Item[0]);
              Arrays.sort(itemSet, convI);
              String lastIName = "";
              int ict = 1;
              final HashSet<Item> doneI = new HashSet<Item>();
              for (final Item dbI : itemSet) {
                if (!lastIName.equals(dbI.Name())) ict = 1;
                else ict++;
                final String rIName = dbI.Name() + "." + ict;
                Item I = null;
                ctr = ict;
                for (final Enumeration<Item> i = M.items(); i.hasMoreElements(); ) {
                  final Item I1 = i.nextElement();
                  if (I1.Name().equalsIgnoreCase(dbI.Name()) && ((--ctr) <= 0)) {
                    I = I1;
                    break;
                  }
                }
                if (I == null) {
                  if (amMerging(doType, mask, dbI) && (!ignore.contains("MISSING"))) {
                    if (mob.session()
                        .confirm(
                            L(
                                "Item: @x1.@x2.@x3 not in local room.\n\rWould you like to add it (y/N)?",
                                dbR.roomID(),
                                dbM.Name(),
                                rIName),
                            L("N"))) {
                      I = (Item) dbI.copyOf();
                      M.addItem(I);
                      doneI.add(I);
                      final Item cI =
                          (dbI.container() == null) ? null : M.findItem(dbI.container().Name());
                      if (cI instanceof Container) I.setContainer((Container) cI);
                      updateMobs = true;
                      Log.sysOut(
                          "Merge",
                          mob.Name()
                              + " added item "
                              + dbR.roomID()
                              + "."
                              + dbM.Name()
                              + "."
                              + rIName);
                    }
                  }
                } else if (amMerging(doType, mask, dbI)) {
                  doneI.add(I);
                  if (!dbI.sameAs(I)) {
                    final Item oldI = (Item) I.copyOf();
                    if ((dbMerge(
                            mob,
                            "^IITEM ^M" + dbR.roomID() + "." + dbM.Name() + "." + rIName + "^N",
                            dbI,
                            I,
                            ignores))
                        && (!oldI.sameAs(I))) {
                      Log.sysOut(
                          "Merge",
                          mob.Name()
                              + " modified item "
                              + dbR.roomID()
                              + "."
                              + dbM.Name()
                              + "."
                              + rIName);
                      updateMobs = true;
                    }
                  }
                }
                lastIName = dbI.Name();
              }
              for (final Enumeration<Item> i = M.items(); i.hasMoreElements(); ) {
                final Item I = i.nextElement();
                if (amMerging(doType, mask, I)
                    && (!doneI.contains(I))
                    && (!ignore.contains("EXTRA"))) {
                  if (mob.session()
                      .confirm(
                          L(
                              "Item: @x1.@x2.@x3 not in database.\n\rWould you like to delete it (y/N)?",
                              R.roomID(),
                              M.Name(),
                              I.Name()),
                          L("N"))) {
                    M.delItem(I);
                    updateMobs = true;
                    Log.sysOut(
                        "Merge",
                        mob.Name()
                            + " deleted item "
                            + R.roomID()
                            + "."
                            + M.Name()
                            + "."
                            + I.Name());
                  }
                }
              }
            }
            lastName = dbM.Name();
          }
          for (final Enumeration<MOB> r = R.inhabitants(); r.hasMoreElements(); ) {
            final MOB M = r.nextElement();
            if (amMerging(doType, mask, M)
                && (!doneM.contains(M))
                && (M.isMonster())
                && (!ignore.contains("EXTRA"))) {
              if (mob.session()
                  .confirm(
                      L(
                          "MOB: @x1.@x2 not in database.\n\rWould you like to delete it (y/N)?",
                          R.roomID(),
                          M.Name()),
                      L("N"))) {
                R.delInhabitant(M);
                updateMobs = true;
                Log.sysOut("Merge", mob.Name() + " deleted mob " + R.roomID() + "." + M.Name());
              }
            }
          }

          final STreeSet<Item> itemSetL = new STreeSet<Item>(convI);
          for (final Enumeration<Item> e = dbR.items(); e.hasMoreElements(); )
            itemSetL.add(e.nextElement());
          final Item[] itemSet = itemSetL.toArray(new Item[0]);
          Arrays.sort(itemSet, convI);
          lastName = "";
          ct = 1;
          final HashSet<Item> doneI = new HashSet<Item>();
          for (final Item dbI : itemSet) {
            if (!lastName.equals(dbI.Name())) ct = 1;
            else ct++;
            final String rName = dbI.Name() + "." + ct;
            Item I = null;
            int ctr = ct;
            for (final Enumeration<Item> i = R.items(); i.hasMoreElements(); ) {
              final Item I1 = i.nextElement();
              if (I1.Name().equalsIgnoreCase(dbI.Name()) && ((--ctr) <= 0)) {
                I = I1;
                break;
              }
            }
            if (I == null) {
              if (amMerging(doType, mask, dbI) && (!ignore.contains("MISSING"))) {
                if (mob.session()
                    .confirm(
                        L(
                            "Item: @x1.@x2 not in local room.\n\rWould you like to add it (y/N)?",
                            dbR.roomID(),
                            rName),
                        L("N"))) {
                  I = (Item) dbI.copyOf();
                  R.addItem(I);
                  doneI.add(I);
                  final Item cI =
                      (dbI.container() == null) ? null : R.findItem(dbI.container().Name());
                  if (cI instanceof Container) I.setContainer((Container) cI);
                  updateItems = true;
                  Log.sysOut("Merge", mob.Name() + " added item " + dbR.roomID() + "." + rName);
                }
              }
            } else if (amMerging(doType, mask, dbI)) {
              doneI.add(I);
              if (!dbI.sameAs(I)) {
                final Item oldI = (Item) I.copyOf();
                if ((dbMerge(mob, "^IITEM " + dbR.roomID() + "." + rName + "^N", dbI, I, ignores))
                    && (!oldI.sameAs(I))) {
                  Log.sysOut("Merge", mob.Name() + " modified item " + dbR.roomID() + "." + rName);
                  updateItems = true;
                }
              }
            }
            lastName = dbI.Name();
          }
          for (final Enumeration<Item> i = R.items(); i.hasMoreElements(); ) {
            final Item I = i.nextElement();
            if (amMerging(doType, mask, I) && (!doneI.contains(I)) && (!ignore.contains("EXTRA"))) {
              if (mob.session()
                  .confirm(
                      L(
                          "Item: @x1.@x2 not in database.\n\rWould you like to delete it (y/N)?",
                          R.roomID(),
                          I.Name()),
                      L("N"))) {
                R.delItem(I);
                updateItems = true;
                Log.sysOut("Merge", mob.Name() + " deleted item " + R.roomID() + "." + I.Name());
              }
            }
          }
          if (updateRoom) CMLib.database().DBUpdateRoom(R);
          if (updateItems) CMLib.database().DBUpdateItems(R);
          if (updateMobs) CMLib.database().DBUpdateMOBs(R);
          CMLib.map().resetRoom(R);
          R.getArea().setAreaState(oldFlags);
        }
        dbR.destroy();
      }
      mob.tell(L("Done"));
    } catch (final CMException cme) {
      mob.tell(L("Cancelled."));
    }
    dbInterface.shutdown();
    return true;
  }
Exemple #10
0
  @Override
  public boolean execute(MOB mob, Vector commands, int metaFlags) throws java.io.IOException {
    final boolean noisy = CMSecurity.isDebugging(CMSecurity.DbgFlag.MERGE);
    Vector placesToDo = new Vector();
    commands.remove(0);
    if (commands.size() == 0) {
      mob.tell(L("Merge what? Try DATABASE or a filename"));
      return false;
    }
    if (mob.isMonster()) {
      mob.tell(L("No can do."));
      return false;
    }
    if ((commands.size() > 0) && ((String) commands.get(0)).equalsIgnoreCase("noprompt"))
      commands.remove(0);

    if ((commands.size() > 0) && ((String) commands.get(0)).equalsIgnoreCase("?")) {
      final StringBuffer allFieldsMsg = new StringBuffer("");
      final Vector allKnownFields = new Vector();
      sortEnumeratedList(CMClass.mobTypes(), allKnownFields, allFieldsMsg);
      sortEnumeratedList(CMClass.basicItems(), allKnownFields, allFieldsMsg);
      sortEnumeratedList(CMClass.weapons(), allKnownFields, allFieldsMsg);
      sortEnumeratedList(CMClass.armor(), allKnownFields, allFieldsMsg);
      sortEnumeratedList(CMClass.clanItems(), allKnownFields, allFieldsMsg);
      sortEnumeratedList(CMClass.miscMagic(), allKnownFields, allFieldsMsg);
      sortEnumeratedList(CMClass.tech(), allKnownFields, allFieldsMsg);
      mob.tell(L("Valid field names are @x1", allFieldsMsg.toString()));
      return false;
    }
    String scope = "WORLD";
    if ((commands.size() > 0) && ((String) commands.get(0)).equalsIgnoreCase("room")) {
      if (!CMSecurity.isAllowed(mob, mob.location(), CMSecurity.SecFlag.MERGE)) {
        mob.tell(L("You are not allowed to do that here."));
        return false;
      }
      commands.remove(0);
      placesToDo.add(mob.location());
      scope = "ROOM";
    }
    if ((commands.size() > 0) && ((String) commands.get(0)).equalsIgnoreCase("area")) {
      if (!CMSecurity.isAllowed(mob, mob.location(), CMSecurity.SecFlag.MERGE)) {
        mob.tell(L("You are not allowed to do that here."));
        return false;
      }
      commands.remove(0);
      placesToDo.add(mob.location().getArea());
      scope = "AREA";
    }
    if ((commands.size() > 0) && ((String) commands.get(0)).equalsIgnoreCase("world")) {
      if (!CMSecurity.isAllowedEverywhere(mob, CMSecurity.SecFlag.MERGE)) {
        mob.tell(L("You are not allowed to do that."));
        return false;
      }
      commands.remove(0);
      placesToDo = new Vector();
      scope = "WORLD";
    }
    if (commands.size() == 0) {
      mob.tell(L("Merge what? DATABASE or filename"));
      return false;
    }
    String firstWord = (String) commands.get(0);
    if (firstWord.equalsIgnoreCase("DATABASE")) {
      commands.remove(0);
      if (commands.size() == 0) {
        mob.tell(L("Merge parameters missing: DBCLASS, DBSERVICE, DBUSER, DBPASS"));
        return false;
      }
      firstWord = (String) commands.get(0);
      return doArchonDBCompare(mob, scope, firstWord, commands);
    }
    final String filename = (String) commands.lastElement();
    commands.remove(filename);
    final StringBuffer buf = new CMFile(filename, mob, CMFile.FLAG_LOGERRORS).text();
    if ((buf == null) || (buf.length() == 0)) {
      mob.tell(L("File not found at: '@x1'!", filename));
      return false;
    }

    final List<String> changes = new Vector();
    final List<String> onfields = new Vector();
    final List<String> ignore = new Vector();
    List<String> use = null;
    final List<String> allKnownFields = new Vector();
    final List things = new Vector();
    boolean aremobs = false;
    if ((buf.length() > 20) && (buf.substring(0, 20).indexOf("<MOBS>") >= 0)) {
      if (mob.session() != null)
        mob.session().rawPrint(L("Unpacking mobs from file: '@x1'...", filename));
      final String error =
          CMLib.coffeeMaker().addMOBsFromXML(buf.toString(), things, mob.session());
      if (mob.session() != null) mob.session().rawPrintln("!");
      if (error.length() > 0) {
        mob.tell(L("An error occurred on merge: @x1", error));
        mob.tell(L("Please correct the problem and try the import again."));
        return false;
      }
      aremobs = true;
    } else if ((buf.length() > 20) && (buf.substring(0, 20).indexOf("<ITEMS>") >= 0)) {
      if (mob.session() != null)
        mob.session().rawPrint(L("Unpacking items from file: '@x1'...", filename));
      final String error =
          CMLib.coffeeMaker().addItemsFromXML(buf.toString(), things, mob.session());
      if (mob.session() != null) mob.session().rawPrintln("!");
      if (error.length() > 0) {
        mob.tell(L("An error occurred on merge: @x1", error));
        mob.tell(L("Please correct the problem and try the import again."));
        return false;
      }
    } else {
      mob.tell(
          L(
              "Files of this type are not yet supported by MERGE.  You must merge an ITEMS or MOBS file at this time."));
      return false;
    }
    if (things.size() == 0) {
      mob.tell(L("Nothing was found in the file to merge!"));
      return false;
    }
    final StringBuffer allFieldsMsg = new StringBuffer("");
    if (aremobs) sortEnumeratedList(CMClass.mobTypes(), allKnownFields, allFieldsMsg);
    else {
      sortEnumeratedList(CMClass.basicItems(), allKnownFields, allFieldsMsg);
      sortEnumeratedList(CMClass.weapons(), allKnownFields, allFieldsMsg);
      sortEnumeratedList(CMClass.armor(), allKnownFields, allFieldsMsg);
      sortEnumeratedList(CMClass.clanItems(), allKnownFields, allFieldsMsg);
      sortEnumeratedList(CMClass.miscMagic(), allKnownFields, allFieldsMsg);
      sortEnumeratedList(CMClass.tech(), allKnownFields, allFieldsMsg);
    }

    allKnownFields.add("REJUV");
    allFieldsMsg.append(L("REJUV "));

    for (int i = 0; i < commands.size(); i++) {
      String str = ((String) commands.get(i)).toUpperCase();
      if (str.startsWith("CHANGE=")) {
        use = changes;
        str = str.substring(7).trim();
      }
      if (str.startsWith("ON=")) {
        use = onfields;
        str = str.substring(3).trim();
      }
      if (str.startsWith("IGNORE=")) {
        use = ignore;
        str = str.substring(7).trim();
      }
      int x = str.indexOf(',');
      while (x >= 0) {
        final String s = str.substring(0, x).trim();
        if (s.length() > 0) {
          if (use == null) {
            mob.tell(L("'@x1' is an unknown parameter!", str));
            return false;
          }
          if (allKnownFields.contains(s)) use.add(s);
          else {
            mob.tell(
                L(
                    "'@x1' is an unknown field name.  Valid fields include: @x2",
                    s,
                    allFieldsMsg.toString()));
            return false;
          }
        }
        str = str.substring(x + 1).trim();
        x = str.indexOf(',');
      }
      if (str.length() > 0) {
        if (use == null) {
          mob.tell(L("'@x1' is an unknown parameter!", str));
          return false;
        }
        if (allKnownFields.contains(str)) use.add(str);
        else {
          mob.tell(
              L(
                  "'@x1' is an unknown field name.  Valid fields include: @x2",
                  str,
                  allFieldsMsg.toString()));
          return false;
        }
      }
    }
    if ((onfields.size() == 0) && (ignore.size() == 0) && (changes.size() == 0)) {
      mob.tell(
          L(
              "You must specify either an ON, CHANGES, or IGNORE parameter for valid matches to be made."));
      return false;
    }
    if (placesToDo.size() == 0)
      for (final Enumeration a = CMLib.map().areas(); a.hasMoreElements(); ) {
        final Area A = (Area) a.nextElement();
        if (A.getCompleteMap().hasMoreElements()
            && CMSecurity.isAllowed(
                mob, (A.getCompleteMap().nextElement()), CMSecurity.SecFlag.MERGE))
          placesToDo.add(A);
      }
    if (placesToDo.size() == 0) {
      mob.tell(L("There are no rooms to merge into!"));
      return false;
    }
    for (int i = placesToDo.size() - 1; i >= 0; i--) {
      if (placesToDo.get(i) instanceof Area) {
        final Area A = (Area) placesToDo.get(i);
        placesToDo.removeElement(A);
        for (final Enumeration r = A.getCompleteMap(); r.hasMoreElements(); ) {
          final Room R = (Room) r.nextElement();
          if (CMSecurity.isAllowed(mob, R, CMSecurity.SecFlag.MERGE)) placesToDo.add(R);
        }
      } else if (placesToDo.get(i) instanceof Room)
        if (mob.session() != null) mob.session().rawPrint(".");
        else return false;
    }
    // now do the merge...
    if (mob.session() != null) mob.session().rawPrint(L("Merging and saving..."));
    if (noisy) mergedebugtell(mob, "Rooms to do: " + placesToDo.size());
    if (noisy) mergedebugtell(mob, "Things loaded: " + things.size());
    if (noisy) mergedebugtell(mob, "On fields=" + CMParms.toStringList(onfields));
    if (noisy) mergedebugtell(mob, "Ignore fields=" + CMParms.toStringList(ignore));
    if (noisy) mergedebugtell(mob, "Change fields=" + CMParms.toStringList(changes));
    Log.sysOut("Import", mob.Name() + " merge '" + filename + "'.");
    for (int r = 0; r < placesToDo.size(); r++) {
      Room R = (Room) placesToDo.get(r);
      if (!CMSecurity.isAllowed(mob, R, CMSecurity.SecFlag.MERGE)) continue;
      if (R.roomID().length() == 0) continue;
      synchronized (("SYNC" + R.roomID()).intern()) {
        R = CMLib.map().getRoom(R);
        final Area.State oldFlags = R.getArea().getAreaState();
        R.getArea().setAreaState(Area.State.FROZEN);
        CMLib.map().resetRoom(R);
        boolean savemobs = false;
        boolean saveitems = false;
        if (aremobs) {
          for (int m = 0; m < R.numInhabitants(); m++) {
            final MOB M = R.fetchInhabitant(m);
            if ((M != null) && (M.isSavable()))
              if (tryMerge(mob, R, M, things, changes, onfields, ignore, noisy)) savemobs = true;
          }
        } else {
          for (int i = 0; i < R.numItems(); i++) {
            final Item I = R.getItem(i);
            if ((I != null) && (tryMerge(mob, R, I, things, changes, onfields, ignore, noisy)))
              saveitems = true;
          }
          for (int m = 0; m < R.numInhabitants(); m++) {
            final MOB M = R.fetchInhabitant(m);
            if ((M != null) && (M.isSavable())) {
              for (int i = 0; i < M.numItems(); i++) {
                final Item I = M.getItem(i);
                if ((I != null) && (tryMerge(mob, R, I, things, changes, onfields, ignore, noisy)))
                  savemobs = true;
              }
              final ShopKeeper SK = CMLib.coffeeShops().getShopKeeper(M);
              if (SK != null) {
                for (final Iterator<Environmental> i = SK.getShop().getStoreInventory();
                    i.hasNext(); ) {
                  final Environmental E = i.next();
                  if (E instanceof Item) {
                    final Item I = (Item) E;
                    if (tryMerge(mob, R, I, things, changes, onfields, ignore, noisy))
                      savemobs = true;
                  }
                }
              }
            }
          }
        }
        if (saveitems) CMLib.database().DBUpdateItems(R);
        if (savemobs) CMLib.database().DBUpdateMOBs(R);
        if (mob.session() != null) mob.session().rawPrint(".");
        R.getArea().setAreaState(oldFlags);
      }
    }

    if (mob.session() != null) mob.session().rawPrintln(L("!\n\rDone!"));
    Area A = null;
    for (int i = 0; i < placesToDo.size(); i++) {
      A = ((Room) placesToDo.get(i)).getArea();
      if ((A != null) && (A.getAreaState() != Area.State.ACTIVE)) A.setAreaState(Area.State.ACTIVE);
    }
    return false;
  }
Exemple #11
0
  public boolean execute(MOB mob, Vector commands, int metaFlags) throws java.io.IOException {
    if (mob.session() == null) return true;
    PlayerStats pstats = mob.playerStats();
    if (pstats == null) return true;

    if ((commands != null)
        && (commands.size() > 1)
        && (commands.elementAt(1) instanceof String)
        && (CMProps.getVar(CMProps.SYSTEM_MAILBOX).length() > 0)) {
      String name = CMParms.combine(commands, 1);
      if (name.equalsIgnoreCase("BOX")) {
        String journalName = CMProps.getVar(CMProps.SYSTEM_MAILBOX);
        Vector<JournalsLibrary.JournalEntry> msgs = CMLib.database().DBReadJournalMsgs(journalName);
        while ((mob.session() != null) && (!mob.session().killFlag())) {
          Vector mymsgs = new Vector();
          StringBuffer messages =
              new StringBuffer(
                  "^X" + CMStrings.padCenter(mob.Name() + "'s MailBox", 48) + "^?^.\n\r");
          messages.append(
              "^X### "
                  + CMStrings.padRight("From", 15)
                  + " "
                  + CMStrings.padRight("Date", 20)
                  + " Subject^?^.\n\r");
          for (int num = 0; num < msgs.size(); num++) {
            JournalsLibrary.JournalEntry thismsg = msgs.elementAt(num);
            String to = (String) thismsg.to;
            if (to.equalsIgnoreCase("ALL")
                || to.equalsIgnoreCase(mob.Name())
                || (to.toUpperCase().trim().startsWith("MASK=")
                    && CMLib.masking().maskCheck(to.trim().substring(5), mob, true))) {
              mymsgs.addElement(thismsg);
              messages.append(
                  CMStrings.padRight("" + mymsgs.size(), 4)
                      + CMStrings.padRight((thismsg.from), 16)
                      + CMStrings.padRight(CMLib.time().date2String(thismsg.date), 21)
                      + (thismsg.subj)
                      + "\n\r");
            }
          }
          if ((mymsgs.size() == 0)
              || (CMath.bset(metaFlags, Command.METAFLAG_POSSESSED))
              || (CMath.bset(metaFlags, Command.METAFLAG_AS))) {
            if (CMath.bset(mob.getBitmap(), MOB.ATT_AUTOFORWARD))
              mob.tell(
                  "You have no email waiting, but then, it's probably been forwarded to you already.");
            else mob.tell("You have no email waiting.");
            return false;
          }
          Session S = mob.session();
          try {
            if (S != null) S.snoopSuspension(1);
            mob.tell(messages.toString());
          } finally {
            if (S != null) S.snoopSuspension(-1);
          }
          String s = mob.session().prompt("Enter a message #", "");
          if ((!CMath.isInteger(s)) || (mob.session().killFlag())) return false;
          int num = CMath.s_int(s);
          if ((num <= 0) || (num > mymsgs.size())) mob.tell("That is not a valid number.");
          else
            while ((mob.session() != null) && (!mob.session().killFlag())) {
              JournalsLibrary.JournalEntry thismsg =
                  (JournalsLibrary.JournalEntry) mymsgs.elementAt(num - 1);
              String key = thismsg.key;
              String from = thismsg.from;
              String date = CMLib.time().date2String(thismsg.date);
              String subj = thismsg.subj;
              String message = thismsg.msg;
              messages = new StringBuffer("");
              messages.append("^XMessage :^?^." + num + "\n\r");
              messages.append("^XFrom    :^?^." + from + "\n\r");
              messages.append("^XDate    :^?^." + date + "\n\r");
              messages.append("^XSubject :^?^." + subj + "\n\r");
              messages.append("^X------------------------------------------------^?^.\n\r");
              messages.append(message + "\n\r\n\r");
              try {
                if (S != null) S.snoopSuspension(1);
                mob.tell(messages.toString());
              } finally {
                if (S != null) S.snoopSuspension(-1);
              }
              s =
                  mob.session()
                      .choose("Would you like to D)elete, H)old, or R)eply (D/H/R)? ", "DHR", "H");
              if (s.equalsIgnoreCase("H")) break;
              if (s.equalsIgnoreCase("R")) {
                if ((from.length() > 0)
                    && (!from.equals(mob.Name()))
                    && (!from.equalsIgnoreCase("BOX"))
                    && (CMLib.players().getLoadPlayer(from) != null))
                  execute(mob, CMParms.makeVector(getAccessWords()[0], from), metaFlags);
                else mob.tell("You can not reply to this email.");
              } else if (s.equalsIgnoreCase("D")) {
                CMLib.database().DBDeleteJournal(journalName, key);
                msgs.remove(thismsg);
                mob.tell("Deleted.");
                break;
              }
            }
        }
      } else {
        MOB M = CMLib.players().getLoadPlayer(name);
        if (M == null) {
          mob.tell(
              "There is no player called '"
                  + name
                  + "' to send email to.  If you were trying to read your mail, try EMAIL BOX.  If you were trying to change your email address, just enter EMAIL without any parameters.");
          return false;
        }
        if (!CMath.bset(M.getBitmap(), MOB.ATT_AUTOFORWARD)) {
          if (!mob.session().confirm("Send email to '" + M.Name() + "' (Y/n)?", "Y")) return false;
        } else {
          if (!mob.session()
              .confirm(
                  "Send email to '"
                      + M.Name()
                      + "', even though their AUTOFORWARD is turned off (y/N)?",
                  "N")) return false;
        }
        if (CMProps.getIntVar(CMProps.SYSTEMI_MAXMAILBOX) > 0) {
          int count =
              CMLib.database()
                  .DBCountJournal(CMProps.getVar(CMProps.SYSTEM_MAILBOX), null, M.Name());
          if (count >= CMProps.getIntVar(CMProps.SYSTEMI_MAXMAILBOX)) {
            mob.tell(M.Name() + "'s mailbox is full.");
            return false;
          }
        }
        String subject = mob.session().prompt("Email Subject: ", "").trim();
        if (subject.length() == 0) {
          mob.tell("Aborted");
          return false;
        }
        String message = mob.session().prompt("Enter your message\n\r: ", "").trim();
        if (message.trim().length() == 0) {
          mob.tell("Aborted");
          return false;
        }
        message +=
            "\n\r\n\rThis message was sent through the "
                + CMProps.getVar(CMProps.SYSTEM_MUDNAME)
                + " mail server at "
                + CMProps.getVar(CMProps.SYSTEM_MUDDOMAIN)
                + ", port"
                + CMProps.getVar(CMProps.SYSTEM_MUDPORTS)
                + ".  Please contact the administrators regarding any abuse of this system.\n\r";
        CMLib.database()
            .DBWriteJournal(
                CMProps.getVar(CMProps.SYSTEM_MAILBOX), mob.Name(), M.Name(), subject, message);
        mob.tell("Your email has been sent.");
        return true;
      }
    }
    if ((pstats.getEmail() == null) || (pstats.getEmail().length() == 0))
      mob.session().println("\n\rYou have no email address on file for this character.");
    else {
      if (commands == null) return true;
      String change =
          mob.session()
              .prompt(
                  "You currently have '"
                      + pstats.getEmail()
                      + "' set as the email address for this character.\n\rChange it (y/N)?",
                  "N");
      if (change.toUpperCase().startsWith("N")) return false;
    }
    if ((CMProps.getVar(CMProps.SYSTEM_EMAILREQ).toUpperCase().startsWith("PASS"))
        && (commands != null)
        && (CMProps.getVar(CMProps.SYSTEM_MAILBOX).length() > 0))
      mob.session()
          .println(
              "\n\r** Changing your email address will cause you to be logged off, and a new password to be generated and emailed to the new address. **\n\r");
    String newEmail = mob.session().prompt("New E-mail Address:");
    if (newEmail == null) return false;
    newEmail = newEmail.trim();
    if (!CMProps.getVar(CMProps.SYSTEM_EMAILREQ).toUpperCase().startsWith("OPTION")) {
      if (newEmail.length() < 6) return false;
      if (newEmail.indexOf("@") < 0) return false;
      String confirmEmail =
          mob.session()
              .prompt("Confirm that '" + newEmail + "' is correct by re-entering.\n\rRe-enter:");
      if (confirmEmail == null) return false;
      confirmEmail = confirmEmail.trim();
      if (confirmEmail.length() == 0) return false;
      if (!(newEmail.equalsIgnoreCase(confirmEmail))) return false;
    }
    pstats.setEmail(newEmail);
    CMLib.database().DBUpdateEmail(mob);
    if ((commands != null)
        && (CMProps.getVar(CMProps.SYSTEM_EMAILREQ).toUpperCase().startsWith("PASS"))
        && (CMProps.getVar(CMProps.SYSTEM_MAILBOX).length() > 0)) {
      String password = "";
      for (int i = 0; i < 6; i++) password += (char) ('a' + CMLib.dice().roll(1, 26, -1));
      pstats.setPassword(password);
      CMLib.database().DBUpdatePassword(mob.Name(), password);
      CMLib.database()
          .DBWriteJournal(
              CMProps.getVar(CMProps.SYSTEM_MAILBOX),
              mob.Name(),
              mob.Name(),
              "Password for " + mob.Name(),
              "Your new password for "
                  + mob.Name()
                  + " is: "
                  + pstats.password()
                  + "\n\rYou can login by pointing your mud client at "
                  + CMProps.getVar(CMProps.SYSTEM_MUDDOMAIN)
                  + " port(s):"
                  + CMProps.getVar(CMProps.SYSTEM_MUDPORTS)
                  + ".\n\rYou may use the PASSWORD command to change it once you are online.");
      mob.tell("You will receive an email with your new password shortly.  Goodbye.");
      if (mob.session() != null) {
        try {
          Thread.sleep(1000);
        } catch (Exception e) {
        }
        mob.session().kill(false, false, false);
      }
    }
    return true;
  }
 public static boolean doRentalProperty(Area A, String ID, String owner, int rent) {
   if (!CMProps.getBoolVar(CMProps.Bool.MUDSTARTED)) return false;
   final int month = A.getTimeObj().getMonth();
   final int day = A.getTimeObj().getDayOfMonth();
   final int year = A.getTimeObj().getYear();
   final Object O = Resources.getResource("RENTAL INFO/" + owner);
   List<PlayerData> pDataV = null;
   if (O instanceof List) pDataV = (List<PlayerData>) O;
   else pDataV = CMLib.database().DBReadData(owner, "RENTAL INFO");
   if (pDataV == null) pDataV = new Vector();
   DatabaseEngine.PlayerData pData = null;
   if (pDataV.size() == 0) {
     pData = new DatabaseEngine.PlayerData();
     pData.who = owner;
     pData.section = "RENTAL INFO";
     pData.key = "RENTAL INFO/" + owner;
     pData.xml = ID + "|~>|" + day + " " + month + " " + year + "|~;|";
     CMLib.database().DBCreateData(owner, "RENTAL INFO", "RENTAL INFO/" + owner, pData.xml);
     pDataV.add(pData);
     Resources.submitResource("RENTAL INFO/" + owner, pDataV);
     return false;
   } else if (pDataV.get(0) != null) {
     pData = pDataV.get(0);
     String parse = pData.xml;
     int x = parse.indexOf("|~;|");
     final StringBuffer reparse = new StringBuffer("");
     boolean changesMade = false;
     boolean needsToPay = false;
     while (x >= 0) {
       String thisOne = parse.substring(0, x);
       if (thisOne.startsWith(ID + "|~>|")) {
         thisOne = thisOne.substring((ID + "|~>|").length());
         final Vector dateV = CMParms.parse(thisOne);
         if (dateV.size() == 3) {
           int lastYear = CMath.s_int((String) dateV.lastElement());
           int lastMonth = CMath.s_int((String) dateV.elementAt(1));
           final int lastDay = CMath.s_int((String) dateV.firstElement());
           while (!needsToPay) {
             if (lastYear < year) needsToPay = true;
             else if ((lastYear == year) && (lastMonth < month) && (day >= lastDay))
               needsToPay = true;
             if (needsToPay) {
               if (CMLib.beanCounter()
                   .modifyLocalBankGold(
                       A,
                       owner,
                       CMLib.utensils().getFormattedDate(A)
                           + ":Withdrawal of "
                           + rent
                           + ": Rent for "
                           + ID,
                       CMLib.beanCounter().getCurrency(A),
                       (-rent))) {
                 lastMonth++;
                 if (lastMonth > A.getTimeObj().getMonthsInYear()) {
                   lastMonth = 1;
                   lastYear++;
                 }
                 changesMade = true;
                 needsToPay = false;
               }
             } else break;
           }
           if (changesMade)
             reparse.append(ID + "|~>|" + lastDay + " " + lastMonth + " " + lastYear + "|~;|");
           if (needsToPay && (!changesMade)) return true;
         }
       } else reparse.append(thisOne + "|~;|");
       parse = parse.substring(x + 4);
       x = parse.indexOf("|~;|");
     }
     if (changesMade) {
       CMLib.database()
           .DBReCreateData(owner, "RENTAL INFO", "RENTAL INFO/" + owner, reparse.toString());
       pData = new DatabaseEngine.PlayerData();
       pData.who = owner;
       pData.section = "RENTAL INFO";
       pData.key = "RENTAL INFO/" + owner;
       pData.xml = reparse.toString();
       pDataV.set(0, pData);
       Resources.removeResource("RENTAL INFO/" + owner);
       Resources.submitResource("RENTAL INFO/" + owner, pDataV);
     }
     return needsToPay;
   }
   return false;
 }
  public static int updateLotWithThisData(
      Room R,
      LandTitle T,
      boolean resetRoomName,
      boolean clearAllItems,
      List optPlayerList,
      int lastNumItems) {
    boolean updateItems = false;
    boolean updateExits = false;
    boolean updateRoom = false;
    synchronized (("SYNC" + R.roomID()).intern()) {
      R = CMLib.map().getRoom(R);
      if (T.getOwnerName().length() == 0) {
        Item I = null;
        for (int i = R.numItems() - 1; i >= 0; i--) {
          I = R.getItem(i);
          if ((I == null) || (I.Name().equalsIgnoreCase("id"))) continue;
          CMLib.catalog().updateCatalogIntegrity(I);
          if (clearAllItems) {
            I.destroy();
            updateItems = true;
          } else {
            if (I.expirationDate() == 0) {
              long now = System.currentTimeMillis();
              now += (TimeManager.MILI_MINUTE * CMProps.getIntVar(CMProps.Int.EXPIRE_PLAYER_DROP));
              I.setExpirationDate(now);
            }
            if ((I.phyStats().rejuv() != PhyStats.NO_REJUV) && (I.phyStats().rejuv() != 0)) {
              I.basePhyStats().setRejuv(PhyStats.NO_REJUV);
              I.recoverPhyStats();
            }
          }
        }
        Ability A = null;
        if (clearAllItems)
          for (final Enumeration<Ability> a = R.effects(); a.hasMoreElements(); ) {
            A = a.nextElement();
            if (((A != null)
                && ((A.classificationCode() & Ability.ALL_ACODES) != Ability.ACODE_PROPERTY))) {
              A.unInvoke();
              R.delEffect(A);
              updateRoom = true;
            }
          }
        for (int d = Directions.NUM_DIRECTIONS() - 1; d >= 0; d--) {
          final Room R2 = R.rawDoors()[d];
          Exit E = R.getRawExit(d);
          if ((E != null) && (E.hasALock()) && (E.isGeneric())) {
            E.setKeyName("");
            E.setDoorsNLocks(E.hasADoor(), E.isOpen(), E.defaultsClosed(), false, false, false);
            updateExits = true;
            if (R2 != null) {
              E = R2.getRawExit(Directions.getOpDirectionCode(d));
              if ((E != null) && (E.hasALock()) && (E.isGeneric())) {
                E.setKeyName("");
                E.setDoorsNLocks(E.hasADoor(), E.isOpen(), E.defaultsClosed(), false, false, false);
                CMLib.database().DBUpdateExits(R2);
                R2.getArea().fillInAreaRoom(R2);
              }
            }
          }
        }
        if (updateExits) {
          CMLib.database().DBUpdateExits(R);
          R.getArea().fillInAreaRoom(R);
        }
        if (updateItems) CMLib.database().DBUpdateItems(R);
        if (updateRoom) CMLib.database().DBUpdateRoom(R);
        colorForSale(R, T.rentalProperty(), resetRoomName);
        return -1;
      }

      if ((lastNumItems < 0)
          && (!CMSecurity.isDisabled(CMSecurity.DisFlag.PROPERTYOWNERCHECKS))
          && (optPlayerList != null)) {
        boolean playerExists = (CMLib.players().getPlayer(T.getOwnerName()) != null);
        if (!playerExists) playerExists = (CMLib.clans().getClan(T.getOwnerName()) != null);
        if (!playerExists) playerExists = optPlayerList.contains(T.getOwnerName());
        if (!playerExists)
          for (int i = 0; i < optPlayerList.size(); i++)
            if (((String) optPlayerList.get(i)).equalsIgnoreCase(T.getOwnerName())) {
              playerExists = true;
              break;
            }
        if (!playerExists) {
          T.setOwnerName("");
          T.updateLot(null);
          return -1;
        }
      }

      int x = R.description().indexOf(SALESTR);
      if (x >= 0) {
        R.setDescription(R.description().substring(0, x));
        CMLib.database().DBUpdateRoom(R);
      }
      x = R.description().indexOf(RENTSTR);
      if (x >= 0) {
        R.setDescription(R.description().substring(0, x));
        CMLib.database().DBUpdateRoom(R);
      }

      // this works on the priciple that
      // 1. if an item has ONLY been removed, the lastNumItems will be != current # items
      // 2. if an item has ONLY been added, the dispossessiontime will be != null
      // 3. if an item has been added AND removed, the dispossession time will be != null on the
      // added
      if ((lastNumItems >= 0) && (R.numItems() != lastNumItems)) updateItems = true;

      for (int i = 0; i < R.numItems(); i++) {
        final Item I = R.getItem(i);
        if ((I.expirationDate() != 0)
            && ((I.isSavable()) || (I.Name().equalsIgnoreCase("id")))
            && ((!(I instanceof DeadBody)) || (((DeadBody) I).isPlayerCorpse()))) {
          I.setExpirationDate(0);
          updateItems = true;
        }

        if ((I.phyStats().rejuv() != Integer.MAX_VALUE) && (I.phyStats().rejuv() != 0)) {
          I.basePhyStats().setRejuv(PhyStats.NO_REJUV);
          I.recoverPhyStats();
          updateItems = true;
        }
      }
      lastNumItems = R.numItems();
      if ((!CMSecurity.isSaveFlag(CMSecurity.SaveFlag.NOPROPERTYITEMS)) && (updateItems))
        CMLib.database().DBUpdateItems(R);
    }
    return lastNumItems;
  }