Finish adding the jailrecord command, this closes #12.

This commit is contained in:
graywolf336
2014-03-06 18:10:53 -06:00
parent 9f9ede433a
commit 2ec69c5650
7 changed files with 126 additions and 12 deletions

View File

@ -23,6 +23,7 @@ import com.graywolf336.jail.command.subcommands.JailDeleteCommand;
import com.graywolf336.jail.command.subcommands.JailListCellsCommand;
import com.graywolf336.jail.command.subcommands.JailListCommand;
import com.graywolf336.jail.command.subcommands.JailMuteCommand;
import com.graywolf336.jail.command.subcommands.JailRecordCommand;
import com.graywolf336.jail.command.subcommands.JailReloadCommand;
import com.graywolf336.jail.command.subcommands.JailStatusCommand;
import com.graywolf336.jail.command.subcommands.JailStopCommand;
@ -181,6 +182,7 @@ public class JailHandler {
load(JailListCellsCommand.class);
load(JailListCommand.class);
load(JailMuteCommand.class);
load(JailRecordCommand.class);
load(JailReloadCommand.class);
load(JailStatusCommand.class);
load(JailStopCommand.class);

View File

@ -0,0 +1,45 @@
package com.graywolf336.jail.command.subcommands;
import java.util.List;
import org.bukkit.command.CommandSender;
import com.graywolf336.jail.JailManager;
import com.graywolf336.jail.command.Command;
import com.graywolf336.jail.command.CommandInfo;
import com.graywolf336.jail.enums.LangString;
@CommandInfo(
maxArgs = 2,
minimumArgs = 1,
needsPlayer = false,
pattern = "reload|r",
permission = "jail.command.jailrecord",
usage = "/jail record"
)
public class JailRecordCommand implements Command {
public boolean execute(JailManager jm, CommandSender sender, String... args) {
if(args.length == 2) {
// /jail record <username>
List<String> entries = jm.getPlugin().getJailIO().getRecordEntries(args[1]);
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.RECORDTIMESJAILED, new String[] { args[1], String.valueOf(entries.size()) }));
}else if(args.length == 3) {
// /jail record <username> something
List<String> entries = jm.getPlugin().getJailIO().getRecordEntries(args[1]);
//Send all the record entries
for(String s : entries) {
sender.sendMessage(s);
}
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.RECORDTIMESJAILED, new String[] { args[1], String.valueOf(entries.size()) }));
}else {
//They didn't do the command right
//send them back to get the usage
return false;
}
return true;
}
}