Readd the method I removed and also change the cells to uuid.

This commit is contained in:
graywolf336 2014-04-29 10:53:36 -05:00
parent 63e117ac72
commit ad9c70cbbf
5 changed files with 22 additions and 12 deletions

View File

@ -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}. */

View File

@ -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;

View File

@ -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 {

View File

@ -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());

View File

@ -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());
}