Package org.groovymud.object.alive

Examples of org.groovymud.object.alive.Player


  protected void savePlayers() {
    logger.info("auto saving..");
    Iterator<LoginShell> i = getObjectRegistry().getActivePlayerHandles().iterator();
    while (i.hasNext()) {
      LoginShell o = i.next();
      Player p = o.getPlayer();
      if (getObjectRegistry().getMudObject(p.getName()) != null) {
        getObjectAttendant().savePlayerData(p);
        try {
          o.getPlayer().getTerminalOutput().writeln("\r\nAuto Saving...");
        } catch (IOException e) {
          logger.error(e, e);
View Full Code Here


    Iterator<LoginShell> x = new HashSet<LoginShell>(getObjectRegistry().getActivePlayerHandles()).iterator();
    CountingMap netDead = getNetDeadPlayers();
    while (x.hasNext()) {
      LoginShell shell = x.next();
      if (!shell.getConnection().isActive()) {
        Player p = getObjectRegistry().getPlayerByHandle(shell);
        if (!netDead.containsKey(p)) {
          // not a good way to do it.. but how.. ?
          logger.info(p.getName() + " is net dead..");
          p.addStatus(NET_DEAD_STATUS);
        }
        netDead.increment(p);
      }
    }
  }
View Full Code Here

    return new ActionCallback(username, action);
  }

  protected void confirmDestIfDupeExisted() throws IOException, UnsupportedCallbackException, FailedLoginException {
    Callback[] cb;
    Player dupe = getDupe();
    if (dupe != null) {
      // we need to dest this player if they say yes
      ConfirmationCallback alreadyPlaying = new ConfirmationCallback("You are already playing. Throw the other copy out?", ConfirmationCallback.INFORMATION, ConfirmationCallback.YES_NO_OPTION, ConfirmationCallback.NO);
      cb = createCallbackArray(alreadyPlaying);
      getCallbackHandler().handle(cb);
      if (alreadyPlaying.getSelectedIndex() == ConfirmationCallback.YES) {
        dupe.dest(true);
      } else {
        throw new FailedLoginException("cannot log in, already logged in!");
      }
    }
  }
View Full Code Here

  protected void destAllPlayers() {
    Iterator<LoginShell> x = new HashSet<LoginShell>(getObjectRegistry().getActivePlayerHandles()).iterator();
    while (x.hasNext()) {
      LoginShell shell = x.next();
      if (shell.getConnection().isActive()) {
        Player p = getObjectRegistry().getPlayerByHandle(shell);
        p.dest(false);
      }
    }
  }
View Full Code Here

  public boolean commit() throws LoginException {
    if (!hasSucceeded()) {
      cleanup();
      return false;
    }
    Player player = getPlayer();
    if (player != null) {
      getPlayerPrincipals().addAll(player.getSubject().getPrincipals());
      logger.info("player principals:");
      for (Principal p : getPlayerPrincipals()) {
        logger.info(p.getName());
      }
      getSubject().getPrincipals().addAll(getPlayerPrincipals());
      player.setSubject(getSubject()); // update the players principals
      PlayerCredentials playerCredentials = new PlayerCredentials(getUsername(), String.valueOf(getPassword()));
      getSubject().getPrivateCredentials().add(playerCredentials);
      player.setPlayerCredentials(playerCredentials);
      cleanup();
      setCommitSucceeded(true);

    } else {
      throw new LoginException("player was null");
View Full Code Here

  boolean addActivePlayerCalled;
  boolean addItemCalled;

  public void testAddActivePlayer() {
    MockControl mockctrl = MockClassControl.createControl(InventoryHandler.class);
    final Player p = (Player) playerCtrl.getMock();
    final LoginShell mudShell = new LoginShell();
    Registry reg = new Registry(null) {

      @Override
      public void addActivePlayerHandle(LoginShell shell, Player player) {
View Full Code Here

   * Test method for
   * 'org.groovymud.object.registry.Registry.removeaActivePlayer(MudShell)'
   */
  public void testNotifyContents() {
    final HashSet items = new HashSet();
    Player item = (Player) playerCtrl.getMock();

    items.add(item);

    Registry reg = new Registry(null) {

      @Override
      public HashSet<MudObject> getMudObjects() {
        // TODO Auto-generated method stub
        return items;
      }
    };
    handler = (IObservable) item;
    event = new MessageEvent();
    item.update(item, event);
    playerCtrl.setVoidCallable(1);
    playerCtrl.replay();
    reg.notifyContents((IObservable) item, event);
    playerCtrl.verify();
  }
View Full Code Here

    if (i.hasNext()) {
      logger.info("auto saving..");
    }
    while (i.hasNext()) {
      LoginShell o = i.next();
      Player p = o.getPlayer();
      if (getObjectRegistry().getMudObject(p.getName()) == null) {
        continue;
      }
      getObjectAttendant().savePlayerData(p);
      p = null;
    }
View Full Code Here

    Iterator<LoginShell> x = new HashSet<LoginShell>(getObjectRegistry().getActivePlayerHandles()).iterator();
    CountingMap<Player> netDead = getNetDeadPlayers();
    while (x.hasNext()) {
      LoginShell shell = x.next();
      if (!shell.getConnection().isActive()) {
        Player p = getObjectRegistry().getPlayerByHandle(shell);
        if (!netDead.containsKey(p)) {
          logger.info(p.getName() + " is net dead..");
          p.addStatus(netDeadStatus);
        }
        netDead.increment(p);
        p = null;
      }
    }
View Full Code Here

  protected void destAllPlayers() {
    Iterator<LoginShell> x = new HashSet<LoginShell>(getObjectRegistry().getActivePlayerHandles()).iterator();
    while (x.hasNext()) {
      LoginShell shell = x.next();
      if (shell.getConnection().isActive()) {
        Player p = getObjectRegistry().getPlayerByHandle(shell);
        getObjectRegistry().dest(p, false);
      }
    }
  }
View Full Code Here

TOP

Related Classes of org.groovymud.object.alive.Player

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.