Add the command to transfer all the prisoners in one jail to another.
This commit is contained in:
parent
b1ca15d10c
commit
950eb638b8
@ -26,6 +26,7 @@ import com.graywolf336.jail.command.subcommands.JailRemoveCellCommand;
|
|||||||
import com.graywolf336.jail.command.subcommands.JailStopCommand;
|
import com.graywolf336.jail.command.subcommands.JailStopCommand;
|
||||||
import com.graywolf336.jail.command.subcommands.JailTeleInCommand;
|
import com.graywolf336.jail.command.subcommands.JailTeleInCommand;
|
||||||
import com.graywolf336.jail.command.subcommands.JailTeleOutCommand;
|
import com.graywolf336.jail.command.subcommands.JailTeleOutCommand;
|
||||||
|
import com.graywolf336.jail.command.subcommands.JailTransferAllCommand;
|
||||||
import com.graywolf336.jail.command.subcommands.JailTransferCommand;
|
import com.graywolf336.jail.command.subcommands.JailTransferCommand;
|
||||||
import com.graywolf336.jail.command.subcommands.JailVersionCommand;
|
import com.graywolf336.jail.command.subcommands.JailVersionCommand;
|
||||||
import com.graywolf336.jail.enums.LangString;
|
import com.graywolf336.jail.enums.LangString;
|
||||||
@ -179,6 +180,7 @@ public class JailHandler {
|
|||||||
load(JailStopCommand.class);
|
load(JailStopCommand.class);
|
||||||
load(JailTeleInCommand.class);
|
load(JailTeleInCommand.class);
|
||||||
load(JailTeleOutCommand.class);
|
load(JailTeleOutCommand.class);
|
||||||
|
load(JailTransferAllCommand.class);
|
||||||
load(JailTransferCommand.class);
|
load(JailTransferCommand.class);
|
||||||
load(JailVersionCommand.class);
|
load(JailVersionCommand.class);
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,56 @@
|
|||||||
|
package com.graywolf336.jail.command.subcommands;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
|
||||||
|
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 = 2,
|
||||||
|
minimumArgs = 2,
|
||||||
|
needsPlayer = false,
|
||||||
|
pattern = "transferall|transall",
|
||||||
|
permission = "jail.command.jailtransferall",
|
||||||
|
usage = "/jail transferall oldjail targetjail"
|
||||||
|
)
|
||||||
|
public class JailTransferAllCommand implements Command {
|
||||||
|
public boolean execute(JailManager jm, CommandSender sender, String... args) throws Exception {
|
||||||
|
if(jm.getJails().isEmpty()) {
|
||||||
|
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOJAILS));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
jm.getPlugin().debug("Starting to transfer everyone from '" + args[1] + "' into '" + args[2] + "'.");
|
||||||
|
|
||||||
|
//Check if the oldjail is not a valid jail
|
||||||
|
if(!jm.isValidJail(args[1])) {
|
||||||
|
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOJAIL, args[1]));
|
||||||
|
return true;
|
||||||
|
}else if(!jm.isValidJail(args[2])) {
|
||||||
|
//Check if the targetjail is a valid jail as well
|
||||||
|
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOJAIL, args[2]));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
jm.getPlugin().debug("Sending the transferring off, jail checks all came clean.");
|
||||||
|
|
||||||
|
Jail old = jm.getJail(args[1]);
|
||||||
|
HashSet<Prisoner> oldPrisoners = new HashSet<Prisoner>(old.getAllPrisoners());
|
||||||
|
|
||||||
|
//Transfer all the prisoners
|
||||||
|
for(Prisoner p : oldPrisoners) {
|
||||||
|
jm.getPlugin().getPrisonerManager().transferPrisoner(old, old.getCellPrisonerIsIn(p.getName()), jm.getJail(args[2]), null, p);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Send the messages to the sender when completed
|
||||||
|
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.TRANSFERALLCOMPLETE, new String[] { old.getName(), args[2] }));
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -74,6 +74,8 @@ public enum LangString {
|
|||||||
TELEIN ("jailing"),
|
TELEIN ("jailing"),
|
||||||
/** The message sent to the sender when they teleport someone to a jail's teleport out location. */
|
/** The message sent to the sender when they teleport someone to a jail's teleport out location. */
|
||||||
TELEOUT ("jailing"),
|
TELEOUT ("jailing"),
|
||||||
|
/** The message sent to the sender when they transfer all a jail's prisoners to another jail. */
|
||||||
|
TRANSFERALLCOMPLETE ("jailing"),
|
||||||
/** The message sent to the sender when they transfer someone to a jail and a cell. */
|
/** The message sent to the sender when they transfer someone to a jail and a cell. */
|
||||||
TRANSFERCOMPLETECELL ("jailing"),
|
TRANSFERCOMPLETECELL ("jailing"),
|
||||||
/** The message sent to the sender when they transfer someone to a jail. */
|
/** The message sent to the sender when they transfer someone to a jail. */
|
||||||
|
@ -53,6 +53,7 @@ language:
|
|||||||
suggestedcell: '&cAn empty cell in the same jail, %0%, was found: %1%'
|
suggestedcell: '&cAn empty cell in the same jail, %0%, was found: %1%'
|
||||||
telein: "&9Teleported %0% to %1%'s teleport in location."
|
telein: "&9Teleported %0% to %1%'s teleport in location."
|
||||||
teleout: "&9Teleported %0% to %1%'s teleport out location."
|
teleout: "&9Teleported %0% to %1%'s teleport out location."
|
||||||
|
transferallcomplete: '&2Successfully transferred all the prisoners from %0% to %1%.'
|
||||||
transfercompletecell: '&2Successfully transferred %0% to %1% in the cell %2%.'
|
transfercompletecell: '&2Successfully transferred %0% to %1% in the cell %2%.'
|
||||||
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%.'
|
||||||
|
Loading…
Reference in New Issue
Block a user