format code
This commit is contained in:
@@ -7,23 +7,29 @@ import java.sql.DriverManager;
|
|||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
|
||||||
public class PrisonAPI extends JavaPlugin {
|
public class PrisonAPI extends JavaPlugin {
|
||||||
public static Connection CONN;
|
|
||||||
public enum Factions {
|
public enum Factions {
|
||||||
NONE, ASIANS, LATINOS, NIGGAZ, POLICE
|
NONE, ASIANS, LATINOS, NIGGAZ, POLICE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Connection CONN;
|
||||||
|
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
try {
|
try {
|
||||||
CONN = DriverManager.getConnection(
|
CONN = DriverManager.getConnection(
|
||||||
"jdbc:mysql://localhost:3306/prison4life",
|
"jdbc:mysql://localhost:3306/prison4life",
|
||||||
"root", "root");
|
"root", "root");
|
||||||
} catch (SQLException e) { e.printStackTrace(); }
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
try {
|
try {
|
||||||
if(!CONN.isClosed())
|
if (!CONN.isClosed())
|
||||||
CONN.close();
|
CONN.close();
|
||||||
} catch (SQLException e) { e.printStackTrace(); }
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,18 +12,20 @@ import java.util.Iterator;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class Faction {
|
public class Faction {
|
||||||
|
|
||||||
private PreparedStatement state;
|
private PreparedStatement state;
|
||||||
private ResultSet r_set;
|
private ResultSet r_set;
|
||||||
private Prisoner me;
|
private Prisoner me;
|
||||||
|
|
||||||
Faction(Prisoner prisoner) {
|
Faction(Prisoner prisoner) {
|
||||||
me = prisoner;
|
me = prisoner;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getType() throws SQLException {
|
public String getType() throws SQLException {
|
||||||
con_t();
|
con_t();
|
||||||
if(r_set.first()) {
|
if (r_set.first()) {
|
||||||
r_set = state.executeQuery("SELECT FACTION FROM player_stats WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
r_set = state.executeQuery("SELECT FACTION FROM player_stats WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||||
if(r_set.first())
|
if (r_set.first())
|
||||||
return r_set.getString(1);
|
return r_set.getString(1);
|
||||||
}
|
}
|
||||||
dis_t();
|
dis_t();
|
||||||
@@ -32,11 +34,11 @@ public class Faction {
|
|||||||
|
|
||||||
public int getId() throws SQLException {
|
public int getId() throws SQLException {
|
||||||
con_t();
|
con_t();
|
||||||
if(r_set.first()) {
|
if (r_set.first()) {
|
||||||
r_set = state.executeQuery("SELECT FACTION FROM player_stats WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
r_set = state.executeQuery("SELECT FACTION FROM player_stats WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||||
if(r_set.first())
|
if (r_set.first())
|
||||||
for(int i = 0; i < PrisonAPI.Factions.values().length; i++)
|
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(r_set.getString(1)))
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
dis_t();
|
dis_t();
|
||||||
@@ -45,9 +47,9 @@ public class Faction {
|
|||||||
|
|
||||||
public int getRangId() throws SQLException {
|
public int getRangId() throws SQLException {
|
||||||
con_t();
|
con_t();
|
||||||
if(r_set.first()) {
|
if (r_set.first()) {
|
||||||
r_set = state.executeQuery("SELECT F_RANG FROM player_stats WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
r_set = state.executeQuery("SELECT F_RANG FROM player_stats WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||||
if(r_set.first())
|
if (r_set.first())
|
||||||
return r_set.getInt(1);
|
return r_set.getInt(1);
|
||||||
}
|
}
|
||||||
dis_t();
|
dis_t();
|
||||||
@@ -65,30 +67,30 @@ public class Faction {
|
|||||||
|
|
||||||
public void addRang(int value) throws SQLException {
|
public void addRang(int value) throws SQLException {
|
||||||
con_t();
|
con_t();
|
||||||
if(r_set.first())
|
if (r_set.first())
|
||||||
state.execute("UPDATE player_stats SET F_RANG = " + (getRangId() + value) + " WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
state.execute("UPDATE player_stats SET F_RANG = " + (getRangId() + value) + " WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||||
dis_t();
|
dis_t();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRang(int value) throws SQLException {
|
public void setRang(int value) throws SQLException {
|
||||||
con_t();
|
con_t();
|
||||||
if(r_set.first())
|
if (r_set.first())
|
||||||
state.execute("UPDATE player_stats SET F_RANG = " + value + " WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
state.execute("UPDATE player_stats SET F_RANG = " + value + " WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||||
dis_t();
|
dis_t();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFaction(int id) throws SQLException {
|
public void setFaction(int id) throws SQLException {
|
||||||
con_t();
|
con_t();
|
||||||
if(r_set.first())
|
if (r_set.first())
|
||||||
state.execute("UPDATE player_stats SET FACTION = '" + PrisonAPI.Factions.values()[id].name() + "' WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
state.execute("UPDATE player_stats SET FACTION = '" + PrisonAPI.Factions.values()[id].name() + "' WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||||
dis_t();
|
dis_t();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getRespect() throws SQLException {
|
public int getRespect() throws SQLException {
|
||||||
con_t();
|
con_t();
|
||||||
if(r_set.first()) {
|
if (r_set.first()) {
|
||||||
r_set = state.executeQuery("SELECT RESPECT FROM prison4life.player_stats WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
r_set = state.executeQuery("SELECT RESPECT FROM prison4life.player_stats WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||||
if(r_set.first())
|
if (r_set.first())
|
||||||
return r_set.getInt(1);
|
return r_set.getInt(1);
|
||||||
}
|
}
|
||||||
dis_t();
|
dis_t();
|
||||||
@@ -97,47 +99,47 @@ public class Faction {
|
|||||||
|
|
||||||
public void addRespect(int value) throws SQLException {
|
public void addRespect(int value) throws SQLException {
|
||||||
con_t();
|
con_t();
|
||||||
if(r_set.first())
|
if (r_set.first())
|
||||||
state.execute("UPDATE player_stats SET RESPECT = " + (getRespect() + value) + " WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
state.execute("UPDATE player_stats SET RESPECT = " + (getRespect() + value) + " WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||||
dis_t();
|
dis_t();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRespect(int value) throws SQLException {
|
public void setRespect(int value) throws SQLException {
|
||||||
con_t();
|
con_t();
|
||||||
if(r_set.first())
|
if (r_set.first())
|
||||||
state.execute("UPDATE player_stats SET RESPECT = " + value + " WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
state.execute("UPDATE player_stats SET RESPECT = " + value + " WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||||
dis_t();
|
dis_t();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getRespectDailyCooldown() throws SQLException {
|
public int getRespectDailyCooldown() throws SQLException {
|
||||||
con_t();
|
con_t();
|
||||||
if(r_set.first())
|
if (r_set.first())
|
||||||
r_set = state.executeQuery("SELECT COOLDOWN FROM daily_respect_task WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
r_set = state.executeQuery("SELECT COOLDOWN FROM daily_respect_task WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||||
if(r_set.first())
|
if (r_set.first())
|
||||||
return r_set.getInt(1);
|
return r_set.getInt(1);
|
||||||
dis_t();
|
dis_t();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addRespectDailyCooldown(int value) throws SQLException {
|
public void addRespectDailyCooldown(int value) throws SQLException {
|
||||||
con_t();
|
con_t();
|
||||||
if(r_set.first())
|
if (r_set.first())
|
||||||
state.execute("UPDATE daily_respect_task SET COOLDOWN = " + (getRespectDailyCooldown() + value)
|
state.execute("UPDATE daily_respect_task SET COOLDOWN = " + (getRespectDailyCooldown() + value)
|
||||||
+ " WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
+ " WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRespectDailyCooldown(int value) throws SQLException {
|
public void setRespectDailyCooldown(int value) throws SQLException {
|
||||||
con_t();
|
con_t();
|
||||||
if(r_set.first())
|
if (r_set.first())
|
||||||
state.execute("UPDATE daily_respect_task SET COOLDOWN = " + value + " WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
state.execute("UPDATE daily_respect_task SET COOLDOWN = " + value + " WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Prisoner> getOnlineList() throws SQLException {
|
public List<Prisoner> getOnlineList() throws SQLException {
|
||||||
List<Prisoner> list = new ArrayList<>();
|
List<Prisoner> list = new ArrayList<>();
|
||||||
Iterator itr = Bukkit.getOnlinePlayers().iterator();
|
Iterator itr = Bukkit.getOnlinePlayers().iterator();
|
||||||
while(itr.hasNext()) {
|
while (itr.hasNext()) {
|
||||||
Prisoner m = new Prisoner((Player) itr.next());
|
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);
|
list.add(m);
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
|
|||||||
@@ -7,15 +7,20 @@ import java.sql.ResultSet;
|
|||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
|
||||||
public class Level {
|
public class Level {
|
||||||
|
|
||||||
private PreparedStatement state;
|
private PreparedStatement state;
|
||||||
private ResultSet r_set;
|
private ResultSet r_set;
|
||||||
private Prisoner me;
|
private Prisoner me;
|
||||||
private Score score;
|
private Score score;
|
||||||
Level(Prisoner prisoner) { me = prisoner; score = new Score(me); }
|
|
||||||
|
Level(Prisoner prisoner) {
|
||||||
|
me = prisoner;
|
||||||
|
score = new Score(me);
|
||||||
|
}
|
||||||
|
|
||||||
public Score getScore() throws SQLException {
|
public Score getScore() throws SQLException {
|
||||||
con_t();
|
con_t();
|
||||||
if(r_set.first())
|
if (r_set.first())
|
||||||
return this.score;
|
return this.score;
|
||||||
dis_t();
|
dis_t();
|
||||||
return null;
|
return null;
|
||||||
@@ -23,9 +28,9 @@ public class Level {
|
|||||||
|
|
||||||
public double getLevel() throws SQLException, NullPointerException {
|
public double getLevel() throws SQLException, NullPointerException {
|
||||||
con_t();
|
con_t();
|
||||||
if(r_set.first()) {
|
if (r_set.first()) {
|
||||||
r_set = state.executeQuery("SELECT LEVEL FROM player_stats WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
r_set = state.executeQuery("SELECT LEVEL FROM player_stats WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||||
if(r_set.first())
|
if (r_set.first())
|
||||||
return r_set.getDouble(1);
|
return r_set.getDouble(1);
|
||||||
}
|
}
|
||||||
dis_t();
|
dis_t();
|
||||||
@@ -34,14 +39,14 @@ public class Level {
|
|||||||
|
|
||||||
public void addLevel(double value) throws SQLException, NullPointerException {
|
public void addLevel(double value) throws SQLException, NullPointerException {
|
||||||
con_t();
|
con_t();
|
||||||
if(r_set.first())
|
if (r_set.first())
|
||||||
state.execute("UPDATE player_stats SET LEVEL = " + (getLevel() + value) + " WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
state.execute("UPDATE player_stats SET LEVEL = " + (getLevel() + value) + " WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||||
dis_t();
|
dis_t();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLevel(double value) throws SQLException, NullPointerException {
|
public void setLevel(double value) throws SQLException, NullPointerException {
|
||||||
con_t();
|
con_t();
|
||||||
if(r_set.first())
|
if (r_set.first())
|
||||||
state.execute("UPDATE player_stats SET LEVEL = " + value + " WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
state.execute("UPDATE player_stats SET LEVEL = " + value + " WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||||
dis_t();
|
dis_t();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,10 +12,10 @@ import java.util.List;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
public class Manager {
|
public class Manager {
|
||||||
|
|
||||||
private File fi;
|
private File fi;
|
||||||
private FileConfiguration cf;
|
private FileConfiguration cf;
|
||||||
|
|
||||||
|
|
||||||
public Manager(String id) {
|
public Manager(String id) {
|
||||||
fi = new File("plugins/PrisonManager/", id);
|
fi = new File("plugins/PrisonManager/", id);
|
||||||
cf = YamlConfiguration.loadConfiguration(fi);
|
cf = YamlConfiguration.loadConfiguration(fi);
|
||||||
@@ -73,7 +73,7 @@ public class Manager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setDiagonal(List<Integer> data) {
|
public void setDiagonal(List<Integer> data) {
|
||||||
if(data.size() == 6) {
|
if (data.size() == 6) {
|
||||||
String dp = "DIAGONAL_POINTS";
|
String dp = "DIAGONAL_POINTS";
|
||||||
cf.set(dp, null);
|
cf.set(dp, null);
|
||||||
cf.set(dp, data);
|
cf.set(dp, data);
|
||||||
@@ -93,7 +93,7 @@ public class Manager {
|
|||||||
|
|
||||||
public int getGlobalNumTerr(int faction) {
|
public int getGlobalNumTerr(int faction) {
|
||||||
int num = 0;
|
int num = 0;
|
||||||
for(File prison : Objects.requireNonNull(fi.getParentFile().listFiles())) {
|
for (File prison : Objects.requireNonNull(fi.getParentFile().listFiles())) {
|
||||||
Manager mng = new Manager(prison.getName());
|
Manager mng = new Manager(prison.getName());
|
||||||
num += mng.getNumTerr(faction);
|
num += mng.getNumTerr(faction);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import java.util.List;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
public class Prisoner {
|
public class Prisoner {
|
||||||
|
|
||||||
private static final String PLUGIN_PATH = "plugins/PrisonManager";
|
private static final String PLUGIN_PATH = "plugins/PrisonManager";
|
||||||
private Player me;
|
private Player me;
|
||||||
private Level level;
|
private Level level;
|
||||||
@@ -32,13 +33,17 @@ public class Prisoner {
|
|||||||
stats = new Stats(this);
|
stats = new Stats(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Player getPlayer() { return me; }
|
public Player getPlayer() {
|
||||||
|
return me;
|
||||||
|
}
|
||||||
|
|
||||||
public Level getPrisonLevel() throws SQLException { return this.level; }
|
public Level getPrisonLevel() throws SQLException {
|
||||||
|
return this.level;
|
||||||
|
}
|
||||||
|
|
||||||
public String getPrison() {
|
public String getPrison() {
|
||||||
Location loc = me.getLocation();
|
Location loc = me.getLocation();
|
||||||
for(File file : Objects.requireNonNull(new File(PLUGIN_PATH).listFiles())) {
|
for (File file : Objects.requireNonNull(new File(PLUGIN_PATH).listFiles())) {
|
||||||
FileConfiguration c_ti = YamlConfiguration.loadConfiguration(file);
|
FileConfiguration c_ti = YamlConfiguration.loadConfiguration(file);
|
||||||
List<List<Integer>> data = new ArrayList<>();
|
List<List<Integer>> data = new ArrayList<>();
|
||||||
List<Integer> from_cfg = c_ti.getIntegerList("DIAGONAL_POINTS"),
|
List<Integer> from_cfg = c_ti.getIntegerList("DIAGONAL_POINTS"),
|
||||||
@@ -46,17 +51,17 @@ public class Prisoner {
|
|||||||
int[] loc_n = {loc.getBlockX(), loc.getBlockY() - 1, loc.getBlockZ()};
|
int[] loc_n = {loc.getBlockX(), loc.getBlockY() - 1, loc.getBlockZ()};
|
||||||
data.add(from_cfg.subList(0, 3));
|
data.add(from_cfg.subList(0, 3));
|
||||||
data.add(from_cfg.subList(3, 6));
|
data.add(from_cfg.subList(3, 6));
|
||||||
for(int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
min.add(Math.min(data.get(0).get(i), data.get(1).get(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)));
|
max.add(Math.max(data.get(0).get(i), data.get(1).get(i)));
|
||||||
}
|
}
|
||||||
int c = 0;
|
int c = 0;
|
||||||
for(int k : loc_n) {
|
for (int k : loc_n) {
|
||||||
for(int n = 0; n < 3; n++)
|
for (int n = 0; n < 3; n++)
|
||||||
if(k >= min.get(n) && k <= max.get(n))
|
if (k >= min.get(n) && k <= max.get(n))
|
||||||
++c;
|
++c;
|
||||||
}
|
}
|
||||||
if(c == 3)
|
if (c == 3)
|
||||||
return file.getName().replace("PRISON_", "").replace(".yml", "");
|
return file.getName().replace("PRISON_", "").replace(".yml", "");
|
||||||
}
|
}
|
||||||
return "Not Prison";
|
return "Not Prison";
|
||||||
@@ -64,53 +69,60 @@ public class Prisoner {
|
|||||||
|
|
||||||
public String getTerritory(String type) {
|
public String getTerritory(String type) {
|
||||||
String prs = getPrison();
|
String prs = getPrison();
|
||||||
if(!prs.equals("Not Prison") && (type.equals("name") || type.equals("owner"))) {
|
if (!prs.equals("Not Prison") && (type.equals("name") || type.equals("owner"))) {
|
||||||
Location loc = me.getLocation();
|
Location loc = me.getLocation();
|
||||||
FileConfiguration c_ti = YamlConfiguration.loadConfiguration(new File(PLUGIN_PATH, "PRISON_" + prs + ".yml"));
|
FileConfiguration c_ti = YamlConfiguration.loadConfiguration(new File(PLUGIN_PATH, "PRISON_" + prs + ".yml"));
|
||||||
try {
|
try {
|
||||||
if(c_ti.getConfigurationSection("TERRITORIES").getKeys(false).size() != 0) {
|
if (c_ti.getConfigurationSection("TERRITORIES").getKeys(false).size() != 0) {
|
||||||
for(String terr : c_ti.getConfigurationSection("TERRITORIES").getKeys(false)) {
|
for (String terr : c_ti.getConfigurationSection("TERRITORIES").getKeys(false)) {
|
||||||
List<List<Integer>> data = new ArrayList<>();
|
List<List<Integer>> data = new ArrayList<>();
|
||||||
List<Integer> from_cfg = c_ti.getIntegerList("TERRITORIES." + terr + ".DIAGONAL_POINTS"),
|
List<Integer> from_cfg = c_ti.getIntegerList("TERRITORIES." + terr + ".DIAGONAL_POINTS"),
|
||||||
min = new ArrayList<>(), max = new ArrayList<>();
|
min = new ArrayList<>(), max = new ArrayList<>();
|
||||||
int[] loc_n = {loc.getBlockX(), loc.getBlockY() - 1, loc.getBlockZ()};
|
int[] loc_n = {loc.getBlockX(), loc.getBlockY() - 1, loc.getBlockZ()};
|
||||||
data.add(from_cfg.subList(0, 3));
|
data.add(from_cfg.subList(0, 3));
|
||||||
data.add(from_cfg.subList(3, 6));
|
data.add(from_cfg.subList(3, 6));
|
||||||
for(int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
min.add(Math.min(data.get(0).get(i), data.get(1).get(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)));
|
max.add(Math.max(data.get(0).get(i), data.get(1).get(i)));
|
||||||
}
|
}
|
||||||
int c = 0;
|
int c = 0;
|
||||||
for(int k : loc_n) {
|
for (int k : loc_n) {
|
||||||
for (int n = 0; n < 3; n++)
|
for (int n = 0; n < 3; n++)
|
||||||
if (k >= min.get(n) && k <= max.get(n))
|
if (k >= min.get(n) && k <= max.get(n))
|
||||||
++c;
|
++c;
|
||||||
}
|
}
|
||||||
if(c == 3)
|
if (c == 3)
|
||||||
return type.equals("name") ? c_ti.getString("TERRITORIES." + terr + ".NAME") :
|
return type.equals("name") ? c_ti.getString("TERRITORIES." + terr + ".NAME") :
|
||||||
(type.equals("owner") ? c_ti.getString("TERRITORIES." + terr + ".OWNER") : null);
|
(type.equals("owner") ? c_ti.getString("TERRITORIES." + terr + ".OWNER") : null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch(NullPointerException z) {}
|
} catch (NullPointerException z) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return "Not Territory";
|
return "Not Territory";
|
||||||
}
|
}
|
||||||
|
|
||||||
public Faction getFaction() { return faction; }
|
public Faction getFaction() {
|
||||||
|
return faction;
|
||||||
|
}
|
||||||
|
|
||||||
public Wallet getWallet() { return wallet; }
|
public Wallet getWallet() {
|
||||||
|
return wallet;
|
||||||
|
}
|
||||||
|
|
||||||
public Stats getStats() { return stats; }
|
public Stats getStats() {
|
||||||
|
return stats;
|
||||||
|
}
|
||||||
|
|
||||||
public void register() throws SQLException {
|
public void register() throws SQLException {
|
||||||
state = PrisonAPI.CONN.prepareStatement("SELECT * UUID FROM player_stats WHERE UUID = ?;");
|
state = PrisonAPI.CONN.prepareStatement("SELECT * UUID FROM player_stats WHERE UUID = ?;");
|
||||||
state.setString(1, me.getUniqueId().toString());
|
state.setString(1, me.getUniqueId().toString());
|
||||||
r_set = state.executeQuery("SELECT UUID FROM player_stats WHERE UUID = '" + me.getUniqueId() + "'");
|
r_set = state.executeQuery("SELECT UUID FROM player_stats WHERE UUID = '" + me.getUniqueId() + "'");
|
||||||
if(!r_set.next()) {
|
if (!r_set.next()) {
|
||||||
state.execute(
|
state.execute(
|
||||||
"INSERT INTO player_stats(NAME, UUID, LEVEL, POINTS, FACTION, RESPECT, F_RANG, WALLET, G_TIME, D_BLOCKS, " +
|
"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()
|
"K_PLAYERS, K_MOBS, DEATHS) VALUES (" + "'" + getPlayer().getName()
|
||||||
+ "', '" + me.getUniqueId() + "', 1, 0, 'NONE', 0, 0, 0, 0, 0, 0, 0, 0);");
|
+ "', '" + me.getUniqueId() + "', 1, 0, 'NONE', 0, 0, 0, 0, 0, 0, 0, 0);");
|
||||||
state.execute("INSERT INTO daily_respect_task(NAME, UUID, COOLDOWN) VALUES ('" + me.getName() + "', '" + me.getUniqueId() + "', (3600 * 24));");
|
state.execute("INSERT INTO daily_respect_task(NAME, UUID, COOLDOWN) VALUES ('" + me.getName() + "', '" + me.getUniqueId() + "', (3600 * 24));");
|
||||||
level = new Level(this);
|
level = new Level(this);
|
||||||
stats = new Stats(this);
|
stats = new Stats(this);
|
||||||
|
|||||||
@@ -7,16 +7,20 @@ import java.sql.ResultSet;
|
|||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
|
||||||
public class Score {
|
public class Score {
|
||||||
|
|
||||||
private PreparedStatement state;
|
private PreparedStatement state;
|
||||||
private ResultSet r_set;
|
private ResultSet r_set;
|
||||||
private Prisoner me;
|
private Prisoner me;
|
||||||
Score(Prisoner prisoner) { me = prisoner; }
|
|
||||||
|
Score(Prisoner prisoner) {
|
||||||
|
me = prisoner;
|
||||||
|
}
|
||||||
|
|
||||||
public double getPoints() throws SQLException {
|
public double getPoints() throws SQLException {
|
||||||
con_t();
|
con_t();
|
||||||
if(r_set.first()) {
|
if (r_set.first()) {
|
||||||
r_set = state.executeQuery("SELECT POINTS FROM player_stats WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
r_set = state.executeQuery("SELECT POINTS FROM player_stats WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||||
if(r_set.first()) {
|
if (r_set.first()) {
|
||||||
return r_set.getDouble(1);
|
return r_set.getDouble(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -26,14 +30,14 @@ public class Score {
|
|||||||
|
|
||||||
public void setPoints(double value) throws SQLException {
|
public void setPoints(double value) throws SQLException {
|
||||||
con_t();
|
con_t();
|
||||||
if(r_set.first())
|
if (r_set.first())
|
||||||
state.execute("UPDATE player_stats SET POINTS = " + value + " WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
state.execute("UPDATE player_stats SET POINTS = " + value + " WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||||
dis_t();
|
dis_t();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addPoints(double value) throws SQLException {
|
public void addPoints(double value) throws SQLException {
|
||||||
con_t();
|
con_t();
|
||||||
if(r_set.first())
|
if (r_set.first())
|
||||||
state.execute("UPDATE player_stats SET POINTS = " + (getPoints() + value) + " WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
state.execute("UPDATE player_stats SET POINTS = " + (getPoints() + value) + " WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||||
dis_t();
|
dis_t();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,23 +7,27 @@ import java.sql.ResultSet;
|
|||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
|
||||||
public class Stats {
|
public class Stats {
|
||||||
|
|
||||||
private PreparedStatement state;
|
private PreparedStatement state;
|
||||||
private ResultSet r_set;
|
private ResultSet r_set;
|
||||||
private Prisoner me;
|
private Prisoner me;
|
||||||
Stats(Prisoner prisoner) { me = prisoner;}
|
|
||||||
|
Stats(Prisoner prisoner) {
|
||||||
|
me = prisoner;
|
||||||
|
}
|
||||||
|
|
||||||
public void setServerTime(int value) throws SQLException {
|
public void setServerTime(int value) throws SQLException {
|
||||||
con_t();
|
con_t();
|
||||||
if(r_set.first())
|
if (r_set.first())
|
||||||
state.execute("UPDATE player_stats SET G_TIME = " + value + " WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
state.execute("UPDATE player_stats SET G_TIME = " + value + " WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||||
dis_t();
|
dis_t();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getServerTime() throws SQLException {
|
public int getServerTime() throws SQLException {
|
||||||
con_t();
|
con_t();
|
||||||
if(r_set.first()) {
|
if (r_set.first()) {
|
||||||
r_set = state.executeQuery("SELECT G_TIME FROM player_stats WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
r_set = state.executeQuery("SELECT G_TIME FROM player_stats WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||||
if(r_set.first())
|
if (r_set.first())
|
||||||
return r_set.getInt(1);
|
return r_set.getInt(1);
|
||||||
}
|
}
|
||||||
dis_t();
|
dis_t();
|
||||||
@@ -32,23 +36,23 @@ public class Stats {
|
|||||||
|
|
||||||
public void addServerTime(int value) throws SQLException {
|
public void addServerTime(int value) throws SQLException {
|
||||||
con_t();
|
con_t();
|
||||||
if(r_set.first())
|
if (r_set.first())
|
||||||
state.execute("UPDATE player_stats SET G_TIME = " + (getServerTime() + value) + " WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
state.execute("UPDATE player_stats SET G_TIME = " + (getServerTime() + value) + " WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||||
dis_t();
|
dis_t();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBlocks(int value) throws SQLException {
|
public void setBlocks(int value) throws SQLException {
|
||||||
con_t();
|
con_t();
|
||||||
if(r_set.first())
|
if (r_set.first())
|
||||||
state.execute("UPDATE player_stats SET B = " + value + " WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
state.execute("UPDATE player_stats SET B = " + value + " WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||||
dis_t();
|
dis_t();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getBlocks() throws SQLException {
|
public int getBlocks() throws SQLException {
|
||||||
con_t();
|
con_t();
|
||||||
if(r_set.first()) {
|
if (r_set.first()) {
|
||||||
r_set = state.executeQuery("SELECT D_BLOCKS FROM player_stats WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
r_set = state.executeQuery("SELECT D_BLOCKS FROM player_stats WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||||
if(r_set.first())
|
if (r_set.first())
|
||||||
return r_set.getInt(1);
|
return r_set.getInt(1);
|
||||||
}
|
}
|
||||||
dis_t();
|
dis_t();
|
||||||
@@ -57,23 +61,23 @@ public class Stats {
|
|||||||
|
|
||||||
public void addBlocks(int value) throws SQLException {
|
public void addBlocks(int value) throws SQLException {
|
||||||
con_t();
|
con_t();
|
||||||
if(r_set.first())
|
if (r_set.first())
|
||||||
state.execute("UPDATE player_stats SET D_BLOCKS = " + (getBlocks() + value) + " WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
state.execute("UPDATE player_stats SET D_BLOCKS = " + (getBlocks() + value) + " WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||||
dis_t();
|
dis_t();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPlayers(int value) throws SQLException {
|
public void setPlayers(int value) throws SQLException {
|
||||||
con_t();
|
con_t();
|
||||||
if(r_set.first())
|
if (r_set.first())
|
||||||
state.execute("UPDATE player_stats SET K_PLAYERS = " + value + " WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
state.execute("UPDATE player_stats SET K_PLAYERS = " + value + " WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||||
dis_t();
|
dis_t();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPlayers() throws SQLException {
|
public int getPlayers() throws SQLException {
|
||||||
con_t();
|
con_t();
|
||||||
if(r_set.first()) {
|
if (r_set.first()) {
|
||||||
r_set = state.executeQuery("SELECT K_PLAYERS FROM player_stats WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
r_set = state.executeQuery("SELECT K_PLAYERS FROM player_stats WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||||
if(r_set.first())
|
if (r_set.first())
|
||||||
return r_set.getInt(1);
|
return r_set.getInt(1);
|
||||||
}
|
}
|
||||||
dis_t();
|
dis_t();
|
||||||
@@ -82,23 +86,23 @@ public class Stats {
|
|||||||
|
|
||||||
public void addPlayers(int value) throws SQLException {
|
public void addPlayers(int value) throws SQLException {
|
||||||
con_t();
|
con_t();
|
||||||
if(r_set.first())
|
if (r_set.first())
|
||||||
state.execute("UPDATE player_stats SET K_PLAYERS = " + (getPlayers() + value) + " WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
state.execute("UPDATE player_stats SET K_PLAYERS = " + (getPlayers() + value) + " WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||||
dis_t();
|
dis_t();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMobs(int value) throws SQLException {
|
public void setMobs(int value) throws SQLException {
|
||||||
con_t();
|
con_t();
|
||||||
if(r_set.first())
|
if (r_set.first())
|
||||||
state.execute("UPDATE player_stats SET K_MOBS = " + value + " WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
state.execute("UPDATE player_stats SET K_MOBS = " + value + " WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||||
dis_t();
|
dis_t();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getMobs() throws SQLException {
|
public int getMobs() throws SQLException {
|
||||||
con_t();
|
con_t();
|
||||||
if(r_set.first()) {
|
if (r_set.first()) {
|
||||||
r_set = state.executeQuery("SELECT K_MOBS FROM player_stats WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
r_set = state.executeQuery("SELECT K_MOBS FROM player_stats WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||||
if(r_set.first())
|
if (r_set.first())
|
||||||
return r_set.getInt(1);
|
return r_set.getInt(1);
|
||||||
}
|
}
|
||||||
dis_t();
|
dis_t();
|
||||||
@@ -107,23 +111,23 @@ public class Stats {
|
|||||||
|
|
||||||
public void addMobs(int value) throws SQLException {
|
public void addMobs(int value) throws SQLException {
|
||||||
con_t();
|
con_t();
|
||||||
if(r_set.first())
|
if (r_set.first())
|
||||||
state.execute("UPDATE player_stats SET K_MOBS = " + (getMobs() + value) + " WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
state.execute("UPDATE player_stats SET K_MOBS = " + (getMobs() + value) + " WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||||
dis_t();
|
dis_t();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDeaths(int value) throws SQLException {
|
public void setDeaths(int value) throws SQLException {
|
||||||
con_t();
|
con_t();
|
||||||
if(r_set.first())
|
if (r_set.first())
|
||||||
state.execute("UPDATE player_stats SET DEATHS = " + value + " WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
state.execute("UPDATE player_stats SET DEATHS = " + value + " WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||||
dis_t();
|
dis_t();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getDeaths() throws SQLException {
|
public int getDeaths() throws SQLException {
|
||||||
con_t();
|
con_t();
|
||||||
if(r_set.first()) {
|
if (r_set.first()) {
|
||||||
r_set = state.executeQuery("SELECT DEATHS FROM player_stats WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
r_set = state.executeQuery("SELECT DEATHS FROM player_stats WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||||
if(r_set.first())
|
if (r_set.first())
|
||||||
return r_set.getInt(1);
|
return r_set.getInt(1);
|
||||||
}
|
}
|
||||||
dis_t();
|
dis_t();
|
||||||
@@ -132,7 +136,7 @@ public class Stats {
|
|||||||
|
|
||||||
public void addDeaths(int value) throws SQLException {
|
public void addDeaths(int value) throws SQLException {
|
||||||
con_t();
|
con_t();
|
||||||
if(r_set.first())
|
if (r_set.first())
|
||||||
state.execute("UPDATE player_stats SET DEATHS = " + (getDeaths() + value) + " WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
state.execute("UPDATE player_stats SET DEATHS = " + (getDeaths() + value) + " WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||||
dis_t();
|
dis_t();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,16 +7,20 @@ import java.sql.ResultSet;
|
|||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
|
||||||
public class Wallet {
|
public class Wallet {
|
||||||
|
|
||||||
private PreparedStatement state;
|
private PreparedStatement state;
|
||||||
private ResultSet r_set;
|
private ResultSet r_set;
|
||||||
private Prisoner me;
|
private Prisoner me;
|
||||||
Wallet(Prisoner prisoner) { me = prisoner; }
|
|
||||||
|
Wallet(Prisoner prisoner) {
|
||||||
|
me = prisoner;
|
||||||
|
}
|
||||||
|
|
||||||
public int getBalance() throws SQLException {
|
public int getBalance() throws SQLException {
|
||||||
con_t();
|
con_t();
|
||||||
if(r_set.first()) {
|
if (r_set.first()) {
|
||||||
r_set = state.executeQuery("SELECT WALLET FROM player_stats WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
r_set = state.executeQuery("SELECT WALLET FROM player_stats WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||||
if(r_set.first())
|
if (r_set.first())
|
||||||
return r_set.getInt(1);
|
return r_set.getInt(1);
|
||||||
}
|
}
|
||||||
dis_t();
|
dis_t();
|
||||||
@@ -25,21 +29,21 @@ public class Wallet {
|
|||||||
|
|
||||||
public void addBalance(int value) throws SQLException {
|
public void addBalance(int value) throws SQLException {
|
||||||
con_t();
|
con_t();
|
||||||
if(r_set.first())
|
if (r_set.first())
|
||||||
state.execute("UPDATE player_stats SET WALLET = " + (getBalance() + value) + " WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
state.execute("UPDATE player_stats SET WALLET = " + (getBalance() + value) + " WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||||
dis_t();
|
dis_t();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deposit(int value) throws SQLException {
|
public void deposit(int value) throws SQLException {
|
||||||
con_t();
|
con_t();
|
||||||
if(r_set.first())
|
if (r_set.first())
|
||||||
state.execute("UPDATE player_stats SET WALLET = " + (getBalance() - value) + " WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
state.execute("UPDATE player_stats SET WALLET = " + (getBalance() - value) + " WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||||
dis_t();
|
dis_t();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBalance(int value) throws SQLException {
|
public void setBalance(int value) throws SQLException {
|
||||||
con_t();
|
con_t();
|
||||||
if(r_set.first())
|
if (r_set.first())
|
||||||
state.execute("UPDATE player_stats SET WALLET = " + value + " WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
state.execute("UPDATE player_stats SET WALLET = " + value + " WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
|
||||||
dis_t();
|
dis_t();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user