Finish using the UUID, we are still using blocking methods.
I want to get fully away from blocking methods and instead make the user/player/prisoner/whatever wait to get an answer while we retrieve the uuid information asynchronously.
This commit is contained in:
parent
ad9c70cbbf
commit
4d4f609b82
@ -700,7 +700,7 @@ public class JailIO {
|
|||||||
+ "`offlinePending`, `toBeTransferred`, `jailer`, `reason`, `inventory`, `armor`, `previousLocation`, `previousGameMode`)"
|
+ "`offlinePending`, `toBeTransferred`, `jailer`, `reason`, `inventory`, `armor`, `previousLocation`, `previousGameMode`)"
|
||||||
+ "VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
|
+ "VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
|
||||||
pPS.setString(1, p.getUUID().toString());
|
pPS.setString(1, p.getUUID().toString());
|
||||||
pPS.setString(2, p.getName());
|
pPS.setString(2, p.getLastKnownName());
|
||||||
pPS.setString(3, j.getName());
|
pPS.setString(3, j.getName());
|
||||||
pPS.setString(4, c.getName());
|
pPS.setString(4, c.getName());
|
||||||
pPS.setBoolean(5, p.isMuted());
|
pPS.setBoolean(5, p.isMuted());
|
||||||
@ -731,7 +731,7 @@ public class JailIO {
|
|||||||
PreparedStatement pPS = con.prepareStatement("REPLACE INTO `" + prefix + "prisoners` (`uuid`, `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.getUUID().toString());
|
pPS.setString(1, p.getUUID().toString());
|
||||||
pPS.setString(2, p.getName());
|
pPS.setString(2, p.getLastKnownName());
|
||||||
pPS.setString(3, j.getName());
|
pPS.setString(3, j.getName());
|
||||||
pPS.setString(4, "");
|
pPS.setString(4, "");
|
||||||
pPS.setBoolean(5, p.isMuted());
|
pPS.setBoolean(5, p.isMuted());
|
||||||
@ -815,7 +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.uuid", p.getUUID().toString());
|
||||||
flat.set(cNode + "prisoner.name", p.getName());
|
flat.set(cNode + "prisoner.name", p.getLastKnownName());
|
||||||
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());
|
||||||
flat.set(cNode + "prisoner.offlinePending", p.isOfflinePending());
|
flat.set(cNode + "prisoner.offlinePending", p.isOfflinePending());
|
||||||
@ -835,7 +835,7 @@ public class JailIO {
|
|||||||
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.getUUID().toString() + ".";
|
String pNode = node + "prisoners." + p.getUUID().toString() + ".";
|
||||||
flat.set(pNode + "name", p.getName());
|
flat.set(pNode + "name", p.getLastKnownName());
|
||||||
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());
|
||||||
@ -900,7 +900,7 @@ public class JailIO {
|
|||||||
PreparedStatement pPS = con.prepareStatement("REPLACE INTO `" + prefix + "prisoners` (`uuid`, `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.getUUID().toString());
|
pPS.setString(1, p.getUUID().toString());
|
||||||
pPS.setString(2, p.getName());
|
pPS.setString(2, p.getLastKnownName());
|
||||||
pPS.setString(3, j.getName());
|
pPS.setString(3, j.getName());
|
||||||
pPS.setString(4, c.getName());
|
pPS.setString(4, c.getName());
|
||||||
pPS.setBoolean(5, p.isMuted());
|
pPS.setBoolean(5, p.isMuted());
|
||||||
@ -954,14 +954,14 @@ public class JailIO {
|
|||||||
PreparedStatement pp = con.prepareStatement("delete from `" + prefix + "prisoners` where uuid = ? limit 1;");
|
PreparedStatement pp = con.prepareStatement("delete from `" + prefix + "prisoners` where uuid = ? limit 1;");
|
||||||
pp.setString(1, p.getUUID().toString());
|
pp.setString(1, p.getUUID().toString());
|
||||||
|
|
||||||
pl.debug("Removing " + p.getName() + " from MySQL database.");
|
pl.debug("Removing " + p.getLastKnownName() + " (" + p.getUUID().toString() + ") from MySQL database.");
|
||||||
|
|
||||||
pp.executeUpdate();
|
pp.executeUpdate();
|
||||||
pp.close();
|
pp.close();
|
||||||
} 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 removing the prisoner '" + p.getName() + "' from the database, please check the error and fix what is wrong.");
|
pl.getLogger().severe("Error while removing the prisoner '" + p.getLastKnownName() + "' from the database, please check the error and fix what is wrong.");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -222,6 +222,45 @@ public class JailManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the {@link Jail} the player is in from their last known username, null if not jailed.
|
||||||
|
*
|
||||||
|
* @param username Last known username to search by
|
||||||
|
* @return {@link Jail jail} player is in
|
||||||
|
*/
|
||||||
|
public Jail getJailPlayerIsInByLastKnownName(String username) {
|
||||||
|
for(Jail j : jails.values())
|
||||||
|
for(Prisoner p : j.getAllPrisoners())
|
||||||
|
if(p.getLastKnownName().equalsIgnoreCase(username))
|
||||||
|
return j;
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the {@link Prisoner}'s data from the last known username, returning null if no prisoner has that name.
|
||||||
|
*
|
||||||
|
* @param username Last known username to go by
|
||||||
|
* @return {@link Prisoner prisoner} data
|
||||||
|
*/
|
||||||
|
public Prisoner getPrisonerByLastKnownName(String username) {
|
||||||
|
for(Prisoner p : this.getAllPrisoners())
|
||||||
|
if(p.getLastKnownName().equalsIgnoreCase(username))
|
||||||
|
return p;
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the provided username is jailed, using last known username.
|
||||||
|
*
|
||||||
|
* @param username Last known username to go by
|
||||||
|
* @return true if they are jailed, false if not
|
||||||
|
*/
|
||||||
|
public boolean isPlayerJailedByLastKnownUsername(String username) {
|
||||||
|
return this.getPrisonerByLastKnownName(username) != null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clears a {@link Jail} of all its prisoners if the jail is provided, otherwise it releases all the prisoners in all the jails.
|
* Clears a {@link Jail} of all its prisoners if the jail is provided, otherwise it releases all the prisoners in all the jails.
|
||||||
*
|
*
|
||||||
|
@ -86,9 +86,9 @@ public class PrisonerManager {
|
|||||||
String msg = "";
|
String msg = "";
|
||||||
|
|
||||||
if(prisoner.getRemainingTime() < 0L)
|
if(prisoner.getRemainingTime() < 0L)
|
||||||
msg = pl.getJailIO().getLanguageString(LangString.BROADCASTMESSAGEFOREVER, new String[] { prisoner.getName() });
|
msg = pl.getJailIO().getLanguageString(LangString.BROADCASTMESSAGEFOREVER, new String[] { prisoner.getLastKnownName() });
|
||||||
else
|
else
|
||||||
msg = pl.getJailIO().getLanguageString(LangString.BROADCASTMESSAGEFORMINUTES, new String[] { prisoner.getName(), String.valueOf(prisoner.getRemainingTimeInMinutes()) });
|
msg = pl.getJailIO().getLanguageString(LangString.BROADCASTMESSAGEFORMINUTES, new String[] { prisoner.getLastKnownName(), String.valueOf(prisoner.getRemainingTimeInMinutes()) });
|
||||||
|
|
||||||
boolean broadcasted = false;
|
boolean broadcasted = false;
|
||||||
//Broadcast the message, if it is enabled
|
//Broadcast the message, if it is enabled
|
||||||
|
@ -334,11 +334,10 @@ public class Jail {
|
|||||||
*
|
*
|
||||||
* @param name The name of the prisoner to get.
|
* @param name The name of the prisoner to get.
|
||||||
* @return the prisoner instance, can be null
|
* @return the prisoner instance, can be null
|
||||||
* @deprecated Use {@link #getPrisoner(UUID)}
|
|
||||||
*/
|
*/
|
||||||
public Prisoner getPrisoner(String name) {
|
public Prisoner getPrisonerByLastKnownName(String name) {
|
||||||
for(Prisoner p : this.getAllPrisoners())
|
for(Prisoner p : this.getAllPrisoners())
|
||||||
if(p.getName().equalsIgnoreCase(name))
|
if(p.getLastKnownName().equalsIgnoreCase(name))
|
||||||
return p;
|
return p;
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
@ -53,8 +53,14 @@ public class Prisoner {
|
|||||||
return UUID.fromString(this.uuid);
|
return UUID.fromString(this.uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Gets the name of this player. */
|
/** Gets the name of this prisoner. */
|
||||||
public String getName() {
|
public String getLastKnownName() {
|
||||||
|
return this.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Sets the name of this prisoner. */
|
||||||
|
public String setLastKnownName(String username) {
|
||||||
|
this.name = username;
|
||||||
return this.name;
|
return this.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ public class HandCuffCommand implements Command {
|
|||||||
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PLAYERNOTONLINE));
|
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PLAYERNOTONLINE));
|
||||||
}else if(player.hasPermission("jail.cantbehandcuffed")) {
|
}else if(player.hasPermission("jail.cantbehandcuffed")) {
|
||||||
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.CANTBEHANDCUFFED, new String[] { player.getName() }));
|
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.CANTBEHANDCUFFED, new String[] { player.getName() }));
|
||||||
}else if(jm.isPlayerJailed(player.getName())) {
|
}else if(jm.isPlayerJailed(player.getUniqueId())) {
|
||||||
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.CURRENTLYJAILEDHANDCUFF, new String[] { player.getName() }));
|
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.CURRENTLYJAILEDHANDCUFF, new String[] { player.getName() }));
|
||||||
}else if(jm.getPlugin().getHandCuffManager().isHandCuffed(player.getName())) {
|
}else if(jm.getPlugin().getHandCuffManager().isHandCuffed(player.getName())) {
|
||||||
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.HANDCUFFSRELEASED, new String[] { player.getName() }));
|
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.HANDCUFFSRELEASED, new String[] { player.getName() }));
|
||||||
|
@ -24,17 +24,17 @@ public class UnJailCommand implements Command {
|
|||||||
|
|
||||||
public boolean execute(JailManager jm, CommandSender sender, String... args) {
|
public boolean execute(JailManager jm, CommandSender sender, String... args) {
|
||||||
//Check if the player is jailed
|
//Check if the player is jailed
|
||||||
if(jm.isPlayerJailed(args[0])) {
|
if(jm.isPlayerJailedByLastKnownUsername(args[0])) {
|
||||||
Jail j = jm.getJailPlayerIsIn(args[0]);
|
Jail j = jm.getJailPlayerIsInByLastKnownName(args[0]);
|
||||||
Prisoner pris = j.getPrisoner(args[0]);
|
Prisoner pris = j.getPrisonerByLastKnownName(args[0]);
|
||||||
Player p = jm.getPlugin().getServer().getPlayerExact(args[0]);
|
Player p = jm.getPlugin().getServer().getPlayer(pris.getUUID());
|
||||||
|
|
||||||
//Check if the player is on the server or not
|
//Check if the player is on the server or not
|
||||||
if(p == null) {
|
if(p == null) {
|
||||||
//Check if the player has offline pending and their remaining time is above 0, if so then
|
//Check if the player has offline pending and their remaining time is above 0, if so then
|
||||||
//forceably unjail them
|
//forceably unjail them
|
||||||
if(pris.isOfflinePending() && pris.getRemainingTime() != 0L) {
|
if(pris.isOfflinePending() && pris.getRemainingTime() != 0L) {
|
||||||
jm.getPlugin().getPrisonerManager().forceUnJail(j, j.getCellPrisonerIsIn(args[0]), p, pris);
|
jm.getPlugin().getPrisonerManager().forceUnJail(j, j.getCellPrisonerIsIn(pris.getUUID()), p, pris);
|
||||||
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.FORCEUNJAILED, args[0]));
|
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.FORCEUNJAILED, args[0]));
|
||||||
}else {
|
}else {
|
||||||
//The player is not, so we'll set the remaining time to zero and do it when they login next
|
//The player is not, so we'll set the remaining time to zero and do it when they login next
|
||||||
@ -45,7 +45,7 @@ public class UnJailCommand implements Command {
|
|||||||
}else {
|
}else {
|
||||||
//Player is online, so let's try unjailing them
|
//Player is online, so let's try unjailing them
|
||||||
try {
|
try {
|
||||||
jm.getPlugin().getPrisonerManager().unJail(j, j.getCellPrisonerIsIn(args[0]), p, pris);
|
jm.getPlugin().getPrisonerManager().unJail(j, j.getCellPrisonerIsIn(pris.getUUID()), p, pris);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
sender.sendMessage(ChatColor.RED + e.getMessage());
|
sender.sendMessage(ChatColor.RED + e.getMessage());
|
||||||
}
|
}
|
||||||
|
@ -21,8 +21,8 @@ public class UnJailForceCommand implements Command {
|
|||||||
|
|
||||||
public boolean execute(JailManager jm, CommandSender sender, String... args) {
|
public boolean execute(JailManager jm, CommandSender sender, String... args) {
|
||||||
//Check if the player is jailed
|
//Check if the player is jailed
|
||||||
if(jm.isPlayerJailed(args[0])) {
|
if(jm.isPlayerJailedByLastKnownUsername(args[0])) {
|
||||||
jm.getPlugin().getPrisonerManager().forceRelease(jm.getPrisoner(args[0]));
|
jm.getPlugin().getPrisonerManager().forceRelease(jm.getPrisonerByLastKnownName(args[0]));
|
||||||
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.FORCEUNJAILED, args[0]));
|
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.FORCEUNJAILED, args[0]));
|
||||||
|
|
||||||
if(jm.getPlugin().getConfig().getBoolean(Settings.LOGJAILINGTOCONSOLE.getPath())) {
|
if(jm.getPlugin().getConfig().getBoolean(Settings.LOGJAILINGTOCONSOLE.getPath())) {
|
||||||
|
@ -22,12 +22,12 @@ public class JailCheckCommand implements Command{
|
|||||||
// Checks the status of the specified prisoner
|
// Checks the status of the specified prisoner
|
||||||
public boolean execute(JailManager jm, CommandSender sender, String... args) {
|
public boolean execute(JailManager jm, CommandSender sender, String... args) {
|
||||||
//Otherwise let's check the first argument
|
//Otherwise let's check the first argument
|
||||||
if(jm.isPlayerJailed(args[1])) {
|
if(jm.isPlayerJailedByLastKnownUsername(args[1])) {
|
||||||
Prisoner p = jm.getPrisoner(args[1]);
|
Prisoner p = jm.getPrisonerByLastKnownName(args[1]);
|
||||||
|
|
||||||
//graywolf663: Being gray's evil twin; CONSOLE (10)
|
//graywolf663: Being gray's evil twin; CONSOLE (10)
|
||||||
//prisoner: reason; jailer (time in minutes)
|
//prisoner: reason; jailer (time in minutes)
|
||||||
sender.sendMessage(ChatColor.BLUE + " " + p.getName() + ": " + p.getReason() + "; " + p.getJailer() + " (" + p.getRemainingTimeInMinutes() + " mins)");
|
sender.sendMessage(ChatColor.BLUE + " " + p.getLastKnownName() + ": " + p.getReason() + "; " + p.getJailer() + " (" + p.getRemainingTimeInMinutes() + " mins)");
|
||||||
}else {
|
}else {
|
||||||
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOTJAILED, args[1]));
|
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOTJAILED, args[1]));
|
||||||
}
|
}
|
||||||
|
@ -74,7 +74,7 @@ public class JailCommand implements Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Check if the given player is already jailed or not
|
//Check if the given player is already jailed or not
|
||||||
if(jm.isPlayerJailed(params.getPlayer())) {
|
if(jm.isPlayerJailedByLastKnownUsername(params.getPlayer())) {
|
||||||
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.ALREADYJAILED, params.getPlayer()));
|
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.ALREADYJAILED, params.getPlayer()));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -166,6 +166,7 @@ public class JailCommand implements Command {
|
|||||||
|
|
||||||
String uuid = "";
|
String uuid = "";
|
||||||
if(p == null) {
|
if(p == null) {
|
||||||
|
//TODO: Make this whole jail command non-blocking
|
||||||
uuid = jm.getPlugin().getServer().getOfflinePlayer(params.getPlayer()).getUniqueId().toString();
|
uuid = jm.getPlugin().getServer().getOfflinePlayer(params.getPlayer()).getUniqueId().toString();
|
||||||
}else {
|
}else {
|
||||||
uuid = p.getUniqueId().toString();
|
uuid = p.getUniqueId().toString();
|
||||||
@ -198,10 +199,10 @@ public class JailCommand implements Command {
|
|||||||
|
|
||||||
//Player is not online
|
//Player is not online
|
||||||
if(p == null) {
|
if(p == null) {
|
||||||
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.OFFLINEJAIL, new String[] { pris.getName(), String.valueOf(pris.getRemainingTimeInMinutes()) }));
|
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.OFFLINEJAIL, new String[] { pris.getLastKnownName(), String.valueOf(pris.getRemainingTimeInMinutes()) }));
|
||||||
}else {
|
}else {
|
||||||
//Player *is* online
|
//Player *is* online
|
||||||
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.ONLINEJAIL, new String[] { pris.getName(), String.valueOf(pris.getRemainingTimeInMinutes()) }));
|
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.ONLINEJAIL, new String[] { pris.getLastKnownName(), String.valueOf(pris.getRemainingTimeInMinutes()) }));
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -30,9 +30,9 @@ public class JailListCellsCommand implements Command {
|
|||||||
String message = "";
|
String message = "";
|
||||||
for(Cell c : j.getCells()) {
|
for(Cell c : j.getCells()) {
|
||||||
if(message.isEmpty()) {
|
if(message.isEmpty()) {
|
||||||
message = c.getName() + (c.getPrisoner() == null ? "" : " (" + c.getPrisoner().getName() + ")");
|
message = c.getName() + (c.getPrisoner() == null ? "" : " (" + c.getPrisoner().getLastKnownName() + ")");
|
||||||
}else {
|
}else {
|
||||||
message += ", " + c.getName() + (c.getPrisoner() == null ? "" : " (" + c.getPrisoner().getName() + ")");
|
message += ", " + c.getName() + (c.getPrisoner() == null ? "" : " (" + c.getPrisoner().getLastKnownName() + ")");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ public class JailListCommand implements Command {
|
|||||||
for(Prisoner p : j.getAllPrisoners()) {
|
for(Prisoner p : j.getAllPrisoners()) {
|
||||||
//graywolf663: Being gray's evil twin; CONSOLE (10)
|
//graywolf663: Being gray's evil twin; CONSOLE (10)
|
||||||
//prisoner: reason; jailer (time in minutes)
|
//prisoner: reason; jailer (time in minutes)
|
||||||
sender.sendMessage(ChatColor.BLUE + " " + p.getName() + ": " + p.getReason() + "; " + p.getJailer() + " (" + p.getRemainingTimeInMinutes() + " mins)");
|
sender.sendMessage(ChatColor.BLUE + " " + p.getLastKnownName() + ": " + p.getReason() + "; " + p.getJailer() + " (" + p.getRemainingTimeInMinutes() + " mins)");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,10 +18,10 @@ import com.graywolf336.jail.enums.LangString;
|
|||||||
public class JailMuteCommand implements Command {
|
public class JailMuteCommand implements Command {
|
||||||
public boolean execute(JailManager jm, CommandSender sender, String... args) throws Exception {
|
public boolean execute(JailManager jm, CommandSender sender, String... args) throws Exception {
|
||||||
//Let's check if the player they're sending us is jailed
|
//Let's check if the player they're sending us is jailed
|
||||||
if(jm.isPlayerJailed(args[1])) {
|
if(jm.isPlayerJailedByLastKnownUsername(args[1])) {
|
||||||
//They are, so let's toggle whether they are muted or not
|
//They are, so let's toggle whether they are muted or not
|
||||||
boolean muted = !jm.getPrisoner(args[1]).isMuted();
|
boolean muted = !jm.getPrisonerByLastKnownName(args[1]).isMuted();
|
||||||
jm.getPrisoner(args[1]).setMuted(muted);
|
jm.getPrisonerByLastKnownName(args[1]).setMuted(muted);
|
||||||
|
|
||||||
//Send the message to the sender based upon whether they are muted or unmuted
|
//Send the message to the sender based upon whether they are muted or unmuted
|
||||||
if(muted)
|
if(muted)
|
||||||
|
@ -31,8 +31,8 @@ public class JailPayCommand implements Command {
|
|||||||
case 1:
|
case 1:
|
||||||
// `/jail pay`
|
// `/jail pay`
|
||||||
//send how much it costs to get out
|
//send how much it costs to get out
|
||||||
if(jm.isPlayerJailed(sender.getName())) {
|
if(jm.isPlayerJailedByLastKnownUsername(sender.getName())) {
|
||||||
Prisoner p = jm.getPrisoner(sender.getName());
|
Prisoner p = jm.getPrisonerByLastKnownName(sender.getName());
|
||||||
String amt = "";
|
String amt = "";
|
||||||
|
|
||||||
if(pm.usingItemsForPayment()) {
|
if(pm.usingItemsForPayment()) {
|
||||||
@ -64,8 +64,8 @@ public class JailPayCommand implements Command {
|
|||||||
case 2:
|
case 2:
|
||||||
// `/jail pay <amount>`
|
// `/jail pay <amount>`
|
||||||
//They are trying to pay for their self
|
//They are trying to pay for their self
|
||||||
if(jm.isPlayerJailed(sender.getName())) {
|
if(jm.isPlayerJailedByLastKnownUsername(sender.getName())) {
|
||||||
Prisoner p = jm.getPrisoner(sender.getName());
|
Prisoner p = jm.getPrisonerByLastKnownName(sender.getName());
|
||||||
|
|
||||||
if(p.getRemainingTime() > 0) {
|
if(p.getRemainingTime() > 0) {
|
||||||
if(!pm.isTimedEnabled()) {
|
if(!pm.isTimedEnabled()) {
|
||||||
@ -129,12 +129,12 @@ public class JailPayCommand implements Command {
|
|||||||
case 3:
|
case 3:
|
||||||
// `/jail pay <amount> <person>
|
// `/jail pay <amount> <person>
|
||||||
//they are trying to pay for someone else
|
//they are trying to pay for someone else
|
||||||
if(jm.isPlayerJailed(sender.getName())) {
|
if(jm.isPlayerJailedByLastKnownUsername(sender.getName())) {
|
||||||
//When they are jailed they can not pay for someone else
|
//When they are jailed they can not pay for someone else
|
||||||
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PAYCANTPAYWHILEJAILED));
|
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PAYCANTPAYWHILEJAILED));
|
||||||
}else {
|
}else {
|
||||||
if(jm.isPlayerJailed(args[2])) {
|
if(jm.isPlayerJailedByLastKnownUsername(args[2])) {
|
||||||
Prisoner p = jm.getPrisoner(args[2]);
|
Prisoner p = jm.getPrisonerByLastKnownName(args[2]);
|
||||||
|
|
||||||
if(p.getRemainingTime() > 0) {
|
if(p.getRemainingTime() > 0) {
|
||||||
if(!pm.isTimedEnabled()) {
|
if(!pm.isTimedEnabled()) {
|
||||||
@ -168,21 +168,21 @@ public class JailPayCommand implements Command {
|
|||||||
//timed sentence
|
//timed sentence
|
||||||
if(amt >= bill) {
|
if(amt >= bill) {
|
||||||
pm.pay((Player) sender, bill);
|
pm.pay((Player) sender, bill);
|
||||||
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PAYPAIDRELEASEDELSE, new String[] { String.valueOf(bill), p.getName() }));
|
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PAYPAIDRELEASEDELSE, new String[] { String.valueOf(bill), p.getLastKnownName() }));
|
||||||
jm.getPlugin().getPrisonerManager().releasePrisoner(jm.getPlugin().getServer().getPlayerExact(p.getName()), p);
|
jm.getPlugin().getPrisonerManager().releasePrisoner(jm.getPlugin().getServer().getPlayer(p.getUUID()), p);
|
||||||
}else {
|
}else {
|
||||||
long minutes = pm.getMinutesPayingFor(amt);
|
long minutes = pm.getMinutesPayingFor(amt);
|
||||||
pm.pay((Player) sender, amt);
|
pm.pay((Player) sender, amt);
|
||||||
long remain = p.subtractTime(TimeUnit.MILLISECONDS.convert(minutes, TimeUnit.MINUTES));
|
long remain = p.subtractTime(TimeUnit.MILLISECONDS.convert(minutes, TimeUnit.MINUTES));
|
||||||
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PAYPAIDLOWEREDTIMEELSE,
|
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PAYPAIDLOWEREDTIMEELSE,
|
||||||
new String[] { String.valueOf(amt), p.getName(), String.valueOf(TimeUnit.MINUTES.convert(remain, TimeUnit.MILLISECONDS)) }));
|
new String[] { String.valueOf(amt), p.getLastKnownName(), String.valueOf(TimeUnit.MINUTES.convert(remain, TimeUnit.MILLISECONDS)) }));
|
||||||
}
|
}
|
||||||
}else {
|
}else {
|
||||||
//infinite jailing
|
//infinite jailing
|
||||||
if(amt >= bill) {
|
if(amt >= bill) {
|
||||||
pm.pay((Player) sender, bill);
|
pm.pay((Player) sender, bill);
|
||||||
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PAYPAIDRELEASEDELSE, new String[] { String.valueOf(bill), p.getName() }));
|
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PAYPAIDRELEASEDELSE, new String[] { String.valueOf(bill), p.getLastKnownName() }));
|
||||||
jm.getPlugin().getPrisonerManager().releasePrisoner(jm.getPlugin().getServer().getPlayerExact(p.getName()), p);
|
jm.getPlugin().getPrisonerManager().releasePrisoner(jm.getPlugin().getServer().getPlayer(p.getUUID()), p);
|
||||||
}else {
|
}else {
|
||||||
//You haven't provided enough money to get them out
|
//You haven't provided enough money to get them out
|
||||||
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PAYNOTENOUGHMONEYPROVIDED));
|
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PAYNOTENOUGHMONEYPROVIDED));
|
||||||
|
@ -13,7 +13,7 @@ import com.graywolf336.jail.enums.LangString;
|
|||||||
maxArgs = 0,
|
maxArgs = 0,
|
||||||
minimumArgs = 0,
|
minimumArgs = 0,
|
||||||
needsPlayer = true,
|
needsPlayer = true,
|
||||||
pattern = "status|time",
|
pattern = "status|s",
|
||||||
permission = "jail.usercmd.jailstatus",
|
permission = "jail.usercmd.jailstatus",
|
||||||
usage = "/jail status"
|
usage = "/jail status"
|
||||||
)
|
)
|
||||||
|
@ -11,7 +11,7 @@ import com.graywolf336.jail.command.CommandInfo;
|
|||||||
maxArgs = 0,
|
maxArgs = 0,
|
||||||
minimumArgs = 0,
|
minimumArgs = 0,
|
||||||
needsPlayer = true,
|
needsPlayer = true,
|
||||||
pattern = "stop|s",
|
pattern = "stop",
|
||||||
permission = "jail.command.jailstop",
|
permission = "jail.command.jailstop",
|
||||||
usage = "/jail stop"
|
usage = "/jail stop"
|
||||||
)
|
)
|
||||||
|
@ -19,14 +19,14 @@ import com.graywolf336.jail.enums.LangString;
|
|||||||
)
|
)
|
||||||
public class JailTimeCommand implements Command {
|
public class JailTimeCommand implements Command {
|
||||||
public boolean execute(JailManager jm, CommandSender sender, String... args) throws Exception {
|
public boolean execute(JailManager jm, CommandSender sender, String... args) throws Exception {
|
||||||
if(jm.isPlayerJailed(args[2])) {
|
if(jm.isPlayerJailedByLastKnownUsername(args[2])) {
|
||||||
Prisoner p = jm.getPrisoner(args[2]);
|
Prisoner p = jm.getPrisonerByLastKnownName(args[2]);
|
||||||
|
|
||||||
switch(args.length) {
|
switch(args.length) {
|
||||||
case 3:
|
case 3:
|
||||||
if(args[1].equalsIgnoreCase("show")) {
|
if(args[1].equalsIgnoreCase("show")) {
|
||||||
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PRISONERSTIME,
|
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PRISONERSTIME,
|
||||||
new String[] { p.getName(), String.valueOf(p.getRemainingTimeInMinutes()) }));
|
new String[] { p.getLastKnownName(), String.valueOf(p.getRemainingTimeInMinutes()) }));
|
||||||
}else {
|
}else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -41,7 +41,7 @@ public class JailTimeCommand implements Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PRISONERSTIME,
|
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PRISONERSTIME,
|
||||||
new String[] { p.getName(), String.valueOf(p.getRemainingTimeInMinutes()) }));
|
new String[] { p.getLastKnownName(), String.valueOf(p.getRemainingTimeInMinutes()) }));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
|
@ -45,7 +45,7 @@ public class JailTransferAllCommand implements Command {
|
|||||||
|
|
||||||
//Transfer all the prisoners
|
//Transfer all the prisoners
|
||||||
for(Prisoner p : oldPrisoners) {
|
for(Prisoner p : oldPrisoners) {
|
||||||
jm.getPlugin().getPrisonerManager().transferPrisoner(old, old.getCellPrisonerIsIn(p.getName()), jm.getJail(args[2]), null, p);
|
jm.getPlugin().getPrisonerManager().transferPrisoner(old, old.getCellPrisonerIsIn(p.getUUID()), jm.getJail(args[2]), null, p);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Send the messages to the sender when completed
|
//Send the messages to the sender when completed
|
||||||
|
@ -10,6 +10,7 @@ import org.bukkit.command.CommandSender;
|
|||||||
import com.graywolf336.jail.JailManager;
|
import com.graywolf336.jail.JailManager;
|
||||||
import com.graywolf336.jail.beans.Cell;
|
import com.graywolf336.jail.beans.Cell;
|
||||||
import com.graywolf336.jail.beans.Jail;
|
import com.graywolf336.jail.beans.Jail;
|
||||||
|
import com.graywolf336.jail.beans.Prisoner;
|
||||||
import com.graywolf336.jail.command.Command;
|
import com.graywolf336.jail.command.Command;
|
||||||
import com.graywolf336.jail.command.CommandInfo;
|
import com.graywolf336.jail.command.CommandInfo;
|
||||||
import com.graywolf336.jail.command.commands.jewels.Transfer;
|
import com.graywolf336.jail.command.commands.jewels.Transfer;
|
||||||
@ -52,7 +53,7 @@ public class JailTransferCommand implements Command {
|
|||||||
if(params.getPlayer() == null) {
|
if(params.getPlayer() == null) {
|
||||||
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PROVIDEAPLAYER, LangString.TRANSFERRING));
|
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PROVIDEAPLAYER, LangString.TRANSFERRING));
|
||||||
return true;
|
return true;
|
||||||
}else if(!jm.isPlayerJailed(params.getPlayer())) {
|
}else if(!jm.isPlayerJailedByLastKnownUsername(params.getPlayer())) {
|
||||||
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOTJAILED, params.getPlayer()));
|
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOTJAILED, params.getPlayer()));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -102,11 +103,12 @@ public class JailTransferCommand implements Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
jm.getPlugin().debug("Calling the PrePrisonerTransferredEvent, jail and cell check all came out clean.");
|
jm.getPlugin().debug("Calling the PrePrisonerTransferredEvent, jail and cell check all came out clean.");
|
||||||
|
Prisoner p = jm.getPrisonerByLastKnownName(params.getPlayer());
|
||||||
|
|
||||||
//Throw the custom event before transferring them, allowing another plugin to cancel it.
|
//Throw the custom event before transferring them, allowing another plugin to cancel it.
|
||||||
PrePrisonerTransferredEvent event = new PrePrisonerTransferredEvent(jm.getJailPlayerIsIn(params.getPlayer()),
|
PrePrisonerTransferredEvent event = new PrePrisonerTransferredEvent(jm.getJailPlayerIsIn(p.getUUID()),
|
||||||
jm.getJailPlayerIsIn(params.getPlayer()).getCellPrisonerIsIn(params.getPlayer()),
|
jm.getJailPlayerIsIn(p.getUUID()).getCellPrisonerIsIn(p.getUUID()),
|
||||||
target, targetCell, jm.getPrisoner(params.getPlayer()), jm.getPlugin().getServer().getPlayer(params.getPlayer()), sender.getName());
|
target, targetCell, p, jm.getPlugin().getServer().getPlayer(p.getUUID()), sender.getName());
|
||||||
jm.getPlugin().getServer().getPluginManager().callEvent(event);
|
jm.getPlugin().getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
if(event.isCancelled()) {
|
if(event.isCancelled()) {
|
||||||
@ -121,9 +123,9 @@ public class JailTransferCommand implements Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Start the transferring of the prisoner
|
//Start the transferring of the prisoner
|
||||||
jm.getPlugin().getPrisonerManager().transferPrisoner(jm.getJailPlayerIsIn(params.getPlayer()),
|
jm.getPlugin().getPrisonerManager().transferPrisoner(jm.getJailPlayerIsIn(p.getUUID()),
|
||||||
jm.getJailPlayerIsIn(params.getPlayer()).getCellPrisonerIsIn(params.getPlayer()),
|
jm.getJailPlayerIsIn(p.getUUID()).getCellPrisonerIsIn(p.getUUID()),
|
||||||
target, targetCell, jm.getPrisoner(params.getPlayer()));
|
target, targetCell, p);
|
||||||
|
|
||||||
//Send the messages to the sender, if no cell then say that but if cell send that as well
|
//Send the messages to the sender, if no cell then say that but if cell send that as well
|
||||||
if(targetCell == null) {
|
if(targetCell == null) {
|
||||||
|
@ -53,8 +53,6 @@ public class LegacyManager {
|
|||||||
} catch (InvalidConfigurationException e) {
|
} catch (InvalidConfigurationException e) {
|
||||||
//e.printStackTrace();
|
//e.printStackTrace();
|
||||||
pl.getLogger().severe("Unable to load the old global config: " + e.getMessage());
|
pl.getLogger().severe("Unable to load the old global config: " + e.getMessage());
|
||||||
}finally {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}else {
|
}else {
|
||||||
pl.debug("The old config file, global.yml, was not found so not loading anything.");
|
pl.debug("The old config file, global.yml, was not found so not loading anything.");
|
||||||
@ -62,9 +60,11 @@ public class LegacyManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
pl.getLogger().info("Starting to convert Jail 2.x data to Jail 3.0, this does use a blocking call (getOfflinePlayer) so expect the server to be held up until we are finished...");
|
||||||
loadOldConfig();
|
loadOldConfig();
|
||||||
loadOldData();
|
loadOldData();
|
||||||
moveOldConfigs();
|
moveOldConfigs();
|
||||||
|
pl.getLogger().info("...finished converting configs and data.");
|
||||||
return true;
|
return true;
|
||||||
}catch (Exception e) {
|
}catch (Exception e) {
|
||||||
if(pl.inDebug()) {
|
if(pl.inDebug()) {
|
||||||
|
@ -162,7 +162,7 @@ public class OldInputOutput {
|
|||||||
|
|
||||||
if(j == null) {
|
if(j == null) {
|
||||||
pl.getLogger().warning("Refusing to load a cell (" + name + ") as it references a Jail which doesn't exist.");
|
pl.getLogger().warning("Refusing to load a cell (" + name + ") as it references a Jail which doesn't exist.");
|
||||||
}else if(j.getCell(name) != null) {
|
}else if(j.isValidCell(name)) {
|
||||||
pl.getLogger().warning("Refusing to load a duplicate named cell, " + name + ", as another one exists with that same name.");
|
pl.getLogger().warning("Refusing to load a duplicate named cell, " + name + ", as another one exists with that same name.");
|
||||||
} else {
|
} else {
|
||||||
Cell c = new Cell(name);
|
Cell c = new Cell(name);
|
||||||
@ -187,7 +187,7 @@ public class OldInputOutput {
|
|||||||
|
|
||||||
//Load the prisoner if he is a valid prisoner
|
//Load the prisoner if he is a valid prisoner
|
||||||
if(!player.isEmpty()) {
|
if(!player.isEmpty()) {
|
||||||
Prisoner p = j.getPrisoner(name);
|
Prisoner p = j.getPrisonerByLastKnownName(name);
|
||||||
|
|
||||||
if(p != null) {
|
if(p != null) {
|
||||||
c.setPrisoner(p);
|
c.setPrisoner(p);
|
||||||
|
@ -24,7 +24,7 @@ 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().getUUID().toString(),
|
pl.getJailIO().addRecordEntry(event.getPrisoner().getUUID().toString(),
|
||||||
event.getPrisoner().getName(),
|
event.getPrisoner().getLastKnownName(),
|
||||||
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());
|
||||||
}
|
}
|
||||||
@ -32,7 +32,7 @@ public class JailingListener implements Listener {
|
|||||||
@EventHandler(ignoreCancelled=true)
|
@EventHandler(ignoreCancelled=true)
|
||||||
public void preJailingListener(PrePrisonerJailedByJailStickEvent event) {
|
public void preJailingListener(PrePrisonerJailedByJailStickEvent event) {
|
||||||
pl.getJailIO().addRecordEntry(event.getPrisoner().getUUID().toString(),
|
pl.getJailIO().addRecordEntry(event.getPrisoner().getUUID().toString(),
|
||||||
event.getPrisoner().getName(),
|
event.getPrisoner().getLastKnownName(),
|
||||||
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());
|
||||||
}
|
}
|
||||||
|
@ -92,6 +92,8 @@ public class PlayerListener implements Listener {
|
|||||||
//Get the prisoner object
|
//Get the prisoner object
|
||||||
Jail j = pl.getJailManager().getJailPlayerIsIn(event.getPlayer().getUniqueId());
|
Jail j = pl.getJailManager().getJailPlayerIsIn(event.getPlayer().getUniqueId());
|
||||||
Prisoner p = j.getPrisoner(event.getPlayer().getUniqueId());
|
Prisoner p = j.getPrisoner(event.getPlayer().getUniqueId());
|
||||||
|
//update their last known username when they login
|
||||||
|
p.setLastKnownName(event.getPlayer().getName());
|
||||||
|
|
||||||
//Check if they're offline pending, as if this is true then they were jailed offline
|
//Check if they're offline pending, as if this is true then they were jailed offline
|
||||||
if(p.isOfflinePending()) {
|
if(p.isOfflinePending()) {
|
||||||
@ -226,11 +228,11 @@ public class PlayerListener implements Listener {
|
|||||||
//Player is not online
|
//Player is not online
|
||||||
if(player == null) {
|
if(player == null) {
|
||||||
attacker.sendMessage(pl.getJailIO().getLanguageString(LangString.OFFLINEJAIL,
|
attacker.sendMessage(pl.getJailIO().getLanguageString(LangString.OFFLINEJAIL,
|
||||||
new String[] { p.getName(), String.valueOf(p.getRemainingTimeInMinutes()) }));
|
new String[] { p.getLastKnownName(), String.valueOf(p.getRemainingTimeInMinutes()) }));
|
||||||
}else {
|
}else {
|
||||||
//Player *is* online
|
//Player *is* online
|
||||||
attacker.sendMessage(pl.getJailIO().getLanguageString(LangString.ONLINEJAIL,
|
attacker.sendMessage(pl.getJailIO().getLanguageString(LangString.ONLINEJAIL,
|
||||||
new String[] { p.getName(), String.valueOf(p.getRemainingTimeInMinutes()) }));
|
new String[] { p.getLastKnownName(), String.valueOf(p.getRemainingTimeInMinutes()) }));
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
Loading…
Reference in New Issue
Block a user