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.");
}
}