Class SessionComponent

java.lang.Object
com.zachsthings.libcomponents.AbstractComponent
com.zachsthings.libcomponents.bukkit.BukkitComponent
com.sk89q.commandbook.component.session.SessionComponent
All Implemented Interfaces:
java.lang.Runnable, org.bukkit.command.CommandExecutor, org.bukkit.event.Listener

public class SessionComponent
extends com.zachsthings.libcomponents.bukkit.BukkitComponent
implements java.lang.Runnable, org.bukkit.event.Listener
  • Field Details

  • Constructor Details

  • Method Details

    • enable

      public void enable()
      Specified by:
      enable in class com.zachsthings.libcomponents.AbstractComponent
    • disable

      public void disable()
      Overrides:
      disable in class com.zachsthings.libcomponents.bukkit.BukkitComponent
    • getSession

      @Deprecated public UserSession getSession​(org.bukkit.command.CommandSender user)
      Deprecated.
      see getSession(Class, org.bukkit.command.CommandSender) with args (UserSession.class, user)
      Get a session.
      Parameters:
      user - The user to get a session for
      Returns:
      The user's session
    • getSessions

      @Deprecated public java.util.Map<java.lang.String,​UserSession> getSessions()
      Deprecated.
      use getSessions(Class) with UserSession.class
      Get sessions.
      Returns:
      UserSessions
    • getAdminSession

      @Deprecated public AdministrativeSession getAdminSession​(org.bukkit.entity.Player user)
      Deprecated.
      see getSession(Class, org.bukkit.command.CommandSender) with args (AdministrativeSession.class, user)
      Get a session.
      Parameters:
      user - The player to get this session for
      Returns:
      The user's session
    • getAdminSessions

      @Deprecated public java.util.Map<java.lang.String,​AdministrativeSession> getAdminSessions()
      Deprecated.
      use getSessions(Class) with UserSession.class
      Get sessions.
      Returns:
      Administrative sessions which currently exist
    • getSessions

      public <T extends PersistentSession> java.util.Map<java.lang.String,​T> getSessions​(java.lang.Class<T> type)
      Return all the currently registered sessions of the given type
      Type Parameters:
      T - The type parameter for the session
      Parameters:
      type - The type of session to get
      Returns:
      The currently registered session types
    • getSessions

      public java.util.Collection<PersistentSession> getSessions​(org.bukkit.command.CommandSender user)
      Return the sessions which currently exist for the specified user
      Parameters:
      user - The user to get a session for
      Returns:
      The sessions which currently exist for this user
    • getSession

      public <T extends PersistentSession> T getSession​(java.lang.Class<T> type, org.bukkit.command.CommandSender user)
      Gets the session of type for user, creating a new instance if none currently exists
      Type Parameters:
      T - The type of session
      Parameters:
      type - The type of session to get
      user - The user to get the session for
      Returns:
      The player's session, or null if the session could not be correctly created
      See Also:
      getSessionFactory(Class)
    • getSessionFactory

      public <T extends PersistentSession> SessionFactory<T> getSessionFactory​(java.lang.Class<T> type)
      Return a SessionFactory used to create new instances of a certain type of session. If no SessionFactory has been previously registered with registerSessionFactory(Class, SessionFactory), a new ReflectiveSessionFactory will be instantiated. This will only create sessions for PersistentSession subclasses with an empty constructor.
      Type Parameters:
      T - The type of PersistentSession
      Parameters:
      type - The subclass of PersistentSession to get a SessionFactory for
      Returns:
      The required SessionFactory
    • registerSessionFactory

      public <T extends PersistentSession> void registerSessionFactory​(java.lang.Class<T> type, SessionFactory<T> factory)
    • addSession

      public void addSession​(PersistentSession session, org.bukkit.command.CommandSender user)
      Add session to the sessions list for user, overwriting any sessions with the same class.
      Parameters:
      session - The session to add
      user - The user to add the session to
    • run

      public void run()
      Specified by:
      run in interface java.lang.Runnable
    • onLogin

      public void onLogin​(org.bukkit.event.player.PlayerLoginEvent event)
    • onPlayerQuit

      public void onPlayerQuit​(org.bukkit.event.player.PlayerQuitEvent event)
      Called on player disconnect.
      Parameters:
      event - Relevant event details