Class UserContext

java.lang.Object
games.stendhal.client.UserContext
All Implemented Interfaces:
RPObjectChangeListener

public class UserContext extends Object implements RPObjectChangeListener
The player user context. This class holds/manages the data for the user of this client. This is independent of any on-screen representation Entity that, while related, serves an entirely different purpose. Currently this is just a helper class for StendhalClient. Maybe it will be directly used by other code later.
  • Method Details

    • get

      public static UserContext get()
    • addFeatureChangeListener

      public void addFeatureChangeListener(FeatureChangeListener l)
      Add a feature change listener.
      Parameters:
      l - The listener.
    • getAdminLevel

      public int getAdminLevel()
      Get the admin level.
      Returns:
      The admin level.
    • getName

      public String getName()
      Get the player character name.
      Returns:
      The player character name.
    • getSheepID

      public int getSheepID()
      Get the player's owned sheep RPObject ID.
      Returns:
      The RPObject ID of the sheep the player owns, or 0 if none.
    • isAdmin

      public boolean isAdmin()
      Determine if the user is an admin.
      Returns:
      true is the user is an admin.
    • getPlayer

      public RPObject getPlayer()
    • setPlayer

      protected void setPlayer(RPObject object)
    • onAdded

      public void onAdded(RPObject object)
      An object was added.
      Specified by:
      onAdded in interface RPObjectChangeListener
      Parameters:
      object - The object.
    • onChangedAdded

      public void onChangedAdded(RPObject object, RPObject changes)
      The object added/changed attribute(s).
      Specified by:
      onChangedAdded in interface RPObjectChangeListener
      Parameters:
      object - The base object.
      changes - The changes.
    • onChangedRemoved

      public void onChangedRemoved(RPObject object, RPObject changes)
      An object removed attribute(s).
      Specified by:
      onChangedRemoved in interface RPObjectChangeListener
      Parameters:
      object - The base object.
      changes - The changes.
    • onRemoved

      public void onRemoved(RPObject object)
      An object was removed.
      Specified by:
      onRemoved in interface RPObjectChangeListener
      Parameters:
      object - The object.
    • onSlotAdded

      public void onSlotAdded(RPObject object, String slotName, RPObject sobject)
      A slot object was added.
      Specified by:
      onSlotAdded in interface RPObjectChangeListener
      Parameters:
      object - The container object.
      slotName - The slot name.
      sobject - The slot object.
    • onSlotChangedAdded

      public void onSlotChangedAdded(RPObject object, String slotName, RPObject sobject, RPObject schanges)
      A slot object added/changed attribute(s).
      Specified by:
      onSlotChangedAdded in interface RPObjectChangeListener
      Parameters:
      object - The base container object.
      slotName - The container's slot name.
      sobject - The slot object.
      schanges - The slot object changes.
    • onSlotChangedRemoved

      public void onSlotChangedRemoved(RPObject object, String slotName, RPObject sobject, RPObject schanges)
      A slot object removed attribute(s).
      Specified by:
      onSlotChangedRemoved in interface RPObjectChangeListener
      Parameters:
      object - The base container object.
      slotName - The container's slot name.
      sobject - The slot object.
      schanges - The slot object changes.
    • onSlotRemoved

      public void onSlotRemoved(RPObject object, String slotName, RPObject sobject)
      A slot object was removed.
      Specified by:
      onSlotRemoved in interface RPObjectChangeListener
      Parameters:
      object - The container object.
      slotName - The slot name.
      sobject - The slot object.
    • setName

      public void setName(String username)
    • hasFeature

      public boolean hasFeature(String name)
      Checks if the player has a feature.