Class ContextKey<T>

java.lang.Object
dev.polv.taleapi.permission.ContextKey<T>
Type Parameters:
T - the type of value this key holds

public final class ContextKey<T> extends Object
Represents a context key used in permission context matching.

Context keys are typed identifiers for context values. Common built-in keys include:

  • world - The world name (e.g., "nether", "overworld")
  • server - The server name in a network
  • gamemode - The player's gamemode

Example


 ContextKey<String> WORLD = ContextKey.of("world", String.class);
 ContextKey<String> GAMEMODE = ContextKey.of("gamemode", String.class);
 
  • Field Details

    • WORLD

      public static final ContextKey<String> WORLD
      Context key for the world name (e.g., "nether", "overworld").
    • SERVER

      public static final ContextKey<String> SERVER
      Context key for the server name in a network.
    • GAMEMODE

      public static final ContextKey<String> GAMEMODE
      Context key for the player's gamemode.
  • Method Details

    • of

      public static <T> ContextKey<T> of(String key, Class<T> type)
      Creates a new context key.
      Type Parameters:
      T - the value type
      Parameters:
      key - the string identifier for this key
      type - the class type of values for this key
      Returns:
      a new ContextKey instance
    • key

      public String key()
      Returns the string identifier for this key.
      Returns:
      the key name
    • type

      public Class<T> type()
      Returns the type of values this key holds.
      Returns:
      the value class type
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object