Add values() to KColors

This commit is contained in:
mooziii
2022-03-29 20:53:51 +02:00
parent faaa11d83d
commit 9959330e84

View File

@@ -3,6 +3,13 @@ package net.axay.kspigot.chat;
import net.kyori.adventure.text.format.TextColor;
import net.kyori.adventure.text.format.TextDecoration;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
@SuppressWarnings("unused")
public class KColors {
public static final TextDecoration MAGIC = TextDecoration.OBFUSCATED;
@@ -731,4 +738,15 @@ public class KColors {
* <div style="width:120px;height:120px;background-color:#9ACD32"></div>
*/
public static final TextColor YELLOWGREEN = TextColor.color(154, 205, 50);
public static List<TextColor> values() {
Field[] fields = KColors.class.getFields();
List<TextColor> finalList = new ArrayList<>(); //yes this could be done with a simple Arrays.stream but didn't work because java is stupid (because of the exception)
for (Field field : fields) {
try {
finalList.add((TextColor) field.get(null));
} catch (IllegalAccessException ignored) {}
}
return finalList;
}
}