Class SimpleNPCDataStore

java.lang.Object
net.citizensnpcs.api.npc.SimpleNPCDataStore
All Implemented Interfaces:
NPCDataStore

public class SimpleNPCDataStore extends Object implements NPCDataStore
  • Constructor Details

    • SimpleNPCDataStore

      public SimpleNPCDataStore(Storage saves)
  • Method Details

    • clearData

      public void clearData(NPC npc)
      Description copied from interface: NPCDataStore
      Clears all data about the given NPC from storage. Called when the NPC is removed.
      Specified by:
      clearData in interface NPCDataStore
      Parameters:
      npc - The NPC to clear data from
    • createUniqueNPCId

      public int createUniqueNPCId(NPCRegistry registry)
      Specified by:
      createUniqueNPCId in interface NPCDataStore
      Parameters:
      registry - The registry for the unique ID.
      Returns:
      An ID for a new NPC to identify them uniquely
    • loadInto

      public void loadInto(NPCRegistry registry)
      Description copied from interface: NPCDataStore
      Loads NPCs from disk into the given NPCRegistry. The registry should be cleared before this is called.
      Specified by:
      loadInto in interface NPCDataStore
      Parameters:
      registry - The NPCRegistry to load NPCs into
    • reloadFromSource

      public void reloadFromSource()
      Description copied from interface: NPCDataStore
      Reloads the data store from source (such as a file on disk).
      Specified by:
      reloadFromSource in interface NPCDataStore
    • saveToDisk

      public void saveToDisk()
      Description copied from interface: NPCDataStore
      Notifies the data store to save all stored data to disk. May be asynchronous.
      Specified by:
      saveToDisk in interface NPCDataStore
    • saveToDiskImmediate

      public void saveToDiskImmediate()
      Description copied from interface: NPCDataStore
      Notifies the data store to save all stored data to disk immediately. Must not be asynchronous.
      Specified by:
      saveToDiskImmediate in interface NPCDataStore
    • store

      public void store(NPC npc)
      Description copied from interface: NPCDataStore
      Stores the given NPC into memory or to a disk representation.
      Specified by:
      store in interface NPCDataStore
      Parameters:
      npc - The NPC to store
    • storeAll

      public void storeAll(NPCRegistry registry)
      Description copied from interface: NPCDataStore
      Stores all NPCs in the given NPCRegistry to disk.
      Specified by:
      storeAll in interface NPCDataStore
      Parameters:
      registry - The registry to store NPCs from
    • create

      public static NPCDataStore create(Storage storage)