code style
This commit is contained in:
@@ -26,8 +26,9 @@ public class PrisonAPI extends JavaPlugin {
|
||||
|
||||
public void onDisable() {
|
||||
try {
|
||||
if (!CONN.isClosed())
|
||||
if (!CONN.isClosed()) {
|
||||
CONN.close();
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -25,8 +25,9 @@ public class Faction {
|
||||
connect();
|
||||
if (resultSet.first()) {
|
||||
resultSet = state.executeQuery("SELECT FACTION FROM player_stats WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||
if (resultSet.first())
|
||||
if (resultSet.first()) {
|
||||
return resultSet.getString(1);
|
||||
}
|
||||
}
|
||||
disconnect();
|
||||
return "null";
|
||||
@@ -36,10 +37,13 @@ public class Faction {
|
||||
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(resultSet.getString(1)))
|
||||
if (resultSet.first()) {
|
||||
for (int i = 0; i < PrisonAPI.Factions.values().length; i++) {
|
||||
if (PrisonAPI.Factions.values()[i].name().equals(resultSet.getString(1))) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
disconnect();
|
||||
return 0;
|
||||
@@ -49,8 +53,9 @@ public class Faction {
|
||||
connect();
|
||||
if (resultSet.first()) {
|
||||
resultSet = state.executeQuery("SELECT F_RANG FROM player_stats WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||
if (resultSet.first())
|
||||
if (resultSet.first()) {
|
||||
return resultSet.getInt(1);
|
||||
}
|
||||
}
|
||||
disconnect();
|
||||
return 0;
|
||||
@@ -67,22 +72,25 @@ public class Faction {
|
||||
|
||||
public void addRang(int value) throws SQLException {
|
||||
connect();
|
||||
if (resultSet.first())
|
||||
if (resultSet.first()) {
|
||||
state.execute("UPDATE player_stats SET F_RANG = " + (getRangId() + value) + " WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||
}
|
||||
disconnect();
|
||||
}
|
||||
|
||||
public void setRang(int value) throws SQLException {
|
||||
connect();
|
||||
if (resultSet.first())
|
||||
if (resultSet.first()) {
|
||||
state.execute("UPDATE player_stats SET F_RANG = " + value + " WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||
}
|
||||
disconnect();
|
||||
}
|
||||
|
||||
public void setFaction(int id) throws SQLException {
|
||||
connect();
|
||||
if (resultSet.first())
|
||||
if (resultSet.first()) {
|
||||
state.execute("UPDATE player_stats SET FACTION = '" + PrisonAPI.Factions.values()[id].name() + "' WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||
}
|
||||
disconnect();
|
||||
}
|
||||
|
||||
@@ -90,8 +98,9 @@ public class Faction {
|
||||
connect();
|
||||
if (resultSet.first()) {
|
||||
resultSet = state.executeQuery("SELECT RESPECT FROM prison4life.player_stats WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||
if (resultSet.first())
|
||||
if (resultSet.first()) {
|
||||
return resultSet.getInt(1);
|
||||
}
|
||||
}
|
||||
disconnect();
|
||||
return 0;
|
||||
@@ -99,39 +108,45 @@ public class Faction {
|
||||
|
||||
public void addRespect(int value) throws SQLException {
|
||||
connect();
|
||||
if (resultSet.first())
|
||||
if (resultSet.first()) {
|
||||
state.execute("UPDATE player_stats SET RESPECT = " + (getRespect() + value) + " WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||
}
|
||||
disconnect();
|
||||
}
|
||||
|
||||
public void setRespect(int value) throws SQLException {
|
||||
connect();
|
||||
if (resultSet.first())
|
||||
if (resultSet.first()) {
|
||||
state.execute("UPDATE player_stats SET RESPECT = " + value + " WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||
}
|
||||
disconnect();
|
||||
}
|
||||
|
||||
public int getRespectDailyCooldown() throws SQLException {
|
||||
connect();
|
||||
if (resultSet.first())
|
||||
if (resultSet.first()) {
|
||||
resultSet = state.executeQuery("SELECT COOLDOWN FROM daily_respect_task WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||
if (resultSet.first())
|
||||
}
|
||||
if (resultSet.first()) {
|
||||
return resultSet.getInt(1);
|
||||
}
|
||||
disconnect();
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void addRespectDailyCooldown(int value) throws SQLException {
|
||||
connect();
|
||||
if (resultSet.first())
|
||||
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 {
|
||||
connect();
|
||||
if (resultSet.first())
|
||||
if (resultSet.first()) {
|
||||
state.execute("UPDATE daily_respect_task SET COOLDOWN = " + value + " WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||
}
|
||||
}
|
||||
|
||||
public List<Prisoner> getOnlineList() throws SQLException {
|
||||
@@ -139,8 +154,9 @@ public class Faction {
|
||||
Iterator itr = Bukkit.getOnlinePlayers().iterator();
|
||||
while (itr.hasNext()) {
|
||||
Prisoner m = new Prisoner((Player) itr.next());
|
||||
if (m.getFaction().getType().equals(me.getFaction().getType()))
|
||||
if (m.getFaction().getType().equals(me.getFaction().getType())) {
|
||||
list.add(m);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@@ -20,8 +20,9 @@ public class Level {
|
||||
|
||||
public Score getScore() throws SQLException {
|
||||
connect();
|
||||
if (resultSet.first())
|
||||
if (resultSet.first()) {
|
||||
return this.score;
|
||||
}
|
||||
disconnect();
|
||||
return null;
|
||||
}
|
||||
@@ -30,8 +31,9 @@ public class Level {
|
||||
connect();
|
||||
if (resultSet.first()) {
|
||||
resultSet = state.executeQuery("SELECT LEVEL FROM player_stats WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||
if (resultSet.first())
|
||||
if (resultSet.first()) {
|
||||
return resultSet.getDouble(1);
|
||||
}
|
||||
}
|
||||
disconnect();
|
||||
return NullPointerException.class.hashCode();
|
||||
@@ -39,15 +41,17 @@ public class Level {
|
||||
|
||||
public void addLevel(double value) throws SQLException, NullPointerException {
|
||||
connect();
|
||||
if (resultSet.first())
|
||||
if (resultSet.first()) {
|
||||
state.execute("UPDATE player_stats SET LEVEL = " + (getLevel() + value) + " WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||
}
|
||||
disconnect();
|
||||
}
|
||||
|
||||
public void setLevel(double value) throws SQLException, NullPointerException {
|
||||
connect();
|
||||
if (resultSet.first())
|
||||
if (resultSet.first()) {
|
||||
state.execute("UPDATE player_stats SET LEVEL = " + value + " WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||
}
|
||||
disconnect();
|
||||
}
|
||||
|
||||
|
||||
@@ -57,12 +57,15 @@ public class Prisoner {
|
||||
}
|
||||
int c = 0;
|
||||
for (int k : loc_n) {
|
||||
for (int n = 0; n < 3; n++)
|
||||
if (k >= min.get(n) && k <= max.get(n))
|
||||
for (int n = 0; n < 3; n++) {
|
||||
if (k >= min.get(n) && k <= max.get(n)) {
|
||||
++c;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (c == 3)
|
||||
if (c == 3) {
|
||||
return file.getName().replace("PRISON_", "").replace(".yml", "");
|
||||
}
|
||||
}
|
||||
return "Not Prison";
|
||||
}
|
||||
@@ -87,13 +90,16 @@ public class Prisoner {
|
||||
}
|
||||
int c = 0;
|
||||
for (int k : loc_n) {
|
||||
for (int n = 0; n < 3; n++)
|
||||
if (k >= min.get(n) && k <= max.get(n))
|
||||
for (int n = 0; n < 3; n++) {
|
||||
if (k >= min.get(n) && k <= max.get(n)) {
|
||||
++c;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (c == 3)
|
||||
if (c == 3) {
|
||||
return type.equals("name") ? fileConfiguration.getString("TERRITORIES." + terr + ".NAME") :
|
||||
(type.equals("owner") ? fileConfiguration.getString("TERRITORIES." + terr + ".OWNER") : null);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (NullPointerException z) {
|
||||
|
||||
@@ -30,15 +30,17 @@ public class Score {
|
||||
|
||||
public void setPoints(double value) throws SQLException {
|
||||
connect();
|
||||
if (resultSet.first())
|
||||
if (resultSet.first()) {
|
||||
state.execute("UPDATE player_stats SET POINTS = " + value + " WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||
}
|
||||
disconnect();
|
||||
}
|
||||
|
||||
public void addPoints(double value) throws SQLException {
|
||||
connect();
|
||||
if (resultSet.first())
|
||||
if (resultSet.first()) {
|
||||
state.execute("UPDATE player_stats SET POINTS = " + (getPoints() + value) + " WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||
}
|
||||
disconnect();
|
||||
}
|
||||
|
||||
|
||||
@@ -18,8 +18,9 @@ public class Stats {
|
||||
|
||||
public void setServerTime(int value) throws SQLException {
|
||||
connect();
|
||||
if (resultSet.first())
|
||||
if (resultSet.first()) {
|
||||
state.execute("UPDATE player_stats SET G_TIME = " + value + " WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||
}
|
||||
disconnect();
|
||||
}
|
||||
|
||||
@@ -27,8 +28,9 @@ public class Stats {
|
||||
connect();
|
||||
if (resultSet.first()) {
|
||||
resultSet = state.executeQuery("SELECT G_TIME FROM player_stats WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||
if (resultSet.first())
|
||||
if (resultSet.first()) {
|
||||
return resultSet.getInt(1);
|
||||
}
|
||||
}
|
||||
disconnect();
|
||||
return NullPointerException.class.hashCode();
|
||||
@@ -36,15 +38,17 @@ public class Stats {
|
||||
|
||||
public void addServerTime(int value) throws SQLException {
|
||||
connect();
|
||||
if (resultSet.first())
|
||||
if (resultSet.first()) {
|
||||
state.execute("UPDATE player_stats SET G_TIME = " + (getServerTime() + value) + " WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||
}
|
||||
disconnect();
|
||||
}
|
||||
|
||||
public void setBlocks(int value) throws SQLException {
|
||||
connect();
|
||||
if (resultSet.first())
|
||||
if (resultSet.first()) {
|
||||
state.execute("UPDATE player_stats SET B = " + value + " WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||
}
|
||||
disconnect();
|
||||
}
|
||||
|
||||
@@ -52,8 +56,9 @@ public class Stats {
|
||||
connect();
|
||||
if (resultSet.first()) {
|
||||
resultSet = state.executeQuery("SELECT D_BLOCKS FROM player_stats WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||
if (resultSet.first())
|
||||
if (resultSet.first()) {
|
||||
return resultSet.getInt(1);
|
||||
}
|
||||
}
|
||||
disconnect();
|
||||
return NullPointerException.class.hashCode();
|
||||
@@ -61,15 +66,17 @@ public class Stats {
|
||||
|
||||
public void addBlocks(int value) throws SQLException {
|
||||
connect();
|
||||
if (resultSet.first())
|
||||
if (resultSet.first()) {
|
||||
state.execute("UPDATE player_stats SET D_BLOCKS = " + (getBlocks() + value) + " WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||
}
|
||||
disconnect();
|
||||
}
|
||||
|
||||
public void setPlayers(int value) throws SQLException {
|
||||
connect();
|
||||
if (resultSet.first())
|
||||
if (resultSet.first()) {
|
||||
state.execute("UPDATE player_stats SET K_PLAYERS = " + value + " WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||
}
|
||||
disconnect();
|
||||
}
|
||||
|
||||
@@ -77,8 +84,9 @@ public class Stats {
|
||||
connect();
|
||||
if (resultSet.first()) {
|
||||
resultSet = state.executeQuery("SELECT K_PLAYERS FROM player_stats WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||
if (resultSet.first())
|
||||
if (resultSet.first()) {
|
||||
return resultSet.getInt(1);
|
||||
}
|
||||
}
|
||||
disconnect();
|
||||
return NullPointerException.class.hashCode();
|
||||
@@ -86,15 +94,17 @@ public class Stats {
|
||||
|
||||
public void addPlayers(int value) throws SQLException {
|
||||
connect();
|
||||
if (resultSet.first())
|
||||
if (resultSet.first()) {
|
||||
state.execute("UPDATE player_stats SET K_PLAYERS = " + (getPlayers() + value) + " WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||
}
|
||||
disconnect();
|
||||
}
|
||||
|
||||
public void setMobs(int value) throws SQLException {
|
||||
connect();
|
||||
if (resultSet.first())
|
||||
if (resultSet.first()) {
|
||||
state.execute("UPDATE player_stats SET K_MOBS = " + value + " WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||
}
|
||||
disconnect();
|
||||
}
|
||||
|
||||
@@ -102,8 +112,9 @@ public class Stats {
|
||||
connect();
|
||||
if (resultSet.first()) {
|
||||
resultSet = state.executeQuery("SELECT K_MOBS FROM player_stats WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||
if (resultSet.first())
|
||||
if (resultSet.first()) {
|
||||
return resultSet.getInt(1);
|
||||
}
|
||||
}
|
||||
disconnect();
|
||||
return NullPointerException.class.hashCode();
|
||||
|
||||
@@ -20,8 +20,9 @@ public class Wallet {
|
||||
connect();
|
||||
if (resultSet.first()) {
|
||||
resultSet = state.executeQuery("SELECT WALLET FROM player_stats WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||
if (resultSet.first())
|
||||
if (resultSet.first()) {
|
||||
return resultSet.getInt(1);
|
||||
}
|
||||
}
|
||||
disconnect();
|
||||
return NullPointerException.class.hashCode();
|
||||
@@ -29,22 +30,25 @@ public class Wallet {
|
||||
|
||||
public void addBalance(int value) throws SQLException {
|
||||
connect();
|
||||
if (resultSet.first())
|
||||
if (resultSet.first()) {
|
||||
state.execute("UPDATE player_stats SET WALLET = " + (getBalance() + value) + " WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||
}
|
||||
disconnect();
|
||||
}
|
||||
|
||||
public void deposit(int value) throws SQLException {
|
||||
connect();
|
||||
if (resultSet.first())
|
||||
if (resultSet.first()) {
|
||||
state.execute("UPDATE player_stats SET WALLET = " + (getBalance() - value) + " WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||
}
|
||||
disconnect();
|
||||
}
|
||||
|
||||
public void setBalance(int value) throws SQLException {
|
||||
connect();
|
||||
if (resultSet.first())
|
||||
if (resultSet.first()) {
|
||||
state.execute("UPDATE player_stats SET WALLET = " + value + " WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||
}
|
||||
disconnect();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user