наименование методов и переменных
This commit is contained in:
@@ -14,7 +14,7 @@ import java.util.List;
|
||||
public class Faction {
|
||||
|
||||
private PreparedStatement state;
|
||||
private ResultSet r_set;
|
||||
private ResultSet resultSet;
|
||||
private Prisoner me;
|
||||
|
||||
Faction(Prisoner prisoner) {
|
||||
@@ -22,37 +22,37 @@ public class Faction {
|
||||
}
|
||||
|
||||
public String getType() throws SQLException {
|
||||
con_t();
|
||||
if (r_set.first()) {
|
||||
r_set = state.executeQuery("SELECT FACTION FROM player_stats WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||
if (r_set.first())
|
||||
return r_set.getString(1);
|
||||
connect();
|
||||
if (resultSet.first()) {
|
||||
resultSet = state.executeQuery("SELECT FACTION FROM player_stats WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||
if (resultSet.first())
|
||||
return resultSet.getString(1);
|
||||
}
|
||||
dis_t();
|
||||
disconnect();
|
||||
return "null";
|
||||
}
|
||||
|
||||
public int getId() throws SQLException {
|
||||
con_t();
|
||||
if (r_set.first()) {
|
||||
r_set = state.executeQuery("SELECT FACTION FROM player_stats WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||
if (r_set.first())
|
||||
connect();
|
||||
if (resultSet.first()) {
|
||||
resultSet = state.executeQuery("SELECT FACTION FROM player_stats WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||
if (resultSet.first())
|
||||
for (int i = 0; i < PrisonAPI.Factions.values().length; i++)
|
||||
if (PrisonAPI.Factions.values()[i].name().equals(r_set.getString(1)))
|
||||
if (PrisonAPI.Factions.values()[i].name().equals(resultSet.getString(1)))
|
||||
return i;
|
||||
}
|
||||
dis_t();
|
||||
disconnect();
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int getRangId() throws SQLException {
|
||||
con_t();
|
||||
if (r_set.first()) {
|
||||
r_set = state.executeQuery("SELECT F_RANG FROM player_stats WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||
if (r_set.first())
|
||||
return r_set.getInt(1);
|
||||
connect();
|
||||
if (resultSet.first()) {
|
||||
resultSet = state.executeQuery("SELECT F_RANG FROM player_stats WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||
if (resultSet.first())
|
||||
return resultSet.getInt(1);
|
||||
}
|
||||
dis_t();
|
||||
disconnect();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -66,71 +66,71 @@ public class Faction {
|
||||
}
|
||||
|
||||
public void addRang(int value) throws SQLException {
|
||||
con_t();
|
||||
if (r_set.first())
|
||||
connect();
|
||||
if (resultSet.first())
|
||||
state.execute("UPDATE player_stats SET F_RANG = " + (getRangId() + value) + " WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||
dis_t();
|
||||
disconnect();
|
||||
}
|
||||
|
||||
public void setRang(int value) throws SQLException {
|
||||
con_t();
|
||||
if (r_set.first())
|
||||
connect();
|
||||
if (resultSet.first())
|
||||
state.execute("UPDATE player_stats SET F_RANG = " + value + " WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||
dis_t();
|
||||
disconnect();
|
||||
}
|
||||
|
||||
public void setFaction(int id) throws SQLException {
|
||||
con_t();
|
||||
if (r_set.first())
|
||||
connect();
|
||||
if (resultSet.first())
|
||||
state.execute("UPDATE player_stats SET FACTION = '" + PrisonAPI.Factions.values()[id].name() + "' WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||
dis_t();
|
||||
disconnect();
|
||||
}
|
||||
|
||||
public int getRespect() throws SQLException {
|
||||
con_t();
|
||||
if (r_set.first()) {
|
||||
r_set = state.executeQuery("SELECT RESPECT FROM prison4life.player_stats WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||
if (r_set.first())
|
||||
return r_set.getInt(1);
|
||||
connect();
|
||||
if (resultSet.first()) {
|
||||
resultSet = state.executeQuery("SELECT RESPECT FROM prison4life.player_stats WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||
if (resultSet.first())
|
||||
return resultSet.getInt(1);
|
||||
}
|
||||
dis_t();
|
||||
disconnect();
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void addRespect(int value) throws SQLException {
|
||||
con_t();
|
||||
if (r_set.first())
|
||||
connect();
|
||||
if (resultSet.first())
|
||||
state.execute("UPDATE player_stats SET RESPECT = " + (getRespect() + value) + " WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||
dis_t();
|
||||
disconnect();
|
||||
}
|
||||
|
||||
public void setRespect(int value) throws SQLException {
|
||||
con_t();
|
||||
if (r_set.first())
|
||||
connect();
|
||||
if (resultSet.first())
|
||||
state.execute("UPDATE player_stats SET RESPECT = " + value + " WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||
dis_t();
|
||||
disconnect();
|
||||
}
|
||||
|
||||
public int getRespectDailyCooldown() throws SQLException {
|
||||
con_t();
|
||||
if (r_set.first())
|
||||
r_set = state.executeQuery("SELECT COOLDOWN FROM daily_respect_task WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||
if (r_set.first())
|
||||
return r_set.getInt(1);
|
||||
dis_t();
|
||||
connect();
|
||||
if (resultSet.first())
|
||||
resultSet = state.executeQuery("SELECT COOLDOWN FROM daily_respect_task WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||
if (resultSet.first())
|
||||
return resultSet.getInt(1);
|
||||
disconnect();
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void addRespectDailyCooldown(int value) throws SQLException {
|
||||
con_t();
|
||||
if (r_set.first())
|
||||
connect();
|
||||
if (resultSet.first())
|
||||
state.execute("UPDATE daily_respect_task SET COOLDOWN = " + (getRespectDailyCooldown() + value)
|
||||
+ " WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||
}
|
||||
|
||||
public void setRespectDailyCooldown(int value) throws SQLException {
|
||||
con_t();
|
||||
if (r_set.first())
|
||||
connect();
|
||||
if (resultSet.first())
|
||||
state.execute("UPDATE daily_respect_task SET COOLDOWN = " + value + " WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||
}
|
||||
|
||||
@@ -145,14 +145,14 @@ public class Faction {
|
||||
return list;
|
||||
}
|
||||
|
||||
private void con_t() throws SQLException {
|
||||
private void connect() throws SQLException {
|
||||
state = PrisonAPI.CONN.prepareStatement("SELECT * UUID FROM player_stats WHERE UUID = ?;");
|
||||
state.setString(1, me.getPlayer().getUniqueId().toString());
|
||||
r_set = state.executeQuery("SELECT UUID FROM player_stats WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||
resultSet = state.executeQuery("SELECT UUID FROM player_stats WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||
}
|
||||
|
||||
private void dis_t() throws SQLException {
|
||||
r_set.close();
|
||||
private void disconnect() throws SQLException {
|
||||
resultSet.close();
|
||||
state.close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import java.sql.SQLException;
|
||||
public class Level {
|
||||
|
||||
private PreparedStatement state;
|
||||
private ResultSet r_set;
|
||||
private ResultSet resultSet;
|
||||
private Prisoner me;
|
||||
private Score score;
|
||||
|
||||
@@ -19,46 +19,46 @@ public class Level {
|
||||
}
|
||||
|
||||
public Score getScore() throws SQLException {
|
||||
con_t();
|
||||
if (r_set.first())
|
||||
connect();
|
||||
if (resultSet.first())
|
||||
return this.score;
|
||||
dis_t();
|
||||
disconnect();
|
||||
return null;
|
||||
}
|
||||
|
||||
public double getLevel() throws SQLException, NullPointerException {
|
||||
con_t();
|
||||
if (r_set.first()) {
|
||||
r_set = state.executeQuery("SELECT LEVEL FROM player_stats WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||
if (r_set.first())
|
||||
return r_set.getDouble(1);
|
||||
connect();
|
||||
if (resultSet.first()) {
|
||||
resultSet = state.executeQuery("SELECT LEVEL FROM player_stats WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||
if (resultSet.first())
|
||||
return resultSet.getDouble(1);
|
||||
}
|
||||
dis_t();
|
||||
disconnect();
|
||||
return NullPointerException.class.hashCode();
|
||||
}
|
||||
|
||||
public void addLevel(double value) throws SQLException, NullPointerException {
|
||||
con_t();
|
||||
if (r_set.first())
|
||||
connect();
|
||||
if (resultSet.first())
|
||||
state.execute("UPDATE player_stats SET LEVEL = " + (getLevel() + value) + " WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||
dis_t();
|
||||
disconnect();
|
||||
}
|
||||
|
||||
public void setLevel(double value) throws SQLException, NullPointerException {
|
||||
con_t();
|
||||
if (r_set.first())
|
||||
connect();
|
||||
if (resultSet.first())
|
||||
state.execute("UPDATE player_stats SET LEVEL = " + value + " WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||
dis_t();
|
||||
disconnect();
|
||||
}
|
||||
|
||||
private void con_t() throws SQLException {
|
||||
private void connect() throws SQLException {
|
||||
state = PrisonAPI.CONN.prepareStatement("SELECT * UUID FROM player_stats WHERE UUID = ?;");
|
||||
state.setString(1, me.getPlayer().getUniqueId().toString());
|
||||
r_set = state.executeQuery("SELECT UUID FROM player_stats WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||
resultSet = state.executeQuery("SELECT UUID FROM player_stats WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||
}
|
||||
|
||||
private void dis_t() throws SQLException {
|
||||
r_set.close();
|
||||
private void disconnect() throws SQLException {
|
||||
resultSet.close();
|
||||
state.close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,72 +13,72 @@ import java.util.Objects;
|
||||
|
||||
public class Manager {
|
||||
|
||||
private File fi;
|
||||
private FileConfiguration cf;
|
||||
private File file;
|
||||
private FileConfiguration fileConfiguration;
|
||||
|
||||
public Manager(String id) {
|
||||
fi = new File("plugins/PrisonManager/", id);
|
||||
cf = YamlConfiguration.loadConfiguration(fi);
|
||||
file = new File("plugins/PrisonManager/", id);
|
||||
fileConfiguration = YamlConfiguration.loadConfiguration(file);
|
||||
}
|
||||
|
||||
public boolean contains() {
|
||||
return fi.exists();
|
||||
return file.exists();
|
||||
}
|
||||
|
||||
public String getWorld() {
|
||||
return cf.getString("WORLD");
|
||||
return fileConfiguration.getString("WORLD");
|
||||
}
|
||||
|
||||
public void setWorld(String name) {
|
||||
String p = "WORLD";
|
||||
cf.set(p, null);
|
||||
cf.set(p, name);
|
||||
fileConfiguration.set(p, null);
|
||||
fileConfiguration.set(p, name);
|
||||
try {
|
||||
cf.save(fi);
|
||||
fileConfiguration.save(file);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean getRebootStatus() {
|
||||
return cf.getBoolean("REBOOT_STATUS");
|
||||
return fileConfiguration.getBoolean("REBOOT_STATUS");
|
||||
}
|
||||
|
||||
public void setRebootStatus(boolean status) {
|
||||
cf.set("REBOOT_STATUS", status);
|
||||
fileConfiguration.set("REBOOT_STATUS", status);
|
||||
try {
|
||||
cf.save(fi);
|
||||
fileConfiguration.save(file);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public List<Integer> getSpawnCords(int faction) {
|
||||
return cf.getIntegerList("FACTIONS." + __selectFactType__(faction) + ".CORDS");
|
||||
return fileConfiguration.getIntegerList("FACTIONS." + selectFactType(faction) + ".CORDS");
|
||||
}
|
||||
|
||||
public void setSpawnCords(int faction, List<Integer> data) {
|
||||
String p = "FACTIONS." + __selectFactType__(faction) + ".CORDS";
|
||||
cf.set(p, null);
|
||||
cf.set(p, data);
|
||||
String p = "FACTIONS." + selectFactType(faction) + ".CORDS";
|
||||
fileConfiguration.set(p, null);
|
||||
fileConfiguration.set(p, data);
|
||||
try {
|
||||
cf.save(fi);
|
||||
fileConfiguration.save(file);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public List<Integer> getDiagonal() {
|
||||
return cf.getIntegerList("DIAGONAL_POINTS");
|
||||
return fileConfiguration.getIntegerList("DIAGONAL_POINTS");
|
||||
}
|
||||
|
||||
public void setDiagonal(List<Integer> data) {
|
||||
if (data.size() == 6) {
|
||||
String dp = "DIAGONAL_POINTS";
|
||||
cf.set(dp, null);
|
||||
cf.set(dp, data);
|
||||
fileConfiguration.set(dp, null);
|
||||
fileConfiguration.set(dp, data);
|
||||
try {
|
||||
cf.save(fi);
|
||||
fileConfiguration.save(file);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -93,7 +93,7 @@ public class Manager {
|
||||
|
||||
public int getGlobalNumTerr(int faction) {
|
||||
int num = 0;
|
||||
for (File prison : Objects.requireNonNull(fi.getParentFile().listFiles())) {
|
||||
for (File prison : Objects.requireNonNull(file.getParentFile().listFiles())) {
|
||||
Manager mng = new Manager(prison.getName());
|
||||
num += mng.getNumTerr(faction);
|
||||
}
|
||||
@@ -101,55 +101,55 @@ public class Manager {
|
||||
}
|
||||
|
||||
public int getNumTerr(int faction) {
|
||||
return cf.getInt("FACTIONS." + __selectFactType__(faction) + ".NUM_TERR");
|
||||
return fileConfiguration.getInt("FACTIONS." + selectFactType(faction) + ".NUM_TERR");
|
||||
}
|
||||
|
||||
public void setNumTerr(int faction, int value) {
|
||||
String p = "FACTIONS." + __selectFactType__(faction) + ".NUM_TERR";
|
||||
cf.set(p, null);
|
||||
cf.set(p, value);
|
||||
String p = "FACTIONS." + selectFactType(faction) + ".NUM_TERR";
|
||||
fileConfiguration.set(p, null);
|
||||
fileConfiguration.set(p, value);
|
||||
try {
|
||||
cf.save(fi);
|
||||
fileConfiguration.save(file);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public String getTerrOwner(String name) {
|
||||
return cf.getString("TERRITORIES." + name + ".OWNER");
|
||||
return fileConfiguration.getString("TERRITORIES." + name + ".OWNER");
|
||||
}
|
||||
|
||||
public void setTerrOwner(String name, String owner) {
|
||||
cf.set("TERRITORIES." + name + ".OWNER", owner);
|
||||
fileConfiguration.set("TERRITORIES." + name + ".OWNER", owner);
|
||||
try {
|
||||
cf.save(fi);
|
||||
fileConfiguration.save(file);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public String getTerrConqurer(String name) {
|
||||
return cf.getString("TERRITORIES." + name + ".CAPTURED");
|
||||
return fileConfiguration.getString("TERRITORIES." + name + ".CAPTURED");
|
||||
}
|
||||
|
||||
public void setTerrConqurer(String name, String status) {
|
||||
cf.set("TERRITORIES." + name + ".CAPTURED", status);
|
||||
fileConfiguration.set("TERRITORIES." + name + ".CAPTURED", status);
|
||||
try {
|
||||
cf.save(fi);
|
||||
fileConfiguration.save(file);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public List<String> getAllTerrs() {
|
||||
return new ArrayList<>(cf.getConfigurationSection("TERRITORIES").getKeys(false));
|
||||
return new ArrayList<>(fileConfiguration.getConfigurationSection("TERRITORIES").getKeys(false));
|
||||
}
|
||||
|
||||
public String __selectFactType__(int id) {
|
||||
public String selectFactType(int id) {
|
||||
return PrisonAPI.Factions.values()[id].name();
|
||||
}
|
||||
|
||||
public int __selectFactId__(String faction) {
|
||||
public int selectFactId(String faction) {
|
||||
return PrisonAPI.Factions.valueOf(faction).ordinal();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ public class Prisoner {
|
||||
private Wallet wallet;
|
||||
private Stats stats;
|
||||
private PreparedStatement state;
|
||||
private ResultSet r_set;
|
||||
private ResultSet resultSet;
|
||||
|
||||
public Prisoner(Player player) {
|
||||
me = player;
|
||||
@@ -44,13 +44,13 @@ public class Prisoner {
|
||||
public String getPrison() {
|
||||
Location loc = me.getLocation();
|
||||
for (File file : Objects.requireNonNull(new File(PLUGIN_PATH).listFiles())) {
|
||||
FileConfiguration c_ti = YamlConfiguration.loadConfiguration(file);
|
||||
FileConfiguration fileConfiguration = YamlConfiguration.loadConfiguration(file);
|
||||
List<List<Integer>> data = new ArrayList<>();
|
||||
List<Integer> from_cfg = c_ti.getIntegerList("DIAGONAL_POINTS"),
|
||||
List<Integer> fromConfig = fileConfiguration.getIntegerList("DIAGONAL_POINTS"),
|
||||
min = new ArrayList<>(), max = new ArrayList<>();
|
||||
int[] loc_n = {loc.getBlockX(), loc.getBlockY() - 1, loc.getBlockZ()};
|
||||
data.add(from_cfg.subList(0, 3));
|
||||
data.add(from_cfg.subList(3, 6));
|
||||
data.add(fromConfig.subList(0, 3));
|
||||
data.add(fromConfig.subList(3, 6));
|
||||
for (int i = 0; i < 3; i++) {
|
||||
min.add(Math.min(data.get(0).get(i), data.get(1).get(i)));
|
||||
max.add(Math.max(data.get(0).get(i), data.get(1).get(i)));
|
||||
@@ -68,19 +68,19 @@ public class Prisoner {
|
||||
}
|
||||
|
||||
public String getTerritory(String type) {
|
||||
String prs = getPrison();
|
||||
if (!prs.equals("Not Prison") && (type.equals("name") || type.equals("owner"))) {
|
||||
String prison = getPrison();
|
||||
if (!prison.equals("Not Prison") && (type.equals("name") || type.equals("owner"))) {
|
||||
Location loc = me.getLocation();
|
||||
FileConfiguration c_ti = YamlConfiguration.loadConfiguration(new File(PLUGIN_PATH, "PRISON_" + prs + ".yml"));
|
||||
FileConfiguration fileConfiguration = YamlConfiguration.loadConfiguration(new File(PLUGIN_PATH, "PRISON_" + prison + ".yml"));
|
||||
try {
|
||||
if (c_ti.getConfigurationSection("TERRITORIES").getKeys(false).size() != 0) {
|
||||
for (String terr : c_ti.getConfigurationSection("TERRITORIES").getKeys(false)) {
|
||||
if (fileConfiguration.getConfigurationSection("TERRITORIES").getKeys(false).size() != 0) {
|
||||
for (String terr : fileConfiguration.getConfigurationSection("TERRITORIES").getKeys(false)) {
|
||||
List<List<Integer>> data = new ArrayList<>();
|
||||
List<Integer> from_cfg = c_ti.getIntegerList("TERRITORIES." + terr + ".DIAGONAL_POINTS"),
|
||||
List<Integer> fromConfig = fileConfiguration.getIntegerList("TERRITORIES." + terr + ".DIAGONAL_POINTS"),
|
||||
min = new ArrayList<>(), max = new ArrayList<>();
|
||||
int[] loc_n = {loc.getBlockX(), loc.getBlockY() - 1, loc.getBlockZ()};
|
||||
data.add(from_cfg.subList(0, 3));
|
||||
data.add(from_cfg.subList(3, 6));
|
||||
data.add(fromConfig.subList(0, 3));
|
||||
data.add(fromConfig.subList(3, 6));
|
||||
for (int i = 0; i < 3; i++) {
|
||||
min.add(Math.min(data.get(0).get(i), data.get(1).get(i)));
|
||||
max.add(Math.max(data.get(0).get(i), data.get(1).get(i)));
|
||||
@@ -92,8 +92,8 @@ public class Prisoner {
|
||||
++c;
|
||||
}
|
||||
if (c == 3)
|
||||
return type.equals("name") ? c_ti.getString("TERRITORIES." + terr + ".NAME") :
|
||||
(type.equals("owner") ? c_ti.getString("TERRITORIES." + terr + ".OWNER") : null);
|
||||
return type.equals("name") ? fileConfiguration.getString("TERRITORIES." + terr + ".NAME") :
|
||||
(type.equals("owner") ? fileConfiguration.getString("TERRITORIES." + terr + ".OWNER") : null);
|
||||
}
|
||||
}
|
||||
} catch (NullPointerException z) {
|
||||
@@ -117,8 +117,8 @@ public class Prisoner {
|
||||
public void register() throws SQLException {
|
||||
state = PrisonAPI.CONN.prepareStatement("SELECT * UUID FROM player_stats WHERE UUID = ?;");
|
||||
state.setString(1, me.getUniqueId().toString());
|
||||
r_set = state.executeQuery("SELECT UUID FROM player_stats WHERE UUID = '" + me.getUniqueId() + "'");
|
||||
if (!r_set.next()) {
|
||||
resultSet = state.executeQuery("SELECT UUID FROM player_stats WHERE UUID = '" + me.getUniqueId() + "'");
|
||||
if (!resultSet.next()) {
|
||||
state.execute(
|
||||
"INSERT INTO player_stats(NAME, UUID, LEVEL, POINTS, FACTION, RESPECT, F_RANG, WALLET, G_TIME, D_BLOCKS, " +
|
||||
"K_PLAYERS, K_MOBS, DEATHS) VALUES (" + "'" + getPlayer().getName()
|
||||
@@ -128,7 +128,7 @@ public class Prisoner {
|
||||
stats = new Stats(this);
|
||||
wallet = new Wallet(this);
|
||||
}
|
||||
r_set.close();
|
||||
resultSet.close();
|
||||
state.close();
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,7 @@ import java.sql.SQLException;
|
||||
public class Score {
|
||||
|
||||
private PreparedStatement state;
|
||||
private ResultSet r_set;
|
||||
private ResultSet resultSet;
|
||||
private Prisoner me;
|
||||
|
||||
Score(Prisoner prisoner) {
|
||||
@@ -17,39 +17,39 @@ public class Score {
|
||||
}
|
||||
|
||||
public double getPoints() throws SQLException {
|
||||
con_t();
|
||||
if (r_set.first()) {
|
||||
r_set = state.executeQuery("SELECT POINTS FROM player_stats WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||
if (r_set.first()) {
|
||||
return r_set.getDouble(1);
|
||||
connect();
|
||||
if (resultSet.first()) {
|
||||
resultSet = state.executeQuery("SELECT POINTS FROM player_stats WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||
if (resultSet.first()) {
|
||||
return resultSet.getDouble(1);
|
||||
}
|
||||
}
|
||||
dis_t();
|
||||
disconnect();
|
||||
return NullPointerException.class.hashCode();
|
||||
}
|
||||
|
||||
public void setPoints(double value) throws SQLException {
|
||||
con_t();
|
||||
if (r_set.first())
|
||||
connect();
|
||||
if (resultSet.first())
|
||||
state.execute("UPDATE player_stats SET POINTS = " + value + " WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||
dis_t();
|
||||
disconnect();
|
||||
}
|
||||
|
||||
public void addPoints(double value) throws SQLException {
|
||||
con_t();
|
||||
if (r_set.first())
|
||||
connect();
|
||||
if (resultSet.first())
|
||||
state.execute("UPDATE player_stats SET POINTS = " + (getPoints() + value) + " WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||
dis_t();
|
||||
disconnect();
|
||||
}
|
||||
|
||||
private void con_t() throws SQLException {
|
||||
private void connect() throws SQLException {
|
||||
state = PrisonAPI.CONN.prepareStatement("SELECT * UUID FROM player_stats WHERE UUID = ?;");
|
||||
state.setString(1, me.getPlayer().getUniqueId().toString());
|
||||
r_set = state.executeQuery("SELECT UUID FROM player_stats WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||
resultSet = state.executeQuery("SELECT UUID FROM player_stats WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||
}
|
||||
|
||||
private void dis_t() throws SQLException {
|
||||
r_set.close();
|
||||
private void disconnect() throws SQLException {
|
||||
resultSet.close();
|
||||
state.close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import java.sql.SQLException;
|
||||
public class Stats {
|
||||
|
||||
private PreparedStatement state;
|
||||
private ResultSet r_set;
|
||||
private ResultSet resultSet;
|
||||
private Prisoner me;
|
||||
|
||||
Stats(Prisoner prisoner) {
|
||||
@@ -17,138 +17,138 @@ public class Stats {
|
||||
}
|
||||
|
||||
public void setServerTime(int value) throws SQLException {
|
||||
con_t();
|
||||
if (r_set.first())
|
||||
connect();
|
||||
if (resultSet.first())
|
||||
state.execute("UPDATE player_stats SET G_TIME = " + value + " WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||
dis_t();
|
||||
disconnect();
|
||||
}
|
||||
|
||||
public int getServerTime() throws SQLException {
|
||||
con_t();
|
||||
if (r_set.first()) {
|
||||
r_set = state.executeQuery("SELECT G_TIME FROM player_stats WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||
if (r_set.first())
|
||||
return r_set.getInt(1);
|
||||
connect();
|
||||
if (resultSet.first()) {
|
||||
resultSet = state.executeQuery("SELECT G_TIME FROM player_stats WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||
if (resultSet.first())
|
||||
return resultSet.getInt(1);
|
||||
}
|
||||
dis_t();
|
||||
disconnect();
|
||||
return NullPointerException.class.hashCode();
|
||||
}
|
||||
|
||||
public void addServerTime(int value) throws SQLException {
|
||||
con_t();
|
||||
if (r_set.first())
|
||||
connect();
|
||||
if (resultSet.first())
|
||||
state.execute("UPDATE player_stats SET G_TIME = " + (getServerTime() + value) + " WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||
dis_t();
|
||||
disconnect();
|
||||
}
|
||||
|
||||
public void setBlocks(int value) throws SQLException {
|
||||
con_t();
|
||||
if (r_set.first())
|
||||
connect();
|
||||
if (resultSet.first())
|
||||
state.execute("UPDATE player_stats SET B = " + value + " WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||
dis_t();
|
||||
disconnect();
|
||||
}
|
||||
|
||||
public int getBlocks() throws SQLException {
|
||||
con_t();
|
||||
if (r_set.first()) {
|
||||
r_set = state.executeQuery("SELECT D_BLOCKS FROM player_stats WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||
if (r_set.first())
|
||||
return r_set.getInt(1);
|
||||
connect();
|
||||
if (resultSet.first()) {
|
||||
resultSet = state.executeQuery("SELECT D_BLOCKS FROM player_stats WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||
if (resultSet.first())
|
||||
return resultSet.getInt(1);
|
||||
}
|
||||
dis_t();
|
||||
disconnect();
|
||||
return NullPointerException.class.hashCode();
|
||||
}
|
||||
|
||||
public void addBlocks(int value) throws SQLException {
|
||||
con_t();
|
||||
if (r_set.first())
|
||||
connect();
|
||||
if (resultSet.first())
|
||||
state.execute("UPDATE player_stats SET D_BLOCKS = " + (getBlocks() + value) + " WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||
dis_t();
|
||||
disconnect();
|
||||
}
|
||||
|
||||
public void setPlayers(int value) throws SQLException {
|
||||
con_t();
|
||||
if (r_set.first())
|
||||
connect();
|
||||
if (resultSet.first())
|
||||
state.execute("UPDATE player_stats SET K_PLAYERS = " + value + " WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||
dis_t();
|
||||
disconnect();
|
||||
}
|
||||
|
||||
public int getPlayers() throws SQLException {
|
||||
con_t();
|
||||
if (r_set.first()) {
|
||||
r_set = state.executeQuery("SELECT K_PLAYERS FROM player_stats WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||
if (r_set.first())
|
||||
return r_set.getInt(1);
|
||||
connect();
|
||||
if (resultSet.first()) {
|
||||
resultSet = state.executeQuery("SELECT K_PLAYERS FROM player_stats WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||
if (resultSet.first())
|
||||
return resultSet.getInt(1);
|
||||
}
|
||||
dis_t();
|
||||
disconnect();
|
||||
return NullPointerException.class.hashCode();
|
||||
}
|
||||
|
||||
public void addPlayers(int value) throws SQLException {
|
||||
con_t();
|
||||
if (r_set.first())
|
||||
connect();
|
||||
if (resultSet.first())
|
||||
state.execute("UPDATE player_stats SET K_PLAYERS = " + (getPlayers() + value) + " WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||
dis_t();
|
||||
disconnect();
|
||||
}
|
||||
|
||||
public void setMobs(int value) throws SQLException {
|
||||
con_t();
|
||||
if (r_set.first())
|
||||
connect();
|
||||
if (resultSet.first())
|
||||
state.execute("UPDATE player_stats SET K_MOBS = " + value + " WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||
dis_t();
|
||||
disconnect();
|
||||
}
|
||||
|
||||
public int getMobs() throws SQLException {
|
||||
con_t();
|
||||
if (r_set.first()) {
|
||||
r_set = state.executeQuery("SELECT K_MOBS FROM player_stats WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||
if (r_set.first())
|
||||
return r_set.getInt(1);
|
||||
connect();
|
||||
if (resultSet.first()) {
|
||||
resultSet = state.executeQuery("SELECT K_MOBS FROM player_stats WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||
if (resultSet.first())
|
||||
return resultSet.getInt(1);
|
||||
}
|
||||
dis_t();
|
||||
disconnect();
|
||||
return NullPointerException.class.hashCode();
|
||||
}
|
||||
|
||||
public void addMobs(int value) throws SQLException {
|
||||
con_t();
|
||||
if (r_set.first())
|
||||
connect();
|
||||
if (resultSet.first())
|
||||
state.execute("UPDATE player_stats SET K_MOBS = " + (getMobs() + value) + " WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||
dis_t();
|
||||
disconnect();
|
||||
}
|
||||
|
||||
public void setDeaths(int value) throws SQLException {
|
||||
con_t();
|
||||
if (r_set.first())
|
||||
connect();
|
||||
if (resultSet.first())
|
||||
state.execute("UPDATE player_stats SET DEATHS = " + value + " WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||
dis_t();
|
||||
disconnect();
|
||||
}
|
||||
|
||||
public int getDeaths() throws SQLException {
|
||||
con_t();
|
||||
if (r_set.first()) {
|
||||
r_set = state.executeQuery("SELECT DEATHS FROM player_stats WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||
if (r_set.first())
|
||||
return r_set.getInt(1);
|
||||
connect();
|
||||
if (resultSet.first()) {
|
||||
resultSet = state.executeQuery("SELECT DEATHS FROM player_stats WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||
if (resultSet.first())
|
||||
return resultSet.getInt(1);
|
||||
}
|
||||
dis_t();
|
||||
disconnect();
|
||||
return NullPointerException.class.hashCode();
|
||||
}
|
||||
|
||||
public void addDeaths(int value) throws SQLException {
|
||||
con_t();
|
||||
if (r_set.first())
|
||||
connect();
|
||||
if (resultSet.first())
|
||||
state.execute("UPDATE player_stats SET DEATHS = " + (getDeaths() + value) + " WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||
dis_t();
|
||||
disconnect();
|
||||
}
|
||||
|
||||
private void con_t() throws SQLException {
|
||||
private void connect() throws SQLException {
|
||||
state = PrisonAPI.CONN.prepareStatement("SELECT * UUID FROM player_stats WHERE UUID = ?;");
|
||||
state.setString(1, me.getPlayer().getUniqueId().toString());
|
||||
r_set = state.executeQuery("SELECT UUID FROM player_stats WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||
resultSet = state.executeQuery("SELECT UUID FROM player_stats WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||
}
|
||||
|
||||
private void dis_t() throws SQLException {
|
||||
r_set.close();
|
||||
private void disconnect() throws SQLException {
|
||||
resultSet.close();
|
||||
state.close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import java.sql.SQLException;
|
||||
public class Wallet {
|
||||
|
||||
private PreparedStatement state;
|
||||
private ResultSet r_set;
|
||||
private ResultSet resultSet;
|
||||
private Prisoner me;
|
||||
|
||||
Wallet(Prisoner prisoner) {
|
||||
@@ -17,45 +17,45 @@ public class Wallet {
|
||||
}
|
||||
|
||||
public int getBalance() throws SQLException {
|
||||
con_t();
|
||||
if (r_set.first()) {
|
||||
r_set = state.executeQuery("SELECT WALLET FROM player_stats WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||
if (r_set.first())
|
||||
return r_set.getInt(1);
|
||||
connect();
|
||||
if (resultSet.first()) {
|
||||
resultSet = state.executeQuery("SELECT WALLET FROM player_stats WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||
if (resultSet.first())
|
||||
return resultSet.getInt(1);
|
||||
}
|
||||
dis_t();
|
||||
disconnect();
|
||||
return NullPointerException.class.hashCode();
|
||||
}
|
||||
|
||||
public void addBalance(int value) throws SQLException {
|
||||
con_t();
|
||||
if (r_set.first())
|
||||
connect();
|
||||
if (resultSet.first())
|
||||
state.execute("UPDATE player_stats SET WALLET = " + (getBalance() + value) + " WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||
dis_t();
|
||||
disconnect();
|
||||
}
|
||||
|
||||
public void deposit(int value) throws SQLException {
|
||||
con_t();
|
||||
if (r_set.first())
|
||||
connect();
|
||||
if (resultSet.first())
|
||||
state.execute("UPDATE player_stats SET WALLET = " + (getBalance() - value) + " WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||
dis_t();
|
||||
disconnect();
|
||||
}
|
||||
|
||||
public void setBalance(int value) throws SQLException {
|
||||
con_t();
|
||||
if (r_set.first())
|
||||
connect();
|
||||
if (resultSet.first())
|
||||
state.execute("UPDATE player_stats SET WALLET = " + value + " WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||
dis_t();
|
||||
disconnect();
|
||||
}
|
||||
|
||||
private void con_t() throws SQLException {
|
||||
private void connect() throws SQLException {
|
||||
state = PrisonAPI.CONN.prepareStatement("SELECT * UUID FROM player_stats WHERE UUID = ?;");
|
||||
state.setString(1, me.getPlayer().getUniqueId().toString());
|
||||
r_set = state.executeQuery("SELECT UUID FROM player_stats WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||
resultSet = state.executeQuery("SELECT UUID FROM player_stats WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||
}
|
||||
|
||||
private void dis_t() throws SQLException {
|
||||
r_set.close();
|
||||
private void disconnect() throws SQLException {
|
||||
resultSet.close();
|
||||
state.close();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user