0

Basically, I am writing an addon for a Minecraft mod called Aura Cascade. Aura Cascade adds aura (as the name suggests), which comes in different colors. I wanted to add some colors of aura, but the valid colors are defined in an enum like this:

public enum EnumAura{WHITE,BLACK,RED,ORANGE,YELLOW,GREEN,BLUE,PURPLE}

How would I add values to EnumAura at runtime?

To clarify, all of my code must run after Aura Cascade is initialized.

Chris J.
  • 1
  • 2
  • 4
    You can't. They're are all basically final values behind the scenes, [for reference](http://stackoverflow.com/questions/478403/can-i-add-and-remove-elements-of-enumeration-at-runtime-in-java) – Andrew Li Jul 04 '16 at 14:26
  • First answer in google [DUPLICATED]: http://stackoverflow.com/questions/478403/can-i-add-and-remove-elements-of-enumeration-at-runtime-in-java – Ami Hollander Jul 04 '16 at 14:29
  • An `enum` is a list of all possible values known at compile time. – Peter Lawrey Jul 04 '16 at 15:43
  • I know normally you can't, but I wanted to be sure that there isn't some way to do it through reflection or some method forge provides before considering it impossible. – Chris J. Jul 05 '16 at 22:12

1 Answers1

1

if I understand your question correctly, you can't do that.

Please take a look to Java documentation about Enums : https://docs.oracle.com/javase/tutorial/java/javaOO/enum.html

Enum Types

An enum type is a special data type that enables for a variable to be a set of predefined constants. The variable must be equal to one of the values that have been predefined for it. Common examples include compass directions (values of NORTH, SOUTH, EAST, and WEST) and the days of the week.

Because they are constants, the names of an enum type's fields are in uppercase letters.

In the Java programming language, you define an enum type by using the enum keyword. For example, you would specify a days-of-the-week enum type as:

public enum Day {
 SUNDAY, MONDAY, TUESDAY, WEDNESDAY,
 THURSDAY, FRIDAY, SATURDAY  } 

You should use enum types any time you need to represent a fixed set of constants. That includes natural enum types such as the planets in our solar system and data sets where you know all possible values at compile time—for example, the choices on a menu, command line flags, and so on.

Mickael
  • 4,458
  • 2
  • 28
  • 40