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
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classSessionComponent.Commands -
Field Summary
Fields Modifier and Type Field Description static longCHECK_FREQUENCY -
Constructor Summary
Constructors Constructor Description SessionComponent() -
Method Summary
Modifier and Type Method Description voidaddSession(PersistentSession session, org.bukkit.command.CommandSender user)Addsessionto the sessions list foruser, overwriting any sessions with the same class.voiddisable()voidenable()AdministrativeSessiongetAdminSession(org.bukkit.entity.Player user)Deprecated.seegetSession(Class, org.bukkit.command.CommandSender)with args (AdministrativeSession.class, user)java.util.Map<java.lang.String,AdministrativeSession>getAdminSessions()Deprecated.usegetSessions(Class)with UserSession.class<T extends PersistentSession>
TgetSession(java.lang.Class<T> type, org.bukkit.command.CommandSender user)Gets the session of type for user, creating a new instance if none currently existsUserSessiongetSession(org.bukkit.command.CommandSender user)Deprecated.seegetSession(Class, org.bukkit.command.CommandSender)with args (UserSession.class, user)<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.java.util.Map<java.lang.String,UserSession>getSessions()Deprecated.usegetSessions(Class)with UserSession.class<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 typejava.util.Collection<PersistentSession>getSessions(org.bukkit.command.CommandSender user)Return the sessions which currently exist for the specified uservoidonLogin(org.bukkit.event.player.PlayerLoginEvent event)voidonPlayerQuit(org.bukkit.event.player.PlayerQuitEvent event)Called on player disconnect.<T extends PersistentSession>
voidregisterSessionFactory(java.lang.Class<T> type, SessionFactory<T> factory)voidrun()Methods inherited from class com.zachsthings.libcomponents.bukkit.BukkitComponent
getCommands, onCommand, registerCommands, setUp, unregisterCommands
-
Field Details
-
CHECK_FREQUENCY
public static final long CHECK_FREQUENCY- See Also:
- Constant Field Values
-
-
Constructor Details
-
SessionComponent
public SessionComponent()
-
-
Method Details
-
enable
public void enable()- Specified by:
enablein classcom.zachsthings.libcomponents.AbstractComponent
-
disable
public void disable()- Overrides:
disablein classcom.zachsthings.libcomponents.bukkit.BukkitComponent
-
getSession
Deprecated.seegetSession(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.usegetSessions(Class)with UserSession.classGet sessions.- Returns:
- UserSessions
-
getAdminSession
Deprecated.seegetSession(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.usegetSessions(Class)with UserSession.classGet 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
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 getuser- 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
Return a SessionFactory used to create new instances of a certain type of session. If no SessionFactory has been previously registered withregisterSessionFactory(Class, SessionFactory), a newReflectiveSessionFactorywill 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
Addsessionto the sessions list foruser, overwriting any sessions with the same class.- Parameters:
session- The session to adduser- The user to add the session to
-
run
public void run()- Specified by:
runin interfacejava.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
-