Add the JailMute, JailTeleIn, and JailTeleOut commands.

This commit is contained in:
graywolf336
2014-01-23 17:52:21 -06:00
parent 4ac89455b0
commit 010b592fb5
8 changed files with 165 additions and 3 deletions

View File

@ -19,8 +19,11 @@ import com.graywolf336.jail.command.commands.JailCommand;
import com.graywolf336.jail.command.commands.JailCreateCommand;
import com.graywolf336.jail.command.commands.JailListCellsCommand;
import com.graywolf336.jail.command.commands.JailListCommand;
import com.graywolf336.jail.command.commands.JailMuteCommand;
import com.graywolf336.jail.command.commands.JailRemoveCellCommand;
import com.graywolf336.jail.command.commands.JailStopCommand;
import com.graywolf336.jail.command.commands.JailTeleInCommand;
import com.graywolf336.jail.command.commands.JailTeleOutCommand;
import com.graywolf336.jail.command.commands.JailVersionCommand;
import com.graywolf336.jail.command.commands.UnHandCuffCommand;
import com.graywolf336.jail.command.commands.UnjailCommand;
@ -156,8 +159,11 @@ public class CommandHandler {
load(JailCreateCommand.class);
load(JailListCellsCommand.class);
load(JailListCommand.class);
load(JailMuteCommand.class);
load(JailRemoveCellCommand.class);
load(JailStopCommand.class);
load(JailTeleInCommand.class);
load(JailTeleOutCommand.class);
load(JailVersionCommand.class);
load(UnHandCuffCommand.class);
load(UnjailCommand.class);

View File

@ -18,8 +18,6 @@ import com.graywolf336.jail.enums.LangString;
usage = "/jaillist"
)
public class JailListCommand implements Command {
@Override
public boolean execute(JailManager jm, CommandSender sender, String... args) {
sender.sendMessage(ChatColor.AQUA + "----------Jails----------");

View File

@ -0,0 +1,38 @@
package com.graywolf336.jail.command.commands;
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 = 1,
minimumArgs = 1,
needsPlayer = false,
pattern = "jailmute|jmute",
permission = "jail.command.jailmute",
usage = "/jailmute <player>"
)
public class JailMuteCommand implements Command {
public boolean execute(JailManager jm, CommandSender sender, String... args) throws Exception {
//Let's check if the player they're sending us is jailed
if(jm.isPlayerJailed(args[0])) {
//They are, so let's toggle whether they are muted or not
boolean muted = !jm.getPrisoner(args[0]).isMuted();
jm.getPrisoner(args[0]).setMuted(muted);
//Send the message to the sender based upon whether they are muted or unmuted
if(muted)
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOWMUTED, args[0]));
else
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOWUNMUTED, args[0]));
}else {
//The player provided is not jailed, so let's tell the sender that
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOTJAILED, args[0]));
}
return true;
}
}

View File

@ -0,0 +1,54 @@
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

@ -0,0 +1,54 @@
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;
}
}

View File

@ -48,6 +48,10 @@ public enum LangString {
NOEMPTYCELLS ("jailing"),
/** The message sent when a player is not jailed and the sender is trying to see/do something about it. */
NOTJAILED ("jailing"),
/** The message sent to the sender when they mute a prisoner. */
NOWMUTED ("jailing"),
/** The message sent to the sender when they unmute a prisoner. */
NOWUNMUTED ("jailing"),
/** The message sent to the jailer when they jail someone offline. */
OFFLINEJAIL ("jailing"),
/** The message sent to the jailer when they jail someone who is online. */
@ -58,6 +62,10 @@ public enum LangString {
PROTECTIONMESSAGENOPENALTY ("jailing"),
/** The message sent to the sender of a command when suggesting a cell. */
SUGGESTEDCELL ("jailing"),
/** The message sent to the sender when they teleport someone to a jail's teleport in location. */
TELEIN ("jailing"),
/** The message sent to the sender when they teleport someone to a jail's teleport out location. */
TELEOUT ("jailing"),
/** The message sent when players are released from jail. */
UNJAILED ("jailing"),
/** The message went when an offline player is unjailed. */