diff --git a/src/main/java/com/graywolf336/jail/PrisonerManager.java b/src/main/java/com/graywolf336/jail/PrisonerManager.java index c11b5f6..115b430 100644 --- a/src/main/java/com/graywolf336/jail/PrisonerManager.java +++ b/src/main/java/com/graywolf336/jail/PrisonerManager.java @@ -1,5 +1,7 @@ package com.graywolf336.jail; +import java.util.UUID; + import org.bukkit.GameMode; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -101,6 +103,11 @@ public class PrisonerManager { } } + public void jailPlayer(UUID uuid) { + Jail j = pl.getJailManager().getJailPlayerIsIn(uuid); + jailPrisoner(j, j.getCellPrisonerIsIn(uuid), pl.getServer().getPlayer(uuid), j.getPrisoner(uuid)); + } + /** * Jails the prisoner with the proper information given. * @@ -283,7 +290,7 @@ public class PrisonerManager { Jail j = pl.getJailManager().getJailPlayerIsIn(player.getUniqueId()); try { - unJail(j, j.getCellPrisonerIsIn(player.getName()), player, prisoner); + unJail(j, j.getCellPrisonerIsIn(player.getUniqueId()), player, prisoner); }catch(Exception e) { if(pl.inDebug()) { e.printStackTrace(); @@ -417,7 +424,7 @@ public class PrisonerManager { /** Forcefully releases a {@link Prisoner prisoner} from {@link Jail}. */ public void forceRelease(Prisoner prisoner) { Jail j = pl.getJailManager().getJailPrisonerIsIn(prisoner); - forceUnJail(j, j.getCellPrisonerIsIn(prisoner.getName()), pl.getServer().getPlayer(prisoner.getUUID()), prisoner); + forceUnJail(j, j.getCellPrisonerIsIn(prisoner.getUUID()), pl.getServer().getPlayer(prisoner.getUUID()), prisoner); } /** Forcefully unjails a {@link Prisoner prisoner} from {@link Jail}. */ diff --git a/src/main/java/com/graywolf336/jail/beans/Jail.java b/src/main/java/com/graywolf336/jail/beans/Jail.java index 3a5859c..5152f8b 100644 --- a/src/main/java/com/graywolf336/jail/beans/Jail.java +++ b/src/main/java/com/graywolf336/jail/beans/Jail.java @@ -184,10 +184,10 @@ public class Jail { } /** Returns the cell which the given player name is jailed in, null if not. */ - public Cell getCellPrisonerIsIn(String name) { + public Cell getCellPrisonerIsIn(UUID uuid) { for(Cell c : cells.values()) - if(c.getPrisoner() != null) - if(c.getPrisoner().getName().equalsIgnoreCase(name)) + if(c.hasPrisoner()) + if(c.getPrisoner().getUUID().equals(uuid)) return c; return null; diff --git a/src/main/java/com/graywolf336/jail/command/subcommands/JailStatusCommand.java b/src/main/java/com/graywolf336/jail/command/subcommands/JailStatusCommand.java index c2c1edc..8493b37 100644 --- a/src/main/java/com/graywolf336/jail/command/subcommands/JailStatusCommand.java +++ b/src/main/java/com/graywolf336/jail/command/subcommands/JailStatusCommand.java @@ -1,6 +1,7 @@ package com.graywolf336.jail.command.subcommands; import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; import com.graywolf336.jail.JailManager; import com.graywolf336.jail.beans.Prisoner; @@ -11,7 +12,7 @@ import com.graywolf336.jail.enums.LangString; @CommandInfo( maxArgs = 0, minimumArgs = 0, - needsPlayer = false, + needsPlayer = true, pattern = "status|time", permission = "jail.usercmd.jailstatus", usage = "/jail status" @@ -19,8 +20,10 @@ import com.graywolf336.jail.enums.LangString; public class JailStatusCommand implements Command{ public boolean execute(JailManager jm, CommandSender sender, String... args) { - if(jm.isPlayerJailed(sender.getName())) { - Prisoner p = jm.getPrisoner(sender.getName()); + Player pl = (Player) sender; + + if(jm.isPlayerJailed(pl.getUniqueId())) { + Prisoner p = jm.getPrisoner(pl.getUniqueId()); //They are jailed, so let's tell them some information sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.STATUS, new String[] { p.getReason(), p.getJailer(), String.valueOf(p.getRemainingTimeInMinutes()) })); }else { diff --git a/src/main/java/com/graywolf336/jail/listeners/MoveProtectionListener.java b/src/main/java/com/graywolf336/jail/listeners/MoveProtectionListener.java index 639c9c9..5c8f76a 100644 --- a/src/main/java/com/graywolf336/jail/listeners/MoveProtectionListener.java +++ b/src/main/java/com/graywolf336/jail/listeners/MoveProtectionListener.java @@ -68,7 +68,7 @@ public class MoveProtectionListener implements Listener { //If the prisoner is in a cell, then let's teleport them to the cell's in location if(j.isJailedInACell(event.getPlayer().getUniqueId())) { - event.setTo(j.getCellPrisonerIsIn(event.getPlayer().getName()).getTeleport()); + event.setTo(j.getCellPrisonerIsIn(event.getPlayer().getUniqueId()).getTeleport()); }else { //Otherwise let's teleport them to the in location of the jail event.setTo(j.getTeleportIn()); diff --git a/src/main/java/com/graywolf336/jail/listeners/PlayerListener.java b/src/main/java/com/graywolf336/jail/listeners/PlayerListener.java index c4a9ae1..3a9ac23 100644 --- a/src/main/java/com/graywolf336/jail/listeners/PlayerListener.java +++ b/src/main/java/com/graywolf336/jail/listeners/PlayerListener.java @@ -99,7 +99,7 @@ public class PlayerListener implements Listener { //If their remaining time is 0, let's unjail them pl.getPrisonerManager().releasePrisoner(event.getPlayer(), p); }else if(p.isToBeTransferred()) { - Cell c = j.getCellPrisonerIsIn(event.getPlayer().getName()); + Cell c = j.getCellPrisonerIsIn(event.getPlayer().getUniqueId()); //If the player is not jailed in a cell, teleport them to the jail's in if(c == null) { @@ -116,7 +116,7 @@ public class PlayerListener implements Listener { p.setToBeTransferred(false); } else { //Their remaining time isn't 0 so let's proceed with jailing of the prisoner - pl.getPrisonerManager().jailPrisoner(event.getPlayer().getUniqueId());//TODO + pl.getPrisonerManager().jailPlayer(event.getPlayer().getUniqueId()); } } @@ -174,7 +174,7 @@ public class PlayerListener implements Listener { Jail j = pl.getJailManager().getJailPlayerIsIn(event.getPlayer().getUniqueId()); if(j.isJailedInACell(event.getPlayer().getUniqueId())) { - event.setRespawnLocation(j.getCellPrisonerIsIn(event.getPlayer().getName()).getTeleport()); + event.setRespawnLocation(j.getCellPrisonerIsIn(event.getPlayer().getUniqueId()).getTeleport()); }else { event.setRespawnLocation(j.getTeleportIn()); }