All Implemented Interfaces:
TurnListener, UseListener, Killer, Cloneable, Iterable<String>, Serializable
Direct Known Subclasses:
LockedDoor, OnePlayerRoomDoor

public abstract class Door extends Portal implements TurnListener
A door is a special kind of portal which can be open or closed. Note that you can link a door with a portal; that way, people only require the key when walking in one direction and can walk in the other direction without any key.
  • Field Details

    • instantAction

      protected boolean instantAction
      Immediate execution of action when player says password.
    • listeningRadius

      protected int listeningRadius
      Radius at which portal will "listen" for speaking players.
    • passwordAcceptedMessage

      protected String passwordAcceptedMessage
      Optional message to give when correct password used.
    • passwordRejectedMessage

      protected String passwordRejectedMessage
      Optional message to give when incorrect password used.
    • portalID

      protected int portalID
      ID for the portal
    • portalIDCounter

      protected static int portalIDCounter
    • rejectedMessage

      protected String rejectedMessage
      The message to give when rejected.
    • requiredPassword

      protected String requiredPassword
      Optional password to use portal.
    • rejectedAction

      protected ChatAction rejectedAction
      Optional action to take when access is rejected.
    • forceStop

      protected boolean forceStop
      Override continuous movement setting.
  • Constructor Details

    • Door

      public Door(String clazz)
      Creates a new door.
      Parameters:
      clazz - The class. Responsible for how this door looks like.
    • Door

      public Door(String clazz, String rejectMessage)
      Creates a new door.
      Parameters:
      clazz - The class. Responsible for how this door looks like.
      rejectMessage - The message to given when rejected.
  • Method Details

    • generateRPClass

      public static void generateRPClass()
    • update

      public void update()
      Overrides:
      update in class Entity
    • open

      public void open()
      Opens the door.
    • close

      protected void close()
      Closes the door.
    • isOpen

      protected boolean isOpen()
      Is the door open?
      Returns:
      true, if opened; false otherwise
    • onUsed

      public boolean onUsed(RPEntity user)
      Teleport (if the door is now open).
      Specified by:
      onUsed in interface UseListener
      Parameters:
      user - that wants to pass.
      Returns:
      true if passed , false otherwise.
    • onUsedBackwards

      public void onUsedBackwards(RPEntity user, boolean hadPath)
      Description copied from class: Portal
      If this portal is the destination of another portal used.
      Overrides:
      onUsedBackwards in class Portal
      Parameters:
      user - the player who used the other portal teleporting to us
      hadPath - determines if entity was using mouse click to use portal
    • describe

      public String describe()
      Description copied from class: Entity
      Describes the entity (if a players looks at it).
      Overrides:
      describe in class Entity
      Returns:
      description from the players point of view
    • onTurnReached

      public void onTurnReached(int currentTurn)
      Description copied from interface: TurnListener
      This method is called when the turn number is reached.
      Specified by:
      onTurnReached in interface TurnListener
      Parameters:
      currentTurn - current turn number
    • getPasswordAcceptedMessage

      public String getPasswordAcceptedMessage()
      Returns:
      Message when password is accepted.
    • getPasswordRejectedMessage

      public String getPasswordRejectedMessage()
      Returns:
      Messager when password is rejected.
    • getListeningRadius

      public int getListeningRadius()
      Returns:
      Radius at which portal detects player speech.
    • getRejectedMessage

      public String getRejectedMessage()
      Gets the message to send when player is denied access to portal.
      Returns:
      Rejected message
    • getRequiredPassword

      public String getRequiredPassword()
      Gets the password required to use the portal.
      Returns:
      Required password
    • hasInstanceAction

      public boolean hasInstanceAction()
      Checks if the portal executes an action immediately after password is said.
      Returns:
      instantAction
    • isAllowed

      protected abstract boolean isAllowed(RPEntity user)
      Determine if this portal can be used.
      Parameters:
      user - The user to be checked.
      Returns:
      true if the user can use the portal.
    • playerIsPortalUnlocked

      public boolean playerIsPortalUnlocked(Player player, Portal portal)
    • logic

      public void logic()
      Overrides:
      logic in class Portal
    • rejected

      protected void rejected(RPEntity user)
      Called when the user is rejected. This sends a rejection message to the user if set.
      Parameters:
      user - The rejected user.
    • sendMessage

      protected void sendMessage(RPEntity user, String text)
      Wrapper to send a message to a user, without getting lost.
      Parameters:
      user - The user to send to.
      text - The message to send.
    • setInstantAction

      public void setInstantAction(boolean instant)
      Parameters:
      instant - Use portal automatically.
    • setPasswordAcceptedMessage

      public void setPasswordAcceptedMessage(String message)
      Set the password accepted message.
      Parameters:
      message - Optional message to be given when correct password used.
    • setPasswordRejectedMessage

      public void setPasswordRejectedMessage(String message)
      Set the password rejected message.
      Parameters:
      message - Optional message to be given when incorrect password used.
    • setListeningRadius

      public void setListeningRadius(int radius)
      Sets the radius at which the portal will "hear" speaking players.
      Parameters:
      radius - Distance at wich portal listens for players speaking.
    • setRejectedMessage

      public void setRejectedMessage(String message)
      Set the rejection message.
      Parameters:
      message - The message to give when rejected.
    • setRequiredPassword

      public void setRequiredPassword(String password)
      Parameters:
      password -
    • setRejectedAction

      public void setRejectedAction(ChatAction rejectedAction)
      Initiates an action to take on rejection.
      Parameters:
      rejectedAction - ChatAction to execute.
    • setForceStop

      public void setForceStop(boolean forceStop)
      Sets flag to override continuous movement & force entity to stop.
      Parameters:
      forceStop - If true, entity is forced to stop movement.