mirror of
https://github.com/kaboomserver/icontrolu.git
synced 2024-11-28 10:25:33 -05:00
Split command into smaller methods
This commit is contained in:
parent
aa8e5bb70e
commit
f3abebe888
1 changed files with 77 additions and 66 deletions
|
@ -17,16 +17,7 @@ import pw.kaboom.icontrolu.Main;
|
|||
import pw.kaboom.icontrolu.utilities.PlayerList;
|
||||
|
||||
public final class CommandIcu implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(final CommandSender sender, final Command command, final String label, final String[] args) {
|
||||
if (sender instanceof ConsoleCommandSender) {
|
||||
sender.sendMessage("Command has to be run by a player");
|
||||
} else {
|
||||
final Player controller = (Player) sender;
|
||||
|
||||
if (args.length == 0) {
|
||||
controller.sendMessage(ChatColor.RED + "Usage: /" + label + " <control|stop>");
|
||||
} else if (args[0].equalsIgnoreCase("control")) {
|
||||
private void controlCommand(final Player controller, final String label, final String[] args) {
|
||||
if (args.length == 1) {
|
||||
controller.sendMessage(ChatColor.RED + "Usage: /" + label + " control <player>");
|
||||
} else {
|
||||
|
@ -57,7 +48,9 @@ public final class CommandIcu implements CommandExecutor {
|
|||
controller.sendMessage("Player \"" + args[1] + "\" not found");
|
||||
}
|
||||
}
|
||||
} else if (args[0].equalsIgnoreCase("stop")) {
|
||||
}
|
||||
|
||||
private void stopCommand(final Player controller) {
|
||||
final Player target = PlayerList.getTarget(controller.getUniqueId());
|
||||
|
||||
if (target != null) {
|
||||
|
@ -84,11 +77,29 @@ public final class CommandIcu implements CommandExecutor {
|
|||
}
|
||||
}.runTaskLater(JavaPlugin.getPlugin(Main.class), tickDelay);
|
||||
|
||||
controller.sendMessage("You are no longer controlling \"" + target.getName() + "\". You are invisible for 10 seconds.");
|
||||
final int seconds = tickDelay / 20;
|
||||
|
||||
controller.sendMessage("You are no longer controlling \"" + target.getName() + "\". You are invisible for " + seconds + " seconds.");
|
||||
} else {
|
||||
controller.sendMessage("You are not controlling anyone at the moment");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final CommandSender sender, final Command command, final String label, final String[] args) {
|
||||
if (sender instanceof ConsoleCommandSender) {
|
||||
sender.sendMessage("Command has to be run by a player");
|
||||
return true;
|
||||
}
|
||||
|
||||
final Player controller = (Player) sender;
|
||||
|
||||
if (args.length == 0) {
|
||||
controller.sendMessage(ChatColor.RED + "Usage: /" + label + " <control|stop>");
|
||||
} else if (args[0].equalsIgnoreCase("control")) {
|
||||
controlCommand(controller, label, args);
|
||||
} else if (args[0].equalsIgnoreCase("stop")) {
|
||||
stopCommand(controller);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue