mirror of
https://github.com/kaboomserver/icontrolu.git
synced 2024-06-03 02:41:24 +00:00
Better command handling in console
This commit is contained in:
parent
e99aef29d0
commit
b3fea2f1e8
|
@ -6,6 +6,7 @@ import org.bukkit.ChatColor;
|
|||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
@ -21,7 +22,11 @@ class CommandIcu implements CommandExecutor {
|
|||
}
|
||||
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (sender instanceof ConsoleCommandSender) {
|
||||
sender.sendMessage("Command has to be run by a player");
|
||||
} else {
|
||||
Player controller = (Player) sender;
|
||||
|
||||
if (args.length == 0) {
|
||||
controller.sendMessage(ChatColor.RED + "Usage: /" + label + " <control|stop>");
|
||||
} else if (args[0].equalsIgnoreCase("control")) {
|
||||
|
@ -56,6 +61,7 @@ class CommandIcu implements CommandExecutor {
|
|||
}
|
||||
} else if (args[0].equalsIgnoreCase("stop")) {
|
||||
Player target = main.targetFor.get(controller.getUniqueId());
|
||||
|
||||
if (target != null) {
|
||||
main.targetFor.remove(controller.getUniqueId());
|
||||
main.controllerFor.remove(target.getUniqueId());
|
||||
|
@ -84,6 +90,7 @@ class CommandIcu implements CommandExecutor {
|
|||
controller.sendMessage("You are not controlling anyone at the moment");
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue