More command workings and using the custom languages.

This commit is contained in:
graywolf336
2014-01-21 18:09:47 -06:00
parent 3ab751baa8
commit 34ac65565c
9 changed files with 88 additions and 17 deletions

View File

@ -9,7 +9,7 @@ import com.graywolf336.jail.command.CommandInfo;
@CommandInfo(
maxArgs = 1,
minimumArgs = 0,
needsPlayer = true,
needsPlayer = false,
pattern = "jailcheck|jcheck",
permission = "jail.command.jailcheck",
usage = "/jailcheck (Player name)"

View File

@ -100,16 +100,17 @@ public class JailCommand implements Command {
//Check if the cell is defined, and if so check to be sure it exists.
if(!params.cell().isEmpty()) {
if(jm.getJail(params.jail()).getCell(params.cell()) == null) {
sender.sendMessage(ChatColor.RED + "The cell provided does not exist.");
//There is cell by that name
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOCELL, new String[] { params.cell(), params.jail() }));
return true;
}else if(jm.getJail(params.jail()).getCell(params.cell()).hasPrisoner()) {
//If the cell has a prisoner, don't allow jailing them to that particular cell
sender.sendMessage(ChatColor.RED + "The destination cell already has a prisoner in it.");
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.CELLNOTEMPTY, params.cell()));
Cell suggestedCell = jm.getJail(params.jail()).getFirstEmptyCell();
if(suggestedCell != null) {
sender.sendMessage(ChatColor.RED + "We found an empty cell in the same jail (" + params.jail() + ") with the name: " + suggestedCell.getName());
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.SUGGESTEDCELL, new String[] { params.jail(), suggestedCell.getName() }));
}else {
sender.sendMessage(ChatColor.RED + "We didn't find any empty cells, this jail's (" + params.jail() + ") cells appear to be full");
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOEMPTYCELLS, params.jail()));
}
return true;
@ -141,7 +142,7 @@ public class JailCommand implements Command {
//check if the event is cancelled
if(event.isCancelled()) {
if(event.getCancelledMessage().isEmpty())
sender.sendMessage(ChatColor.RED + "Jailing " + params.player() + " was cancelled by another plugin and they didn't leave you a message.");
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.CANCELLEDBYANOTHERPLUGIN, params.player()));
else
sender.sendMessage(event.getCancelledMessage());

View File

@ -8,6 +8,7 @@ import com.graywolf336.jail.beans.Cell;
import com.graywolf336.jail.beans.Jail;
import com.graywolf336.jail.command.Command;
import com.graywolf336.jail.command.CommandInfo;
import com.graywolf336.jail.enums.LangString;
@CommandInfo(
maxArgs = 1,
@ -36,15 +37,15 @@ public class JailListCellsCommand implements Command {
}
if(message.isEmpty()) {
sender.sendMessage(ChatColor.RED + "There are no cells for the jail '" + args[0] + "'.");
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOCELLS, j.getName()));
}else {
sender.sendMessage(ChatColor.GREEN + message);
}
}else {
sender.sendMessage(ChatColor.RED + "No jail by the name of '" + args[0] + "'.");
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOJAIL, args[0]));
}
}else {
sender.sendMessage(ChatColor.RED + " There are no jails.");
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOJAILS));
}
sender.sendMessage(ChatColor.AQUA + "-------------------------");

View File

@ -7,6 +7,7 @@ import com.graywolf336.jail.JailManager;
import com.graywolf336.jail.beans.Jail;
import com.graywolf336.jail.command.Command;
import com.graywolf336.jail.command.CommandInfo;
import com.graywolf336.jail.enums.LangString;
@CommandInfo(
maxArgs = 0,
@ -27,7 +28,7 @@ public class JailListCommand implements Command {
sender.sendMessage(ChatColor.BLUE + " " + j.getName() + " (" + j.getAllPrisoners().size() + ")");
}
}else {
sender.sendMessage(ChatColor.RED + " There are no jails.");
sender.sendMessage(" " + jm.getPlugin().getJailIO().getLanguageString(LangString.NOJAILS));
}
sender.sendMessage(ChatColor.AQUA + "-------------------------");

View File

@ -3,23 +3,47 @@ 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.command.Command;
import com.graywolf336.jail.command.CommandInfo;
import com.graywolf336.jail.enums.LangString;
@CommandInfo(
maxArgs = 2,
minimumArgs = 1,
needsPlayer = true,
minimumArgs = 2,
needsPlayer = false,
pattern = "jailremovecell|jrcell",
permission = "jail.command.jailremovecell",
usage = "/jailremovecell [Jail Name] (Cell Name)"
)
public class JailRemoveCellCommand implements Command{
// Remove the specified Cell from the Specified Jail, if no cell specified will delete nearest cell
// Remove the specified Cell from the Specified Jail
public boolean execute(JailManager jm, CommandSender sender, String... args) {
return true; //If they made it this far, the command is intact and ready to be processed. :)
Jail j = jm.getJail(args[0]);
if(j != null) {
if(!j.getCells().isEmpty()) {
if(j.getCell(args[1]) != null) {
//remove it!
j.removeCell(args[1]);
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.CELLREMOVED,
new String[] { args[1], args[0] }));
}else {
//No cell by that name
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOCELL,
new String[] { args[1], args[0] }));
}
}else {
//No cells in this jail
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOCELLS, args[0]));
}
}else {
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOJAIL, args[0]));
}
return true;
}
}

View File

@ -8,6 +8,7 @@ import com.graywolf336.jail.JailManager;
import com.graywolf336.jail.beans.Jail;
import com.graywolf336.jail.command.Command;
import com.graywolf336.jail.command.CommandInfo;
import com.graywolf336.jail.enums.LangString;
@CommandInfo(
maxArgs = 1,
@ -20,12 +21,19 @@ import com.graywolf336.jail.command.CommandInfo;
public class UnjailCommand implements Command {
public boolean execute(JailManager jm, CommandSender sender, String... args) {
//Check if the player is jailed
if(jm.isPlayerJailed(args[0])) {
Jail j = jm.getJailPlayerIsIn(args[0]);
Player p = jm.getPlugin().getServer().getPlayerExact(args[0]);
//Check if the player is on the server or not
if(p == null) {
sender.sendMessage(ChatColor.RED + "Offline unjailing is not implemented yet.");
//The player is not, so we'll set the remaining time to zero and do it when they login next
j.getPrisoner(args[0]).setRemainingTime(0L);
j.getPrisoner(args[0]).setOfflinePending(true);
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.WILLBEUNJAILED, args[0]));
}else {
Jail j = jm.getJailPlayerIsIn(args[0]);
//Player is online, so let's try unjailing them
try {
jm.getPlugin().getPrisonerManager().unJail(j, j.getCellPrisonerIsIn(args[0]), p, j.getPrisoner(args[0]));
} catch (Exception e) {
@ -33,7 +41,8 @@ public class UnjailCommand implements Command {
}
}
}else {
sender.sendMessage(ChatColor.RED + "That player is not jailed.");
//The player is not currently jailed
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOTJAILED, args[0]));
}
return true;