Package org.groovymud.object

Examples of org.groovymud.object.MudObject


    Iterator x = objects.iterator();
    int count = 0;
    while (x.hasNext()) {
      Object object = x.next();
      if (object instanceof MudObject) {
        MudObject mudObject = (MudObject) object;
        if (messageFor.equals(mudObject)) {
          message = message.replaceFirst("\\%" + count++, "You");
        } else {
          String name = (String) mudObject.getShortNames().toArray()[0];
          message = message.replaceAll("\\%" + count++, (mudObject.isArticleRequired() ? WordUtils.affixIndefiniteArticle(name) : name));
        }
      }
    }
    return message;
  }
View Full Code Here


    int i = 0;
    while (keys.hasNext()) {
      String key = (String) keys.next();
      HashSet set = (HashSet) contentCopy.get(key);
      Iterator x = set.iterator();
      MudObject obj = (MudObject) x.next();
      if (set.size() > 1) {
        key = pluralize(key, set.size()); // there are two of them, we
        // just use the name
        // pluralized
      }
View Full Code Here

  protected void initialise() {
    Observable informer = null;
    if (getInformer() == null) {
      try {
        MudObject obj = getAttendant().load(getShutDownInformer());
        if (obj instanceof Observable) {
          informer = (Observable) obj;
          informer.addObserver(attendant.getObjectRegistry());
          setInformer(informer);
        } else {
View Full Code Here

  public void handleShutdown() {
    if (shutdownHeartBeats++ == getMaxShutdownHeartBeats()) {
      if (informer != null) {
        String message = "";
        if (informer instanceof MudObject) {
          MudObject obj = (MudObject) informer;
          message += WordUtils.affixDefiniteArticle(obj) + " shouts:";
        }
        message += "Mud shutting down NOW!!";
        MessengerUtils.sendMessageToMud(informer, "", message);
      }
View Full Code Here

  public void informMudOfShutdown() {
    String timeLeft = calculateTimeLeft();
    if (informer != null) {
      String message = "";
      if (informer instanceof MudObject) {
        MudObject obj = (MudObject) informer;
        message += WordUtils.affixDefiniteArticle(obj) + " shouts:";
      }
      message += "Mud shutting down in " + timeLeft;
      MessengerUtils.sendMessageToMud(informer, "", message);
    }
View Full Code Here

   * @param ObjectLocation
   *            location - representing where the object can be found in the
   *            spring container
   */
  public MudObject load(ObjectLocation location) {
    MudObject obj = null;
    if (!getApplicationContext().containsBean(location.getBeanId())) {
      logger.info("loading definition" + location.getDefinition());
      loadDefinition(location.getDefinition());
    }
    String beanId = location.getBeanId();
View Full Code Here

    return obj;
  }

  public MudObject findOrLoad(String beanId) {
    MudObject obj;
    if (!getApplicationContext().containsBean(beanId)) {
      // check the registry
      obj = getObjectRegistry().getMudObject(beanId);
      if (logger.isDebugEnabled()) {
        logger.debug("found beanId" + beanId + " in registry:" + obj);
View Full Code Here

  protected void resetRooms() {
    logger.info("Resetting rooms");
    Iterator<MudObject> i = getObjectRegistry().getMudObjects().iterator();
    while (i.hasNext()) {
      MudObject o = i.next();

      if (o instanceof Room) {
        ((Room) o).initialise();
      }
      Thread.yield();
View Full Code Here

  protected void doHeartBeat() {
    Set<MudObject> objects = getObjectRegistry().getMudObjects();
    Iterator<MudObject> i = objects.iterator();
    while (i.hasNext()) {
      MudObject o = i.next();

      if (o instanceof HeartBeatListener) {
        try {
          ((HeartBeatListener) o).heartBeat();
        } catch (Exception e) {
View Full Code Here

      argHolder.parse(nextCommand, player);

      Container container = player.getCurrentContainer();
      boolean commandRun = false;
      MudObject containerMO = (MudObject) container;
      if (containerMO != null) {
        // the object means to do the action with the container, it
        // holds a list of
        // local commands that need to be run.
        commandRun = containerMO.doCommand(player, argHolder.command, argHolder.args);
      }

      if (!commandRun) {
        // run through a privileged action so we don't access stuff we
        // shouldn't
View Full Code Here

TOP

Related Classes of org.groovymud.object.MudObject

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.