Package games.stendhal.server.core.events

Examples of games.stendhal.server.core.events.TurnNotifier


    // check first could player use the door
    final boolean couldUse = super.onUsed(user);

    if (couldUse) {
      // open door, or stop door from closing
      final TurnNotifier turnNotifier = SingletonRepository.getTurnNotifier();
      if (isOpen()) {
        // The door is still open because another player just used it.
        // Thus, it is scheduled to auto-close soon. We delay this
        // auto-closing.
        turnNotifier.dontNotify(this);
      } else {
        open();
      }

      // register automatic close
      turnNotifier.notifyInSeconds(SECONDS_TO_STAY_OPEN, this);
    } else {
      // player may not use it
      if (isOpen()) {
        // close now to make visible that the entity is not allowed
        // to pass
View Full Code Here


  @Test
  public final void testRejected() {
    final AccessCheckingPortal port = new MockAccessCheckingPortal();
    final Player player = PlayerTestHelper.createPlayer("mayNot");
    port.rejected(player);
    TurnNotifier turnNotifier = SingletonRepository.getTurnNotifier();
    final Set<TurnListener> bla = turnNotifier.getEventListForDebugging().get(
        Integer.valueOf(turnNotifier.getCurrentTurnForDebugging() + 1));
    final TurnListener[] listenerset = new TurnListener[bla.size()];
    bla.toArray(listenerset);
    assertTrue(listenerset[0] instanceof AccessCheckingPortal.SendMessage);
    final SendMessage sm = (SendMessage) listenerset[0];
    sm.onTurnReached(0);
View Full Code Here

  @Override
  public void execute(final Player admin, final List<String> args) {
    int outdated = 0;
    final ObjectCounter<Class< ? >> counter = new ObjectCounter<Class< ? >>();

    final TurnNotifier turnNotifier = SingletonRepository.getTurnNotifier();
    final int currentTurn = turnNotifier.getCurrentTurnForDebugging();
    final Map<Integer, Set<TurnListener>> events = turnNotifier.getEventListForDebugging();

    for (final Map.Entry<Integer, Set<TurnListener>> it : events.entrySet()) {
      final Integer turn = it.getKey();

      // count outdated
View Full Code Here

      }

      if (user.nextTo((Entity) base)) {
        if (useItem(userplayer)) {
          /* set the timer for the duration */
          final TurnNotifier notifier = SingletonRepository.getTurnNotifier();
          notifier.notifyInTurns(getAmount(), this);
          player = new WeakReference<Player>(userplayer);
          this.removeOne();
          user.notifyWorldAboutChanges();
        }
        result = true;
View Full Code Here

   * Set the door open or closed.
   *
   * @param open true if the door is opened, false otherwise
   */
  private void setOpen(final boolean open) {
    final TurnNotifier turnNotifier = SingletonRepository.getTurnNotifier();
   
    if (open) {
      setResistance(0);
      if (autoCloseDelay != 0) {
        turnNotifier.notifyInSeconds(autoCloseDelay, this);
      }
    } else {
      // Closing the gate - check there's nobody on the way
      if (getZone() != null)  {
        for (Entity entity : getZone().getEntitiesAt(getX(), getY())) {
          if (entity.getResistance() > 0) {
            return;
          }
        }
      }
      setResistance(100);
      // Stop the notifier, so that the door does not slam in front
      // of someone who just opened it
      turnNotifier.dontNotify(this);
    }
    isOpen = open;
    notifyWorldAboutChanges();
  }
View Full Code Here

    /*
     * If something was on the way, the closing failed.
     * Try again after the usual delay.
     */
    if (isOpen) {
      final TurnNotifier turnNotifier = SingletonRepository.getTurnNotifier();
      turnNotifier.notifyInSeconds(autoCloseDelay, this);
    }
  }
View Full Code Here

  public boolean feed(final ConsumableItem item, final Player player) {
    player.setImmune();
   
    // set a timer to remove the immunity effect after some time
    final TurnNotifier notifier = SingletonRepository.getTurnNotifier();
    // first remove all effects from previously used immunities to
    // restart the timer
   
    final TurnListener tl = new AntidoteEater(player);
    notifier.dontNotify(tl);
    notifier.notifyInTurns(item.getAmount(), tl);
    item.removeOne();
   
    return true;
   
  }
View Full Code Here

TOP

Related Classes of games.stendhal.server.core.events.TurnNotifier

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.