Class StendhalRPRuleProcessor

java.lang.Object
games.stendhal.server.core.engine.StendhalRPRuleProcessor
All Implemented Interfaces:
IRPRuleProcessor

public class StendhalRPRuleProcessor extends Object implements IRPRuleProcessor
adds game rules for Stendhal to the marauroa environment.
Author:
hendrik
  • Field Details

  • Constructor Details

    • StendhalRPRuleProcessor

      protected StendhalRPRuleProcessor()
      creates a new StendhalRPRuleProcessor
  • Method Details

    • get

      public static StendhalRPRuleProcessor get()
      gets the singleton instance of StendhalRPRuleProcessor
      Returns:
      StendhalRPRuleProcessor
    • getOnlinePlayers

      public PlayerList getOnlinePlayers()
      gets a list of online players
      Returns:
      list of online players
    • setContext

      public void setContext(RPServerManager rpman)
      Description copied from interface: IRPRuleProcessor
      Set the context where the actions are executed.
      Specified by:
      setContext in interface IRPRuleProcessor
      Parameters:
      rpman - the RPServerManager object that is running our actions
    • checkGameVersion

      public boolean checkGameVersion(String game, String version)
      Description copied from interface: IRPRuleProcessor
      Returns true if the version of the game is compatible
      Specified by:
      checkGameVersion in interface IRPRuleProcessor
      Parameters:
      game - the game name
      version - the game version
      Returns:
      true if game,version is compatible
    • killRPEntity

      public void killRPEntity(RPEntity entity, Entity killer)
      Kills an RPEntity.
      Parameters:
      entity -
      killer -
    • removePlayerText

      public void removePlayerText(Player player)
    • getPlayer

      public Player getPlayer(String name)
      Finds an online player with a specific name.
      Parameters:
      name - The player's name
      Returns:
      The player, or null if no player with the given name is currently online.
    • onActionAdd

      public boolean onActionAdd(RPObject caster, RPAction action, List<RPAction> actionList)
      Description copied from interface: IRPRuleProcessor
      This method is called *before* adding an action by RPScheduler so you can choose not to allow the action to be added by returning false
      Specified by:
      onActionAdd in interface IRPRuleProcessor
      Parameters:
      caster - the object that casted the action
      action - the action that is going to be added.
      actionList - the actions that this player already owns.
      Returns:
      true if we approve the action to be added.
    • execute

      public void execute(RPObject caster, RPAction action)
      Description copied from interface: IRPRuleProcessor
      Execute an action in the name of a player.
      Specified by:
      execute in interface IRPRuleProcessor
      Parameters:
      caster - the object that executes
      action - the action to execute
    • getTurn

      public int getTurn()
    • beginTurn

      public void beginTurn()
      Notify it when a new turn happens.
      Specified by:
      beginTurn in interface IRPRuleProcessor
    • logNumberOfPlayersOnline

      protected void logNumberOfPlayersOnline()
    • handlePlayersRmTexts

      protected void handlePlayersRmTexts()
    • executeNPCsPreLogic

      protected void executeNPCsPreLogic()
    • executePlayerLogic

      protected void executePlayerLogic()
    • handleKilledEntities

      protected void handleKilledEntities()
    • endTurn

      public void endTurn()
      Description copied from interface: IRPRuleProcessor
      Notify it when a end of actual turn happens.
      Specified by:
      endTurn in interface IRPRuleProcessor
    • onInit

      public boolean onInit(RPObject object)
      Description copied from interface: IRPRuleProcessor
      Callback method called when a new player enters in the game
      Specified by:
      onInit in interface IRPRuleProcessor
      Parameters:
      object - the new player that enters in the game.
      Returns:
      true if object has been added.
    • onExit

      public boolean onExit(RPObject object)
      Description copied from interface: IRPRuleProcessor
      Callback method called when a player exits the game
      Specified by:
      onExit in interface IRPRuleProcessor
      Parameters:
      object - the new player that exits the game.
      Returns:
      true to allow player to exit
    • onTimeout

      public void onTimeout(RPObject object)
      Description copied from interface: IRPRuleProcessor
      Callback method called when a new player time out. This method MUST logout the player
      Specified by:
      onTimeout in interface IRPRuleProcessor
      Parameters:
      object - the new player that timeouts.
    • createAccount

      public AccountResult createAccount(String username, String password, String email)
      Description copied from interface: IRPRuleProcessor
      Creates an account for the game
      Specified by:
      createAccount in interface IRPRuleProcessor
      Parameters:
      username - the username who is going to be added.
      password - the password for our username.
      email - the email of the player for notifications or password reminders.
      Returns:
      the Result of creating the account.
    • createAccountWithToken

      public AccountResult createAccountWithToken(String username, String tokenType, String token)
      Description copied from interface: IRPRuleProcessor
      Create an account for a player in game. Uses token instead of password for cases like 3rd party authentication (e.g. google sign-in).
      Specified by:
      createAccountWithToken in interface IRPRuleProcessor
      Parameters:
      username - username for a new account
      tokenType - token type for useful data about token
      token - auth token to verify, usually obtained from 3rd party
      Returns:
      the Result of creating a new account
    • createCharacter

      public CharacterResult createCharacter(String username, String character, RPObject template)
      Description copied from interface: IRPRuleProcessor
      Creates an new character for an account already logged into the game
      Specified by:
      createCharacter in interface IRPRuleProcessor
      Parameters:
      username - the username who owns the account of the character to be added.
      character - the character to create
      template - the desired values of the avatar representing the character.
      Returns:
      the Result of creating the character.
    • getRPManager

      public RPServerManager getRPManager()
    • tellAllPlayers

      public void tellAllPlayers(NotificationType notificationType, String message)
      Tell this message all players.
      Parameters:
      notificationType - type of notification message, usually NotificationType.PRIVMSG
      message - Message to tell all players
    • sendMessageToSupporters

      public void sendMessageToSupporters(String message)
      Sends a message to all supporters.
      Parameters:
      message - Support message
    • sendMessageToSupporters

      public void sendMessageToSupporters(String source, String message)
      Sends a message to all supporters.
      Parameters:
      source - a player or script name
      message - Support message
    • getAmountOfOnlinePlayers

      public static int getAmountOfOnlinePlayers()
    • notifyOnlineStatus

      public void notifyOnlineStatus(boolean isOnline, Player playerToNotifyAbout)
      Notifies buddies about going online/offline.
      Parameters:
      isOnline - did the player login?
      playerToNotifyAbout - name of the player
    • removeZone

      public void removeZone(StendhalRPZone zone)
      Removes a zone (like a personalized vault).
      Parameters:
      zone - StendhalRPZone to remove
    • setWelcomeMessage

      public static void setWelcomeMessage(String msg)
      Sets the welcome message.
      Parameters:
      msg - welcome message
    • logGameEvent

      public void logGameEvent(GameEvent gameEvent)
      logs a gameEvent
      Parameters:
      gameEvent - a game event
    • logGameEvent

      public void logGameEvent(String source, String event, String... params)
      logs a game event
      Parameters:
      source - source
      event - event
      params - parameters
    • getMimeTypeForResource

      public String getMimeTypeForResource(String resource)
      gets the content type for the requested resource
      Specified by:
      getMimeTypeForResource in interface IRPRuleProcessor
      Parameters:
      resource - name of resource
      Returns:
      mime content/type or null
    • getResource

      public InputStream getResource(String resource)
      gets an input stream to the requested resource
      Specified by:
      getResource in interface IRPRuleProcessor
      Parameters:
      resource - name of resource
      Returns:
      InputStream or null