Package cz.jeme.bestium.api
Interface Bestium
@NullMarked
public interface Bestium
The core system for managing custom Minecraft entities.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final classHolds all the internal singleton instances. -
Method Summary
Modifier and TypeMethodDescriptionorg.bukkit.NamespacedKeyConstructs aNamespacedKeyfrom the given string key value.static BestiumReturns the Bestium plugin instance cast asBestium.static @Nullable net.kyori.adventure.key.KeygetInjectedEntityKey(org.bukkit.entity.Entity entity) Retrieves the BestiumKeyof the injected BukkitEntity, ornullif not injected.static EntityInjectorReturns the main entity injector instance, which handles the registration and management of custom entities within Bestium.static org.bukkit.plugin.java.JavaPluginReturns the Bestium plugin instance.static PluginSupportReturns the plugin support instance, providing access to functions for checking the status of external optional dependencies.static booleanisInjectedEntity(org.bukkit.entity.Entity entity) Checks whether the given BukkitEntityis an injected entity.static net.kyori.adventure.key.KeyrequireInjectedEntityKey(org.bukkit.entity.Entity entity) Retrieves the BestiumKeyof the injected BukkitEntity.static <T extends net.minecraft.world.entity.Entity>
@Nullable Tspawn(org.bukkit.Location location, Class<T> entityClass, net.minecraft.world.entity.EntitySpawnReason entitySpawnReason, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason creatureSpawnReason) Spawns a custom injected entity with default initialization logic.static <T extends net.minecraft.world.entity.Entity>
@Nullable Tspawn(org.bukkit.Location location, Class<T> entityClass, net.minecraft.world.entity.EntitySpawnReason entitySpawnReason, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason creatureSpawnReason, Consumer<T> consumer) Spawns a custom injected entity of the specified class at the given location.
-
Method Details
-
getPlugin
static org.bukkit.plugin.java.JavaPlugin getPlugin()Returns the Bestium plugin instance.- Returns:
- the
JavaPlugininstance - Throws:
IllegalStateException- if called before the plugin is loaded
-
getBestium
Returns the Bestium plugin instance cast asBestium.This instance can be safely cast back to a
JavaPlugin.- Returns:
- the
Bestiuminstance - Throws:
IllegalStateException- if called before the plugin is loaded
-
getInjector
Returns the main entity injector instance, which handles the registration and management of custom entities within Bestium.- Returns:
- the injector instance
- Throws:
IllegalStateException- if called before the Bestium bootstrap happens- See Also:
-
getPluginSupport
Returns the plugin support instance, providing access to functions for checking the status of external optional dependencies.- Returns:
- the plugin support instance
- Throws:
IllegalStateException- if called before Bestium plugin is loaded- See Also:
-
spawn
static <T extends net.minecraft.world.entity.Entity> @Nullable T spawn(org.bukkit.Location location, Class<T> entityClass, net.minecraft.world.entity.EntitySpawnReason entitySpawnReason, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason creatureSpawnReason, Consumer<T> consumer) Spawns a custom injected entity of the specified class at the given location.- Type Parameters:
T- the type of the entity- Parameters:
location- the location where the entity should spawnentityClass- the class of the injected entity to spawnentitySpawnReason- the MinecraftEntitySpawnReasonto use when spawningcreatureSpawnReason- the BukkitCreatureSpawnEvent.SpawnReasonto use when triggering eventsconsumer- a consumer that is called after the entity is created but before it is added to the world- Returns:
- the spawned entity instance, or
nullif spawning failed - Throws:
IllegalArgumentException- if the given class is not a registered injected entity
-
spawn
static <T extends net.minecraft.world.entity.Entity> @Nullable T spawn(org.bukkit.Location location, Class<T> entityClass, net.minecraft.world.entity.EntitySpawnReason entitySpawnReason, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason creatureSpawnReason) Spawns a custom injected entity with default initialization logic.- Type Parameters:
T- the type of the entity- Parameters:
location- the location where the entity should spawnentityClass- the class of the injected entity to spawnentitySpawnReason- the MinecraftEntitySpawnReasonto use when spawningcreatureSpawnReason- the BukkitCreatureSpawnEvent.SpawnReasonto use when triggering events- Returns:
- the spawned entity instance, or
nullif spawning failed - Throws:
IllegalArgumentException- if the given class is not a registered injected entity- See Also:
-
getInjectedEntityKey
static @Nullable net.kyori.adventure.key.Key getInjectedEntityKey(org.bukkit.entity.Entity entity) Retrieves the BestiumKeyof the injected BukkitEntity, ornullif not injected.This is the same key that was used when registering the entity injection.
- Parameters:
entity- the BukkitEntityto retrieve the key from- Returns:
- the
Keyidentifying the injected entity type, ornullif the entity is not an injected entity - See Also:
-
requireInjectedEntityKey
static net.kyori.adventure.key.Key requireInjectedEntityKey(org.bukkit.entity.Entity entity) Retrieves the BestiumKeyof the injected BukkitEntity.This is the same key that was used when registering the entity injection. Throws an exception if the entity is not injected.
- Parameters:
entity- the BukkitEntityto retrieve the key from- Returns:
- the
Keyidentifying the injected entity type - Throws:
IllegalArgumentException- if the entity is not an injected entity- See Also:
-
isInjectedEntity
static boolean isInjectedEntity(org.bukkit.entity.Entity entity) Checks whether the given BukkitEntityis an injected entity.- Parameters:
entity- the BukkitEntityto check- Returns:
trueif the entity was injected by Bestium,falseotherwise
-
createKey
Constructs aNamespacedKeyfrom the given string key value.- Parameters:
key- the string value of the key. Must follow theKeyPattern.Valueformat- Returns:
- a
NamespacedKeyconstructed from the given value
-