Fix compatibility with CraftBukkit

Still recommend Spigot, for what it's worth
This commit is contained in:
Dan Mulloy 2019-12-26 11:39:23 -05:00
parent 1a434e9ea2
commit 22c2a4abcc
No known key found for this signature in database
GPG Key ID: 2B62F7DACFF133E8
1 changed files with 6 additions and 2 deletions

View File

@ -50,6 +50,7 @@ public class BukkitCloner implements Cloner {
} catch (RuntimeException ignored) { }
}
@SuppressWarnings({"unchecked", "rawtypes"})
private static void fromConverter(Supplier<Class<?>> getClass, EquivalentConverter converter) {
try {
Class<?> nmsClass = getClass.get();
@ -80,9 +81,12 @@ public class BukkitCloner implements Cloner {
fromManual(MinecraftReflection::getNonNullListClass, source -> nonNullListCloner().clone(source));
fromWrapper(MinecraftReflection::getNBTBaseClass, NbtFactory::fromNMS);
fromWrapper(MinecraftReflection::getIChatBaseComponentClass, WrappedChatComponent::fromHandle);
fromManual(ComponentConverter::getBaseComponentArrayClass, source ->
ComponentConverter.clone((BaseComponent[]) source));
fromWrapper(WrappedVillagerData::getNmsClass, WrappedVillagerData::fromHandle);
try {
fromManual(ComponentConverter::getBaseComponentArrayClass, source ->
ComponentConverter.clone((BaseComponent[]) source));
} catch (Throwable ignored) { }
}
private Function<Object, Object> findCloner(Class<?> type) {