Class CustomPlayersHandler<T extends CustomPlayer>

java.lang.Object
com.jubiman.customplayerlib.CustomPlayersHandler<T>
Type Parameters:
T - your CustomPlayer class
Direct Known Subclasses:
CustomPlayersHandlerTickable

public abstract class CustomPlayersHandler<T extends CustomPlayer> extends Object
Handler for handling custom players in your mod
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final String
    The name of the handler (usually tied to the mod name)
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs the storage class for custom players
  • Method Summary

    Modifier and Type
    Method
    Description
    get(long auth)
    A null safe way to get a player from the map, adds player if they don't exist yet
    Iterate through the keys (player auths).
    void
    loadEnter(necesse.engine.save.LoadData loadData)
    Load player from saved data.
    void
    loadExit(necesse.engine.save.LoadData loadData)
    Load player from saved data.
    void
    save(necesse.engine.save.SaveData saveData, necesse.engine.network.server.ServerClient player)
    Save player's data.
    void
    When switching worlds or on server stop this will be called to avoid overwriting data in other (older) worlds
    Iterate through the values.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • name

      protected final String name
      The name of the handler (usually tied to the mod name)
  • Constructor Details

    • CustomPlayersHandler

      public CustomPlayersHandler(Class<T> clazz, String name)
      Constructs the storage class for custom players
      Parameters:
      clazz - the class extending CustomPlayer
      name - the name of the class, used for creating a save component
  • Method Details

    • get

      public T get(long auth)
      A null safe way to get a player from the map, adds player if they don't exist yet
      Parameters:
      auth - the authentication of the player's ServerClient
      Returns:
      the object belonging to the player
    • keyIterator

      public Set<Long> keyIterator()
      Iterate through the keys (player auths).
      Returns:
      a set of all keys (all player auths )
    • valueIterator

      public Collection<T> valueIterator()
      Iterate through the values.
      Returns:
      a collection of all values (all CustomPlayers)
    • save

      public void save(necesse.engine.save.SaveData saveData, necesse.engine.network.server.ServerClient player)
      Save player's data.
      Parameters:
      saveData - the parent save object (usually ServerClient)
      player - the player to save
    • loadEnter

      public void loadEnter(necesse.engine.save.LoadData loadData)
      Load player from saved data. Gets called before the rest of the player is loaded.
      Parameters:
      loadData - data to load from (should be the same as where you save, usually ServerClient)
    • loadExit

      public void loadExit(necesse.engine.save.LoadData loadData)
      Load player from saved data. Gets called after the rest of the player is loaded.
      Parameters:
      loadData - data to load from (should be the same as where you save, usually ServerClient)
    • stop

      public void stop()
      When switching worlds or on server stop this will be called to avoid overwriting data in other (older) worlds