Class CitizensAPI

java.lang.Object
net.citizensnpcs.api.CitizensAPI

public final class CitizensAPI extends Object
Contains methods used in order to utilize the Citizens API.
  • Method Details

    • createAnonymousNPCRegistry

      public static NPCRegistry createAnonymousNPCRegistry(NPCDataStore store)
      Creates a new anonymous NPCRegistry with its own set of NPCs. This is not stored by the Citizens plugin.
      Parameters:
      store - The NPCDataStore to use with the registry
      Returns:
      A new anonymous NPCRegistry that is not accessible via getNamedNPCRegistry(String)
      Since:
      2.0.8
    • createInMemoryNPCRegistry

      public static NPCRegistry createInMemoryNPCRegistry(String name)
      Creates a new NPCRegistry with its own set of NPCs that does not save to disk.
    • createNamedNPCRegistry

      public static NPCRegistry createNamedNPCRegistry(String name, NPCDataStore store)
      Creates a new NPCRegistry with its own set of NPCs. This is stored in memory with the Citizens plugin, and can be accessed via getNamedNPCRegistry(String).
      Parameters:
      name - The plugin name
      store - The NPCDataStore to use with the registry
      Returns:
      A new NPCRegistry, that can also be retrieved via getNamedNPCRegistry(String)
      Since:
      2.0.8
    • getCommandManager

      public static CommandManager getCommandManager()
    • getDataFolder

      public static File getDataFolder()
      Returns:
      The data folder of the current implementation
    • getDefaultNPCSelector

      public static NPCSelector getDefaultNPCSelector()
      Returns:
      The default NPC selector
    • getLocationLookup

      public static LocationLookup getLocationLookup()
    • getNamedNPCRegistry

      public static NPCRegistry getNamedNPCRegistry(String name)
      Retrieves the NPCRegistry previously created via createNamedNPCRegistry(String, NPCDataStore) with the given name, or null if not found.
      Parameters:
      name - The registry name
      Returns:
      A NPCRegistry previously created via createNamedNPCRegistry(String, NPCDataStore), or null if not found
      Since:
      2.0.8
    • getNMSHelper

      public static NMSHelper getNMSHelper()
    • getNPCRegistries

      public static Iterable<NPCRegistry> getNPCRegistries()
    • getNPCRegistry

      public static NPCRegistry getNPCRegistry()
      Gets the current implementation's default NPCRegistry.
      Returns:
      The NPC registry
    • getPlugin

      public static Plugin getPlugin()
      Returns:
      The current Plugin providing an implementation
    • getTemplateRegistry

      public static TemplateRegistry getTemplateRegistry()
    • getTemporaryNPCRegistry

      public static NPCRegistry getTemporaryNPCRegistry()
      Gets the current implementation's default temporary NPCRegistry.
      Returns:
      The temporary NPC registry
    • getTraitFactory

      public static TraitFactory getTraitFactory()
      Gets the current implementation's TraitFactory.
      Returns:
      Citizens trait factory
      See Also:
    • hasImplementation

      public static boolean hasImplementation()
      Returns:
      Whether a Citizens implementation is currently present
    • registerEvents

      public static void registerEvents(Listener listener)
      A helper method for registering events using the current implementation's Plugin.
      Parameters:
      listener - The listener to register events for
      See Also:
    • removeNamedNPCRegistry

      public static void removeNamedNPCRegistry(String name)
      Removes any previously created NPCRegistry stored under the given name.
      Parameters:
      name - The name previously given to createNamedNPCRegistry(String, NPCDataStore)
      Since:
      2.0.8
    • setImplementation

      public static void setImplementation(CitizensPlugin implementation)
      Sets the current Citizens implementation.
      Parameters:
      implementation - The new implementation
    • shutdown

      public static void shutdown()
      Shuts down any resources currently being held.
    • talk

      public static void talk(SpeechContext context)