Class EntityTrackerRegistry

java.lang.Object
kr.toxicity.model.api.tracker.EntityTrackerRegistry

public final class EntityTrackerRegistry extends Object
A registry of each entity's tracker
  • Field Details

    • TRACKING_ID

      @NotNull public static final @NotNull org.bukkit.NamespacedKey TRACKING_ID
      Tracker's namespace.
  • Method Details

    • registry

      @Nullable public static @Nullable EntityTrackerRegistry registry(@NotNull @NotNull UUID uuid)
      Gets registry by uuid
      Parameters:
      uuid - uuid
      Returns:
      registry or null
    • registry

      @Nullable public static @Nullable EntityTrackerRegistry registry(int id)
      Gets registry by id
      Parameters:
      id - id
      Returns:
      registry or null
    • registry

      @Nullable public static @Nullable EntityTrackerRegistry registry(@NotNull @NotNull BaseEntity entity)
      Gets registry by entity
      Parameters:
      entity - entity
      Returns:
      registry or null
    • registries

      public static void registries(@NotNull @NotNull Consumer<EntityTrackerRegistry> consumer)
      Uses all registries
      Parameters:
      consumer - consumer
    • registries

      @NotNull public static @NotNull @Unmodifiable List<EntityTrackerRegistry> registries()
      Gets all registries
      Returns:
      all registries
    • getOrCreate

      @Internal @NotNull public static @NotNull EntityTrackerRegistry getOrCreate(@NotNull @NotNull BaseEntity entity)
      Gets or creates registry by entity
      Parameters:
      entity - entity
      Returns:
      registry
    • entity

      @NotNull public @NotNull BaseEntity entity()
      Gets source entity
      Returns:
      entity
    • uuid

      @NotNull public @NotNull UUID uuid()
      Gets entity's uuid
      Returns:
      uuid
    • id

      public int id()
      Gets entity's id
      Returns:
      id
    • trackers

      @NotNull public @NotNull @Unmodifiable Collection<EntityTracker> trackers()
      Gets all trackers of this registry
      Returns:
      all trackers
    • tracker

      @Nullable public @Nullable EntityTracker tracker(@Nullable @Nullable String key)
      Gets some tracker by its name
      Parameters:
      key - key
      Returns:
      tracker or null
    • first

      @Nullable public @Nullable EntityTracker first()
      Gets first tracker of this register
      Returns:
      first tracker
    • create

      @Internal @NotNull public @NotNull EntityTracker create(@NotNull @NotNull String key, @NotNull @NotNull Function<EntityTrackerRegistry,EntityTracker> supplier)
      Creates tracker in this registry
      Parameters:
      key - key
      supplier - supplier
      Returns:
      created tracker
    • getOrCreate

      @Internal @NotNull public @NotNull EntityTracker getOrCreate(@NotNull @NotNull String key, @NotNull @NotNull Function<EntityTrackerRegistry,EntityTracker> supplier)
      Gets or creates tracker in this registry
      Parameters:
      key - key
      supplier - supplier
      Returns:
      created tracker
    • remove

      public boolean remove(@NotNull @NotNull String key)
      Removes some tracker in this registry
      Parameters:
      key - key
      Returns:
      success
    • isClosed

      public boolean isClosed()
      Checks this registry is closed
      Returns:
      is closed
    • close

      public boolean close()
      Closes this registry
      Returns:
      success
    • reload

      public void reload()
      Reloads this registry
    • refresh

      public void refresh()
      Refreshes this registry
    • despawn

      public void despawn()
      Despawns this registry to all players
    • load

      public void load(@NotNull @NotNull Stream<TrackerData> stream)
      Loads tracker data in this registry
      Parameters:
      stream - stream
    • load

      public void load()
      Loads entity's tracker this in this registry
    • save

      public void save()
      Saves entity data
    • displays

      @NotNull public @NotNull Stream<ModelDisplay> displays()
      Gets all displays as stream
      Returns:
      all displays
    • serialize

      @NotNull public @NotNull com.google.gson.JsonArray serialize()
      Serializes all tracker's data
      Returns:
      tracker's data
    • isSpawned

      public boolean isSpawned(@NotNull @NotNull org.bukkit.entity.Player player)
      Checks this tracker is spawned by some player
      Parameters:
      player - player
      Returns:
      is spawned
    • isSpawned

      public boolean isSpawned(@NotNull @NotNull UUID uuid)
      Checks this tracker is spawned by some player
      Parameters:
      uuid - player's uuid
      Returns:
      is spawned
    • spawn

      public boolean spawn(@NotNull @NotNull org.bukkit.entity.Player player)
      Spawns this tracker to some player
      Parameters:
      player - target player
      Returns:
      success
    • spawnIfNotSpawned

      public boolean spawnIfNotSpawned(@NotNull @NotNull org.bukkit.entity.Player player)
      Spawns not spawned tracker to some player
      Parameters:
      player - target player
      Returns:
      success
    • viewedPlayer

      @NotNull public @NotNull Stream<PlayerChannelHandler> viewedPlayer()
      Gets all viewed player as stream
      Returns:
      viewed player
    • remove

      public boolean remove(@NotNull @NotNull org.bukkit.entity.Player player)
      Removes player from this registry
      Parameters:
      player - player
      Returns:
      success
    • hideOption

      @NotNull public @NotNull EntityHideOption hideOption(@NotNull @NotNull UUID uuid)
      Gets hide option for some player
      Parameters:
      uuid - uuid
      Returns:
      hide option
    • mountedHitBox

      @NotNull public @NotNull @Unmodifiable Map<UUID,EntityTrackerRegistry.MountedHitBox> mountedHitBox()
      Gets currently mounted hitbox
      Returns:
      mounted hitbox
    • hasPassenger

      public boolean hasPassenger()
      Checks this tracker has passenger
      Returns:
      has passenger
    • hasControllingPassenger

      public boolean hasControllingPassenger()
      Checks this tracker has controlling passenger
      Returns:
      has controlling passenger