Delete Level.java
This commit is contained in:
@@ -1,58 +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 Level extends DataBasePrison4Life {
|
|
||||||
private PreparedStatement state;
|
|
||||||
private ResultSet r_set;
|
|
||||||
private Prisoner me;
|
|
||||||
private Score score;
|
|
||||||
Level(Prisoner prisoner) { me = prisoner; }
|
|
||||||
|
|
||||||
public Score getScore() throws SQLException {
|
|
||||||
setInResUUID();
|
|
||||||
if(r_set.first())
|
|
||||||
return this.score;
|
|
||||||
disconnect();
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getLevel() throws SQLException, NullPointerException {
|
|
||||||
setInResUUID();
|
|
||||||
if(r_set.first()) {
|
|
||||||
r_set = state.executeQuery("SELECT LEVEL FROM PLAYERS_LEVEL WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
|
||||||
if(r_set.first())
|
|
||||||
return r_set.getDouble(1);
|
|
||||||
}
|
|
||||||
disconnect();
|
|
||||||
return NullPointerException.class.hashCode();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addLevel(double value) throws SQLException, NullPointerException {
|
|
||||||
setInResUUID();
|
|
||||||
if(r_set.first())
|
|
||||||
state.execute("UPDATE PLAYERS_LEVEL SET LEVEL = " + (getLevel() + value) + " WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
|
||||||
disconnect();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLevel(double value) throws SQLException, NullPointerException {
|
|
||||||
setInResUUID();
|
|
||||||
if(r_set.first())
|
|
||||||
state.execute("UPDATE PLAYERS_LEVEL SET LEVEL = " + value + " WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
|
||||||
}
|
|
||||||
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user