Build will fail. Started work on converting to using uuid's internally.

While doing this I deleted one method that I shouldn't have, so going to
revert that. Next I have to build a method or two which will allow me to
do last known names lookups, etc. Might switch to using a library to
handle getting names async so we don't block the server up, doing this
will result in us having to recode some of the commands internally.

If you have any suggestions or questions, I'm open.
This commit is contained in:
graywolf336 2014-04-28 23:52:52 -05:00
parent 0981fe659f
commit 63e117ac72
9 changed files with 106 additions and 125 deletions

View File

@ -167,8 +167,8 @@ public class JailMain extends JavaPlugin {
if(getConfig().getBoolean(Settings.SCOREBOARDENABLED.getPath())) {
for(Jail j : jm.getJails()) {
for(Prisoner p : j.getAllPrisoners()) {
if(getServer().getPlayerExact(p.getName()) != null) {
this.sbm.addScoreBoard(getServer().getPlayerExact(p.getName()), p);
if(getServer().getPlayer(p.getUUID()) != null) {
this.sbm.addScoreBoard(getServer().getPlayer(p.getUUID()), p);
}
}
}

View File

@ -3,6 +3,7 @@ package com.graywolf336.jail;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.UUID;
import org.bukkit.Location;
import org.bukkit.command.CommandSender;
@ -178,58 +179,44 @@ public class JailManager {
public Jail getJailPrisonerIsIn(Prisoner prisoner) {
if(prisoner == null) return null;
return getJailPlayerIsIn(prisoner.getName());
return getJailPlayerIsIn(prisoner.getUUID());
}
/**
* Gets the {@link Jail jail} the given player is in.
*
* @param name The name of the player whos jail we are getting.
* @param uuid The uuid of the player who's jail we are getting.
* @return The jail the player is in, <strong>CAN BE NULL</strong>.
*/
public Jail getJailPlayerIsIn(String name) {
Jail re = null;
public Jail getJailPlayerIsIn(UUID uuid) {
for(Jail j : jails.values())
if(j.isPlayerJailed(uuid))
return j;
for(Jail j : jails.values()) {
if(j.isPlayerAPrisoner(name)) {
re = j;
break;
}
}
return re;
return null;
}
/**
* Gets if the given player is jailed or not, in all the jails and cells.
* Gets if the given uuid of a player is jailed or not, in all the jails and cells.
*
* @param name The name of the player to check.
* @param uuid The uuid of the player to check.
* @return true if they are jailed, false if not.
*/
public boolean isPlayerJailed(String name) {
boolean r = false;
for(Jail j : jails.values()) {
if(j.isPlayerAPrisoner(name)) {
r = true;
break;
}
}
return r;
public boolean isPlayerJailed(UUID uuid) {
return getJailPlayerIsIn(uuid) != null;
}
/**
* Gets the {@link Prisoner} data from for this user, if they are jailed.
*
* @param name The name of prisoner who's data to get
* @param uuid The uuid of prisoner who's data to get
* @return {@link Prisoner prisoner} data.
*/
public Prisoner getPrisoner(String name) {
Jail j = getJailPlayerIsIn(name);
public Prisoner getPrisoner(UUID uuid) {
Jail j = getJailPlayerIsIn(uuid);
if(j != null) {
return j.getPrisoner(name);
return j.getPrisoner(uuid);
}else {
return null;
}
@ -248,7 +235,7 @@ public class JailManager {
if(j != null) {
for(Prisoner p : j.getAllPrisoners()) {
getPlugin().getPrisonerManager().releasePrisoner(getPlugin().getServer().getPlayerExact(p.getName()), p);
getPlugin().getPrisonerManager().releasePrisoner(getPlugin().getServer().getPlayer(p.getUUID()), p);
}
return getPlugin().getJailIO().getLanguageString(LangString.PRISONERSCLEARED, j.getName());
@ -272,7 +259,7 @@ public class JailManager {
}else {
for(Jail j : getJails()) {
for(Prisoner p : j.getAllPrisoners()) {
getPlugin().getPrisonerManager().releasePrisoner(getPlugin().getServer().getPlayerExact(p.getName()), p);
getPlugin().getPrisonerManager().releasePrisoner(getPlugin().getServer().getPlayer(p.getUUID()), p);
}
}

View File

@ -69,7 +69,7 @@ public class JailTimer {
for(Prisoner p : j.getAllPrisoners()) {
//only execute this code if the prisoner's time is more than 0 milliseconds
if(p.getRemainingTime() > 0) {
Player player = pl.getServer().getPlayerExact(p.getName());
Player player = pl.getServer().getPlayer(p.getUUID());
//Check if the player is offline
if(player == null) {

View File

@ -101,17 +101,6 @@ public class PrisonerManager {
}
}
/**
* Jails the prisoner with the given name.
*
* @param name of the prisoner to jail.
*/
public void jailPrisoner(String name) {
Jail j = pl.getJailManager().getJailPlayerIsIn(name);
jailPrisoner(j, j.getCellPrisonerIsIn(name), pl.getServer().getPlayerExact(name), j.getPrisoner(name));
}
/**
* Jails the prisoner with the proper information given.
*
@ -291,7 +280,7 @@ public class PrisonerManager {
prisoner.setOfflinePending(true);
prisoner.setRemainingTime(0);
}else {
Jail j = pl.getJailManager().getJailPlayerIsIn(player.getName());
Jail j = pl.getJailManager().getJailPlayerIsIn(player.getUniqueId());
try {
unJail(j, j.getCellPrisonerIsIn(player.getName()), player, prisoner);
@ -428,7 +417,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().getPlayerExact(prisoner.getName()), prisoner);
forceUnJail(j, j.getCellPrisonerIsIn(prisoner.getName()), pl.getServer().getPlayer(prisoner.getUUID()), prisoner);
}
/** Forcefully unjails a {@link Prisoner prisoner} from {@link Jail}. */
@ -461,7 +450,7 @@ public class PrisonerManager {
* @param prisoner The prisoner data we're handling.
*/
public void transferPrisoner(Jail originJail, Cell originCell, Jail targetJail, Cell targetCell, Prisoner prisoner) {
Player player = pl.getServer().getPlayer(prisoner.getName());
Player player = pl.getServer().getPlayer(prisoner.getUUID());
//If there is no origin cell, then we need to basically just put them to their targetJail
if(originCell == null) {

View File

@ -1,6 +1,7 @@
package com.graywolf336.jail;
import java.util.HashMap;
import java.util.UUID;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
@ -16,13 +17,13 @@ import com.graywolf336.jail.enums.Settings;
public class ScoreBoardManager {
private JailMain pl;
private ScoreboardManager man;
private HashMap<String, Scoreboard> boards;
private HashMap<UUID, Scoreboard> boards;
private OfflinePlayer time;
public ScoreBoardManager(JailMain plugin) {
this.pl = plugin;
this.man = plugin.getServer().getScoreboardManager();
this.boards = new HashMap<String, Scoreboard>();
this.boards = new HashMap<UUID, Scoreboard>();
this.time = plugin.getServer().getOfflinePlayer(Util.getColorfulMessage(pl.getConfig().getString(Settings.SCOREBOARDTIME.getPath())));
//Start the task if it is enabled
@ -43,7 +44,7 @@ public class ScoreBoardManager {
*/
public void addScoreBoard(Player player, Prisoner pris) {
if(!boards.containsKey(player.getName())) {
boards.put(player.getName(), man.getNewScoreboard());
boards.put(player.getUniqueId(), man.getNewScoreboard());
Objective o = boards.get(player.getName()).registerNewObjective("test", "dummy");
o.setDisplaySlot(DisplaySlot.SIDEBAR);
o.setDisplayName(Util.getColorfulMessage(pl.getConfig().getString(Settings.SCOREBOARDTITLE.getPath())));
@ -60,23 +61,23 @@ public class ScoreBoardManager {
* @param player of whom to remove the scoreboard for.
*/
public void removeScoreBoard(Player player) {
boards.remove(player.getName());
boards.remove(player.getUniqueId());
//TODO: See if this works or if we need to set it to a new one
player.setScoreboard(man.getMainScoreboard());
}
/** Removes all of the scoreboards from the prisoners. */
public void removeAllScoreboards() {
HashMap<String, Scoreboard> temp = new HashMap<String, Scoreboard>(boards);
HashMap<UUID, Scoreboard> temp = new HashMap<UUID, Scoreboard>(boards);
for(String s : temp.keySet()) {
Player p = pl.getServer().getPlayerExact(s);
for(UUID id : temp.keySet()) {
Player p = pl.getServer().getPlayer(id);
if(p != null) {
p.setScoreboard(man.getMainScoreboard());
}
boards.remove(s);
boards.remove(id);
}
}
@ -84,8 +85,8 @@ public class ScoreBoardManager {
private void updatePrisonersTime() {
for(Jail j : pl.getJailManager().getJails()) {
for(Prisoner p : j.getAllPrisoners()) {
if(pl.getServer().getPlayerExact(p.getName()) != null) {
addScoreBoard(pl.getServer().getPlayerExact(p.getName()), p);
if(pl.getServer().getPlayer(p.getUUID()) != null) {
addScoreBoard(pl.getServer().getPlayer(p.getUUID()), p);
}
}
}

View File

@ -2,6 +2,7 @@ package com.graywolf336.jail.beans;
import java.util.HashMap;
import java.util.HashSet;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.Location;
@ -282,52 +283,47 @@ public class Jail {
* @return true if is jailed, false if not.
*/
public boolean isPlayerJailed(Player player) {
return this.isPlayerAPrisoner(player.getName());
return this.isPlayerAPrisoner(player.getUniqueId());
}
/**
* Returns whether the name of a player is a prisoner in the system, whether in a cell or no cell.
* Returns whether the uuid of a player is a prisoner in the system, whether in a cell or no cell.
*
* @param name The name of the person we're checking.
* @param uuid The uuid of the person we're checking.
* @return true if is jailed, false if not.
*/
public boolean isPlayerJailed(String name) {
return this.isPlayerAPrisoner(name);
public boolean isPlayerJailed(UUID uuid) {
return this.isPlayerAPrisoner(uuid);
}
/**
* Returns whether the name of a player is a prisoner in the system, whether in a cell or no cell.
* Returns whether the uuid of a player is a prisoner in this jail, no matter if they're in a cell or not.
*
* @param name The name of the person we're checking.
* @param uuid The name of the person we're checking.
* @return true if is a prisoner, false if not.
*/
public boolean isPlayerAPrisoner(String name) {
boolean is = false;
private boolean isPlayerAPrisoner(UUID uuid) {
for(Prisoner p : this.getAllPrisoners())
if(p.getUUID().equals(uuid))
return true;
for(Prisoner p : this.getAllPrisoners()) {
if(p.getName().equalsIgnoreCase(name)) {
is = true;
break;
}
}
return is;
return false;
}
/**
* Checks if the given name is a prisoner in a cell.
* Checks if the given uuid of a player is a prisoner in a cell.
*
* @param name of the prisoner to check.
* @param uuid of the prisoner to check.
* @return true if is jailed in a cell, false if not.
*/
public boolean isJailedInACell(String name) {
public boolean isJailedInACell(UUID uuid) {
for(Prisoner p : nocellPrisoners)
if(p.getName().equalsIgnoreCase(name))
if(p.getUUID().equals(uuid))
return false;
for(Cell c : cells.values())
if(c.getPrisoner() != null)
if(c.getPrisoner().getName().equalsIgnoreCase(name))
if(c.getPrisoner().getUUID().equals(uuid))
return true;
return false;
@ -338,18 +334,28 @@ 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) {
Prisoner r = null;
for(Prisoner p : this.getAllPrisoners())
if(p.getName().equalsIgnoreCase(name))
return p;
for(Prisoner p : this.getAllPrisoners()) {
if(p.getName().equalsIgnoreCase(name)) {
r = p;
break;
}
}
return null;
}
return r;
/**
* Gets the {@link Prisoner prisoner} instance for the given uuid.
*
* @param uuid The uuid of the prisoner to get.
* @return the prisoner instance, can be null
*/
public Prisoner getPrisoner(UUID uuid) {
for(Prisoner p : this.getAllPrisoners())
if(p.getUUID().equals(uuid))
return p;
return null;
}
/**

View File

@ -27,9 +27,9 @@ public class MoveProtectionListener implements Listener {
//Other wise we don't need to deal with it.
if(pl.getConfig().getBoolean(Settings.MOVEPROTECTION.getPath())) {
//Let's be sure the player we're dealing with is in jail
if(pl.getJailManager().isPlayerJailed(event.getPlayer().getName())) {
Jail j = pl.getJailManager().getJailPlayerIsIn(event.getPlayer().getName());
Prisoner p = j.getPrisoner(event.getPlayer().getName());
if(pl.getJailManager().isPlayerJailed(event.getPlayer().getUniqueId())) {
Jail j = pl.getJailManager().getJailPlayerIsIn(event.getPlayer().getUniqueId());
Prisoner p = j.getPrisoner(event.getPlayer().getUniqueId());
//If the player is being teleported, let's ignore it
if(p.isTeleporting()) {
@ -45,7 +45,7 @@ public class MoveProtectionListener implements Listener {
if (!j.isInside(event.getTo())) {
try {
long add = Util.getTime(pl.getConfig().getString(Settings.MOVEPENALTY.getPath()));
pl.getJailManager().getPrisoner(event.getPlayer().getName()).addTime(add);
pl.getJailManager().getPrisoner(event.getPlayer().getUniqueId()).addTime(add);
String msg = "";
if(add == 0L) {
@ -67,7 +67,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().getName())) {
if(j.isJailedInACell(event.getPlayer().getUniqueId())) {
event.setTo(j.getCellPrisonerIsIn(event.getPlayer().getName()).getTeleport());
}else {
//Otherwise let's teleport them to the in location of the jail

View File

@ -62,8 +62,8 @@ public class PlayerListener implements Listener {
@EventHandler(ignoreCancelled=true, priority = EventPriority.LOW)
public void chatting(AsyncPlayerChatEvent event) {
if(pl.getJailManager().isPlayerJailed(event.getPlayer().getName())) {
if(pl.getJailManager().getPrisoner(event.getPlayer().getName()).isMuted()) {
if(pl.getJailManager().isPlayerJailed(event.getPlayer().getUniqueId())) {
if(pl.getJailManager().getPrisoner(event.getPlayer().getUniqueId()).isMuted()) {
event.setCancelled(true);
event.getPlayer().sendMessage(pl.getJailIO().getLanguageString(LangString.MUTED));
}
@ -75,11 +75,9 @@ public class PlayerListener implements Listener {
if(pl.inDebug()) pl.getLogger().info("Debug - There are " + event.getRecipients().size() + " players getting the message before.");
Set<Player> rec = new HashSet<Player>(event.getRecipients());
for(Jail j : pl.getJailManager().getJails()) {
for(Prisoner p : j.getAllPrisoners()) {
rec.remove(pl.getServer().getPlayerExact(p.getName()));
}
}
for(Jail j : pl.getJailManager().getJails())
for(Prisoner p : j.getAllPrisoners())
rec.remove(pl.getServer().getPlayer(p.getUUID()));
event.getRecipients().clear();
event.getRecipients().addAll(rec);
@ -90,10 +88,10 @@ public class PlayerListener implements Listener {
@EventHandler
public void checkForOfflineJailStuff(PlayerJoinEvent event) {
//Let's check if the player is jailed
if(pl.getJailManager().isPlayerJailed(event.getPlayer().getName())) {
if(pl.getJailManager().isPlayerJailed(event.getPlayer().getUniqueId())) {
//Get the prisoner object
Jail j = pl.getJailManager().getJailPlayerIsIn(event.getPlayer().getName());
Prisoner p = j.getPrisoner(event.getPlayer().getName());
Jail j = pl.getJailManager().getJailPlayerIsIn(event.getPlayer().getUniqueId());
Prisoner p = j.getPrisoner(event.getPlayer().getUniqueId());
//Check if they're offline pending, as if this is true then they were jailed offline
if(p.isOfflinePending()) {
@ -118,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().getName());
pl.getPrisonerManager().jailPrisoner(event.getPlayer().getUniqueId());//TODO
}
}
@ -136,7 +134,7 @@ public class PlayerListener implements Listener {
@EventHandler
public void handleGoingOffline(PlayerQuitEvent event) {
if(pl.getJailManager().isPlayerJailed(event.getPlayer().getName())) {
if(pl.getJailManager().isPlayerJailed(event.getPlayer().getUniqueId())) {
//Remove the scoreboard to them if it is enabled
if(pl.getConfig().getBoolean(Settings.SCOREBOARDENABLED.getPath())) {
pl.getScoreBoardManager().removeScoreBoard(event.getPlayer());
@ -146,7 +144,7 @@ public class PlayerListener implements Listener {
@EventHandler(ignoreCancelled=true)
public void handleGettingKicked(PlayerKickEvent event) {
if(pl.getJailManager().isPlayerJailed(event.getPlayer().getName())) {
if(pl.getJailManager().isPlayerJailed(event.getPlayer().getUniqueId())) {
//Remove the scoreboard to them if it is enabled
if(pl.getConfig().getBoolean(Settings.SCOREBOARDENABLED.getPath())) {
pl.getScoreBoardManager().removeScoreBoard(event.getPlayer());
@ -157,7 +155,7 @@ public class PlayerListener implements Listener {
@EventHandler(priority = EventPriority.LOW)
public void foodControl(FoodLevelChangeEvent event) {
if(pl.getConfig().getBoolean(Settings.FOODCONTROL.getPath())) {
if(pl.getJailManager().isPlayerJailed(event.getEntity().getName())) {
if(pl.getJailManager().isPlayerJailed(event.getEntity().getUniqueId())) {
int min = pl.getConfig().getInt(Settings.FOODCONTROLMIN.getPath());
int max = pl.getConfig().getInt(Settings.FOODCONTROLMAX.getPath());
@ -172,10 +170,10 @@ public class PlayerListener implements Listener {
@EventHandler
public void onPlayerRespawn(PlayerRespawnEvent event) {
if(pl.getJailManager().isPlayerJailed(event.getPlayer().getName())) {
Jail j = pl.getJailManager().getJailPlayerIsIn(event.getPlayer().getName());
if(pl.getJailManager().isPlayerJailed(event.getPlayer().getUniqueId())) {
Jail j = pl.getJailManager().getJailPlayerIsIn(event.getPlayer().getUniqueId());
if(j.isJailedInACell(event.getPlayer().getName())) {
if(j.isJailedInACell(event.getPlayer().getUniqueId())) {
event.setRespawnLocation(j.getCellPrisonerIsIn(event.getPlayer().getName()).getTeleport());
}else {
event.setRespawnLocation(j.getTeleportIn());
@ -196,7 +194,7 @@ public class PlayerListener implements Listener {
if(pl.getJailStickManager().isValidStick(attacker.getItemInHand().getType())) {
if(attacker.hasPermission("jail.usejailstick." + attacker.getItemInHand().getType().toString().toLowerCase())) {
//The person the attacker is trying to jail stick is already jailed, don't handle that
if(pl.getJailManager().isPlayerJailed(player.getName())) {
if(pl.getJailManager().isPlayerJailed(player.getUniqueId())) {
attacker.sendMessage(pl.getJailIO().getLanguageString(LangString.ALREADYJAILED, player.getName()));
}else {
if(player.hasPermission("jail.cantbejailed")) {

View File

@ -32,7 +32,7 @@ public class ProtectionListener implements Listener {
//Let's check if the player is jailed, otherwise the other listener
//in the BlockListener class will take care of protecting inside
//of the jails.
if(pl.getJailManager().isPlayerJailed(event.getPlayer().getName())) {
if(pl.getJailManager().isPlayerJailed(event.getPlayer().getUniqueId())) {
//Get the breaking whitelist, check if the current item is in there
if(!Util.isStringInsideList(pl.getConfig().getStringList(Settings.BLOCKBREAKWHITELIST.getPath()),
event.getBlock().getType().toString().toLowerCase())) {
@ -41,7 +41,7 @@ public class ProtectionListener implements Listener {
//as a fail safe, don't want us to go crazy adding tons of time.
try {
long add = Util.getTime(pl.getConfig().getString(Settings.BLOCKBREAKPENALTY.getPath()));
pl.getJailManager().getPrisoner(event.getPlayer().getName()).addTime(add);
pl.getJailManager().getPrisoner(event.getPlayer().getUniqueId()).addTime(add);
String msg = "";
if(add == 0L) {
@ -77,7 +77,7 @@ public class ProtectionListener implements Listener {
//Let's check if the player is jailed, otherwise the other listener
//in the BlockListener class will take care of protecting inside
//of the jails.
if(pl.getJailManager().isPlayerJailed(event.getPlayer().getName())) {
if(pl.getJailManager().isPlayerJailed(event.getPlayer().getUniqueId())) {
//Get the placing whitelist, check if the current item is in there
if(!Util.isStringInsideList(pl.getConfig().getStringList(Settings.BLOCKPLACEWHITELIST.getPath()),
event.getBlock().getType().toString().toLowerCase())) {
@ -86,7 +86,7 @@ public class ProtectionListener implements Listener {
//as a fail safe, don't want us to go crazy adding tons of time.
try {
long add = Util.getTime(pl.getConfig().getString(Settings.BLOCKPLACEPENALTY.getPath()));
pl.getJailManager().getPrisoner(event.getPlayer().getName()).addTime(add);
pl.getJailManager().getPrisoner(event.getPlayer().getUniqueId()).addTime(add);
String msg = "";
if(add == 0L) {
@ -121,7 +121,7 @@ public class ProtectionListener implements Listener {
if(pl.getConfig().getBoolean(Settings.COMMANDPROTECTION.getPath())) {
//Let's check if this player is jailed, if so then we continue
//otherwise we don't care about commands in here
if(pl.getJailManager().isPlayerJailed(event.getPlayer().getName())) {
if(pl.getJailManager().isPlayerJailed(event.getPlayer().getUniqueId())) {
boolean match = false;
for(String whited : pl.getConfig().getStringList(Settings.COMMANDWHITELIST.getPath()))
@ -132,7 +132,7 @@ public class ProtectionListener implements Listener {
if(!match) {
try {
long add = Util.getTime(pl.getConfig().getString(Settings.COMMANDPENALTY.getPath()));
pl.getJailManager().getPrisoner(event.getPlayer().getName()).addTime(add);
pl.getJailManager().getPrisoner(event.getPlayer().getUniqueId()).addTime(add);
String msg = "";
if(add == 0L) {
@ -163,13 +163,13 @@ public class ProtectionListener implements Listener {
@EventHandler(ignoreCancelled=true, priority = EventPriority.LOW)
public void chestProtection(PlayerInteractEvent event) {
//First thing is first, let's be sure the player we're dealing with is in jail
if(pl.getJailManager().isPlayerJailed(event.getPlayer().getName())) {
if(pl.getJailManager().isPlayerJailed(event.getPlayer().getUniqueId())) {
//Next, let's check if it is a chest and if they're in a cell
//If they are in a cell and are opening a chest, then we check
//the config to see if they can open the chests
if(event.getAction() == Action.RIGHT_CLICK_BLOCK && event.getClickedBlock().getType() == Material.CHEST) {
//Let's get the cell the player is in, then check if it is null or not.
if(pl.getJailManager().getJailPlayerIsIn(event.getPlayer().getName()).isJailedInACell(event.getPlayer().getName())) {
if(pl.getJailManager().getJailPlayerIsIn(event.getPlayer().getUniqueId()).isJailedInACell(event.getPlayer().getUniqueId())) {
if(pl.getConfig().getBoolean(Settings.PRISONEROPENCHEST.getPath())) {
//The prisoner is in a cell, so let's check if it is a couple chest.
Material bpos1 = event.getClickedBlock().getLocation().add(-1, 0, 0).getBlock().getType();
@ -208,14 +208,14 @@ public class ProtectionListener implements Listener {
@EventHandler(ignoreCancelled=true, priority = EventPriority.LOWEST)
public void cropTramplingProtection(PlayerInteractEvent event) {
//First thing is first, let's be sure the player we're dealing with is in jail
if(pl.getJailManager().isPlayerJailed(event.getPlayer().getName())) {
if(pl.getJailManager().isPlayerJailed(event.getPlayer().getUniqueId())) {
//Next, check if crap trampling protection is enabled
if(pl.getConfig().getBoolean(Settings.CROPTRAMPLINGPROTECTION.getPath())) {
if(event.getAction() == Action.PHYSICAL && event.getClickedBlock().getType() == Material.SOIL) {
if(pl.getJailManager().getJailFromLocation(event.getClickedBlock().getLocation()) != null) {
try {
long add = Util.getTime(pl.getConfig().getString(Settings.CROPTRAMPLINGPENALTY.getPath()));
pl.getJailManager().getPrisoner(event.getPlayer().getName()).addTime(add);
pl.getJailManager().getPrisoner(event.getPlayer().getUniqueId()).addTime(add);
String msg = "";
if(add == 0L) {
@ -248,7 +248,7 @@ public class ProtectionListener implements Listener {
//As the old version didn't do anything with Physical interactions, we won't either
if (event.getAction() != Action.PHYSICAL) {
//First thing is first, let's be sure the player we're dealing with is in jail
if(pl.getJailManager().isPlayerJailed(event.getPlayer().getName())) {
if(pl.getJailManager().isPlayerJailed(event.getPlayer().getUniqueId())) {
//Let's check if they've interacted with a block
if (event.getClickedBlock() != null) {
@ -258,7 +258,7 @@ public class ProtectionListener implements Listener {
event.getClickedBlock().getType().toString().toLowerCase())) {
try {
long add = Util.getTime(pl.getConfig().getString(Settings.PREVENTINTERACTIONBLOCKSPENALTY.getPath()));
pl.getJailManager().getPrisoner(event.getPlayer().getName()).addTime(add);
pl.getJailManager().getPrisoner(event.getPlayer().getUniqueId()).addTime(add);
String msg = "";
if(add == 0L) {
@ -289,7 +289,7 @@ public class ProtectionListener implements Listener {
event.getClickedBlock().getType().toString().toLowerCase())) {
try {
long add = Util.getTime(pl.getConfig().getString(Settings.PREVENTINTERACTIONITEMSPENALTY.getPath()));
pl.getJailManager().getPrisoner(event.getPlayer().getName()).addTime(add);
pl.getJailManager().getPrisoner(event.getPlayer().getUniqueId()).addTime(add);
String msg = "";
if(add == 0L) {