Class InMemeryTeleportService
java.lang.Object
com.ultikits.ultitools.services.impl.InMemeryTeleportService
- All Implemented Interfaces:
BaseService,TeleportService
Teleport service implementation.
- Version:
- 1.0.0
- Author:
- wisdomme
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static classResult object for delay teleport tick processing. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static booleanTrue once ANY instance of this class has registeredteleportingPlayers/locationMap/inMemoryLocationRecord-- static fields shared by every instance -- with the livePlayerCacheManagerfor quit-based sweeping (GEN-08, D-03).private static boolean -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) static voidCheck movement for all teleporting players.(package private) static booleancheckPlayerMovement(UUID playerUUID) Check if a single player has moved during teleport delay.(package private) static voidClear all teleporting data.voiddelayTeleport(org.bukkit.entity.Player player, org.bukkit.Location location, int delay) Delay teleport player.private voidAttempts lazy first-use registration of THIS instance -- as the reference-identity handle for the three shared static fields above -- with the livePlayerCacheManagersingleton.Optional<org.bukkit.Location> getLastTeleportLocation(UUID uuid) Get last teleport location of the player (before teleport).getName()Get service name, this name will appear in the console or in the game.(package private) static BooleangetTeleportingStatus(UUID playerUUID) Get a player's teleporting status.intVersion number, used to compare the version number of the registered service, currently not in use.(package private) static voidInitialize the movement check scheduler.(package private) static InMemeryTeleportService.DelayTeleportResultprocessDelayTeleportTick(org.bukkit.entity.Player player, org.bukkit.Location location, float time) Process a single tick of the delay teleport countdown.(package private) static voidsetTeleportingStatus(UUID playerUUID, boolean status) Set a player's teleporting status.voidteleport(org.bukkit.entity.Player player, org.bukkit.Location location) Teleport player instantly.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.ultikits.ultitools.interfaces.BaseService
getResourceFolderName
-
Field Details
-
teleportingPlayers
-
locationMap
-
inMemoryLocationRecord
-
schedulerInitialized
private static volatile boolean schedulerInitialized -
playerCacheRegistered
private static volatile boolean playerCacheRegisteredTrue once ANY instance of this class has registeredteleportingPlayers/locationMap/inMemoryLocationRecord-- static fields shared by every instance -- with the livePlayerCacheManagerfor quit-based sweeping (GEN-08, D-03). A STATIC flag, not per-instance, mirroring the identical rationale onInMemoryNotificationService#playerCacheRegistered: only the first instance to reachdelayTeleport(Player, Location, int)registers. Set lazily rather than in a constructor for the same reason asCooldownValidator's field of the same name: a barenew InMemeryTeleportService()must never attempt contact with a core plugin that may not exist yet.
-
-
Constructor Details
-
InMemeryTeleportService
public InMemeryTeleportService()
-
-
Method Details
-
ensurePlayerCacheRegistered
private void ensurePlayerCacheRegistered()Attempts lazy first-use registration of THIS instance -- as the reference-identity handle for the three shared static fields above -- with the livePlayerCacheManagersingleton. SeeplayerCacheRegistered's javadoc for the static-flag rationale. -
initScheduler
static void initScheduler()Initialize the movement check scheduler. Called lazily to avoid static initializer issues in tests. -
checkAllPlayersMovement
static void checkAllPlayersMovement()Check movement for all teleporting players. This method is extracted from BukkitRunnable for testability. -
checkPlayerMovement
Check if a single player has moved during teleport delay. This method is extracted from BukkitRunnable for testability.- Parameters:
playerUUID- the UUID of the player to check- Returns:
- true if the player moved (teleport should be cancelled), false otherwise
-
teleport
public void teleport(org.bukkit.entity.Player player, org.bukkit.Location location) Description copied from interface:TeleportServiceTeleport player instantly.- Specified by:
teleportin interfaceTeleportService- Parameters:
player- playerlocation- location
-
delayTeleport
public void delayTeleport(org.bukkit.entity.Player player, org.bukkit.Location location, int delay) Description copied from interface:TeleportServiceDelay teleport player.- Specified by:
delayTeleportin interfaceTeleportService- Parameters:
player- playerlocation- locationdelay- delay
-
processDelayTeleportTick
static InMemeryTeleportService.DelayTeleportResult processDelayTeleportTick(org.bukkit.entity.Player player, org.bukkit.Location location, float time) Process a single tick of the delay teleport countdown. This method is extracted from BukkitRunnable for testability.- Parameters:
player- the player being teleportedlocation- the target locationtime- the current remaining time- Returns:
- the result containing whether to cancel and the new remaining time
-
setTeleportingStatus
Set a player's teleporting status. Used for testing. -
getTeleportingStatus
Get a player's teleporting status. Used for testing. -
clearTeleportingData
static void clearTeleportingData()Clear all teleporting data. Used for testing. -
getLastTeleportLocation
Description copied from interface:TeleportServiceGet last teleport location of the player (before teleport).- Specified by:
getLastTeleportLocationin interfaceTeleportService- Parameters:
uuid- player uuid- Returns:
- last teleport location
-
getName
Description copied from interface:BaseServiceGet service name, this name will appear in the console or in the game.- Specified by:
getNamein interfaceBaseService- Returns:
- Service name
-
getAuthor
- Specified by:
getAuthorin interfaceBaseService- Returns:
- Author name
-
getVersion
public int getVersion()Description copied from interface:BaseServiceVersion number, used to compare the version number of the registered service, currently not in use.- Specified by:
getVersionin interfaceBaseService- Returns:
- service version
-