[Solved] Test if Class is TextColor

This doesn’t get triggered:

if (clazz.isInstance(TextColor.class)) {

}

Why does
org.spongepowered.api.text.format.TextColor
become
org.spongepowered.common.text.format.SpongeTextColor
when you run the plugin?

Because TextColor is an interface. I’m not at all sure why you’re trying to check whether a class is assignable from instead of a simple instanceof check. But even then, you have the default TextColors class containing the instances of the various default supported colors. So, perhaps a better question is: Why are you checking if something is assignable?

Sorry. I meant isInstance.
I’m making a method that converts a string (that is read from a config file) into an object of the class that is given via the parameters of the method.

Use

TextColor.class.isAssignableFrom(clazz)

isInstance tests if an object is an instance of the class, but you’re wanting to test if the class is of the type TextColor correct?

Yes. Thank you (again) :smile: