This commit is contained in:
SeanOMik 2022-05-08 15:48:18 -04:00
parent a705cdfaf4
commit fdd3641e2d
1 changed files with 7 additions and 2 deletions

View File

@ -1,6 +1,5 @@
package net.seanomik.tamablefoxes.util.io.sqlite; package net.seanomik.tamablefoxes.util.io.sqlite;
import net.seanomik.tamablefoxes.util.Utils;
import net.seanomik.tamablefoxes.util.io.Config; import net.seanomik.tamablefoxes.util.io.Config;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
@ -20,7 +19,7 @@ public class SQLiteHelper {
public static SQLiteHelper getInstance(Plugin plugin) { public static SQLiteHelper getInstance(Plugin plugin) {
if (instance == null) { if (instance == null) {
instance = new SQLiteHelper(); instance = new SQLiteHelper();
instance.plugin = plugin; SQLiteHelper.plugin = plugin;
} }
return instance; return instance;
@ -59,6 +58,8 @@ public class SQLiteHelper {
} }
public int getPlayerFoxAmount(UUID uuid) { public int getPlayerFoxAmount(UUID uuid) {
sqLiteHandler = SQLiteHandler.getInstance();
try { try {
sqLiteHandler.connect(plugin); sqLiteHandler.connect(plugin);
PreparedStatement statement = sqLiteHandler.getConnection() PreparedStatement statement = sqLiteHandler.getConnection()
@ -85,6 +86,8 @@ public class SQLiteHelper {
} }
public void addPlayerFoxAmount(UUID uuid, int amt) { public void addPlayerFoxAmount(UUID uuid, int amt) {
sqLiteHandler = SQLiteHandler.getInstance();
try { try {
String query = "UPDATE " + userAmountTableName + " SET AMOUNT = AMOUNT + " + amt + " WHERE UUID = '" + uuid.toString() + "'"; String query = "UPDATE " + userAmountTableName + " SET AMOUNT = AMOUNT + " + amt + " WHERE UUID = '" + uuid.toString() + "'";
if (getPlayerFoxAmount(uuid) == -1) { if (getPlayerFoxAmount(uuid) == -1) {
@ -109,6 +112,8 @@ public class SQLiteHelper {
} }
public void removePlayerFoxAmount(UUID uuid, int amt) { public void removePlayerFoxAmount(UUID uuid, int amt) {
sqLiteHandler = SQLiteHandler.getInstance();
try { try {
String query = "UPDATE " + userAmountTableName + " SET AMOUNT = AMOUNT - " + amt + " WHERE UUID = '" + uuid.toString() + "'"; String query = "UPDATE " + userAmountTableName + " SET AMOUNT = AMOUNT - " + amt + " WHERE UUID = '" + uuid.toString() + "'";