Send a message to the unjailer when they unjail someone.

This commit is contained in:
graywolf336 2014-07-14 21:11:46 -05:00
parent 9e1b75c602
commit 049ea63102
5 changed files with 17 additions and 11 deletions

View File

@ -4,6 +4,7 @@ import java.util.UUID;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory; import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@ -287,7 +288,7 @@ public class PrisonerManager {
Jail j = pl.getJailManager().getJailPlayerIsIn(player.getUniqueId()); Jail j = pl.getJailManager().getJailPlayerIsIn(player.getUniqueId());
try { try {
unJail(j, j.getCellPrisonerIsIn(player.getUniqueId()), player, prisoner); unJail(j, j.getCellPrisonerIsIn(player.getUniqueId()), player, prisoner, null);
}catch(Exception e) { }catch(Exception e) {
if(pl.inDebug()) { if(pl.inDebug()) {
e.printStackTrace(); e.printStackTrace();
@ -310,9 +311,10 @@ public class PrisonerManager {
* @param cell which the prisoner is in, can be null * @param cell which the prisoner is in, can be null
* @param player instance for the prisoner we're unjailing * @param player instance for the prisoner we're unjailing
* @param prisoner data where everything resides * @param prisoner data where everything resides
* @param sender The {@link CommandSender} who unjailed this player, can be null.
* @throws Exception * @throws Exception
*/ */
public void unJail(Jail jail, Cell cell, Player player, Prisoner prisoner) throws Exception { public void unJail(Jail jail, Cell cell, Player player, Prisoner prisoner, CommandSender sender) throws Exception {
//Do some checks of whether the passed params are null. //Do some checks of whether the passed params are null.
if(jail == null) if(jail == null)
throw new Exception("The jail can not be null."); throw new Exception("The jail can not be null.");
@ -416,16 +418,17 @@ public class PrisonerManager {
pl.getServer().getPluginManager().callEvent(event); pl.getServer().getPluginManager().callEvent(event);
player.sendMessage(pl.getJailIO().getLanguageString(LangString.UNJAILED)); player.sendMessage(pl.getJailIO().getLanguageString(LangString.UNJAILED));
if(sender != null) sender.sendMessage(pl.getJailIO().getLanguageString(LangString.UNJAILSUCCESS, player.getName()));
} }
/** Forcefully releases a {@link Prisoner prisoner} from {@link Jail}. */ /** Forcefully releases a {@link Prisoner prisoner} from {@link Jail}. */
public void forceRelease(Prisoner prisoner) { public void forceRelease(Prisoner prisoner, CommandSender sender) {
Jail j = pl.getJailManager().getJailPrisonerIsIn(prisoner); Jail j = pl.getJailManager().getJailPrisonerIsIn(prisoner);
forceUnJail(j, j.getCellPrisonerIsIn(prisoner.getUUID()), pl.getServer().getPlayer(prisoner.getUUID()), prisoner); forceUnJail(j, j.getCellPrisonerIsIn(prisoner.getUUID()), pl.getServer().getPlayer(prisoner.getUUID()), prisoner, sender);
} }
/** Forcefully unjails a {@link Prisoner prisoner} from {@link Jail}. */ /** Forcefully unjails a {@link Prisoner prisoner} from {@link Jail}. */
public void forceUnJail(Jail jail, Cell cell, Player player, Prisoner prisoner) { public void forceUnJail(Jail jail, Cell cell, Player player, Prisoner prisoner, CommandSender sender) {
if(player == null) { if(player == null) {
//Player is offline, we just forcefully remove them from the database //Player is offline, we just forcefully remove them from the database
pl.getJailIO().removePrisoner(jail, cell, prisoner); pl.getJailIO().removePrisoner(jail, cell, prisoner);
@ -435,9 +438,11 @@ public class PrisonerManager {
}else { }else {
cell.removePrisoner(); cell.removePrisoner();
} }
if(sender != null) sender.sendMessage(pl.getJailIO().getLanguageString(LangString.FORCEUNJAILED, prisoner.getLastKnownName()));
}else { }else {
try { try {
unJail(jail, cell, player, prisoner); unJail(jail, cell, player, prisoner, sender);
} catch (Exception e) { } catch (Exception e) {
releasePrisoner(player, prisoner); releasePrisoner(player, prisoner);
} }

View File

@ -34,8 +34,7 @@ public class UnJailCommand implements Command {
//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(pris.getUUID()), p, pris); jm.getPlugin().getPrisonerManager().forceUnJail(j, j.getCellPrisonerIsIn(pris.getUUID()), p, pris, sender);
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
pris.setRemainingTime(0L); pris.setRemainingTime(0L);
@ -45,7 +44,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(pris.getUUID()), p, pris); jm.getPlugin().getPrisonerManager().unJail(j, j.getCellPrisonerIsIn(pris.getUUID()), p, pris, sender);
} catch (Exception e) { } catch (Exception e) {
sender.sendMessage(ChatColor.RED + e.getMessage()); sender.sendMessage(ChatColor.RED + e.getMessage());
} }

View File

@ -22,8 +22,7 @@ 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.isPlayerJailedByLastKnownUsername(args[0])) { if(jm.isPlayerJailedByLastKnownUsername(args[0])) {
jm.getPlugin().getPrisonerManager().forceRelease(jm.getPrisonerByLastKnownName(args[0])); jm.getPlugin().getPrisonerManager().forceRelease(jm.getPrisonerByLastKnownName(args[0]), sender);
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())) {
jm.getPlugin().getLogger().info(ChatColor.stripColor(jm.getPlugin().getJailIO().getLanguageString(LangString.BROADCASTUNJAILING, new String[] { args[0], sender.getName() }))); jm.getPlugin().getLogger().info(ChatColor.stripColor(jm.getPlugin().getJailIO().getLanguageString(LangString.BROADCASTUNJAILING, new String[] { args[0], sender.getName() })));

View File

@ -90,6 +90,8 @@ public enum LangString {
TRANSFERRED ("jailing"), TRANSFERRED ("jailing"),
/** The message sent when players are released from jail. */ /** The message sent when players are released from jail. */
UNJAILED ("jailing"), UNJAILED ("jailing"),
/** The message sent to the person who released a prisoner from jail. */
UNJAILSUCCESS ("jailing"),
/** The message went when an offline player is unjailed. */ /** The message went when an offline player is unjailed. */
WILLBEUNJAILED ("jailing"), WILLBEUNJAILED ("jailing"),
/** The message sent to the sender when they check their jail status and they aren't jailed. */ /** The message sent to the sender when they check their jail status and they aren't jailed. */

View File

@ -73,6 +73,7 @@ language:
transfercompletenocell: '&2Successfully transferred %0% to %1%.' transfercompletenocell: '&2Successfully transferred %0% to %1%.'
transferred: '&9You have been transferred to %0%.' transferred: '&9You have been transferred to %0%.'
unjailed: '&2You have been released! Please respect the server rules.' unjailed: '&2You have been released! Please respect the server rules.'
unjailsuccess: '&2%0% has been released from jail.'
willbeunjailed: '&2%0% will be released the next time they log on.' willbeunjailed: '&2%0% will be released the next time they log on.'
youarenotjailed: '&2You are not jailed.' youarenotjailed: '&2You are not jailed.'
jailpay: jailpay: