From 9ef4aafb553a17e44b2277174b1f6826f5762991 Mon Sep 17 00:00:00 2001 From: SeanOMik Date: Mon, 2 Nov 2020 18:08:54 -0600 Subject: [PATCH] Fix a crash on some machines --- pom.xml | 2 +- src/main/java/net/seanomik/tamablefoxes/TamableFoxes.java | 4 ++-- .../net/seanomik/tamablefoxes/io/sqlite/SQLiteHandler.java | 7 +++---- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/pom.xml b/pom.xml index 5b4a3ed..150e4ea 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ net.seanomik tamablefoxes - 1.7.8-SNAPSHOT + 1.7.9-SNAPSHOT jar Tamablefoxes diff --git a/src/main/java/net/seanomik/tamablefoxes/TamableFoxes.java b/src/main/java/net/seanomik/tamablefoxes/TamableFoxes.java index fedd2b7..1c2f9bf 100644 --- a/src/main/java/net/seanomik/tamablefoxes/TamableFoxes.java +++ b/src/main/java/net/seanomik/tamablefoxes/TamableFoxes.java @@ -15,8 +15,8 @@ import org.bukkit.plugin.java.JavaPlugin; // @TODO: -/* @CHANGELOG (1.7.8-SNAPSHOT): - * Add a permission to allow players to bypass the tame limit. +/* @CHANGELOG (1.7.9-SNAPSHOT): + * Fix some crashes and errors with the sqlite database failing to be found. */ public final class TamableFoxes extends JavaPlugin implements Listener { private static TamableFoxes plugin; diff --git a/src/main/java/net/seanomik/tamablefoxes/io/sqlite/SQLiteHandler.java b/src/main/java/net/seanomik/tamablefoxes/io/sqlite/SQLiteHandler.java index 33f8f98..5449e25 100644 --- a/src/main/java/net/seanomik/tamablefoxes/io/sqlite/SQLiteHandler.java +++ b/src/main/java/net/seanomik/tamablefoxes/io/sqlite/SQLiteHandler.java @@ -1,5 +1,6 @@ package net.seanomik.tamablefoxes.io.sqlite; +import net.seanomik.tamablefoxes.TamableFoxes; import org.bukkit.Bukkit; import java.sql.Connection; @@ -21,10 +22,8 @@ public class SQLiteHandler { public void connect() { try { - String baseLoc = Bukkit.getWorldContainer().toURI().toString().substring(6); - baseLoc = baseLoc.substring(0,baseLoc.length()-2); - - String url = "jdbc:sqlite:" + baseLoc + "plugins/Tamablefoxes/userFoxAmount.db"; + String pluginFolder = TamableFoxes.getPlugin().getDataFolder().getAbsolutePath(); + String url = "jdbc:sqlite:" + pluginFolder + "/userFoxAmount.db"; connection = DriverManager.getConnection(url); } catch (SQLException e) {