Class PetConfigLookup

java.lang.Object
de.Keyle.MyPet.api.config.PetConfigLookup

public final class PetConfigLookup extends Object
Resolves per-pet config values from a runtime Class<? extends Pet> reference — the form marker interfaces (PetFlyingEntity.canFly, PetSwimmingEntity.canSwim, etc.) need. Callers with a compile-time dependency on plugin pet classes should prefer the direct field reference (e.g. PetCreeper.ALLOW_LIGHTNING_POWER.get()) which gives typed access and skips the class-name parsing.

This class converts the pet class to its pet-type name (stripping the "Pet" prefix from the simple name) and delegates to ConfigKeyRegistry, which transitively loads every pet class on first call so all keys are registered before any read.

  • Method Details

    • boolValue

      public static boolean boolValue(Class<? extends Pet> petClass, String key, boolean fallback)
      Returns the boolean value for (petClass, key) from the registry, or fallback if no such key is registered (e.g. a third-party pet that hasn't declared this flag).
      Parameters:
      petClass - the pet class to resolve against
      key - the key's short name
      fallback - returned when the key is absent
      Returns:
      the configured value, or fallback
    • configItemValue

      public static ConfigItem configItemValue(Class<? extends Pet> petClass, String key)
      Returns the ConfigItem for (petClass, key), or null if no such key is registered.
      Parameters:
      petClass - the pet class to resolve against
      key - the key's short name
      Returns:
      the configured item, or null if the key is absent