Add the jailstop, jailtelein, and jailteleout to subcommands.

This commit is contained in:
graywolf336
2014-01-30 14:10:51 -06:00
parent edb563a9ec
commit 1e632017c7
8 changed files with 78 additions and 20 deletions

View File

@ -1,32 +0,0 @@
package com.graywolf336.jail.command.commands;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import com.graywolf336.jail.JailManager;
import com.graywolf336.jail.command.Command;
import com.graywolf336.jail.command.CommandInfo;
@CommandInfo(
maxArgs = 0,
minimumArgs = 0,
needsPlayer = true,
pattern = "jailstop",
permission = "jail.command.jailstop",
usage = "/jailstop"
)
public class JailStopCommand implements Command {
public boolean execute(JailManager jm, CommandSender sender, String... args) {
if(jm.isCreatingACell(sender.getName())) {
jm.removeCellCreationPlayer(sender.getName());
sender.sendMessage(ChatColor.RED + "You have stopped creating cells.");
}
if(jm.isCreatingAJail(sender.getName())) {
jm.removeJailCreationPlayer(sender.getName());
sender.sendMessage(ChatColor.RED + "You have stopped creating a jail.");
}
return true;
}
}

View File

@ -1,54 +0,0 @@
package com.graywolf336.jail.command.commands;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
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 = false,
pattern = "jailtelein|jailteleportin",
permission = "jail.command.jailtelein",
usage = "/jailtelein <jailname> (player)"
)
public class JailTeleInCommand implements Command {
public boolean execute(JailManager jm, CommandSender sender, String... args) throws Exception {
Jail j = jm.getJail(args[0]);
//The jail doesn't exist
if(j == null) {
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOJAIL, args[0]));
}else {
//The jail does exist
//now let's check the size of the command
//if it has two args then someone is sending someone else in
//otherwise it is just the sender going in
if(args.length == 2) {
Player p = jm.getPlugin().getServer().getPlayer(args[1]);
//If the player they're trying to send is offline, don't do anything
if(p == null) {
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PLAYERNOTONLINE, args[1]));
}else {
p.teleport(j.getTeleportIn());
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.TELEIN, new String[] { args[1], args[0] }));
}
}else {
if(sender instanceof Player) {
((Player) sender).teleport(j.getTeleportIn());
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.TELEIN, new String[] { sender.getName(), args[0] }));
}else {
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PLAYERCONTEXTREQUIRED));
}
}
}
return true;
}
}

View File

@ -1,54 +0,0 @@
package com.graywolf336.jail.command.commands;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
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 = false,
pattern = "jailteleout|jailteleportout",
permission = "jail.command.jailteleout",
usage = "/jailteleout <jailname> (player)"
)
public class JailTeleOutCommand implements Command {
public boolean execute(JailManager jm, CommandSender sender, String... args) throws Exception {
Jail j = jm.getJail(args[0]);
//The jail doesn't exist
if(j == null) {
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOJAIL, args[0]));
}else {
//The jail does exist
//now let's check the size of the command
//if it has two args then someone is sending someone else in
//otherwise it is just the sender going in
if(args.length == 2) {
Player p = jm.getPlugin().getServer().getPlayer(args[1]);
//If the player they're trying to send is offline, don't do anything
if(p == null) {
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PLAYERNOTONLINE, args[1]));
}else {
p.teleport(j.getTeleportFree());
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.TELEOUT, new String[] { args[1], args[0] }));
}
}else {
if(sender instanceof Player) {
((Player) sender).teleport(j.getTeleportFree());
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.TELEOUT, new String[] { sender.getName(), args[0] }));
}else {
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PLAYERCONTEXTREQUIRED));
}
}
}
return true;
}
}