Help with configurate-yaml

Hi, I am trying to use Configurate-YAML in Spigot, but I am having trouble doing so.

Here is my code:

package org.example;

import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
import org.spongepowered.configurate.CommentedConfigurationNode;
import org.spongepowered.configurate.loader.ConfigurationLoader;
import org.spongepowered.configurate.yaml.YamlConfigurationLoader;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;

public class Main extends JavaPlugin {

    //config files
    public File testFile;
    public CommentedConfigurationNode test;
    public ConfigurationLoader<CommentedConfigurationNode> testLoader;

    public void onEnable() {
        try {
            registerConfigFiles();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }

        Bukkit.getConsoleSender().sendMessage(test.node("test").getString());
    }

    public void registerConfigFiles() throws IOException {
        if(!getDataFolder().exists()) {
            getDataFolder().mkdirs();
        }

        //test file
        testFile = new File(getDataFolder(), "/test.yml");
        testLoader = YamlConfigurationLoader.builder().file(testFile).build();

        if(!testFile.exists()) {
            InputStream in = getClass().getResourceAsStream("/test.yml");
            if(in != null) {
                Files.copy(in, testFile.toPath());
            }
        }
        test = testLoader.load();
    }
}

When I start my Spigot server, I get this error in the console:

[17:27:44 INFO]: [ConfigurateYamlTest] Enabling ConfigurateYamlTest v22.0
[17:27:44 ERROR]: Error occurred while enabling ConfigurateYamlTest v22.0 (Is it up to date?)
java.lang.NoSuchMethodError: org.yaml.snakeyaml.parser.ParserImpl.<init>(Lorg/yaml/snakeyaml/scanner/Scanner;)V
        at org.spongepowered.configurate.yaml.ConfigurateYaml.loadConfigurate(ConfigurateYaml.java:36) ~[?:?]
        at org.spongepowered.configurate.yaml.YamlConfigurationLoader.loadInternal(YamlConfigurationLoader.java:158) ~[?:?]
        at org.spongepowered.configurate.yaml.YamlConfigurationLoader.loadInternal(YamlConfigurationLoader.java:42) ~[?:?]
        at org.spongepowered.configurate.loader.AbstractConfigurationLoader.load(AbstractConfigurationLoader.java:155) ~[?:?]
        at org.spongepowered.configurate.loader.AbstractConfigurationLoader.load(AbstractConfigurationLoader.java:63) ~[?:?]
        at org.spongepowered.configurate.loader.ConfigurationLoader.load(ConfigurationLoader.java:56) ~[?:?]
        at org.example.Main.registerConfigFiles(Main.java:46) ~[?:?]
        at org.example.Main.onEnable(Main.java:23) ~[?:?]
        at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:321) ~[spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-21fe707-741a1bd]
        at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:340) [spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-21fe707-741a1bd]
        at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:405) [spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-21fe707-741a1bd]
        at org.bukkit.craftbukkit.v1_8_R3.CraftServer.loadPlugin(CraftServer.java:357) [spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-21fe707-741a1bd]
        at org.bukkit.craftbukkit.v1_8_R3.CraftServer.enablePlugins(CraftServer.java:317) [spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-21fe707-741a1bd]
        at net.minecraft.server.v1_8_R3.MinecraftServer.s(MinecraftServer.java:414) [spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-21fe707-741a1bd]
        at net.minecraft.server.v1_8_R3.MinecraftServer.k(MinecraftServer.java:378) [spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-21fe707-741a1bd]
        at net.minecraft.server.v1_8_R3.MinecraftServer.a(MinecraftServer.java:333) [spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-21fe707-741a1bd]
        at net.minecraft.server.v1_8_R3.DedicatedServer.init(DedicatedServer.java:263) [spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-21fe707-741a1bd]
        at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:525) [spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-21fe707-741a1bd]
        at java.lang.Thread.run(Thread.java:750) [?:1.8.0_352]
[17:27:44 INFO]: Done (19,555s)! For help, type "help" or "?"

What am I doing wrong? Thanks in advance.

Hey this the sponge forums. For bukkit help, take a look at the spigot forums

1 Like

And the spigot forum will tell me to come here because Configurate was developed by Sponge. Infinite loop?

The Snakeyaml version used by configurate and the one included by Spigot are different. This may be the cause of your issue. I suggest shading and relocating Configurate and Snakeyaml into your plugin.

Dont know why you got redirected back to here as its now in paper. But as Yeregorix said, thats probably the issue whereby the version your depending on is newer then the one provided by paper. Even if you include the newer version with your plugin it will load the paper version first, ignoring yours.

So you need to shade and relocate the configuration. That essentially means it puts the library in a different package.