diff --git a/src/main/java/ru/prisonlife/template/Wallet.java b/src/main/java/ru/prisonlife/template/Wallet.java deleted file mode 100644 index aed2f2c..0000000 --- a/src/main/java/ru/prisonlife/template/Wallet.java +++ /dev/null @@ -1,60 +0,0 @@ -package ru.prisonlife.PrisonAPI.template; - -import ru.prisonlife.PrisonAPI.connect.DataBasePrison4Life; - -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; - -public class Wallet extends DataBasePrison4Life { - private PreparedStatement state; - private ResultSet r_set; - private Prisoner me; - Wallet(Prisoner prisoner) { me = prisoner; } - - public int getBalance() throws SQLException { - setInResUUID(); - if(r_set.first()) { - r_set = state.executeQuery("SELECT WALLET FROM ECONOMY WHERE UUID = '" + me.getPlayer().getUniqueId() + "'"); - if(r_set.first()) { - return r_set.getInt(1); - } - disconnect(); - } - return NullPointerException.class.hashCode(); - } - - public void addBalance(int value) throws SQLException { - setInResUUID(); - if(r_set.first()) { - state.execute("UPDATE ECONOMY SET WALLET = " + (getBalance() + value) + " WHERE UUID = '" + me.getPlayer().getUniqueId() + "'"); - disconnect(); - } - } - - public void deposit(int value) throws SQLException { - setInResUUID(); - if(r_set.first()) { - state.execute("UPDATE ECONOMY SET WALLET = " + (getBalance() - value) + " WHERE UUID = '" + me.getPlayer().getUniqueId() + "'"); - } - } - - public void setBalance(int value) throws SQLException { - setInResUUID(); - if(r_set.first()) { - state.execute("UPDATE ECONOMY SET WALLET = " + value + " WHERE UUID = '" + me.getPlayer().getUniqueId() + "'"); - disconnect(); - } - } - - private void setInResUUID() throws SQLException { - state = connection.prepareStatement("SELECT * UUID FROM ECONOMY WHERE UUID = ?;"); - state.setString(1, me.getPlayer().getUniqueId().toString()); - r_set = state.executeQuery("SELECT UUID FROM ECONOMY WHERE UUID = '" + me.getPlayer().getUniqueId() + "'"); - } - - private void disconnect() throws SQLException { - r_set.close(); - state.close(); - } -}