Contents
- Description
- Field Summary
- Constructor Summary
- Method Summary
- Field Details
- Constructor Details
- Method Details
- onPlayerAddedToWorld(AddPlayerToWorldEvent)
- updatePathOfLoadedPrefab(Path, Path)
- isEditingAPrefab(UUID)
- getPrefabEditSession(UUID)
- getActiveEditSessions()
- hasInProgressLoading(UUID)
- cancelLoading(UUID)
- isLoadingCancelled(UUID)
- clearLoadingState(UUID)
- createEditSessionForNewPrefab(Ref, Player, PrefabEditorCreationSettings, ComponentAccessor)
- loadPrefabAndCreateEditSession(Ref, Player, PrefabEditorCreationSettings, ComponentAccessor)
- loadPrefabAndCreateEditSession(Ref, Player, PrefabEditorCreationSettings, ComponentAccessor, Consumer)
- isInEditWorld(PlayerRef, Store)
- sendToEditWorld(Ref, World, PlayerRef)
- exitEditSession(Ref, World, PlayerRef, ComponentAccessor)
- cleanupCancelledSession(UUID, String, Consumer)
- cleanupCancelledSession(UUID, String)
Class PrefabEditSessionManager
java.lang.Object
com.hypixel.hytale.builtin.buildertools.prefabeditor.PrefabEditSessionManager
Manages all active Prefab Edit Sessions on the server
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe default chunk environment for all prefab editor worlds.static final StringThe default weather for all prefab editor worlds.static final StringThe default grass tint as a hex string.static final StringA default block to place when creating a new prefab, helpful for void worlds.static final ColorThe default tint of a world-- grass-greenish.static final floatThe default time in a new edit session world.static final StringThe prefix for world folders for edit session worlds. -
Constructor Summary
ConstructorsConstructorDescriptionPrefabEditSessionManager(JavaPlugin plugin) Default Constructor for aPrefabEditSessionManagerinstance. -
Method Summary
Modifier and TypeMethodDescriptionvoidcancelLoading(UUID playerUuid) Marks a player's loading operation as cancelled.cleanupCancelledSession(UUID playerUuid, String worldName) Cleans up a cancelled loading session without progress callbacks.cleanupCancelledSession(UUID playerUuid, String worldName, Consumer<PrefabLoadingState> progressCallback) Cleans up a cancelled loading session, removing the world and active session tracking.voidclearLoadingState(UUID playerUuid) Clears the in-progress and cancelled loading state for a player.createEditSessionForNewPrefab(Ref<EntityStore> ref, Player editor, PrefabEditorCreationSettings settings, ComponentAccessor<EntityStore> componentAccessor) Create an emptyPrefabEditSessioninstance world where the player can build a new prefabexitEditSession(Ref<EntityStore> ref, World world, PlayerRef playerRef, ComponentAccessor<EntityStore> componentAccessor) Exits and ends a PrefabEditSession, unloading the world and teleporting you out.getPrefabEditSession(UUID playerUUID) Retrieve thePrefabEditSessionthat the player is currently a part ofbooleanhasInProgressLoading(UUID playerUuid) Checks if a player has an in-progress loading operation.booleanisEditingAPrefab(UUID playerUUID) booleanisInEditWorld(PlayerRef playerRef, Store<EntityStore> store) booleanisLoadingCancelled(UUID playerUuid) Checks if a player's loading operation has been cancelled.loadPrefabAndCreateEditSession(Ref<EntityStore> ref, Player editor, PrefabEditorCreationSettings settings, ComponentAccessor<EntityStore> componentAccessor) Create aPrefabEditSessioninstance world, load the specified prefab(s), and teleport the provided player into it.loadPrefabAndCreateEditSession(Ref<EntityStore> ref, Player editor, PrefabEditorCreationSettings settings, ComponentAccessor<EntityStore> componentAccessor, Consumer<PrefabLoadingState> progressCallback) Create aPrefabEditSessioninstance world, load the specified prefab(s), and teleport the provided player into it.voidWhen a player being teleported to the prefab editing world begins being added to world, we cannot get the world that they are being teleported to from thePlayerReadyEvent, so we need to store it in this eventsendToEditWorld(Ref<EntityStore> ref, World world, PlayerRef playerRef) voidupdatePathOfLoadedPrefab(Path oldPath, Path newPath) Updates the stored prefab paths in theprefabsBeingEdited
-
Field Details
-
NOON_TIME
public static final float NOON_TIMEThe default time in a new edit session world.- See Also:
-
DEFAULT_NEW_WORLD_ZERO_COORDINATE_BLOCK_NAME
A default block to place when creating a new prefab, helpful for void worlds.- See Also:
-
DEFAULT_ENVIRONMENT
The default weather for all prefab editor worlds.- See Also:
-
DEFAULT_CHUNK_ENVIRONMENT
The default chunk environment for all prefab editor worlds. This should be a grasslands-like environment to match the default weather.- See Also:
-
PREFAB_EDITING_WORLD_NAME_PREFIX
The prefix for world folders for edit session worlds.- See Also:
-
DEFAULT_TINT
The default tint of a world-- grass-greenish. -
DEFAULT_GRASS_TINT_HEX
-
-
Constructor Details
-
PrefabEditSessionManager
Default Constructor for aPrefabEditSessionManagerinstance.- Parameters:
plugin- TheJavaPluginthat this manager is associated with.
-
-
Method Details
-
onPlayerAddedToWorld
When a player being teleported to the prefab editing world begins being added to world, we cannot get the world that they are being teleported to from thePlayerReadyEvent, so we need to store it in this event- Parameters:
event- TheAddPlayerToWorldEventthat was called
-
updatePathOfLoadedPrefab
-
isEditingAPrefab
- Parameters:
playerUUID- The UUID of a player- Returns:
- true if the player is currently editing a prefab
-
getPrefabEditSession
Retrieve thePrefabEditSessionthat the player is currently a part of- Parameters:
playerUUID- The UUID of the Player to fetch their edit session- Returns:
- The
PrefabEditSessionthat the player is in
-
getActiveEditSessions
- Returns:
- all active prefab edit sessions, keyed by player UUID.
-
hasInProgressLoading
Checks if a player has an in-progress loading operation.- Parameters:
playerUuid- The UUID of the player.- Returns:
- true if the player has an in-progress loading operation.
-
cancelLoading
Marks a player's loading operation as cancelled. The loading chain will check this and abort early.- Parameters:
playerUuid- The UUID of the player.
-
isLoadingCancelled
Checks if a player's loading operation has been cancelled.- Parameters:
playerUuid- The UUID of the player.- Returns:
- true if the loading was cancelled.
-
clearLoadingState
Clears the in-progress and cancelled loading state for a player. Should be called when loading completes (successfully or not) or after cleanup.- Parameters:
playerUuid- The UUID of the player.
-
createEditSessionForNewPrefab
@Nonnull public CompletableFuture<Void> createEditSessionForNewPrefab(@Nonnull Ref<EntityStore> ref, @Nonnull Player editor, @Nonnull PrefabEditorCreationSettings settings, @Nonnull ComponentAccessor<EntityStore> componentAccessor) Create an emptyPrefabEditSessioninstance world where the player can build a new prefab- Parameters:
ref- The entity reference of the player entity.editor- The player who is editing the prefab.settings- The settings to use for creating the prefab edit session.componentAccessor- TheComponentAccessor<EntityStore>for component access.- Returns:
- A
CompletableFuturethat handles all the above tasks, or null if something went wrong
-
loadPrefabAndCreateEditSession
@Nullable public CompletableFuture<Void> loadPrefabAndCreateEditSession(@Nonnull Ref<EntityStore> ref, @Nonnull Player editor, @Nonnull PrefabEditorCreationSettings settings, @Nonnull ComponentAccessor<EntityStore> componentAccessor) Create aPrefabEditSessioninstance world, load the specified prefab(s), and teleport the provided player into it.- Parameters:
ref- The entity reference of the player entity.editor- The player who is editing the prefab.settings- The settings to use for creating the prefab edit session.componentAccessor- TheComponentAccessor<EntityStore>for component access.- Returns:
- A
CompletableFuturethat handles all the above tasks, or null if something went wrong
-
loadPrefabAndCreateEditSession
@Nullable public CompletableFuture<Void> loadPrefabAndCreateEditSession(@Nonnull Ref<EntityStore> ref, @Nonnull Player editor, @Nonnull PrefabEditorCreationSettings settings, @Nonnull ComponentAccessor<EntityStore> componentAccessor, @Nullable Consumer<PrefabLoadingState> progressCallback) Create aPrefabEditSessioninstance world, load the specified prefab(s), and teleport the provided player into it.- Parameters:
ref- The entity reference of the player entity.editor- The player who is editing the prefab.settings- The settings to use for creating the prefab edit session.componentAccessor- TheComponentAccessor<EntityStore>for component access.progressCallback- Optional callback to receive progress updates.- Returns:
- A
CompletableFuturethat handles all the above tasks, or null if something went wrong
-
isInEditWorld
-
sendToEditWorld
@Nullable public CompletableFuture<Void> sendToEditWorld(@Nonnull Ref<EntityStore> ref, @Nonnull World world, @Nonnull PlayerRef playerRef) -
exitEditSession
@Nullable public CompletableFuture<Void> exitEditSession(@Nonnull Ref<EntityStore> ref, @Nonnull World world, @Nonnull PlayerRef playerRef, @Nonnull ComponentAccessor<EntityStore> componentAccessor) Exits and ends a PrefabEditSession, unloading the world and teleporting you out.- Parameters:
ref- The entity reference of the instigating player entity.world- The world that the instigating player entity is in.playerRef- ThePlayerRefcomponent of the instigating player entity.componentAccessor- TheComponentAccessor<EntityStore>for component access.- Returns:
- a CompletableFuture handling the removal of the world, or null if something went wrong.
-
cleanupCancelledSession
@Nonnull public CompletableFuture<Void> cleanupCancelledSession(@Nonnull UUID playerUuid, @Nonnull String worldName, @Nullable Consumer<PrefabLoadingState> progressCallback) Cleans up a cancelled loading session, removing the world and active session tracking. Called when the user cancels loading via the UI.This method runs asynchronously and provides progress updates via the callback.
- Parameters:
playerUuid- The UUID of the player who cancelled.worldName- The name of the world that was being created.progressCallback- Optional callback to receive progress updates during shutdown.- Returns:
- A CompletableFuture that completes when cleanup is finished.
-
cleanupCancelledSession
@Nonnull public CompletableFuture<Void> cleanupCancelledSession(@Nonnull UUID playerUuid, @Nonnull String worldName) Cleans up a cancelled loading session without progress callbacks.- Parameters:
playerUuid- The UUID of the player who cancelled.worldName- The name of the world that was being created.- Returns:
- A CompletableFuture that completes when cleanup is finished.
-