diff --git a/pom.xml b/pom.xml
index f8b08ee..deed67f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -7,6 +7,18 @@
ru.prisonlife
PrisonAPI
0.0.1
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+
+ 7
+ 7
+
+
+
+
diff --git a/src/main/java/ru/prisonlife/PrisonAPI/template/Faction.java b/src/main/java/ru/prisonlife/PrisonAPI/template/Faction.java
new file mode 100644
index 0000000..35b7650
--- /dev/null
+++ b/src/main/java/ru/prisonlife/PrisonAPI/template/Faction.java
@@ -0,0 +1,40 @@
+package ru.prisonlife.PrisonAPI.template;
+
+import ru.prisonlife.PrisonAPI.PrisonAPI;
+
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.HashMap;
+import java.util.Map;
+
+public class Faction {
+ private enum Factions { NONE, ASIANS, LATINOS, NIGGAZ, POLICE }
+ private Map pick = new HashMap();
+ {
+ for(int i = 0; i < Factions.values().length; i++)
+ pick.put(i, Factions.values()[i]);
+ }
+ private PreparedStatement state;
+ private ResultSet r_set;
+ private Prisoner me;
+ Faction(Prisoner prisoner) { me = prisoner; }
+
+ public void change(int id) throws SQLException {
+ get_t();
+ if(r_set.first())
+ state.execute("UPDATE player_stats SET FACTION = '" + pick.get(id) + "'");
+ dis_t();
+ }
+
+ private void get_t() 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() + "'");
+ }
+
+ private void dis_t() throws SQLException {
+ r_set.close();
+ state.close();
+ }
+}
diff --git a/src/main/java/ru/prisonlife/PrisonAPI/template/Level.java b/src/main/java/ru/prisonlife/PrisonAPI/template/Level.java
index 2a91f75..d88323c 100644
--- a/src/main/java/ru/prisonlife/PrisonAPI/template/Level.java
+++ b/src/main/java/ru/prisonlife/PrisonAPI/template/Level.java
@@ -43,6 +43,7 @@ public class Level {
setInResUUID();
if(r_set.first())
state.execute("UPDATE player_stats SET LEVEL = " + value + " WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
+ disconnect();
}
private void setInResUUID() throws SQLException {
diff --git a/src/main/java/ru/prisonlife/PrisonAPI/template/Prisoner.java b/src/main/java/ru/prisonlife/PrisonAPI/template/Prisoner.java
index 8672d9b..f071eb5 100644
--- a/src/main/java/ru/prisonlife/PrisonAPI/template/Prisoner.java
+++ b/src/main/java/ru/prisonlife/PrisonAPI/template/Prisoner.java
@@ -10,35 +10,39 @@ import java.sql.SQLException;
public class Prisoner {
private Player me;
private Level level;
- private Stats stats;
+ private Faction faction;
private Wallet wallet;
+ private Stats stats;
private PreparedStatement state;
private ResultSet r_set;
public Prisoner(Player player) {
me = player;
level = new Level(this);
- stats = new Stats(this);
wallet = new Wallet(this);
+ faction = new Faction(this);
+ stats = new Stats(this);
}
public Player getPlayer() { return me; }
+ public Level getPrisonLevel() throws SQLException { return this.level; }
+
+ public Faction getFaction() { return faction; }
+
public Wallet getWallet() { return wallet; }
public Stats getStats() { return stats; }
- public Level getPrisonLevel() throws SQLException { return this.level; }
-
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()) {
state.execute(
- "INSERT INTO player_stats(NAME, UUID, LEVEL, POINTS, G_TIME, D_BLOCKS, " +
- "K_PLAYERS, K_MOBS, DEATHS, WALLET) VALUES (" +"'" + getPlayer().getName()
- + "', '" + me.getUniqueId() + "', 1, 0, 0, 0, 0, 0, 0, 0);");
+ "INSERT INTO player_stats(NAME, UUID, LEVEL, POINTS, FACTION, WALLET, G_TIME, D_BLOCKS, " +
+ "K_PLAYERS, K_MOBS, DEATHS) VALUES (" +"'" + getPlayer().getName()
+ + "', '" + me.getUniqueId() + "', 1, 0, 'None', 0, 0, 0, 0, 0, 0);");
level = new Level(this);
stats = new Stats(this);
wallet = new Wallet(this);
diff --git a/src/main/java/ru/prisonlife/PrisonAPI/template/Wallet.java b/src/main/java/ru/prisonlife/PrisonAPI/template/Wallet.java
index 2887e42..4df322e 100644
--- a/src/main/java/ru/prisonlife/PrisonAPI/template/Wallet.java
+++ b/src/main/java/ru/prisonlife/PrisonAPI/template/Wallet.java
@@ -16,35 +16,32 @@ public class Wallet {
setInResUUID();
if(r_set.first()) {
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);
- }
- disconnect();
}
+ disconnect();
return NullPointerException.class.hashCode();
}
public void addBalance(int value) throws SQLException {
setInResUUID();
- if(r_set.first()) {
+ if(r_set.first())
state.execute("UPDATE player_stats SET WALLET = " + (getBalance() + value) + " WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
- disconnect();
- }
+ disconnect();
}
public void deposit(int value) throws SQLException {
setInResUUID();
- if(r_set.first()) {
+ if(r_set.first())
state.execute("UPDATE player_stats SET WALLET = " + (getBalance() - value) + " WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
- }
+ disconnect();
}
public void setBalance(int value) throws SQLException {
setInResUUID();
- if(r_set.first()) {
+ if(r_set.first())
state.execute("UPDATE player_stats SET WALLET = " + value + " WHERE UUID = '" + me.getPlayer().getUniqueId() + "'");
- disconnect();
- }
+ disconnect();
}
private void setInResUUID() throws SQLException {