All Implemented Interfaces:
UseListener, Killer, Cloneable, Iterable<String>, Serializable
Direct Known Subclasses:
ConditionAndActionPortal, Door, HousePortal, KeyedPortal, LevelCheckingPortal, OneWayPortalDestination, PasswordPortal, QuestCheckingPortal, QuestCompletedPortal, Teleporter

public class Portal extends Entity implements UseListener
A portal which teleports the player to another portal if used.
  • Field Details

  • Constructor Details

    • Portal

      public Portal()
      Creates a new portal.
    • Portal

      public Portal(RPObject object)
  • Method Details

    • generateRPClass

      public static void generateRPClass()
    • setIdentifier

      public void setIdentifier(Object reference)
      Set the portal reference to identify this specific portal with-in a zone. This value is opaque and requires a working equals(), but typically uses a String or Integer.
      Parameters:
      reference - A reference tag.
    • setIgnoreNoDestination

      public void setIgnoreNoDestination(boolean ignoreNoDestination)
      Sets flag to suppress error about missing destination.
    • getIdentifier

      public Object getIdentifier()
      gets the identifier of this portal.
      Returns:
      identifier
    • setDestination

      public void setDestination(String zone, Object reference)
      Set the destination portal zone and reference. The reference should match the same type/value as that passed to setReference() in the corresponding portal.
      Parameters:
      zone - The target zone.
      reference - A reference tag.
    • getDestinationReference

      public Object getDestinationReference()
    • getDestinationZone

      public String getDestinationZone()
    • isHidden

      public boolean isHidden()
      Determine if this portal is hidden from players.
      Overrides:
      isHidden in class RPObject
      Returns:
      true if hidden.
    • setHidden

      public void setHidden(boolean hide)
      Sets or removes the "hidden" attribute.
      Parameters:
      hide - If true, adds "hidden" attribute, otherwise removes it.
    • loaded

      public boolean loaded()
    • logic

      public void logic()
    • toString

      public String toString()
      Description copied from class: RPObject
      This method returns a String that represent the object
      Overrides:
      toString in class RPObject
      Returns:
      a string representing the object.
    • usePortal

      protected boolean usePortal(Player player)
      Use the portal.
      Parameters:
      player - the Player who wants to use this portal
      Returns:
      true if the portal worked, false otherwise.
    • onUsed

      public boolean onUsed(RPEntity user)
      Description copied from interface: UseListener
      Invoked when the object is used.
      Specified by:
      onUsed in interface UseListener
      Parameters:
      user - the RPEntity who uses the object
      Returns:
      true if successful
    • onUsedBackwards

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

      public void onPushedOntoFrom(RPEntity pushed, RPEntity pusher, Point prevPos)
      Sub-classes can override for actions to be taken if entity was pushed onto portal.
    • setFaceDirection

      public final void setFaceDirection(Direction dir)
      Sets the direction attribute for the portal which determines the direction the player should face when this portal is used as a destination.
      Parameters:
      dir - Direction player should face.
    • setFaceDirection

      public final void setFaceDirection(String dir)
      Setup direction player should face after using portal as a destination. dir can be one of "north", "east", "south", "west", "up", "right", "down", or "left".
      Parameters:
      dir - String representation of direction to face.
    • getFaceDirection

      public final Direction getFaceDirection()
      Get the direction player should face when portal is used as a destination.
      Returns:
      Direction player should face.
    • hasFaceDirection

      public final boolean hasFaceDirection()
      Check if the portal has defined a direction for player to face when portal is used as a destination.
      Returns:
      true if portal's direction attribute is set.
    • getOffset

      public final int getOffset()
      Gets offset positioning value when used as a destination. Valid values are 0-7.
      Returns:
      Integer value of offset.
    • hasOffset

      public final boolean hasOffset()
      Checks if portal has an offset positioning when used as a destination.
      Returns:
      true if "offset" attribute set.