Search in sources :

Example 1 with Registry

use of com.sk89q.worldedit.registry.Registry in project FastAsyncWorldEdit by IntellectualSites.

the class RegistryConverter method from.

@SuppressWarnings("unchecked")
private static <V extends Keyed> RegistryConverter<V> from(Class<Keyed> registryType) {
    try {
        Field registryField = registryType.getDeclaredField("REGISTRY");
        Registry<V> registry = (Registry<V>) registryField.get(null);
        return new RegistryConverter<>(registry);
    } catch (NoSuchFieldException e) {
        throw new IllegalArgumentException("Not a registry-backed type: " + registryType.getName());
    } catch (IllegalAccessException e) {
        throw new IllegalStateException("Registry field inaccessible on " + registryType.getName());
    }
}
Also used : Field(java.lang.reflect.Field) Registry(com.sk89q.worldedit.registry.Registry)

Aggregations

Registry (com.sk89q.worldedit.registry.Registry)1 Field (java.lang.reflect.Field)1