Add the JailClearCommand back, this time releasing all the prisoners.
This commit is contained in:
parent
13363f6d9a
commit
4ac89455b0
@ -13,6 +13,7 @@ import com.graywolf336.jail.JailManager;
|
||||
import com.graywolf336.jail.command.commands.CellCreateCommand;
|
||||
import com.graywolf336.jail.command.commands.HandCuffCommand;
|
||||
import com.graywolf336.jail.command.commands.JailCheckCommand;
|
||||
import com.graywolf336.jail.command.commands.JailClearCommand;
|
||||
import com.graywolf336.jail.command.commands.JailClearForceCommand;
|
||||
import com.graywolf336.jail.command.commands.JailCommand;
|
||||
import com.graywolf336.jail.command.commands.JailCreateCommand;
|
||||
@ -149,6 +150,7 @@ public class CommandHandler {
|
||||
load(CellCreateCommand.class);
|
||||
load(HandCuffCommand.class);
|
||||
load(JailCheckCommand.class);
|
||||
load(JailClearCommand.class);
|
||||
load(JailClearForceCommand.class);
|
||||
load(JailCommand.class);
|
||||
load(JailCreateCommand.class);
|
||||
|
@ -0,0 +1,53 @@
|
||||
package com.graywolf336.jail.command.commands;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.graywolf336.jail.JailManager;
|
||||
import com.graywolf336.jail.beans.Jail;
|
||||
import com.graywolf336.jail.beans.Prisoner;
|
||||
import com.graywolf336.jail.command.Command;
|
||||
import com.graywolf336.jail.command.CommandInfo;
|
||||
import com.graywolf336.jail.enums.LangString;
|
||||
|
||||
@CommandInfo(
|
||||
maxArgs = 1,
|
||||
minimumArgs = 0,
|
||||
needsPlayer = false,
|
||||
pattern = "jailclear|jclear",
|
||||
permission = "jail.command.jailclear",
|
||||
usage = "/jailclear (Jail name)"
|
||||
)
|
||||
public class JailClearCommand implements Command {
|
||||
|
||||
// If Jail is specified unjails all the prisoners from that Jail (new feature) otherwise it unjails all the prisoners from all the jails
|
||||
public boolean execute(JailManager jm, CommandSender sender, String... args) {
|
||||
if(args.length == 1) {
|
||||
Jail j = jm.getJail(args[0]);
|
||||
|
||||
if(j != null) {
|
||||
for(Prisoner p : j.getAllPrisoners()) {
|
||||
jm.getPlugin().getPrisonerManager().releasePrisoner(jm.getPlugin().getServer().getPlayerExact(p.getName()), p);
|
||||
}
|
||||
|
||||
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()) {
|
||||
for(Prisoner p : j.getAllPrisoners()) {
|
||||
jm.getPlugin().getPrisonerManager().releasePrisoner(jm.getPlugin().getServer().getPlayerExact(p.getName()), p);
|
||||
}
|
||||
}
|
||||
|
||||
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PRISONERSCLEARED,
|
||||
jm.getPlugin().getJailIO().getLanguageString(LangString.ALLJAILS)));
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user