Package org.groovymud.shell.telnetd

Examples of org.groovymud.shell.telnetd.ExtendedTerminalIO


  public void writeLookFooter(Alive looker, MudObject object) {
  }

  public void writeDynamicText(Alive looker, MudObject target, String text) {

    ExtendedTerminalIO stream = looker.getTerminalOutput();
    Map binding = new HashMap();
    binding.put("it", target);
    binding.put("looker", looker);
    TemplateEngine engine = new IncludeTemplateEngine();
    try {
      // auto import some utils
      String header = "<%import static org.groovymud.utils.WordUtils.*;\nimport static org.groovymud.utils.NumberToWordConverter.*%>";
      Template template = engine.createTemplate(header + text);

      stream.writeln(colorizeText(template.make(binding).toString(), BOLD));
    } catch (CompilationFailedException e) {
      logger.error(e, e);
    } catch (ClassNotFoundException e) {
      logger.error(e, e);
    } catch (IOException e) {
View Full Code Here


public class RoomView extends ContainerView {

  private transient static final Logger logger = Logger.getLogger(RoomView.class);

  public void writeLookHeader(Alive looker, MudObject target) {
    ExtendedTerminalIO stream = looker.getTerminalOutput();

    try {
      stream.writeln(colorizeText(target.getName().toString(), GREEN));
    } catch (IOException e) {
      logger.error(e, e);
    }
  }
View Full Code Here

    }
  }

  public void writeLookBody(Alive looker, MudObject target) {
    Room container = (Room) target;
    ExtendedTerminalIO stream = looker.getTerminalOutput();

    try {
      writeDynamicText(looker, target, target.getDescription());

      if (container.getInventoryHandler().getMudObjectsMap(false).size() > 0) {
        stream.write("You see: ");
        super.writeLookBody(looker, target);
        stream.writeln(".");
      }
      Map<String, Set<MudObject>> alive = container.getInventoryHandler().getMudObjectsMap(true);
      ContentsHelper contentsHelper = createContentsHelper();
      String aliveContents = contentsHelper.getContentsDescription(alive, looker, true);

      int aliveSize = container.getInventoryHandler().size(true) - 1;
      if (aliveSize > 0) {
        stream.write(colorizeText(aliveContents, GREEN));
      }
      if (aliveSize > 0) {
        stream.writeln(aliveSize > 1 ? " are here." : " is here.");
      }
    } catch (IOException e) {
      logger.error(e, e);
    }
  }
View Full Code Here

  }

  public void writeLookFooter(Alive looker, MudObject target) {
    Room room = (Room) target;
    Set exits = room.getExitInventory().getMudObjects();
    ExtendedTerminalIO stream = looker.getTerminalOutput();
    try {
      stream.write(colorizeText("There " + (exits.size() == 1 && exits.size() != 0 ? "is" : "are") + " " + pluralize("exit", exits.size()) + ": ", CYAN));
      Iterator iter = exits.iterator();
      int i = 0;
      while (iter.hasNext()) {
        Exit exit = (Exit) iter.next();
        stream.write(colorizeText(exit.getDirection() + (i < exits.size() - 1 ? ", " : "\r\n"), WHITE));
        i++;
      }
    } catch (IOException e) {
      logger.error(e, e);
    }
View Full Code Here

    while (all.hasNext()) {
      Set<MudObject> nextSet = all.next();
      Iterator<MudObject> setIterator = nextSet.iterator();
      while (setIterator.hasNext()) {
        Alive obj = (Alive) setIterator.next();
        ExtendedTerminalIO term = obj.getTerminalOutput();
        if (term == null) {
          continue;
        }
        if (mEvent.getSource() == obj) {
          try {
            term.writeln(mEvent.getSourceMessage());
          } catch (IOException e) {
            logger.error(e, e);
          }
        } else {
          try {
            if (mEvent.getScopeMessage() != null) {
              term.writeln(mEvent.getScopeMessage());
            }
            if (mEvent.getTargets().contains(obj)) {
              term.writeln(mEvent.getTargetMessage());
            }
          } catch (IOException e) {
            logger.error(e, e);
          }
        }
View Full Code Here

    while (all.hasNext()) {
      Set<MudObject> nextSet = all.next();
      Iterator<MudObject> setIterator = nextSet.iterator();
      while (setIterator.hasNext()) {
        Alive obj = (Alive) setIterator.next();
        ExtendedTerminalIO term = obj.getTerminalOutput();
        if (term == null) {
          continue;
        }
        if (mEvent.getSource() == obj) {
          try {
            term.writeln(mEvent.getSourceMessage());
          } catch (IOException e) {
            logger.error(e, e);
          }
        } else {
          try {
            if (mEvent.getScopeMessage() != null) {
              term.writeln(mEvent.getScopeMessage());
            }
            if (mEvent.getTargets().contains(obj)) {
              term.writeln(mEvent.getTargetMessage());
            }
          } catch (IOException e) {
            logger.error(e, e);
          }
        }
View Full Code Here

  public void writeLookFooter(Alive looker, MudObject object) {
  }

  public void writeDynamicText(Alive looker, MudObject target, String text) {

    ExtendedTerminalIO stream = looker.getTerminalOutput();
    Map binding = new HashMap();
    binding.put("it", target);
    binding.put("looker", looker);
    TemplateEngine engine = new IncludeTemplateEngine();
    try {
      //auto import some utils
      String header = "<%import static org.groovymud.utils.WordUtils.*;\nimport static org.groovymud.utils.NumberToWordConverter.*%>";
      Template template = engine.createTemplate(header + text);

      stream.writeln(colorizeText(template.make(binding).toString(), BOLD));
    } catch (CompilationFailedException e) {
      logger.error(e, e);
    } catch (ClassNotFoundException e) {
      logger.error(e, e);
    } catch (IOException e) {
View Full Code Here

TOP

Related Classes of org.groovymud.shell.telnetd.ExtendedTerminalIO

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.