Jump to content

Creating Forge Modpack: Exception message: java.lang.ClassNotFoundException: org.yaml.snakeyaml.DumperOptions


Recommended Posts

I am currently trying to make a mod with a database using SnakeYAML. I am currently using VSCODE, Minecraft forge version 1.19, and Forge Gradle. I was previously trying to use SQLite, but had the same error so I switched to Snake.

I have experience with Java, but no experience with SnakeYAML or Minecraft modding so let me know if I'm missing something.

I have cleaned and rebuilt multiple times.  I have also assured that SnakeYAML is being built into the .jar, which it is (It is listed as a dependency for the jar when built.)

Exception message: java.lang.ClassNotFoundException: org.yaml.snakeyaml.DumperOptions

DatabaseManager (where I intialize the SnakeYAML class):

package me.cadenwolfdog.furclasses.Data;

import me.cadenwolfdog.furclasses.PlayerClass;
import org.yaml.snakeyaml.DumperOptions;
import org.yaml.snakeyaml.Yaml;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

public class DatabaseManager {
    private static final File configFile = new File("mods/FurClasses/players.yaml");
    private static final DumperOptions options = new DumperOptions();
    private static final Yaml yaml = new Yaml(options);

    private static final Map<UUID, PlayerClass> playerData = new HashMap<>();
    

    public static void initializeDatabase() {
        configFile.getParentFile().mkdirs();

        if (!configFile.exists()) {
            try {
                configFile.createNewFile();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }


    public static void setPlayerClass(UUID playerUUID, PlayerClass playerClass) {
        playerData.put(playerUUID, playerClass);

        try (FileWriter writer = new FileWriter(configFile)) {
            yaml.dump(playerData, writer);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }


    public static PlayerClass getPlayerClass(UUID playerUUID) {
        return playerData.get(playerUUID);
    }
}

The common set up where I am running the database initialization:

private void commonSetup(final FMLCommonSetupEvent event) {
        // Some common setup code
        LOGGER.info("HELLO FROM COMMON SETUP");
        try{
            DatabaseManager.initializeDatabase();
        }catch (Exception e){
            LOGGER.info("EXCEPTION MADE: " + e.toString());
        }
        finally {
            LOGGER.info("Database initialization successful.");
        }
    }
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.