Add work on jailclear and also the jail command to use language string.
This commit is contained in:
parent
38438e2eb8
commit
c956018d1e
@ -181,6 +181,18 @@ public class Jail {
|
|||||||
return new HashSet<Cell>(this.cells.values());
|
return new HashSet<Cell>(this.cells.values());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Clears all the prisoners from this Jail. */
|
||||||
|
public void clearPrisoners() {
|
||||||
|
//Remove the prisoners from all the cells
|
||||||
|
for(Cell c : getCells()) {
|
||||||
|
c.removePrisoner();
|
||||||
|
}
|
||||||
|
|
||||||
|
//Replace all the current no cell prisoners with
|
||||||
|
//a new hashset of prisoners.
|
||||||
|
this.nocellPrisoners = new HashSet<Prisoner>();
|
||||||
|
}
|
||||||
|
|
||||||
/** Gets a HashSet of <b>all</b> the prisoners, the ones in cells and ones who aren't. */
|
/** Gets a HashSet of <b>all</b> the prisoners, the ones in cells and ones who aren't. */
|
||||||
public HashSet<Prisoner> getAllPrisoners() {
|
public HashSet<Prisoner> getAllPrisoners() {
|
||||||
HashSet<Prisoner> all = new HashSet<Prisoner>(nocellPrisoners); //initalize the temp one to return with the prisoners not in any cells
|
HashSet<Prisoner> all = new HashSet<Prisoner>(nocellPrisoners); //initalize the temp one to return with the prisoners not in any cells
|
||||||
|
@ -3,8 +3,10 @@ package com.graywolf336.jail.command.commands;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
import com.graywolf336.jail.JailManager;
|
import com.graywolf336.jail.JailManager;
|
||||||
|
import com.graywolf336.jail.beans.Jail;
|
||||||
import com.graywolf336.jail.command.Command;
|
import com.graywolf336.jail.command.Command;
|
||||||
import com.graywolf336.jail.command.CommandInfo;
|
import com.graywolf336.jail.command.CommandInfo;
|
||||||
|
import com.graywolf336.jail.enums.LangString;
|
||||||
|
|
||||||
@CommandInfo(
|
@CommandInfo(
|
||||||
maxArgs = 1,
|
maxArgs = 1,
|
||||||
@ -17,8 +19,29 @@ import com.graywolf336.jail.command.CommandInfo;
|
|||||||
public class JailClearCommand implements Command {
|
public class JailClearCommand implements Command {
|
||||||
|
|
||||||
// If Jail is specified clear all prisoners from that Jail (new feature) else, clear all players from all jails
|
// If Jail is specified clear all prisoners from that Jail (new feature) else, clear all players from all jails
|
||||||
|
|
||||||
public boolean execute(JailManager jm, CommandSender sender, String... args) {
|
public boolean execute(JailManager jm, CommandSender sender, String... args) {
|
||||||
|
if(args.length == 1) {
|
||||||
|
Jail j = jm.getJail(args[0]);
|
||||||
|
|
||||||
|
if(j != null) {
|
||||||
|
j.clearPrisoners();
|
||||||
|
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PRISONERSCLEARED, j.getName()));
|
||||||
|
}else {
|
||||||
|
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOJAIL, args[0]));
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
if(jm.getJails().size() == 0) {
|
||||||
|
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOJAILS));
|
||||||
|
}else {
|
||||||
|
for(Jail j : jm.getJails()) {
|
||||||
|
j.clearPrisoners();
|
||||||
|
}
|
||||||
|
|
||||||
|
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PRISONERSCLEARED,
|
||||||
|
jm.getPlugin().getJailIO().getLanguageString(LangString.ALLJAILS)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true; //If they made it this far, the command is intact and ready to be processed. :)
|
return true; //If they made it this far, the command is intact and ready to be processed. :)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ public class JailCommand implements Command {
|
|||||||
public boolean execute(JailManager jm, CommandSender sender, String... args) {
|
public boolean execute(JailManager jm, CommandSender sender, String... args) {
|
||||||
|
|
||||||
if(jm.getJails().size() == 0) {
|
if(jm.getJails().size() == 0) {
|
||||||
sender.sendMessage(ChatColor.RED + "No jails found.");
|
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOJAILS));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,7 +59,7 @@ public class JailCommand implements Command {
|
|||||||
|
|
||||||
//Check if the given player is already jailed or not
|
//Check if the given player is already jailed or not
|
||||||
if(jm.isPlayerJailed(params.player())) {
|
if(jm.isPlayerJailed(params.player())) {
|
||||||
sender.sendMessage(ChatColor.RED + "That player is already jailed.");
|
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.ALREADYJAILED));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,7 +75,7 @@ public class JailCommand implements Command {
|
|||||||
time = Util.getTime(params.time());
|
time = Util.getTime(params.time());
|
||||||
}
|
}
|
||||||
}catch(Exception e) {
|
}catch(Exception e) {
|
||||||
sender.sendMessage(ChatColor.RED + "Number format is incorrect.");
|
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NUMBERFORMATINCORRECT));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,7 +93,7 @@ public class JailCommand implements Command {
|
|||||||
params.setJail(jm.getPlugin().getConfig().getString(Settings.DEFAULTJAIL.getPath()));
|
params.setJail(jm.getPlugin().getConfig().getString(Settings.DEFAULTJAIL.getPath()));
|
||||||
}
|
}
|
||||||
}else if(jm.getJail(params.jail()) == null) {
|
}else if(jm.getJail(params.jail()) == null) {
|
||||||
sender.sendMessage(ChatColor.RED + "No jail found by the name of '" + params.jail() + "'.");
|
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOJAIL, params.jail()));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,6 +14,8 @@ public enum LangString {
|
|||||||
|
|
||||||
/** The message displayed when players are kicked for being afk. */
|
/** The message displayed when players are kicked for being afk. */
|
||||||
AFKKICKMESSAGE ("jailing"),
|
AFKKICKMESSAGE ("jailing"),
|
||||||
|
/** The message sent when jailing someone that is already jailed. */
|
||||||
|
ALREADYJAILED ("jailing"),
|
||||||
/** The message sent when we broadcast/log the message for time below -1. */
|
/** The message sent when we broadcast/log the message for time below -1. */
|
||||||
BROADCASTMESSAGEFOREVER ("jailing"),
|
BROADCASTMESSAGEFOREVER ("jailing"),
|
||||||
/** The message sent when we broadcast/log the message for any time above -1. */
|
/** The message sent when we broadcast/log the message for any time above -1. */
|
||||||
@ -54,12 +56,22 @@ public enum LangString {
|
|||||||
|
|
||||||
//General section, used by different parts
|
//General section, used by different parts
|
||||||
|
|
||||||
|
/** Part message of any messages which require 'all the jails' or such. */
|
||||||
|
ALLJAILS ("general"),
|
||||||
|
/** The message sent whenever the sender does something which the jail does not found. */
|
||||||
|
NOJAIL ("general"),
|
||||||
|
/** The message sent whenever the sender does something and there are no jails. */
|
||||||
|
NOJAILS ("general"),
|
||||||
/** The message sent whenever the sender/player doesn't have permission. */
|
/** The message sent whenever the sender/player doesn't have permission. */
|
||||||
NOPERMISSION ("general"),
|
NOPERMISSION ("general"),
|
||||||
|
/** The message sent whenever the sender/player supplies a number format that is incorrect. */
|
||||||
|
NUMBERFORMATINCORRECT ("general"),
|
||||||
/** The message sent whenever something is done that needs a player but doesn't have it. */
|
/** The message sent whenever something is done that needs a player but doesn't have it. */
|
||||||
PLAYERCONTEXTREQUIRED ("general"),
|
PLAYERCONTEXTREQUIRED ("general"),
|
||||||
/** The message sent whenever an online player is required but not found. */
|
/** The message sent whenever an online player is required but not found. */
|
||||||
PLAYERNOTONLINE ("general"),
|
PLAYERNOTONLINE ("general"),
|
||||||
|
/** The message sent whenever the prisoners are cleared from jail(s). */
|
||||||
|
PRISONERSCLEARED ("general"),
|
||||||
/** The message sent whenever someone does a command we don't know. */
|
/** The message sent whenever someone does a command we don't know. */
|
||||||
UNKNOWNCOMMAND ("general");
|
UNKNOWNCOMMAND ("general");
|
||||||
|
|
||||||
|
@ -4,16 +4,22 @@ language:
|
|||||||
blockplacing: 'placing a block'
|
blockplacing: 'placing a block'
|
||||||
command: 'trying to use a command'
|
command: 'trying to use a command'
|
||||||
general:
|
general:
|
||||||
unknowncommand: '&cNo commands registered by the name of %0%.'
|
alljails: 'all the jails'
|
||||||
|
nojail: '&cNo jail found by the name of %0%.'
|
||||||
|
nojails: '&cThere are currently no jails.'
|
||||||
nopermission: '&cInsufficient permission.'
|
nopermission: '&cInsufficient permission.'
|
||||||
|
numberformatincorrect: '&cNumber format is incorrect.'
|
||||||
playercontextrequired: '&cA player context is required for this.'
|
playercontextrequired: '&cA player context is required for this.'
|
||||||
playernotonline: '&cThat player is not online!'
|
playernotonline: '&cThat player is not online!'
|
||||||
|
prisonerscleared: '&cAll the prisoners from %0% have been cleared.'
|
||||||
|
unknowncommand: '&cNo commands registered by the name of %0%.'
|
||||||
jailing:
|
jailing:
|
||||||
afkkickmessage: '&cYou can not be afk while being jailed.'
|
afkkickmessage: '&cYou can not be afk while being jailed.'
|
||||||
|
alreadyjailed: '&cThat player is already jailed.'
|
||||||
broadcastmessageforever: '&9%0% has been jailed forever.'
|
broadcastmessageforever: '&9%0% has been jailed forever.'
|
||||||
broadcastmessageforminutes: '&9%0% has been jailed for %1% minutes.'
|
broadcastmessageforminutes: '&9%0% has been jailed for %1% minutes.'
|
||||||
cantbejailed: '&cThat player can not be jailed.'
|
cantbejailed: '&cThat player can not be jailed.'
|
||||||
defaultjailedreason: Breaking the rules.
|
defaultjailedreason: 'Breaking the rules.'
|
||||||
jailed: '&cYou have been jailed!'
|
jailed: '&cYou have been jailed!'
|
||||||
jailedwithreason: '&cYou have been jailed for: %0%'
|
jailedwithreason: '&cYou have been jailed for: %0%'
|
||||||
muted: '&cStop talking, you are in jail.'
|
muted: '&cStop talking, you are in jail.'
|
||||||
|
Loading…
Reference in New Issue
Block a user