Class SidedValue<T>

java.lang.Object
etithespirit.orimod.util.SidedValue<T>
Type Parameters:
T - The type of value to store.

public final class SidedValue<T> extends Object
A value that exists independently for both sides of the game. This is intended for static use, as instances of objects will (or should) exist for either side no matter what.
  • Field Details

  • Constructor Details

    • SidedValue

      public SidedValue(T def)
      Construct a new SidedValue. The specific side is determined by whether or not this game is an instance of the dedicated server.
      Parameters:
      def - The default value to store.
  • Method Details

    • set

      public void set(boolean onClient, T newValue) throws IllegalArgumentException
      Sets the value for the given side.
      Parameters:
      onClient - Whether or not to set the client value.
      newValue - The new value to use.
      Throws:
      IllegalArgumentException - If isClient is true, but this is running in a dedicated server (making that impossible).
    • get

      public T get(boolean onClient) throws IllegalArgumentException
      Gets the value for the given side.
      Parameters:
      onClient - Whether or not to get the client value.
      Returns:
      The value appropriate for the given side.
      Throws:
      IllegalArgumentException - If isClient is true, but this is running in a dedicated server (making that impossible).