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`)"
|
||||
+ "VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
|
||||
pPS.setString(1, p.getUUID().toString());
|
||||
pPS.setString(2, p.getName());
|
||||
pPS.setString(2, p.getLastKnownName());
|
||||
pPS.setString(3, j.getName());
|
||||
pPS.setString(4, c.getName());
|
||||
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`,"
|
||||
+ "`offlinePending`, `toBeTransferred`, `jailer`, `reason`, `inventory`, `armor`, `previousLocation`, `previousGameMode`) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
|
||||
pPS.setString(1, p.getUUID().toString());
|
||||
pPS.setString(2, p.getName());
|
||||
pPS.setString(2, p.getLastKnownName());
|
||||
pPS.setString(3, j.getName());
|
||||
pPS.setString(4, "");
|
||||
pPS.setBoolean(5, p.isMuted());
|
||||
@ -815,7 +815,7 @@ public class JailIO {
|
||||
if(c.getPrisoner() != null) {
|
||||
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.getLastKnownName());
|
||||
flat.set(cNode + "prisoner.muted", p.isMuted());
|
||||
flat.set(cNode + "prisoner.time", p.getRemainingTime());
|
||||
flat.set(cNode + "prisoner.offlinePending", p.isOfflinePending());
|
||||
@ -835,7 +835,7 @@ public class JailIO {
|
||||
flat.set(node + "prisoners", null);
|
||||
for(Prisoner p : j.getPrisonersNotInCells()) {
|
||||
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 + "time", p.getRemainingTime());
|
||||
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`,"
|
||||
+ "`offlinePending`, `toBeTransferred`, `jailer`, `reason`, `inventory`, `armor`, `previousLocation`, `previousGameMode`) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
|
||||
pPS.setString(1, p.getUUID().toString());
|
||||
pPS.setString(2, p.getName());
|
||||
pPS.setString(2, p.getLastKnownName());
|
||||
pPS.setString(3, j.getName());
|
||||
pPS.setString(4, c.getName());
|
||||
pPS.setBoolean(5, p.isMuted());
|
||||
@ -954,14 +954,14 @@ public class JailIO {
|
||||
PreparedStatement pp = con.prepareStatement("delete from `" + prefix + "prisoners` where uuid = ? limit 1;");
|
||||
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.close();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
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;
|
||||
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.
|
||||
*
|
||||
|
@ -86,9 +86,9 @@ public class PrisonerManager {
|
||||
String msg = "";
|
||||
|
||||
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
|
||||
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;
|
||||
//Broadcast the message, if it is enabled
|
||||
|
@ -334,11 +334,10 @@ public class Jail {
|
||||
*
|
||||
* @param name The name of the prisoner to get.
|
||||
* @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())
|
||||
if(p.getName().equalsIgnoreCase(name))
|
||||
if(p.getLastKnownName().equalsIgnoreCase(name))
|
||||
return p;
|
||||
|
||||
return null;
|
||||
|
@ -53,8 +53,14 @@ public class Prisoner {
|
||||
return UUID.fromString(this.uuid);
|
||||
}
|
||||
|
||||
/** Gets the name of this player. */
|
||||
public String getName() {
|
||||
/** Gets the name of this prisoner. */
|
||||
public String getLastKnownName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/** Sets the name of this prisoner. */
|
||||
public String setLastKnownName(String username) {
|
||||
this.name = username;
|
||||
return this.name;
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@ public class HandCuffCommand implements Command {
|
||||
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PLAYERNOTONLINE));
|
||||
}else if(player.hasPermission("jail.cantbehandcuffed")) {
|
||||
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() }));
|
||||
}else if(jm.getPlugin().getHandCuffManager().isHandCuffed(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) {
|
||||
//Check if the player is jailed
|
||||
if(jm.isPlayerJailed(args[0])) {
|
||||
Jail j = jm.getJailPlayerIsIn(args[0]);
|
||||
Prisoner pris = j.getPrisoner(args[0]);
|
||||
Player p = jm.getPlugin().getServer().getPlayerExact(args[0]);
|
||||
if(jm.isPlayerJailedByLastKnownUsername(args[0])) {
|
||||
Jail j = jm.getJailPlayerIsInByLastKnownName(args[0]);
|
||||
Prisoner pris = j.getPrisonerByLastKnownName(args[0]);
|
||||
Player p = jm.getPlugin().getServer().getPlayer(pris.getUUID());
|
||||
|
||||
//Check if the player is on the server or not
|
||||
if(p == null) {
|
||||
//Check if the player has offline pending and their remaining time is above 0, if so then
|
||||
//forceably unjail them
|
||||
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]));
|
||||
}else {
|
||||
//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 {
|
||||
//Player is online, so let's try unjailing them
|
||||
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) {
|
||||
sender.sendMessage(ChatColor.RED + e.getMessage());
|
||||
}
|
||||
|
@ -21,8 +21,8 @@ public class UnJailForceCommand implements Command {
|
||||
|
||||
public boolean execute(JailManager jm, CommandSender sender, String... args) {
|
||||
//Check if the player is jailed
|
||||
if(jm.isPlayerJailed(args[0])) {
|
||||
jm.getPlugin().getPrisonerManager().forceRelease(jm.getPrisoner(args[0]));
|
||||
if(jm.isPlayerJailedByLastKnownUsername(args[0])) {
|
||||
jm.getPlugin().getPrisonerManager().forceRelease(jm.getPrisonerByLastKnownName(args[0]));
|
||||
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.FORCEUNJAILED, args[0]));
|
||||
|
||||
if(jm.getPlugin().getConfig().getBoolean(Settings.LOGJAILINGTOCONSOLE.getPath())) {
|
||||
|
@ -22,12 +22,12 @@ public class JailCheckCommand implements Command{
|
||||
// Checks the status of the specified prisoner
|
||||
public boolean execute(JailManager jm, CommandSender sender, String... args) {
|
||||
//Otherwise let's check the first argument
|
||||
if(jm.isPlayerJailed(args[1])) {
|
||||
Prisoner p = jm.getPrisoner(args[1]);
|
||||
if(jm.isPlayerJailedByLastKnownUsername(args[1])) {
|
||||
Prisoner p = jm.getPrisonerByLastKnownName(args[1]);
|
||||
|
||||
//graywolf663: Being gray's evil twin; CONSOLE (10)
|
||||
//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 {
|
||||
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
|
||||
if(jm.isPlayerJailed(params.getPlayer())) {
|
||||
if(jm.isPlayerJailedByLastKnownUsername(params.getPlayer())) {
|
||||
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.ALREADYJAILED, params.getPlayer()));
|
||||
return true;
|
||||
}
|
||||
@ -166,6 +166,7 @@ public class JailCommand implements Command {
|
||||
|
||||
String uuid = "";
|
||||
if(p == null) {
|
||||
//TODO: Make this whole jail command non-blocking
|
||||
uuid = jm.getPlugin().getServer().getOfflinePlayer(params.getPlayer()).getUniqueId().toString();
|
||||
}else {
|
||||
uuid = p.getUniqueId().toString();
|
||||
@ -198,10 +199,10 @@ public class JailCommand implements Command {
|
||||
|
||||
//Player is not online
|
||||
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 {
|
||||
//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 {
|
||||
|
@ -30,9 +30,9 @@ public class JailListCellsCommand implements Command {
|
||||
String message = "";
|
||||
for(Cell c : j.getCells()) {
|
||||
if(message.isEmpty()) {
|
||||
message = c.getName() + (c.getPrisoner() == null ? "" : " (" + c.getPrisoner().getName() + ")");
|
||||
message = c.getName() + (c.getPrisoner() == null ? "" : " (" + c.getPrisoner().getLastKnownName() + ")");
|
||||
}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()) {
|
||||
//graywolf663: Being gray's evil twin; CONSOLE (10)
|
||||
//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 boolean execute(JailManager jm, CommandSender sender, String... args) throws Exception {
|
||||
//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
|
||||
boolean muted = !jm.getPrisoner(args[1]).isMuted();
|
||||
jm.getPrisoner(args[1]).setMuted(muted);
|
||||
boolean muted = !jm.getPrisonerByLastKnownName(args[1]).isMuted();
|
||||
jm.getPrisonerByLastKnownName(args[1]).setMuted(muted);
|
||||
|
||||
//Send the message to the sender based upon whether they are muted or unmuted
|
||||
if(muted)
|
||||
|
@ -31,8 +31,8 @@ public class JailPayCommand implements Command {
|
||||
case 1:
|
||||
// `/jail pay`
|
||||
//send how much it costs to get out
|
||||
if(jm.isPlayerJailed(sender.getName())) {
|
||||
Prisoner p = jm.getPrisoner(sender.getName());
|
||||
if(jm.isPlayerJailedByLastKnownUsername(sender.getName())) {
|
||||
Prisoner p = jm.getPrisonerByLastKnownName(sender.getName());
|
||||
String amt = "";
|
||||
|
||||
if(pm.usingItemsForPayment()) {
|
||||
@ -64,8 +64,8 @@ public class JailPayCommand implements Command {
|
||||
case 2:
|
||||
// `/jail pay <amount>`
|
||||
//They are trying to pay for their self
|
||||
if(jm.isPlayerJailed(sender.getName())) {
|
||||
Prisoner p = jm.getPrisoner(sender.getName());
|
||||
if(jm.isPlayerJailedByLastKnownUsername(sender.getName())) {
|
||||
Prisoner p = jm.getPrisonerByLastKnownName(sender.getName());
|
||||
|
||||
if(p.getRemainingTime() > 0) {
|
||||
if(!pm.isTimedEnabled()) {
|
||||
@ -129,12 +129,12 @@ public class JailPayCommand implements Command {
|
||||
case 3:
|
||||
// `/jail pay <amount> <person>
|
||||
//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
|
||||
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PAYCANTPAYWHILEJAILED));
|
||||
}else {
|
||||
if(jm.isPlayerJailed(args[2])) {
|
||||
Prisoner p = jm.getPrisoner(args[2]);
|
||||
if(jm.isPlayerJailedByLastKnownUsername(args[2])) {
|
||||
Prisoner p = jm.getPrisonerByLastKnownName(args[2]);
|
||||
|
||||
if(p.getRemainingTime() > 0) {
|
||||
if(!pm.isTimedEnabled()) {
|
||||
@ -168,21 +168,21 @@ public class JailPayCommand implements Command {
|
||||
//timed sentence
|
||||
if(amt >= bill) {
|
||||
pm.pay((Player) sender, bill);
|
||||
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PAYPAIDRELEASEDELSE, new String[] { String.valueOf(bill), p.getName() }));
|
||||
jm.getPlugin().getPrisonerManager().releasePrisoner(jm.getPlugin().getServer().getPlayerExact(p.getName()), p);
|
||||
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PAYPAIDRELEASEDELSE, new String[] { String.valueOf(bill), p.getLastKnownName() }));
|
||||
jm.getPlugin().getPrisonerManager().releasePrisoner(jm.getPlugin().getServer().getPlayer(p.getUUID()), p);
|
||||
}else {
|
||||
long minutes = pm.getMinutesPayingFor(amt);
|
||||
pm.pay((Player) sender, amt);
|
||||
long remain = p.subtractTime(TimeUnit.MILLISECONDS.convert(minutes, TimeUnit.MINUTES));
|
||||
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 {
|
||||
//infinite jailing
|
||||
if(amt >= bill) {
|
||||
pm.pay((Player) sender, bill);
|
||||
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PAYPAIDRELEASEDELSE, new String[] { String.valueOf(bill), p.getName() }));
|
||||
jm.getPlugin().getPrisonerManager().releasePrisoner(jm.getPlugin().getServer().getPlayerExact(p.getName()), p);
|
||||
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PAYPAIDRELEASEDELSE, new String[] { String.valueOf(bill), p.getLastKnownName() }));
|
||||
jm.getPlugin().getPrisonerManager().releasePrisoner(jm.getPlugin().getServer().getPlayer(p.getUUID()), p);
|
||||
}else {
|
||||
//You haven't provided enough money to get them out
|
||||
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PAYNOTENOUGHMONEYPROVIDED));
|
||||
|
@ -13,7 +13,7 @@ import com.graywolf336.jail.enums.LangString;
|
||||
maxArgs = 0,
|
||||
minimumArgs = 0,
|
||||
needsPlayer = true,
|
||||
pattern = "status|time",
|
||||
pattern = "status|s",
|
||||
permission = "jail.usercmd.jailstatus",
|
||||
usage = "/jail status"
|
||||
)
|
||||
|
@ -11,7 +11,7 @@ import com.graywolf336.jail.command.CommandInfo;
|
||||
maxArgs = 0,
|
||||
minimumArgs = 0,
|
||||
needsPlayer = true,
|
||||
pattern = "stop|s",
|
||||
pattern = "stop",
|
||||
permission = "jail.command.jailstop",
|
||||
usage = "/jail stop"
|
||||
)
|
||||
|
@ -19,14 +19,14 @@ import com.graywolf336.jail.enums.LangString;
|
||||
)
|
||||
public class JailTimeCommand implements Command {
|
||||
public boolean execute(JailManager jm, CommandSender sender, String... args) throws Exception {
|
||||
if(jm.isPlayerJailed(args[2])) {
|
||||
Prisoner p = jm.getPrisoner(args[2]);
|
||||
if(jm.isPlayerJailedByLastKnownUsername(args[2])) {
|
||||
Prisoner p = jm.getPrisonerByLastKnownName(args[2]);
|
||||
|
||||
switch(args.length) {
|
||||
case 3:
|
||||
if(args[1].equalsIgnoreCase("show")) {
|
||||
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 {
|
||||
return false;
|
||||
}
|
||||
@ -41,7 +41,7 @@ public class JailTimeCommand implements Command {
|
||||
}
|
||||
|
||||
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;
|
||||
default:
|
||||
return false;
|
||||
|
@ -45,7 +45,7 @@ public class JailTransferAllCommand implements Command {
|
||||
|
||||
//Transfer all the prisoners
|
||||
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
|
||||
|
@ -10,6 +10,7 @@ import org.bukkit.command.CommandSender;
|
||||
import com.graywolf336.jail.JailManager;
|
||||
import com.graywolf336.jail.beans.Cell;
|
||||
import com.graywolf336.jail.beans.Jail;
|
||||
import com.graywolf336.jail.beans.Prisoner;
|
||||
import com.graywolf336.jail.command.Command;
|
||||
import com.graywolf336.jail.command.CommandInfo;
|
||||
import com.graywolf336.jail.command.commands.jewels.Transfer;
|
||||
@ -52,7 +53,7 @@ public class JailTransferCommand implements Command {
|
||||
if(params.getPlayer() == null) {
|
||||
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PROVIDEAPLAYER, LangString.TRANSFERRING));
|
||||
return true;
|
||||
}else if(!jm.isPlayerJailed(params.getPlayer())) {
|
||||
}else if(!jm.isPlayerJailedByLastKnownUsername(params.getPlayer())) {
|
||||
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOTJAILED, params.getPlayer()));
|
||||
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.");
|
||||
Prisoner p = jm.getPrisonerByLastKnownName(params.getPlayer());
|
||||
|
||||
//Throw the custom event before transferring them, allowing another plugin to cancel it.
|
||||
PrePrisonerTransferredEvent event = new PrePrisonerTransferredEvent(jm.getJailPlayerIsIn(params.getPlayer()),
|
||||
jm.getJailPlayerIsIn(params.getPlayer()).getCellPrisonerIsIn(params.getPlayer()),
|
||||
target, targetCell, jm.getPrisoner(params.getPlayer()), jm.getPlugin().getServer().getPlayer(params.getPlayer()), sender.getName());
|
||||
PrePrisonerTransferredEvent event = new PrePrisonerTransferredEvent(jm.getJailPlayerIsIn(p.getUUID()),
|
||||
jm.getJailPlayerIsIn(p.getUUID()).getCellPrisonerIsIn(p.getUUID()),
|
||||
target, targetCell, p, jm.getPlugin().getServer().getPlayer(p.getUUID()), sender.getName());
|
||||
jm.getPlugin().getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if(event.isCancelled()) {
|
||||
@ -121,9 +123,9 @@ public class JailTransferCommand implements Command {
|
||||
}
|
||||
|
||||
//Start the transferring of the prisoner
|
||||
jm.getPlugin().getPrisonerManager().transferPrisoner(jm.getJailPlayerIsIn(params.getPlayer()),
|
||||
jm.getJailPlayerIsIn(params.getPlayer()).getCellPrisonerIsIn(params.getPlayer()),
|
||||
target, targetCell, jm.getPrisoner(params.getPlayer()));
|
||||
jm.getPlugin().getPrisonerManager().transferPrisoner(jm.getJailPlayerIsIn(p.getUUID()),
|
||||
jm.getJailPlayerIsIn(p.getUUID()).getCellPrisonerIsIn(p.getUUID()),
|
||||
target, targetCell, p);
|
||||
|
||||
//Send the messages to the sender, if no cell then say that but if cell send that as well
|
||||
if(targetCell == null) {
|
||||
|
@ -53,8 +53,6 @@ public class LegacyManager {
|
||||
} catch (InvalidConfigurationException e) {
|
||||
//e.printStackTrace();
|
||||
pl.getLogger().severe("Unable to load the old global config: " + e.getMessage());
|
||||
}finally {
|
||||
|
||||
}
|
||||
}else {
|
||||
pl.debug("The old config file, global.yml, was not found so not loading anything.");
|
||||
@ -62,9 +60,11 @@ public class LegacyManager {
|
||||
}
|
||||
|
||||
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();
|
||||
loadOldData();
|
||||
moveOldConfigs();
|
||||
pl.getLogger().info("...finished converting configs and data.");
|
||||
return true;
|
||||
}catch (Exception e) {
|
||||
if(pl.inDebug()) {
|
||||
|
@ -162,7 +162,7 @@ public class OldInputOutput {
|
||||
|
||||
if(j == null) {
|
||||
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.");
|
||||
} else {
|
||||
Cell c = new Cell(name);
|
||||
@ -187,7 +187,7 @@ public class OldInputOutput {
|
||||
|
||||
//Load the prisoner if he is a valid prisoner
|
||||
if(!player.isEmpty()) {
|
||||
Prisoner p = j.getPrisoner(name);
|
||||
Prisoner p = j.getPrisonerByLastKnownName(name);
|
||||
|
||||
if(p != null) {
|
||||
c.setPrisoner(p);
|
||||
|
@ -24,7 +24,7 @@ public class JailingListener implements Listener {
|
||||
@EventHandler(ignoreCancelled=true)
|
||||
public void preJailingListener(PrePrisonerJailedEvent event) {
|
||||
pl.getJailIO().addRecordEntry(event.getPrisoner().getUUID().toString(),
|
||||
event.getPrisoner().getName(),
|
||||
event.getPrisoner().getLastKnownName(),
|
||||
event.getPrisoner().getJailer(), dateFormat.format(new Date()),
|
||||
event.getPrisoner().getRemainingTimeInMinutes(), event.getPrisoner().getReason());
|
||||
}
|
||||
@ -32,7 +32,7 @@ public class JailingListener implements Listener {
|
||||
@EventHandler(ignoreCancelled=true)
|
||||
public void preJailingListener(PrePrisonerJailedByJailStickEvent event) {
|
||||
pl.getJailIO().addRecordEntry(event.getPrisoner().getUUID().toString(),
|
||||
event.getPrisoner().getName(),
|
||||
event.getPrisoner().getLastKnownName(),
|
||||
event.getPrisoner().getJailer(), dateFormat.format(new Date()),
|
||||
event.getPrisoner().getRemainingTimeInMinutes(), event.getPrisoner().getReason());
|
||||
}
|
||||
|
@ -92,6 +92,8 @@ public class PlayerListener implements Listener {
|
||||
//Get the prisoner object
|
||||
Jail j = pl.getJailManager().getJailPlayerIsIn(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
|
||||
if(p.isOfflinePending()) {
|
||||
@ -226,11 +228,11 @@ public class PlayerListener implements Listener {
|
||||
//Player is not online
|
||||
if(player == null) {
|
||||
attacker.sendMessage(pl.getJailIO().getLanguageString(LangString.OFFLINEJAIL,
|
||||
new String[] { p.getName(), String.valueOf(p.getRemainingTimeInMinutes()) }));
|
||||
new String[] { p.getLastKnownName(), String.valueOf(p.getRemainingTimeInMinutes()) }));
|
||||
}else {
|
||||
//Player *is* online
|
||||
attacker.sendMessage(pl.getJailIO().getLanguageString(LangString.ONLINEJAIL,
|
||||
new String[] { p.getName(), String.valueOf(p.getRemainingTimeInMinutes()) }));
|
||||
new String[] { p.getLastKnownName(), String.valueOf(p.getRemainingTimeInMinutes()) }));
|
||||
}
|
||||
|
||||
try {
|
||||
|
Loading…
Reference in New Issue
Block a user