Class SpecialItemUseSession
java.lang.Object
de.marcely.bedwars.api.game.specialitem.SpecialItemUseSession
Represents a session of a special item use
A new session is created every time someone uses a special item.
Make sure to call
Also make sure to invoke
A new session is created every time someone uses a special item.
Make sure to call
stop()
, even when you're handler, after you're done as
the plugin will invoke handleStop()
for EVERY still active session after the round ended.Also make sure to invoke
takeItem()
if you wish the item to be taken away-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescription@Nullable PlayerUseSpecialItemEvent
getEvent()
Returns the event/session detailsprotected abstract void
Forcefully stops and cleans the sessionboolean
isActive()
Returns true whenstop()
hasn't been called yetboolean
stop()
Safely stops and cleans the session
It's safe to call this even if it hasn't been passed yet toSpecialItemUseHandler.openSession(PlayerUseSpecialItemEvent)
boolean
takeItem()
Takes a special item from the players inventory
-
Constructor Details
-
SpecialItemUseSession
-
-
Method Details
-
handleStop
protected abstract void handleStop()Forcefully stops and cleans the session -
isActive
public boolean isActive()Returns true whenstop()
hasn't been called yet- Returns:
- Whether or not the session is still active
-
getEvent
Returns the event/session details- Returns:
- The event included in this session.
null
whenisActive()
returns false
-
stop
public boolean stop()Safely stops and cleans the session
It's safe to call this even if it hasn't been passed yet toSpecialItemUseHandler.openSession(PlayerUseSpecialItemEvent)
- Returns:
false
if it already has been stopped
-
takeItem
public boolean takeItem()Takes a special item from the players inventory- Returns:
false
if it failed as he doesn't have any special items of that type anymore- Throws:
IllegalStateException
- When the session already has been stopped
-