Package games.stendhal.server.core.events

Source Code of games.stendhal.server.core.events.GuaranteedDelayedPlayerTextSender

/**
*
*/
package games.stendhal.server.core.events;

import games.stendhal.server.core.engine.SingletonRepository;
import games.stendhal.server.core.engine.dbcommand.StoreMessageCommand;
import games.stendhal.server.entity.player.Player;

import marauroa.server.db.command.DBCommandQueue;

/**
* Sends a private message to a player after a short delay, and if they weren't online, uses postman
*
* @author kymara
*
*/
public class GuaranteedDelayedPlayerTextSender extends DelayedPlayerTextSender {
  private final String source;
 
  /**
   * Creates a new GuaranteedDelayedPlayerTextSender.
   * @param source
   * @param player
   * @param message
   * @param seconds
   */
  public GuaranteedDelayedPlayerTextSender(final String source, final Player player, final String message,
      int seconds) {
    super(player, message, seconds);
    this.source = source;
  }
 
  public void onTurnReached(final int currentTurn) {
    final String playername = player.getName();
    final Player playerNow = SingletonRepository.getRuleProcessor().getPlayer(playername);
    if (playerNow != null) {
      playerNow.sendPrivateText(source + " tells you:\n" + message);
    } else {
      DBCommandQueue.get().enqueue(new StoreMessageCommand(source, playername, message, "N"));
    }
  }
}
TOP

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

TOP
Copyright © 2018 www.massapi.com. 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.