From 9959330e84a9332f72952af3b027e58aa741773e Mon Sep 17 00:00:00 2001 From: mooziii <63669478+mooziii@users.noreply.github.com> Date: Tue, 29 Mar 2022 20:53:51 +0200 Subject: [PATCH] Add values() to KColors --- .../java/net/axay/kspigot/chat/KColors.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/main/java/net/axay/kspigot/chat/KColors.java b/src/main/java/net/axay/kspigot/chat/KColors.java index 6112961f..2710ea03 100644 --- a/src/main/java/net/axay/kspigot/chat/KColors.java +++ b/src/main/java/net/axay/kspigot/chat/KColors.java @@ -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 { *
*/ public static final TextColor YELLOWGREEN = TextColor.color(154, 205, 50); + + public static List values() { + Field[] fields = KColors.class.getFields(); + List 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; + } }