public interface NucleusAFKService
Modifier and Type | Method and Description |
---|---|
boolean |
canBeKicked(org.spongepowered.api.entity.living.player.User user)
Returns whether a
User can be kicked for inactivity. |
boolean |
canGoAFK(org.spongepowered.api.entity.living.player.User user)
Returns whether the
User in question can go AFK. |
default AutoCloseable |
disableTrackingFor(org.spongepowered.api.entity.living.player.Player player)
Deprecated.
Use
disableTrackingForPlayer(Player, int) instead. |
default AutoCloseable |
disableTrackingFor(org.spongepowered.api.entity.living.player.Player player,
int ticks)
Deprecated.
Use
disableTrackingForPlayer(Player, int) instead. |
default NoExceptionAutoClosable |
disableTrackingForPlayer(org.spongepowered.api.entity.living.player.Player player)
Disables activity tracking for the specified
Player for the next tick. |
NoExceptionAutoClosable |
disableTrackingForPlayer(org.spongepowered.api.entity.living.player.Player player,
int ticks)
Disables activity tracking for the specified
Player for up to the number of ticks specified. |
Collection<org.spongepowered.api.entity.living.player.Player> |
getAfk()
Returns a collection of players who are currently AFK.
|
void |
invalidateCachedPermissions()
Invalidates cached permissions, used to resync a player's exemption status.
|
boolean |
isAFK(org.spongepowered.api.entity.living.player.Player player)
Returns whether a player is AFK
|
Instant |
lastActivity(org.spongepowered.api.entity.living.player.Player player)
Returns the last recorded active moment of the player.
|
boolean |
setAFK(org.spongepowered.api.event.cause.Cause cause,
org.spongepowered.api.entity.living.player.Player player,
boolean isAfk)
Sets a player's AFK status, if the player can go AFK.
|
Optional<Duration> |
timeForInactivity(org.spongepowered.api.entity.living.player.User user)
Returns how long the specified
User has to be inactive before going AFK. |
Optional<Duration> |
timeForKick(org.spongepowered.api.entity.living.player.User user)
Returns how long the specified
User has to be inactive before being kicked. |
default Duration |
timeSinceLastActivity(org.spongepowered.api.entity.living.player.Player player)
Returns the
Duration since last recorded active moment of the player. |
void |
updateActivityForUser(org.spongepowered.api.entity.living.player.Player player)
Forces an activity tracking update for a
Player , such that Nucleus
thinks that the player has recently been active and resets their AFK timer. |
boolean canGoAFK(org.spongepowered.api.entity.living.player.User user)
User
in question can go AFK.user
- The User
in questionCollection<org.spongepowered.api.entity.living.player.Player> getAfk()
Collection
of Player
sboolean isAFK(org.spongepowered.api.entity.living.player.Player player)
player
- The player in question.boolean setAFK(org.spongepowered.api.event.cause.Cause cause, org.spongepowered.api.entity.living.player.Player player, boolean isAfk)
cause
- The cause for going AFK. The root cause must be a PluginContainer
.player
- The player to set the status of.isAfk
- Whether the player should go AFK.true
if successful, otherwise false
, usually because the player is exempt from going AFK.boolean canBeKicked(org.spongepowered.api.entity.living.player.User user)
User
can be kicked for inactivity.user
- The User
in question.Instant lastActivity(org.spongepowered.api.entity.living.player.Player player)
player
- The player in questionInstant
default Duration timeSinceLastActivity(org.spongepowered.api.entity.living.player.Player player)
Duration
since last recorded active moment of the player.player
- The player in questionInstant
Optional<Duration> timeForInactivity(org.spongepowered.api.entity.living.player.User user)
User
has to be inactive before going AFK.user
- The User
in question.Duration
, or Optional.empty()
if the player cannot go AFK.Optional<Duration> timeForKick(org.spongepowered.api.entity.living.player.User user)
User
has to be inactive before being kicked.user
- The User
in question.Duration
, or Optional.empty()
if the player cannot go AFK.void invalidateCachedPermissions()
void updateActivityForUser(org.spongepowered.api.entity.living.player.Player player)
Player
, such that Nucleus
thinks that the player has recently been active and resets their AFK timer.player
- The player to update the activity of.@Deprecated default AutoCloseable disableTrackingFor(org.spongepowered.api.entity.living.player.Player player)
disableTrackingForPlayer(Player, int)
instead.Player
for the next tick. See disableTrackingFor(Player, int)
for more
information on how to use this method.player
- Player to disable tracking for.AutoCloseable
that will re-enable the tracking when done.disableTrackingFor(Player, int)
default NoExceptionAutoClosable disableTrackingForPlayer(org.spongepowered.api.entity.living.player.Player player)
Player
for the next tick. See disableTrackingFor(Player, int)
for more
information on how to use this method.player
- Player to disable tracking for.AutoCloseable
that will re-enable the tracking when done.disableTrackingFor(Player, int)
@Deprecated default AutoCloseable disableTrackingFor(org.spongepowered.api.entity.living.player.Player player, int ticks)
disableTrackingForPlayer(Player, int)
instead.Player
for up to the number of ticks specified.
This method returns an AutoCloseable
, and as such, the recommended way of using this method is using "try with resources":
try (AutoClosable dummy = disableTrackingFor(player, 1)){ // perform actions here, most likely something like: player.setLocation(location); // Any actions here will not disable the AFK timer. } // any actions here that move the player will be tracked again.
This pattern isn't strictly required, as the AutoCloseable
will close itself after the specified number of ticks. However, it's
prudent to consider the following:
disableTrackingFor(Player)
for a sane
default.
If you do not use "try with resources", call the close
method upon completion to reactivate tracking.
player
- The Player
to disable tracking for.ticks
- The number of ticks to disable tracking for.AutoCloseable
that will re-enable the tracking when done.NoExceptionAutoClosable disableTrackingForPlayer(org.spongepowered.api.entity.living.player.Player player, int ticks)
Player
for up to the number of ticks specified.
This method returns an AutoCloseable
, and as such, the recommended way of using this method is using "try with resources":
try (AutoClosable dummy = disableTrackingFor(player, 1)){ // perform actions here, most likely something like: player.setLocation(location); // Any actions here will not disable the AFK timer. } // any actions here that move the player will be tracked again.
This pattern isn't strictly required, as the AutoCloseable
will close itself after the specified number of ticks. However, it's
prudent to consider the following:
disableTrackingFor(Player)
for a sane
default.
If you do not use "try with resources", call the close
method upon completion to reactivate tracking.
player
- The Player
to disable tracking for.ticks
- The number of ticks to disable tracking for.AutoCloseable
that will re-enable the tracking when done.