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.JailCreateCommand;
import com.graywolf336.jail.command.commands.JailListCellsCommand; import com.graywolf336.jail.command.commands.JailListCellsCommand;
import com.graywolf336.jail.command.commands.JailListCommand; 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.JailRemoveCellCommand;
import com.graywolf336.jail.command.commands.JailStopCommand; 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.JailVersionCommand;
import com.graywolf336.jail.command.commands.UnHandCuffCommand; import com.graywolf336.jail.command.commands.UnHandCuffCommand;
import com.graywolf336.jail.command.commands.UnjailCommand; import com.graywolf336.jail.command.commands.UnjailCommand;
@ -156,8 +159,11 @@ public class CommandHandler {
load(JailCreateCommand.class); load(JailCreateCommand.class);
load(JailListCellsCommand.class); load(JailListCellsCommand.class);
load(JailListCommand.class); load(JailListCommand.class);
load(JailMuteCommand.class);
load(JailRemoveCellCommand.class); load(JailRemoveCellCommand.class);
load(JailStopCommand.class); load(JailStopCommand.class);
load(JailTeleInCommand.class);
load(JailTeleOutCommand.class);
load(JailVersionCommand.class); load(JailVersionCommand.class);
load(UnHandCuffCommand.class); load(UnHandCuffCommand.class);
load(UnjailCommand.class); load(UnjailCommand.class);

View File

@ -18,8 +18,6 @@ import com.graywolf336.jail.enums.LangString;
usage = "/jaillist" usage = "/jaillist"
) )
public class JailListCommand implements Command { public class JailListCommand implements Command {
@Override
public boolean execute(JailManager jm, CommandSender sender, String... args) { public boolean execute(JailManager jm, CommandSender sender, String... args) {
sender.sendMessage(ChatColor.AQUA + "----------Jails----------"); 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"), NOEMPTYCELLS ("jailing"),
/** The message sent when a player is not jailed and the sender is trying to see/do something about it. */ /** The message sent when a player is not jailed and the sender is trying to see/do something about it. */
NOTJAILED ("jailing"), 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. */ /** The message sent to the jailer when they jail someone offline. */
OFFLINEJAIL ("jailing"), OFFLINEJAIL ("jailing"),
/** The message sent to the jailer when they jail someone who is online. */ /** The message sent to the jailer when they jail someone who is online. */
@ -58,6 +62,10 @@ public enum LangString {
PROTECTIONMESSAGENOPENALTY ("jailing"), PROTECTIONMESSAGENOPENALTY ("jailing"),
/** The message sent to the sender of a command when suggesting a cell. */ /** The message sent to the sender of a command when suggesting a cell. */
SUGGESTEDCELL ("jailing"), 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. */ /** The message sent when players are released from jail. */
UNJAILED ("jailing"), UNJAILED ("jailing"),
/** The message went when an offline player is unjailed. */ /** The message went when an offline player is unjailed. */

View File

@ -36,11 +36,15 @@ language:
muted: '&cStop talking, you are in jail.' muted: '&cStop talking, you are in jail.'
noemptycells: '&cNo empty cells were found for %0%, all them appear to be full.' noemptycells: '&cNo empty cells were found for %0%, all them appear to be full.'
notjailed: '&c%0% is not jailed.' notjailed: '&c%0% is not jailed.'
nowmuted: '&9%0% is now muted.'
nowunmuted: '&9%0% is now unmuted.'
offlinejail: '&2%0% is offline and will be jailed when they next come online for %1% minutes.' offlinejail: '&2%0% is offline and will be jailed when they next come online for %1% minutes.'
onlinejail: '&2%0% was jailed for %1% minutes.' onlinejail: '&2%0% was jailed for %1% minutes.'
protectionmessage: '&c%0% minutes have been added to your time for %1%.' protectionmessage: '&c%0% minutes have been added to your time for %1%.'
protectionmessagenopenalty: '&cProtection enabled for %0%, do not do it again.' protectionmessagenopenalty: '&cProtection enabled for %0%, do not do it again.'
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."
teleout: "&9Teleported %0% to %1%'s teleport out location."
unjailed: '&2You have been released! Please respect the server rules.' unjailed: '&2You have been released! Please respect the server rules.'
willbeunjailed: '&2%0% will be released the next time they log on.' willbeunjailed: '&2%0% will be released the next time they log on.'
handcuffing: handcuffing:

View File

@ -4,7 +4,7 @@ version: ${project.version}-b${BUILD_NUMBER}
description: Ban too harsh? Kick/mute/whatever not enough? Jail bad players! description: Ban too harsh? Kick/mute/whatever not enough? Jail bad players!
authors: [matejdro,multidude,graywolf336] authors: [matejdro,multidude,graywolf336]
website: dev.bukkit.org/server-mods/jail/ website: dev.bukkit.org/server-mods/jail/
softdepend: [Spout, WorldEdit, Vault, Notifications] softdepend: [WorldEdit, Vault]
load: POSTWORLD load: POSTWORLD
commands: commands:
jailcreate: jailcreate: