Shynixn / MCCoroutine

MCCoroutine is a library, which adds extensive support for Kotlin Coroutines for Minecraft Server environments.
Other
211 stars 19 forks source link

Can only work on spigot #8

Closed Itsusinn closed 4 years ago

Itsusinn commented 4 years ago

This article is translated by Google

When using mc-coroutine on my paper server It crashed (plugin activation failed

After viewing the error message

I think a field called pluginParentTimer is causing this problem This field exists in org.bukkit.plugin.java.JavaPluginLoader

Let's take a look at the implementation of JavaPluginLoader on spigot

public final class JavaPluginLoader implements PluginLoader {
    final Server server;
    private final Pattern[] fileFilters = new Pattern[]{Pattern.compile("\\.jar$")};
    private final Map<String, Class<?>> classes = new ConcurrentHashMap<String, Class<?>>();
    private final List<PluginClassLoader> loaders = new CopyOnWriteArrayList<PluginClassLoader>();
    public static final CustomTimingsHandler pluginParentTimer = new CustomTimingsHandler("** Plugins"); // Spigot
}

on paper

public final class JavaPluginLoader implements PluginLoader {
    final Server server;
    private static final boolean DISABLE_CLASS_PRIORITIZATION = Boolean.getBoolean("Paper.DisableClassPrioritization"); // Paper
    private final Pattern[] fileFilters = new Pattern[]{Pattern.compile("\\.jar$")};
    private final Map<String, Class<?>> classes = new ConcurrentHashMap<String, Class<?>>();
    private final Map<String, java.util.concurrent.locks.ReentrantReadWriteLock> classLoadLock = new java.util.HashMap<String, java.util.concurrent.locks.ReentrantReadWriteLock>(); // Paper
    private final Map<String, Integer> classLoadLockCount = new java.util.HashMap<String, Integer>(); // Paper
    private final List<PluginClassLoader> loaders = new CopyOnWriteArrayList<PluginClassLoader>();
}

So JavaPluginLoader.pluginParentTimer is only defined on spigot But JavaPluginLoader.pluginParentTimer is used in line 134 in mccoroutine-bukkit-core/src/main/java/com/github/shynixn/mccoroutine/service/EventServiceImpl.kt

Shynixn commented 4 years ago

Hi @Itsusinn !

Thanks for pointing this out. I'll fix it.

Please notice that this project still needs to mature over time until I fully integrated it into my plugins. However, I appreciate feedback.