2013-12-16 21:21:32 +01:00
|
|
|
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.command.Command;
|
|
|
|
import com.graywolf336.jail.command.CommandInfo;
|
|
|
|
|
|
|
|
@CommandInfo(
|
|
|
|
maxArgs = -1,
|
|
|
|
minimumArgs = 1,
|
|
|
|
needsPlayer = false,
|
|
|
|
pattern = "jail|j",
|
|
|
|
permission = "jail.command.jail",
|
2013-12-16 22:51:25 +01:00
|
|
|
usage = "/jail [p:name] (t:time) (j:Jail name) (c:Cell name) (m:Muted) (r:Reason)"
|
2013-12-16 21:21:32 +01:00
|
|
|
)
|
|
|
|
public class JailCommand implements Command {
|
|
|
|
|
|
|
|
public boolean execute(JailManager jm, CommandSender sender, String... args) {
|
2013-12-16 21:32:06 +01:00
|
|
|
String player = "", jail = "", cell = "", reason = "";
|
|
|
|
int time = 30;
|
|
|
|
boolean muted = false;
|
|
|
|
|
|
|
|
for(String s : args) {
|
|
|
|
if(s.startsWith("p:")) {
|
|
|
|
player = s.substring(2);
|
|
|
|
}else if(s.startsWith("t:")) {
|
2013-12-16 22:51:25 +01:00
|
|
|
time = Integer.parseInt(s.substring(2));
|
2013-12-16 21:32:06 +01:00
|
|
|
}else if(s.startsWith("j:")) {
|
|
|
|
jail = s.substring(2);
|
|
|
|
}else if(s.startsWith("c:")) {
|
|
|
|
cell = s.substring(2);
|
|
|
|
}else if(s.startsWith("m:")) {
|
|
|
|
muted = Boolean.parseBoolean(s.substring(2));
|
|
|
|
}else if(s.startsWith("r:")) {
|
|
|
|
reason = s.substring(2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Player p = jm.getPlugin().getServer().getPlayer(player);
|
2013-12-16 21:21:32 +01:00
|
|
|
|
|
|
|
//Player is not online
|
|
|
|
if(p == null) {
|
2013-12-16 22:51:25 +01:00
|
|
|
sender.sendMessage(player + " is offline and will be jailed for " + time + " minutes in the jail " + jail + " and will be muted: " + muted + ".");
|
2013-12-16 21:21:32 +01:00
|
|
|
}else {
|
|
|
|
//Player *is* online
|
2013-12-16 22:51:25 +01:00
|
|
|
sender.sendMessage(player + " is offline and will be jailed for " + time + " minutes in the jail " + jail + " and will be muted: " + muted + ".");
|
2013-12-16 21:21:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|