Interface Options


public interface Options
A simple options (metadata) API.
  • Method Summary

    Static Methods
    Modifier and Type
    Method
    Description
    get(@NotNull com.mojang.authlib.GameProfile profile, @NotNull String key)
    Gets the value of an option for the given (potentially) offline player.
    get(@NotNull com.mojang.authlib.GameProfile profile, @NotNull String key, String defaultValue)
    Gets the value of an option for the given player, falling back to the defaultValue if nothing is returned from the provider.
    static <T> @NotNull CompletableFuture<Optional<T>>
    get(@NotNull com.mojang.authlib.GameProfile profile, @NotNull String key, @NotNull Function<String, ? extends T> valueTransformer)
    Gets the value of an option for the given player, and runs it through the given valueTransformer.
    static <T> CompletableFuture<T>
    get(@NotNull com.mojang.authlib.GameProfile profile, @NotNull String key, T defaultValue, @NotNull Function<String, ? extends T> valueTransformer)
    Gets the value of an option for the given player, runs it through the given valueTransformer, and falls back to the defaultValue if nothing is returned.
    get(@NotNull UUID uuid, @NotNull String key)
    Gets the value of an option for the given (potentially) offline player.
    get(@NotNull UUID uuid, @NotNull String key, String defaultValue)
    Gets the value of an option for the given player, falling back to the defaultValue if nothing is returned from the provider.
    static <T> @NotNull CompletableFuture<Optional<T>>
    get(@NotNull UUID uuid, @NotNull String key, @NotNull Function<String, ? extends T> valueTransformer)
    Gets the value of an option for the given player, and runs it through the given valueTransformer.
    static <T> CompletableFuture<T>
    get(@NotNull UUID uuid, @NotNull String key, T defaultValue, @NotNull Function<String, ? extends T> valueTransformer)
    Gets the value of an option for the given player, runs it through the given valueTransformer, and falls back to the defaultValue if nothing is returned.
    static @NotNull Optional<String>
    get(@NotNull net.minecraft.commands.SharedSuggestionProvider source, @NotNull String key)
    Gets the value of an option for the given source.
    static String
    get(@NotNull net.minecraft.commands.SharedSuggestionProvider source, @NotNull String key, String defaultValue)
    Gets the value of an option for the given source, falling back to the defaultValue if nothing is returned from the provider.
    static <T> @NotNull Optional<T>
    get(@NotNull net.minecraft.commands.SharedSuggestionProvider source, @NotNull String key, @NotNull Function<String, ? extends T> valueTransformer)
    Gets the value of an option for the given source, and runs it through the given valueTransformer.
    static <T> T
    get(@NotNull net.minecraft.commands.SharedSuggestionProvider source, @NotNull String key, T defaultValue, @NotNull Function<String, ? extends T> valueTransformer)
    Gets the value of an option for the given source, runs it through the given valueTransformer, and falls back to the defaultValue if nothing is returned.
    get(@NotNull net.minecraft.server.players.NameAndId entry, @NotNull String key)
    Gets the value of an option for the given (potentially) offline player.
    get(@NotNull net.minecraft.server.players.NameAndId entry, @NotNull String key, String defaultValue)
    Gets the value of an option for the given player, falling back to the defaultValue if nothing is returned from the provider.
    static <T> @NotNull CompletableFuture<Optional<T>>
    get(@NotNull net.minecraft.server.players.NameAndId entry, @NotNull String key, @NotNull Function<String, ? extends T> valueTransformer)
    Gets the value of an option for the given player, and runs it through the given valueTransformer.
    static <T> CompletableFuture<T>
    get(@NotNull net.minecraft.server.players.NameAndId entry, @NotNull String key, T defaultValue, @NotNull Function<String, ? extends T> valueTransformer)
    Gets the value of an option for the given player, runs it through the given valueTransformer, and falls back to the defaultValue if nothing is returned.
    static @NotNull Optional<String>
    get(@NotNull net.minecraft.world.entity.Entity entity, @NotNull String key)
    Gets the value of an option for the given entity.
    static String
    get(@NotNull net.minecraft.world.entity.Entity entity, @NotNull String key, String defaultValue)
    Gets the value of an option for the given entity, falling back to the defaultValue if nothing is returned from the provider.
    static <T> @NotNull Optional<T>
    get(@NotNull net.minecraft.world.entity.Entity entity, @NotNull String key, @NotNull Function<String, ? extends T> valueTransformer)
    Gets the value of an option for the given entity, and runs it through the given valueTransformer.
    static <T> T
    get(@NotNull net.minecraft.world.entity.Entity entity, @NotNull String key, T defaultValue, @NotNull Function<String, ? extends T> valueTransformer)
    Gets the value of an option for the given entity, runs it through the given valueTransformer, and falls back to the defaultValue if nothing is returned.
  • Method Details

    • get

      @NotNull static @NotNull Optional<String> get(@NotNull @NotNull net.minecraft.commands.SharedSuggestionProvider source, @NotNull @NotNull String key)
      Gets the value of an option for the given source.
      Parameters:
      source - the source
      key - the option key
      Returns:
      the option value
    • get

      @Contract("_, _, !null -> !null") static String get(@NotNull @NotNull net.minecraft.commands.SharedSuggestionProvider source, @NotNull @NotNull String key, String defaultValue)
      Gets the value of an option for the given source, falling back to the defaultValue if nothing is returned from the provider.
      Parameters:
      source - the source
      key - the option key
      defaultValue - the default value to use if nothing is returned
      Returns:
      the option value
    • get

      @NotNull static <T> @NotNull Optional<T> get(@NotNull @NotNull net.minecraft.commands.SharedSuggestionProvider source, @NotNull @NotNull String key, @NotNull @NotNull Function<String, ? extends T> valueTransformer)
      Gets the value of an option for the given source, and runs it through the given valueTransformer.

      If nothing is returned from the provider, an empty optional is returned. (the transformer will never be passed a null argument)

      The transformer is allowed to throw IllegalArgumentException or return null. This will also result in an empty optional being returned.

      For example, to parse and return an integer meta value, use:

          get(source, "my-int-value", Integer::parseInt).orElse(0);
      
      Type Parameters:
      T - the type of the transformed result
      Parameters:
      source - the source
      key - the option key
      valueTransformer - the transformer used to transform the value
      Returns:
      the transformed option value
    • get

      @Contract("_, _, !null, _ -> !null") static <T> T get(@NotNull @NotNull net.minecraft.commands.SharedSuggestionProvider source, @NotNull @NotNull String key, T defaultValue, @NotNull @NotNull Function<String, ? extends T> valueTransformer)
      Gets the value of an option for the given source, runs it through the given valueTransformer, and falls back to the defaultValue if nothing is returned.

      If nothing is returned from the provider, the defaultValue is returned. (the transformer will never be passed a null argument)

      The transformer is allowed to throw IllegalArgumentException or return null. This will also result in the defaultValue being returned.

      For example, to parse and return an integer meta value, use:

          get(source, "my-int-value", 0, Integer::parseInt);
      
      Type Parameters:
      T - the type of the transformed result
      Parameters:
      source - the source
      key - the option key
      defaultValue - the default value
      valueTransformer - the transformer used to transform the value
      Returns:
      the transformed option value
    • get

      @NotNull static @NotNull Optional<String> get(@NotNull @NotNull net.minecraft.world.entity.Entity entity, @NotNull @NotNull String key)
      Gets the value of an option for the given entity.
      Parameters:
      entity - the entity
      key - the option key
      Returns:
      the option value
    • get

      @Contract("_, _, !null -> !null") static String get(@NotNull @NotNull net.minecraft.world.entity.Entity entity, @NotNull @NotNull String key, String defaultValue)
      Gets the value of an option for the given entity, falling back to the defaultValue if nothing is returned from the provider.
      Parameters:
      entity - the entity
      key - the option key
      defaultValue - the default value to use if nothing is returned
      Returns:
      the option value
    • get

      @NotNull static <T> @NotNull Optional<T> get(@NotNull @NotNull net.minecraft.world.entity.Entity entity, @NotNull @NotNull String key, @NotNull @NotNull Function<String, ? extends T> valueTransformer)
      Gets the value of an option for the given entity, and runs it through the given valueTransformer.

      If nothing is returned from the provider, an empty optional is returned. (the transformer will never be passed a null argument)

      The transformer is allowed to throw IllegalArgumentException or return null. This will also result in an empty optional being returned.

      For example, to parse and return an integer meta value, use:

          get(entity, "my-int-value", Integer::parseInt).orElse(0);
      
      Type Parameters:
      T - the type of the transformed result
      Parameters:
      entity - the entity
      key - the option key
      valueTransformer - the transformer used to transform the value
      Returns:
      the transformed option value
    • get

      @Contract("_, _, !null, _ -> !null") static <T> T get(@NotNull @NotNull net.minecraft.world.entity.Entity entity, @NotNull @NotNull String key, T defaultValue, @NotNull @NotNull Function<String, ? extends T> valueTransformer)
      Gets the value of an option for the given entity, runs it through the given valueTransformer, and falls back to the defaultValue if nothing is returned.

      If nothing is returned from the provider, the defaultValue is returned. (the transformer will never be passed a null argument)

      The transformer is allowed to throw IllegalArgumentException or return null. This will also result in the defaultValue being returned.

      For example, to parse and return an integer meta value, use:

          get(entity, "my-int-value", 0, Integer::parseInt);
      
      Type Parameters:
      T - the type of the transformed result
      Parameters:
      entity - the entity
      key - the option key
      defaultValue - the default value
      valueTransformer - the transformer used to transform the value
      Returns:
      the transformed option value
    • get

      @NotNull static @NotNull CompletableFuture<Optional<String>> get(@NotNull @NotNull UUID uuid, @NotNull @NotNull String key)
      Gets the value of an option for the given (potentially) offline player.
      Parameters:
      uuid - the uuid of the player
      key - the option key
      Returns:
      the option value
    • get

      @Contract("_, _, !null -> !null") static CompletableFuture<String> get(@NotNull @NotNull UUID uuid, @NotNull @NotNull String key, String defaultValue)
      Gets the value of an option for the given player, falling back to the defaultValue if nothing is returned from the provider.
      Parameters:
      uuid - the uuid of the player
      key - the option key
      defaultValue - the default value to use if nothing is returned
      Returns:
      the option value
    • get

      @NotNull static <T> @NotNull CompletableFuture<Optional<T>> get(@NotNull @NotNull UUID uuid, @NotNull @NotNull String key, @NotNull @NotNull Function<String, ? extends T> valueTransformer)
      Gets the value of an option for the given player, and runs it through the given valueTransformer.

      If nothing is returned from the provider, an empty optional is returned. (the transformer will never be passed a null argument)

      The transformer is allowed to throw IllegalArgumentException or return null. This will also result in an empty optional being returned.

      For example, to parse and return an integer meta value, use:

          get(uuid, "my-int-value", Integer::parseInt).orElse(0);
      
      Type Parameters:
      T - the type of the transformed result
      Parameters:
      uuid - the uuid of the player
      key - the option key
      valueTransformer - the transformer used to transform the value
      Returns:
      the transformed option value
    • get

      @Contract("_, _, !null, _ -> !null") static <T> CompletableFuture<T> get(@NotNull @NotNull UUID uuid, @NotNull @NotNull String key, T defaultValue, @NotNull @NotNull Function<String, ? extends T> valueTransformer)
      Gets the value of an option for the given player, runs it through the given valueTransformer, and falls back to the defaultValue if nothing is returned.

      If nothing is returned from the provider, the defaultValue is returned. (the transformer will never be passed a null argument)

      The transformer is allowed to throw IllegalArgumentException or return null. This will also result in the defaultValue being returned.

      For example, to parse and return an integer meta value, use:

          get(uuid, "my-int-value", 0, Integer::parseInt);
      
      Type Parameters:
      T - the type of the transformed result
      Parameters:
      uuid - the uuid of the player
      key - the option key
      defaultValue - the default value
      valueTransformer - the transformer used to transform the value
      Returns:
      the transformed option value
    • get

      @NotNull static @NotNull CompletableFuture<Optional<String>> get(@NotNull @NotNull com.mojang.authlib.GameProfile profile, @NotNull @NotNull String key)
      Gets the value of an option for the given (potentially) offline player.
      Parameters:
      profile - the player profile
      key - the option key
      Returns:
      the option value
    • get

      @Contract("_, _, !null -> !null") static CompletableFuture<String> get(@NotNull @NotNull com.mojang.authlib.GameProfile profile, @NotNull @NotNull String key, String defaultValue)
      Gets the value of an option for the given player, falling back to the defaultValue if nothing is returned from the provider.
      Parameters:
      profile - the player profile
      key - the option key
      defaultValue - the default value to use if nothing is returned
      Returns:
      the option value
    • get

      @NotNull static <T> @NotNull CompletableFuture<Optional<T>> get(@NotNull @NotNull com.mojang.authlib.GameProfile profile, @NotNull @NotNull String key, @NotNull @NotNull Function<String, ? extends T> valueTransformer)
      Gets the value of an option for the given player, and runs it through the given valueTransformer.

      If nothing is returned from the provider, an empty optional is returned. (the transformer will never be passed a null argument)

      The transformer is allowed to throw IllegalArgumentException or return null. This will also result in an empty optional being returned.

      For example, to parse and return an integer meta value, use:

          get(uuid, "my-int-value", Integer::parseInt).orElse(0);
      
      Type Parameters:
      T - the type of the transformed result
      Parameters:
      profile - the player profile
      key - the option key
      valueTransformer - the transformer used to transform the value
      Returns:
      the transformed option value
    • get

      @Contract("_, _, !null, _ -> !null") static <T> CompletableFuture<T> get(@NotNull @NotNull com.mojang.authlib.GameProfile profile, @NotNull @NotNull String key, T defaultValue, @NotNull @NotNull Function<String, ? extends T> valueTransformer)
      Gets the value of an option for the given player, runs it through the given valueTransformer, and falls back to the defaultValue if nothing is returned.

      If nothing is returned from the provider, the defaultValue is returned. (the transformer will never be passed a null argument)

      The transformer is allowed to throw IllegalArgumentException or return null. This will also result in the defaultValue being returned.

      For example, to parse and return an integer meta value, use:

          get(uuid, "my-int-value", 0, Integer::parseInt);
      
      Type Parameters:
      T - the type of the transformed result
      Parameters:
      profile - the player profile
      key - the option key
      defaultValue - the default value
      valueTransformer - the transformer used to transform the value
      Returns:
      the transformed option value
    • get

      @NotNull static @NotNull CompletableFuture<Optional<String>> get(@NotNull @NotNull net.minecraft.server.players.NameAndId entry, @NotNull @NotNull String key)
      Gets the value of an option for the given (potentially) offline player.
      Parameters:
      entry - the player config entry
      key - the option key
      Returns:
      the option value
    • get

      @Contract("_, _, !null -> !null") static CompletableFuture<String> get(@NotNull @NotNull net.minecraft.server.players.NameAndId entry, @NotNull @NotNull String key, String defaultValue)
      Gets the value of an option for the given player, falling back to the defaultValue if nothing is returned from the provider.
      Parameters:
      entry - the player config entry
      key - the option key
      defaultValue - the default value to use if nothing is returned
      Returns:
      the option value
    • get

      @NotNull static <T> @NotNull CompletableFuture<Optional<T>> get(@NotNull @NotNull net.minecraft.server.players.NameAndId entry, @NotNull @NotNull String key, @NotNull @NotNull Function<String, ? extends T> valueTransformer)
      Gets the value of an option for the given player, and runs it through the given valueTransformer.

      If nothing is returned from the provider, an empty optional is returned. (the transformer will never be passed a null argument)

      The transformer is allowed to throw IllegalArgumentException or return null. This will also result in an empty optional being returned.

      For example, to parse and return an integer meta value, use:

          get(uuid, "my-int-value", Integer::parseInt).orElse(0);
      
      Type Parameters:
      T - the type of the transformed result
      Parameters:
      entry - the player config entry
      key - the option key
      valueTransformer - the transformer used to transform the value
      Returns:
      the transformed option value
    • get

      @Contract("_, _, !null, _ -> !null") static <T> CompletableFuture<T> get(@NotNull @NotNull net.minecraft.server.players.NameAndId entry, @NotNull @NotNull String key, T defaultValue, @NotNull @NotNull Function<String, ? extends T> valueTransformer)
      Gets the value of an option for the given player, runs it through the given valueTransformer, and falls back to the defaultValue if nothing is returned.

      If nothing is returned from the provider, the defaultValue is returned. (the transformer will never be passed a null argument)

      The transformer is allowed to throw IllegalArgumentException or return null. This will also result in the defaultValue being returned.

      For example, to parse and return an integer meta value, use:

          get(uuid, "my-int-value", 0, Integer::parseInt);
      
      Type Parameters:
      T - the type of the transformed result
      Parameters:
      entry - the player config entry
      key - the option key
      defaultValue - the default value
      valueTransformer - the transformer used to transform the value
      Returns:
      the transformed option value