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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal @Nullable PlayerUseSpecialItemEventgetEvent()Returns the event/session detailsprotected abstract voidForcefully stops and cleans the sessionfinal booleanisActive()Returns true whenstop()hasn't been called yetbooleanGet whether this session shall stop if the player quits the arena.final booleanstop()Safely stops and cleans the session
It's safe to call this even if it hasn't been passed yet toSpecialItemUseHandler.openSession(PlayerUseSpecialItemEvent)final booleantakeItem()Takes a special item from the players inventory
-
Constructor Details
-
SpecialItemUseSession
-
-
Method Details
-
handleStop
protected abstract void handleStop()Forcefully stops and cleans the session -
isStoppedWithPlayerQuit
public boolean isStoppedWithPlayerQuit()Get whether this session shall stop if the player quits the arena.The default implementation always retruns
true. You may override this method and include your own logic.- Returns:
trueto callstop()as a result
-
isActive
public final 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.
nullwhenisActive()returns false
-
stop
public final 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:
falseif it already has been stopped
-
takeItem
public final boolean takeItem()Takes a special item from the players inventory- Returns:
falseif it failed as he doesn't have any special items of that type anymore- Throws:
IllegalStateException- When the session already has been stopped
-