Closed mooziii closed 2 years ago
there are TextColors and TextDecorations in KColors now, so I'd suggest making two methods. And you'd have to add a type check as you'll get a ClassCastException in your current method.
btw it can be done with streams:
return Arrays.stream(KColors.class.getFields())
.filter(field -> field.getType() == TextColor.class)
.map(field -> {
try {
return (TextColor) field.get(null);
} catch (IllegalArgumentException | IllegalAccessException ignored) {
return null;
}
})
.filter(Objects::nonNull)
.collect(Collectors.toList());
although I guess that this will be a lot slower because of the low amount of fields
bump?
Would be nice to have this e.g to get random colors