Unicopia/src/main/java/com/minelittlepony/unicopia/spell/SpellAffinity.java
2019-03-11 20:50:32 +02:00

63 lines
1.4 KiB
Java

package com.minelittlepony.unicopia.spell;
import net.minecraft.util.text.TextFormatting;
public enum SpellAffinity {
GOOD(TextFormatting.BLUE, -1),
NEUTRAL(TextFormatting.WHITE, 0),
BAD(TextFormatting.RED, 1);
private final TextFormatting color;
private final int corruption;
private SpellAffinity[] implications;
SpellAffinity(TextFormatting color, int corruption) {
this.color = color;
this.corruption = corruption;
}
public TextFormatting getColourCode() {
return color;
}
public String getTranslationKey() {
return this == BAD ? "curse" : "spell";
}
public String getUnlocalizedName() {
return "affinity." + getTranslationKey() + ".name";
}
public int getCorruption() {
return corruption;
}
public boolean isNeutral() {
return this == NEUTRAL;
}
public SpellAffinity[] getImplicators() {
if (implications != null) {
return implications;
}
if (this == NEUTRAL) {
implications = values();
} else {
implications = new SpellAffinity[] { this };
}
return implications;
}
public static SpellAffinity of(String s) {
try {
if (s != null)
return valueOf(s.toUpperCase());
} catch (Throwable e) {}
return SpellAffinity.NEUTRAL;
}
}