First attempt to use UUID, not tested one ounce.
And I imagine the unit tests are going to fail.
This commit is contained in:
parent
1de176e67e
commit
a3d9a54ff0
4
pom.xml
4
pom.xml
@ -43,14 +43,14 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.bukkit</groupId>
|
<groupId>org.bukkit</groupId>
|
||||||
<artifactId>bukkit</artifactId>
|
<artifactId>bukkit</artifactId>
|
||||||
<version>1.7.2-R0.2-SNAPSHOT</version>
|
<version>1.7.9-R0.1-SNAPSHOT</version>
|
||||||
<type>jar</type>
|
<type>jar</type>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.bukkit</groupId>
|
<groupId>org.bukkit</groupId>
|
||||||
<artifactId>craftbukkit</artifactId>
|
<artifactId>craftbukkit</artifactId>
|
||||||
<version>1.7.2-R0.2-SNAPSHOT</version>
|
<version>1.7.9-R0.1-SNAPSHOT</version>
|
||||||
<type>jar</type>
|
<type>jar</type>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
@ -286,6 +286,7 @@ public class JailIO {
|
|||||||
st.executeUpdate(cellCreateCmd);
|
st.executeUpdate(cellCreateCmd);
|
||||||
|
|
||||||
String prisCreateCmd = "CREATE TABLE IF NOT EXISTS `" + prefix + "prisoners` ("
|
String prisCreateCmd = "CREATE TABLE IF NOT EXISTS `" + prefix + "prisoners` ("
|
||||||
|
+ "`uuid` VARCHAR(36) NOT NULL COMMENT 'The UUID of the prisoner.',"
|
||||||
+ "`name` VARCHAR(16) NOT NULL COMMENT 'The name of the prisoner.',"
|
+ "`name` VARCHAR(16) NOT NULL COMMENT 'The name of the prisoner.',"
|
||||||
+ "`jail` VARCHAR(250) NOT NULL COMMENT 'The jail the prisoner is in.',"
|
+ "`jail` VARCHAR(250) NOT NULL COMMENT 'The jail the prisoner is in.',"
|
||||||
+ "`cell` VARCHAR(250) NULL COMMENT 'The cell the prisoner is in.',"
|
+ "`cell` VARCHAR(250) NULL COMMENT 'The cell the prisoner is in.',"
|
||||||
@ -299,8 +300,8 @@ public class JailIO {
|
|||||||
+ "`armor` BLOB NULL COMMENT 'The armor in base64.',"
|
+ "`armor` BLOB NULL COMMENT 'The armor in base64.',"
|
||||||
+ "`previousLocation` VARCHAR(250) NULL COMMENT 'A string of their previous location.',"
|
+ "`previousLocation` VARCHAR(250) NULL COMMENT 'A string of their previous location.',"
|
||||||
+ "`previousGameMode` VARCHAR(16) NULL COMMENT 'Their previous gamemode before they were jailed.',"
|
+ "`previousGameMode` VARCHAR(16) NULL COMMENT 'Their previous gamemode before they were jailed.',"
|
||||||
+ "PRIMARY KEY (`name`),"
|
+ "PRIMARY KEY (`uuid`),"
|
||||||
+ "UNIQUE INDEX `name_UNIQUE` (`name` ASC))"
|
+ "UNIQUE INDEX `uuid_UNIQUE` (`uuid` ASC))"
|
||||||
+ "COMMENT = 'Contains all the prisoners, in cells and jails.';";
|
+ "COMMENT = 'Contains all the prisoners, in cells and jails.';";
|
||||||
|
|
||||||
//pl.debug(prisCreateCmd);
|
//pl.debug(prisCreateCmd);
|
||||||
@ -308,6 +309,7 @@ public class JailIO {
|
|||||||
|
|
||||||
String proCreateCmd = "CREATE TABLE IF NOT EXISTS `" + prefix + "records` ("
|
String proCreateCmd = "CREATE TABLE IF NOT EXISTS `" + prefix + "records` ("
|
||||||
+ "`recordid` INT NOT NULL AUTO_INCREMENT COMMENT 'Auto generated number for the records database.',"
|
+ "`recordid` INT NOT NULL AUTO_INCREMENT COMMENT 'Auto generated number for the records database.',"
|
||||||
|
+ "`uuid` VARCHAR(36) NOT NULL COMMENT 'The UUID of the prisoner.',"
|
||||||
+ "`username` VARCHAR(16) NOT NULL COMMENT 'The username of the prisoner.',"
|
+ "`username` VARCHAR(16) NOT NULL COMMENT 'The username of the prisoner.',"
|
||||||
+ "`jailer` VARCHAR(250) NOT NULL COMMENT 'The name of the person who jailed the prisoner.',"
|
+ "`jailer` VARCHAR(250) NOT NULL COMMENT 'The name of the person who jailed the prisoner.',"
|
||||||
+ "`date` VARCHAR(32) NOT NULL COMMENT 'A string of the date.',"
|
+ "`date` VARCHAR(32) NOT NULL COMMENT 'A string of the date.',"
|
||||||
@ -460,7 +462,7 @@ public class JailIO {
|
|||||||
String cellname = set.getString("cell");
|
String cellname = set.getString("cell");
|
||||||
Cell c = j.getCell(cellname);
|
Cell c = j.getCell(cellname);
|
||||||
|
|
||||||
Prisoner p = new Prisoner(set.getString("name"), set.getBoolean("muted"), set.getLong("time"), set.getString("jailer"), set.getString("reason"));
|
Prisoner p = new Prisoner(set.getString("uuid"), set.getString("name"), set.getBoolean("muted"), set.getLong("time"), set.getString("jailer"), set.getString("reason"));
|
||||||
p.setOfflinePending(set.getBoolean("offlinePending"));
|
p.setOfflinePending(set.getBoolean("offlinePending"));
|
||||||
p.setToBeTransferred(set.getBoolean("toBeTransferred"));
|
p.setToBeTransferred(set.getBoolean("toBeTransferred"));
|
||||||
Blob inv = set.getBlob("inventory");
|
Blob inv = set.getBlob("inventory");
|
||||||
@ -593,7 +595,8 @@ public class JailIO {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(flat.contains(cellNode + "prisoner")) {
|
if(flat.contains(cellNode + "prisoner")) {
|
||||||
Prisoner p = new Prisoner(flat.getString(cellNode + "prisoner.name"),
|
Prisoner p = new Prisoner(flat.getString(cellNode + "prisoner.uuid"),
|
||||||
|
flat.getString(cellNode + "prisoner.name"),
|
||||||
flat.getBoolean(cellNode + "prisoner.muted"),
|
flat.getBoolean(cellNode + "prisoner.muted"),
|
||||||
flat.getLong(cellNode + "prisoner.time"),
|
flat.getLong(cellNode + "prisoner.time"),
|
||||||
flat.getString(cellNode + "prisoner.jailer"),
|
flat.getString(cellNode + "prisoner.jailer"),
|
||||||
@ -615,9 +618,10 @@ public class JailIO {
|
|||||||
if(flat.isConfigurationSection(node + "prisoners")) {
|
if(flat.isConfigurationSection(node + "prisoners")) {
|
||||||
Set<String> prisoners = flat.getConfigurationSection(node + "prisoners").getKeys(false);
|
Set<String> prisoners = flat.getConfigurationSection(node + "prisoners").getKeys(false);
|
||||||
if(!prisoners.isEmpty()) {
|
if(!prisoners.isEmpty()) {
|
||||||
for(String prisoner : prisoners) {
|
for(String uuid : prisoners) {
|
||||||
String pNode = node + "prisoners." + prisoner + ".";
|
String pNode = node + "prisoners." + uuid + ".";
|
||||||
Prisoner pris = new Prisoner(prisoner,
|
Prisoner pris = new Prisoner(uuid,
|
||||||
|
flat.getString(pNode + "prisoner"),
|
||||||
flat.getBoolean(pNode + "muted"),
|
flat.getBoolean(pNode + "muted"),
|
||||||
flat.getLong(pNode + "time"),
|
flat.getLong(pNode + "time"),
|
||||||
flat.getString(pNode + "jailer"),
|
flat.getString(pNode + "jailer"),
|
||||||
@ -693,22 +697,23 @@ public class JailIO {
|
|||||||
for(Cell c : j.getCells()) {
|
for(Cell c : j.getCells()) {
|
||||||
if(c.hasPrisoner()) {
|
if(c.hasPrisoner()) {
|
||||||
Prisoner p = c.getPrisoner();
|
Prisoner p = c.getPrisoner();
|
||||||
PreparedStatement pPS = con.prepareStatement("REPLACE INTO `" + prefix + "prisoners` (`name`, `jail`, `cell`, `muted`, `time`,"
|
PreparedStatement pPS = con.prepareStatement("REPLACE INTO `" + prefix + "prisoners` (`uuid`, `name`, `jail`, `cell`, `muted`, `time`,"
|
||||||
+ "`offlinePending`, `toBeTransferred`, `jailer`, `reason`, `inventory`, `armor`, `previousLocation`, `previousGameMode`)"
|
+ "`offlinePending`, `toBeTransferred`, `jailer`, `reason`, `inventory`, `armor`, `previousLocation`, `previousGameMode`)"
|
||||||
+ "VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)");
|
+ "VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
|
||||||
pPS.setString(1, p.getName());
|
pPS.setString(1, p.getUUID().toString());
|
||||||
pPS.setString(2, j.getName());
|
pPS.setString(2, p.getName());
|
||||||
pPS.setString(3, c.getName());
|
pPS.setString(3, j.getName());
|
||||||
pPS.setBoolean(4, p.isMuted());
|
pPS.setString(4, c.getName());
|
||||||
pPS.setFloat(5, p.getRemainingTime());
|
pPS.setBoolean(5, p.isMuted());
|
||||||
pPS.setBoolean(6, p.isOfflinePending());
|
pPS.setFloat(6, p.getRemainingTime());
|
||||||
pPS.setBoolean(7, p.isToBeTransferred());
|
pPS.setBoolean(7, p.isOfflinePending());
|
||||||
pPS.setString(8, p.getJailer());
|
pPS.setBoolean(8, p.isToBeTransferred());
|
||||||
pPS.setString(9, p.getReason());
|
pPS.setString(9, p.getJailer());
|
||||||
pPS.setBytes(10, p.getInventory().getBytes());
|
pPS.setString(10, p.getReason());
|
||||||
pPS.setBytes(11, p.getArmor().getBytes());
|
pPS.setBytes(11, p.getInventory().getBytes());
|
||||||
pPS.setString(12, p.getPreviousLocationString());
|
pPS.setBytes(12, p.getArmor().getBytes());
|
||||||
pPS.setString(13, p.getPreviousGameMode().toString());
|
pPS.setString(13, p.getPreviousLocationString());
|
||||||
|
pPS.setString(14, p.getPreviousGameMode().toString());
|
||||||
|
|
||||||
pPS.executeUpdate();
|
pPS.executeUpdate();
|
||||||
pPS.close();
|
pPS.close();
|
||||||
@ -724,21 +729,22 @@ public class JailIO {
|
|||||||
if(con == null) this.prepareStorage(false);
|
if(con == null) this.prepareStorage(false);
|
||||||
|
|
||||||
for(Prisoner p : j.getPrisonersNotInCells()) {
|
for(Prisoner p : j.getPrisonersNotInCells()) {
|
||||||
PreparedStatement pPS = con.prepareStatement("REPLACE INTO `" + prefix + "prisoners` (`name`, `jail`, `cell`, `muted`, `time`,"
|
PreparedStatement pPS = con.prepareStatement("REPLACE INTO `" + prefix + "prisoners` (`uuid`, `name`, `jail`, `cell`, `muted`, `time`,"
|
||||||
+ "`offlinePending`, `toBeTransferred`, `jailer`, `reason`, `inventory`, `armor`, `previousLocation`, `previousGameMode`) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)");
|
+ "`offlinePending`, `toBeTransferred`, `jailer`, `reason`, `inventory`, `armor`, `previousLocation`, `previousGameMode`) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
|
||||||
pPS.setString(1, p.getName());
|
pPS.setString(1, p.getUUID().toString());
|
||||||
pPS.setString(2, j.getName());
|
pPS.setString(2, p.getName());
|
||||||
pPS.setString(3, "");
|
pPS.setString(3, j.getName());
|
||||||
pPS.setBoolean(4, p.isMuted());
|
pPS.setString(4, "");
|
||||||
pPS.setFloat(5, p.getRemainingTime());
|
pPS.setBoolean(5, p.isMuted());
|
||||||
pPS.setBoolean(6, p.isOfflinePending());
|
pPS.setFloat(6, p.getRemainingTime());
|
||||||
pPS.setBoolean(7, p.isToBeTransferred());
|
pPS.setBoolean(7, p.isOfflinePending());
|
||||||
pPS.setString(8, p.getJailer());
|
pPS.setBoolean(8, p.isToBeTransferred());
|
||||||
pPS.setString(9, p.getReason());
|
pPS.setString(9, p.getJailer());
|
||||||
pPS.setBytes(10, p.getInventory().getBytes());
|
pPS.setString(10, p.getReason());
|
||||||
pPS.setBytes(11, p.getArmor().getBytes());
|
pPS.setBytes(11, p.getInventory().getBytes());
|
||||||
pPS.setString(12, p.getPreviousLocationString());
|
pPS.setBytes(12, p.getArmor().getBytes());
|
||||||
pPS.setString(13, p.getPreviousGameMode().toString());
|
pPS.setString(13, p.getPreviousLocationString());
|
||||||
|
pPS.setString(14, p.getPreviousGameMode().toString());
|
||||||
|
|
||||||
pPS.executeUpdate();
|
pPS.executeUpdate();
|
||||||
pPS.close();
|
pPS.close();
|
||||||
@ -809,6 +815,7 @@ public class JailIO {
|
|||||||
|
|
||||||
if(c.getPrisoner() != null) {
|
if(c.getPrisoner() != null) {
|
||||||
Prisoner p = c.getPrisoner();
|
Prisoner p = c.getPrisoner();
|
||||||
|
flat.set(cNode + "prisoner.uuid", p.getUUID().toString());
|
||||||
flat.set(cNode + "prisoner.name", p.getName());
|
flat.set(cNode + "prisoner.name", p.getName());
|
||||||
flat.set(cNode + "prisoner.muted", p.isMuted());
|
flat.set(cNode + "prisoner.muted", p.isMuted());
|
||||||
flat.set(cNode + "prisoner.time", p.getRemainingTime());
|
flat.set(cNode + "prisoner.time", p.getRemainingTime());
|
||||||
@ -828,7 +835,8 @@ public class JailIO {
|
|||||||
//Null all the prisoners out before we save them again, this way no prisoners are left behind
|
//Null all the prisoners out before we save them again, this way no prisoners are left behind
|
||||||
flat.set(node + "prisoners", null);
|
flat.set(node + "prisoners", null);
|
||||||
for(Prisoner p : j.getPrisonersNotInCells()) {
|
for(Prisoner p : j.getPrisonersNotInCells()) {
|
||||||
String pNode = node + "prisoners." + p.getName() + ".";
|
String pNode = node + "prisoners." + p.getUUID().toString() + ".";
|
||||||
|
flat.set(pNode + "name", p.getName());
|
||||||
flat.set(pNode + "muted", p.isMuted());
|
flat.set(pNode + "muted", p.isMuted());
|
||||||
flat.set(pNode + "time", p.getRemainingTime());
|
flat.set(pNode + "time", p.getRemainingTime());
|
||||||
flat.set(pNode + "offlinePending", p.isOfflinePending());
|
flat.set(pNode + "offlinePending", p.isOfflinePending());
|
||||||
@ -890,20 +898,21 @@ public class JailIO {
|
|||||||
|
|
||||||
if(c.hasPrisoner()) {
|
if(c.hasPrisoner()) {
|
||||||
Prisoner p = c.getPrisoner();
|
Prisoner p = c.getPrisoner();
|
||||||
PreparedStatement pPS = con.prepareStatement("REPLACE INTO `" + prefix + "prisoners` (`name`, `jail`, `cell`, `muted`, `time`,"
|
PreparedStatement pPS = con.prepareStatement("REPLACE INTO `" + prefix + "prisoners` (`uuid`, `name`, `jail`, `cell`, `muted`, `time`,"
|
||||||
+ "`offlinePending`, `toBeTransferred`, `jailer`, `reason`, `inventory`, `armor`, `previousLocation`, `previousGameMode`) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)");
|
+ "`offlinePending`, `toBeTransferred`, `jailer`, `reason`, `inventory`, `armor`, `previousLocation`, `previousGameMode`) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
|
||||||
pPS.setString(1, p.getName());
|
pPS.setString(1, p.getUUID().toString());
|
||||||
pPS.setString(2, j.getName());
|
pPS.setString(2, p.getName());
|
||||||
pPS.setString(3, c.getName());
|
pPS.setString(3, j.getName());
|
||||||
pPS.setBoolean(4, p.isMuted());
|
pPS.setString(4, c.getName());
|
||||||
pPS.setFloat(5, p.getRemainingTime());
|
pPS.setBoolean(5, p.isMuted());
|
||||||
pPS.setBoolean(6, p.isOfflinePending());
|
pPS.setFloat(6, p.getRemainingTime());
|
||||||
pPS.setBoolean(7, p.isToBeTransferred());
|
pPS.setBoolean(7, p.isOfflinePending());
|
||||||
pPS.setString(8, p.getReason());
|
pPS.setBoolean(8, p.isToBeTransferred());
|
||||||
pPS.setBytes(9, p.getInventory().getBytes());
|
pPS.setString(9, p.getReason());
|
||||||
pPS.setBytes(10, p.getArmor().getBytes());
|
pPS.setBytes(10, p.getInventory().getBytes());
|
||||||
pPS.setString(11, p.getPreviousLocationString());
|
pPS.setBytes(11, p.getArmor().getBytes());
|
||||||
pPS.setString(12, p.getPreviousGameMode().toString());
|
pPS.setString(12, p.getPreviousLocationString());
|
||||||
|
pPS.setString(13, p.getPreviousGameMode().toString());
|
||||||
|
|
||||||
pPS.executeUpdate();
|
pPS.executeUpdate();
|
||||||
pPS.close();
|
pPS.close();
|
||||||
@ -943,8 +952,8 @@ public class JailIO {
|
|||||||
case 1:
|
case 1:
|
||||||
case 2:
|
case 2:
|
||||||
try {
|
try {
|
||||||
PreparedStatement pp = con.prepareStatement("delete from `" + prefix + "prisoners` where name = ? limit 1;");
|
PreparedStatement pp = con.prepareStatement("delete from `" + prefix + "prisoners` where uuid = ? limit 1;");
|
||||||
pp.setString(1, p.getName());
|
pp.setString(1, p.getUUID().toString());
|
||||||
|
|
||||||
pl.debug("Removing " + p.getName() + " from MySQL database.");
|
pl.debug("Removing " + p.getName() + " from MySQL database.");
|
||||||
|
|
||||||
@ -958,7 +967,7 @@ public class JailIO {
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if(c == null)
|
if(c == null)
|
||||||
flat.set("jails." + j.getName() + ".prisoners." + p.getName(), null);
|
flat.set("jails." + j.getName() + ".prisoners." + p.getUUID().toString(), null);
|
||||||
else
|
else
|
||||||
flat.set("jails." + j.getName() + "." + c.getName() + ".prisoner", null);
|
flat.set("jails." + j.getName() + "." + c.getName() + ".prisoner", null);
|
||||||
|
|
||||||
@ -1063,24 +1072,26 @@ public class JailIO {
|
|||||||
/**
|
/**
|
||||||
* Adds an entry to the database/file for the user, logging when they was jailed.
|
* Adds an entry to the database/file for the user, logging when they was jailed.
|
||||||
*
|
*
|
||||||
|
* @param uuid of the player
|
||||||
* @param username of the player
|
* @param username of the player
|
||||||
* @param jailer who jailed them
|
* @param jailer who jailed them
|
||||||
* @param date string of when they are jailed
|
* @param date string of when they are jailed
|
||||||
* @param time of the player's sentence
|
* @param time of the player's sentence
|
||||||
* @param reason the player is jailed
|
* @param reason the player is jailed
|
||||||
*/
|
*/
|
||||||
public void addRecordEntry(String username, String jailer, String date, long time, String reason) {
|
public void addRecordEntry(String uuid, String username, String jailer, String date, long time, String reason) {
|
||||||
switch(storage) {
|
switch(storage) {
|
||||||
case 1:
|
case 1:
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
try {
|
try {
|
||||||
PreparedStatement p = con.prepareStatement("insert into `" + prefix + "records` (`username`, `jailer`, `date`, `time`, `reason`) VALUES (?,?,?,?,?);");
|
PreparedStatement p = con.prepareStatement("insert into `" + prefix + "records` (`uuid`, `username`, `jailer`, `date`, `time`, `reason`) VALUES (?,?,?,?,?,?);");
|
||||||
p.setString(1, username);
|
p.setString(1, uuid);
|
||||||
p.setString(2, jailer);
|
p.setString(2, username);
|
||||||
p.setString(3, date);
|
p.setString(3, jailer);
|
||||||
p.setLong(4, time);
|
p.setString(4, date);
|
||||||
p.setString(5, reason);
|
p.setLong(5, time);
|
||||||
|
p.setString(6, reason);
|
||||||
|
|
||||||
p.executeUpdate();
|
p.executeUpdate();
|
||||||
p.close();
|
p.close();
|
||||||
@ -1093,8 +1104,8 @@ public class JailIO {
|
|||||||
default:
|
default:
|
||||||
if(records == null) records = YamlConfiguration.loadConfiguration(new File(pl.getDataFolder(), "records.yml"));
|
if(records == null) records = YamlConfiguration.loadConfiguration(new File(pl.getDataFolder(), "records.yml"));
|
||||||
|
|
||||||
List<String> previous = records.getStringList("username");
|
List<String> previous = records.getStringList(uuid);
|
||||||
previous.add(this.getLanguageString(LangString.RECORDENTRY, new String[] { date, username, jailer, String.valueOf(time), reason }));
|
previous.add(this.getLanguageString(LangString.RECORDENTRY, new String[] { date, username, jailer, String.valueOf(time), reason, uuid }));
|
||||||
|
|
||||||
records.set(username, previous);
|
records.set(username, previous);
|
||||||
|
|
||||||
@ -1115,7 +1126,7 @@ public class JailIO {
|
|||||||
* @param username of the prisoner to get.
|
* @param username of the prisoner to get.
|
||||||
* @return A List of strings containing the record entries.
|
* @return A List of strings containing the record entries.
|
||||||
*/
|
*/
|
||||||
public List<String> getRecordEntries(String username) {
|
public List<String> getRecordEntries(String uuid) {
|
||||||
List<String> entries = new ArrayList<String>();
|
List<String> entries = new ArrayList<String>();
|
||||||
|
|
||||||
switch(storage) {
|
switch(storage) {
|
||||||
@ -1123,13 +1134,13 @@ public class JailIO {
|
|||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
try {
|
try {
|
||||||
PreparedStatement ps = con.prepareStatement("SELECT * FROM " + prefix + "records where username = ?");
|
PreparedStatement ps = con.prepareStatement("SELECT * FROM " + prefix + "records where uuid = ?");
|
||||||
ps.setString(1, username);
|
ps.setString(1, uuid);
|
||||||
ResultSet set = ps.executeQuery();
|
ResultSet set = ps.executeQuery();
|
||||||
|
|
||||||
while(set.next()) {
|
while(set.next()) {
|
||||||
entries.add(this.getLanguageString(LangString.RECORDENTRY,
|
entries.add(this.getLanguageString(LangString.RECORDENTRY,
|
||||||
new String[] { set.getString("date"), username, set.getString("jailer"), String.valueOf(set.getLong("time")), set.getString("reason") }));
|
new String[] { set.getString("date"), set.getString("username"), set.getString("jailer"), String.valueOf(set.getLong("time")), set.getString("reason") }));
|
||||||
}
|
}
|
||||||
|
|
||||||
set.close();
|
set.close();
|
||||||
@ -1137,13 +1148,13 @@ public class JailIO {
|
|||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
pl.getLogger().severe("---------- Jail Error!!! ----------");
|
pl.getLogger().severe("---------- Jail Error!!! ----------");
|
||||||
pl.getLogger().severe("Error while getting all the record entries for '" + username + "', please check the error and fix what is wrong.");
|
pl.getLogger().severe("Error while getting all the record entries for '" + uuid + "', please check the error and fix what is wrong.");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if(records == null) records = YamlConfiguration.loadConfiguration(new File(pl.getDataFolder(), "records.yml"));
|
if(records == null) records = YamlConfiguration.loadConfiguration(new File(pl.getDataFolder(), "records.yml"));
|
||||||
|
|
||||||
entries = records.getStringList(username);
|
entries = records.getStringList(uuid);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.graywolf336.jail.beans;
|
package com.graywolf336.jail.beans;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -14,7 +15,7 @@ import org.bukkit.Location;
|
|||||||
* @version 3.0.1
|
* @version 3.0.1
|
||||||
*/
|
*/
|
||||||
public class Prisoner {
|
public class Prisoner {
|
||||||
private String name, jailer, reason, inventory, armor;
|
private String uuid, name, jailer, reason, inventory, armor;
|
||||||
private boolean muted, offlinePending, teleporting, toBeTransferred;
|
private boolean muted, offlinePending, teleporting, toBeTransferred;
|
||||||
private long time, afk;
|
private long time, afk;
|
||||||
private Location previousPosition;
|
private Location previousPosition;
|
||||||
@ -23,13 +24,15 @@ public class Prisoner {
|
|||||||
/**
|
/**
|
||||||
* Creates a new prisoner with a name and whether they are muted or not.
|
* Creates a new prisoner with a name and whether they are muted or not.
|
||||||
*
|
*
|
||||||
|
* @param uuid The uuid of the prisoner
|
||||||
* @param name The name of the prisoner
|
* @param name The name of the prisoner
|
||||||
* @param muted Whether the prisoner is muted or not
|
* @param muted Whether the prisoner is muted or not
|
||||||
* @param time The amount of remaining time the prisoner has
|
* @param time The amount of remaining time the prisoner has
|
||||||
* @param jailer The name of the person who jailed this prisoner
|
* @param jailer The name of the person who jailed this prisoner
|
||||||
* @param reason The reason why this prisoner is in jail
|
* @param reason The reason why this prisoner is in jail
|
||||||
*/
|
*/
|
||||||
public Prisoner(String name, boolean muted, long time, String jailer, String reason) {
|
public Prisoner(String uuid, String name, boolean muted, long time, String jailer, String reason) {
|
||||||
|
this.uuid = uuid;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.muted = muted;
|
this.muted = muted;
|
||||||
this.time = time;
|
this.time = time;
|
||||||
@ -45,6 +48,11 @@ public class Prisoner {
|
|||||||
this.afk = 0;
|
this.afk = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Returns the UUID of the prisoner. */
|
||||||
|
public UUID getUUID() {
|
||||||
|
return UUID.fromString(this.uuid);
|
||||||
|
}
|
||||||
|
|
||||||
/** Gets the name of this player. */
|
/** Gets the name of this player. */
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return this.name;
|
return this.name;
|
||||||
|
@ -164,10 +164,17 @@ public class JailCommand implements Command {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String uuid = "";
|
||||||
|
if(p == null) {
|
||||||
|
uuid = jm.getPlugin().getServer().getOfflinePlayer(params.getPlayer()).getUniqueId().toString();
|
||||||
|
}else {
|
||||||
|
uuid = p.getUniqueId().toString();
|
||||||
|
}
|
||||||
|
|
||||||
//Get the jail instance from the name of jail in the params.
|
//Get the jail instance from the name of jail in the params.
|
||||||
Jail j = jm.getJail(jailName);
|
Jail j = jm.getJail(jailName);
|
||||||
Cell c = j.getCell(params.getCell());
|
Cell c = j.getCell(params.getCell());
|
||||||
Prisoner pris = new Prisoner(params.getPlayer(), muted, time, sender.getName(), reason);
|
Prisoner pris = new Prisoner(uuid, params.getPlayer(), muted, time, sender.getName(), reason);
|
||||||
|
|
||||||
//call the event
|
//call the event
|
||||||
PrePrisonerJailedEvent event = new PrePrisonerJailedEvent(j, c, pris, p, p == null, pris.getJailer());
|
PrePrisonerJailedEvent event = new PrePrisonerJailedEvent(j, c, pris, p, p == null, pris.getJailer());
|
||||||
|
@ -118,7 +118,7 @@ public class OldInputOutput {
|
|||||||
|
|
||||||
//Check if the jail exists, if not then we refuse to load it
|
//Check if the jail exists, if not then we refuse to load it
|
||||||
if(j != null) {
|
if(j != null) {
|
||||||
Prisoner p = new Prisoner(name, set.getBoolean("muted"), (long) set.getInt("RemainTime"), set.getString("Jailer"), set.getString("reason"));
|
Prisoner p = new Prisoner(pl.getServer().getOfflinePlayer(name).getUniqueId().toString(), name, set.getBoolean("muted"), (long) set.getInt("RemainTime"), set.getString("Jailer"), set.getString("reason"));
|
||||||
p.setOfflinePending(set.getBoolean("Offline"));
|
p.setOfflinePending(set.getBoolean("Offline"));
|
||||||
p.setToBeTransferred(transfer);
|
p.setToBeTransferred(transfer);
|
||||||
|
|
||||||
|
@ -23,14 +23,16 @@ public class JailingListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler(ignoreCancelled=true)
|
@EventHandler(ignoreCancelled=true)
|
||||||
public void preJailingListener(PrePrisonerJailedEvent event) {
|
public void preJailingListener(PrePrisonerJailedEvent event) {
|
||||||
pl.getJailIO().addRecordEntry(event.getPrisoner().getName(),
|
pl.getJailIO().addRecordEntry(event.getPrisoner().getUUID().toString(),
|
||||||
|
event.getPrisoner().getName(),
|
||||||
event.getPrisoner().getJailer(), dateFormat.format(new Date()),
|
event.getPrisoner().getJailer(), dateFormat.format(new Date()),
|
||||||
event.getPrisoner().getRemainingTimeInMinutes(), event.getPrisoner().getReason());
|
event.getPrisoner().getRemainingTimeInMinutes(), event.getPrisoner().getReason());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(ignoreCancelled=true)
|
@EventHandler(ignoreCancelled=true)
|
||||||
public void preJailingListener(PrePrisonerJailedByJailStickEvent event) {
|
public void preJailingListener(PrePrisonerJailedByJailStickEvent event) {
|
||||||
pl.getJailIO().addRecordEntry(event.getPrisoner().getName(),
|
pl.getJailIO().addRecordEntry(event.getPrisoner().getUUID().toString(),
|
||||||
|
event.getPrisoner().getName(),
|
||||||
event.getPrisoner().getJailer(), dateFormat.format(new Date()),
|
event.getPrisoner().getJailer(), dateFormat.format(new Date()),
|
||||||
event.getPrisoner().getRemainingTimeInMinutes(), event.getPrisoner().getReason());
|
event.getPrisoner().getRemainingTimeInMinutes(), event.getPrisoner().getReason());
|
||||||
}
|
}
|
||||||
|
@ -204,7 +204,7 @@ public class PlayerListener implements Listener {
|
|||||||
}else {
|
}else {
|
||||||
Stick s = pl.getJailStickManager().getStick(attacker.getItemInHand().getType());
|
Stick s = pl.getJailStickManager().getStick(attacker.getItemInHand().getType());
|
||||||
|
|
||||||
Prisoner p = new Prisoner(player.getName(),
|
Prisoner p = new Prisoner(player.getUniqueId().toString(), player.getName(),
|
||||||
pl.getConfig().getBoolean(Settings.AUTOMATICMUTE.getPath()),
|
pl.getConfig().getBoolean(Settings.AUTOMATICMUTE.getPath()),
|
||||||
s.getTime(), attacker.getName(), s.getReason());
|
s.getTime(), attacker.getName(), s.getReason());
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ language:
|
|||||||
playernotonline: '&cThat player is not online!'
|
playernotonline: '&cThat player is not online!'
|
||||||
pluginreloaded: '&9Jail data successfully reloaded.'
|
pluginreloaded: '&9Jail data successfully reloaded.'
|
||||||
prisonerscleared: '&cAll the prisoners from %0% have been cleared.'
|
prisonerscleared: '&cAll the prisoners from %0% have been cleared.'
|
||||||
recordentry: '&7[%0%]: &9%1% &fjailed by &9%2% &ffor &9%3% &fminutes with a reason of &9%4%&f.'
|
recordentry: '&7[%0%]: &9%1% &fjailed by &9%2% &ffor &9%3% &fminutes with a reason of &9%4%&f. [%5%]'
|
||||||
recordtimesjailed: '&c%0% has been jailed &a%1% &ctimes.'
|
recordtimesjailed: '&c%0% has been jailed &a%1% &ctimes.'
|
||||||
timeformat: "MM/dd/yyyy HH:mm:ss"
|
timeformat: "MM/dd/yyyy HH:mm:ss"
|
||||||
transferring: '&9transferring'
|
transferring: '&9transferring'
|
||||||
|
@ -15,7 +15,7 @@ import org.bukkit.World;
|
|||||||
import org.bukkit.WorldCreator;
|
import org.bukkit.WorldCreator;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.command.ConsoleCommandSender;
|
import org.bukkit.command.ConsoleCommandSender;
|
||||||
import org.bukkit.craftbukkit.v1_7_R1.inventory.CraftItemFactory;
|
import org.bukkit.craftbukkit.v1_7_R3.inventory.CraftItemFactory;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.permissions.Permission;
|
import org.bukkit.permissions.Permission;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
Loading…
Reference in New Issue
Block a user