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 Details

    • register

      void register(MobDefinition definition, Object owner)
      Declares a mob of its own.
      Parameters:
      definition - the mob to declare
      owner - the plugin declaring it
      Throws:
      IllegalArgumentException - if MobDefinition.networkType() is not a known entity type
      Since:
      0.1.0
    • attach

      void attach(Key mobType, MobBehaviour.Factory factory, Object owner)
      Attaches a behaviour to every mob of a kind spawned from now on.
      Parameters:
      mobType - the mob to bend, built-in or registered
      factory - builds the behaviour for each such mob
      owner - the plugin attaching it
      Since:
      0.1.0
    • unregister

      boolean unregister(Key mobType)
      Drops a definition declared through register(MobDefinition, Object).
      Parameters:
      mobType - the key to drop
      Returns:
      true if a definition was registered under that key
      Since:
      0.1.0
    • detach

      boolean detach(Key mobType, Object owner)
      Drops the behaviours one plugin attached to a mob.
      Parameters:
      mobType - the mob to leave alone
      owner - the plugin that attached them
      Returns:
      true if at least one behaviour was dropped
      Since:
      0.1.0
    • unregisterAll

      void unregisterAll(Object owner)
      Drops every definition and behaviour a plugin declared.
      Parameters:
      owner - the plugin to clean up after
      Since:
      0.1.0
    • definition

      Optional<MobDefinition> definition(Key mobType)
      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<Key> types()
      Returns:
      every key that can be spawned, built-in mobs included
      Since:
      0.1.0
    • isMob

      boolean isMob(Key mobType)
      Parameters:
      mobType - the key to test
      Returns:
      true when a mob can be spawned under that key
      Since:
      0.1.0
    • spawn

      Optional<Mob> spawn(Key mobType, World world, Location location)
      Spawns a mob into the world.
      Parameters:
      mobType - the mob to spawn
      world - the world to spawn it in
      location - where to put it
      Returns:
      the mob, empty when the key is unknown or its implementation exposes no handle
      Since:
      0.1.0