Skip to content
Kiooeht edited this page Feb 14, 2018 · 2 revisions

The @SpireEnum annotation allows a mod to add new values to existing enums in Slay The Spire.

This is done by marking any static field with the @SpireEnum annotation. The type of the field must be the enum type you want to add a value to and the field name will be the name of the new enum value.

Note: A new enum value cannot be defined inside a class deriving from the class that defines the enum.

public class Foo
{
    @SpireEnum
    public static AbstractPlayer.PlayerClass EXAMPLE_CHARACTER;
}

public class ExampleCharacter extends AbstractPlayer
{
    // ...

    static void foo(AbstractPlayer.PlayerClass playerClass)
    {
        // Prints "[IRONCLAD, THE_SILENT, CROWBOT, EXAMPLE_CHARACTER]"
        System.out.println(Arrays.toString(AbstractPlayer.PlayerClass.values()));

        switch (playerClass) {
            case AbstractPlayer.PlayerClass.IRONCLAD:
                // ...
                break;
            case AbstractPlayer.PlayerClass.THE_SILENT:
                // ...
                break;
            case AbstractPlayer.PlayerClass.CROWBOT:
                // ...
                break;
            case Foo.EXAMPLE_CHARACTER:
                // ...
                break;
        }
    }
}