Interface MobRegistry
public interface MobRegistry
Where mobs are declared: the built-in ones, the ones plugins bend, and the ones they invent.
- Since:
- 0.1.0
-
Method Summary
Modifier and TypeMethodDescriptionvoidattach(TypedKey<EntityType> mobType, MobBehaviour.Factory factory, Object owner) Attaches a behaviour to every mob of a kind spawned from now on.definition(TypedKey<EntityType> mobType) booleandetach(TypedKey<EntityType> mobType, Object owner) Drops the behaviours one plugin attached to a mob.booleanisMob(TypedKey<EntityType> mobType) voidregister(MobDefinition definition, Object owner) Declares a mob of its own.spawn(TypedKey<EntityType> mobType, Location location) Spawns a mob into the world.types()booleanunregister(TypedKey<EntityType> mobType) Drops a definition declared throughregister(MobDefinition, Object).voidunregisterAll(Object owner) Drops every definition and behaviour a plugin declared.
-
Method Details
-
register
Declares a mob of its own.- Parameters:
definition- the mob to declareowner- the plugin declaring it- Throws:
IllegalArgumentException- ifMobDefinition.networkType()is not a known entity type- Since:
- 0.1.0
-
attach
Attaches a behaviour to every mob of a kind spawned from now on.- Parameters:
mobType- the mob to bend, built-in or registeredfactory- builds the behaviour for each such mobowner- the plugin attaching it- Since:
- 0.1.0
-
unregister
Drops a definition declared throughregister(MobDefinition, Object).- Parameters:
mobType- the key to drop- Returns:
trueif a definition was registered under that key- Since:
- 0.1.0
-
detach
Drops the behaviours one plugin attached to a mob.- Parameters:
mobType- the mob to leave aloneowner- the plugin that attached them- Returns:
trueif at least one behaviour was dropped- Since:
- 0.1.0
-
unregisterAll
Drops every definition and behaviour a plugin declared.- Parameters:
owner- the plugin to clean up after- Since:
- 0.1.0
-
definition
- Parameters:
mobType- the key to look up- Returns:
- the definition registered under that key, empty for a built-in mob
- Since:
- 0.1.0
-
definitions
Collection<MobDefinition> definitions()- Returns:
- every definition registered by a plugin
- Since:
- 0.1.0
-
types
Set<TypedKey<EntityType>> types()- Returns:
- every key that can be spawned, built-in mobs included
- Since:
- 0.1.0
-
isMob
- Parameters:
mobType- the key to test- Returns:
truewhen a mob can be spawned under that key- Since:
- 0.1.0
-
spawn
Spawns a mob into the world.- Parameters:
mobType- the mob to spawnlocation- where to put it- Returns:
- the mob, empty when the key is unknown or its implementation exposes no handle
- Since:
- 0.1.0
-