package net.mcbat.LightningEvent.Commands; import net.mcbat.LightningEvent.LightningEvent; import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; public class SubcommandFake { private final LightningEvent _plugin; private final CommandCast _command; public SubcommandFake(LightningEvent plugin, CommandCast command) { _plugin = plugin; _command = command; } public boolean onConsoleCommand(CommandSender sender, Command command, String label, String[] args) { switch (args.length) { case 5: if (_command.checkWorld(args[1]) && _command.checkLocation(args[2], args[3], args[4])) _plugin.castFakeLightningAtLocation(new Location(_plugin.getServer().getWorld(args[1]), Integer.parseInt(args[2]), Integer.parseInt(args[3]), Integer.parseInt(args[4]))); else commandUsage(sender, label, false); break; case 2: if (_command.checkPlayer(args[1])) _plugin.castFakeLightningAtLocation(_plugin.getServer().getPlayer(args[1]).getLocation()); else commandUsage(sender, label, false); break; default: commandUsage(sender, label, false); break; } return true; } public boolean onPlayerCommand(CommandSender sender, Command command, String label, String[] args) { switch (args.length) { case 5: if (_command.checkWorld(args[1]) && _command.checkLocation(args[2], args[3], args[4])) _plugin.castFakeLightningAtLocation(new Location(_plugin.getServer().getWorld(args[1]), Integer.parseInt(args[2]), Integer.parseInt(args[3]), Integer.parseInt(args[4]))); else commandUsage(sender, label, true); break; case 4: if (_command.checkLocation(args[1], args[2], args[3])) _plugin.castFakeLightningAtLocation(new Location(((Player) sender).getWorld(), Integer.parseInt(args[1]), Integer.parseInt(args[2]), Integer.parseInt(args[3]))); else commandUsage(sender, label, true); break; case 2: if (_command.checkPlayer(args[1])) _plugin.castFakeLightningAtLocation(_plugin.getServer().getPlayer(args[1]).getLocation()); else commandUsage(sender, label, true); break; case 1: _plugin.castFakeLightningAtLocation(((Player) sender).getTargetBlock(null, 600).getLocation()); break; default: commandUsage(sender, label, true); break; } return true; } private void commandUsage(CommandSender sender, String label, boolean isPlayer) { if (!isPlayer) { sender.sendMessage(ChatColor.RED+"[==== "+ChatColor.GREEN+"/"+label+" fake"+ChatColor.RED+" ====]"); sender.sendMessage(ChatColor.GREEN+"/"+label+" fake "+ChatColor.LIGHT_PURPLE+" "+ChatColor.GREEN+" - "+ChatColor.WHITE+"Casts a fake lightning bolt."); sender.sendMessage(ChatColor.GREEN+"/"+label+" fake "+ChatColor.LIGHT_PURPLE+""+ChatColor.GREEN+" - "+ChatColor.WHITE+"Casts a fake lightning bolt on a player."); } else { sender.sendMessage(ChatColor.RED+"[==== "+ChatColor.GREEN+"/"+label+" fake"+ChatColor.RED+" ====]"); sender.sendMessage(ChatColor.GREEN+"/"+label+" fake "+ChatColor.LIGHT_PURPLE+" "+ChatColor.GREEN+" - "+ChatColor.WHITE+"Casts a fake lightning bolt in the specified world and location."); sender.sendMessage(ChatColor.GREEN+"/"+label+" fake "+ChatColor.LIGHT_PURPLE+" "+ChatColor.GREEN+" - "+ChatColor.WHITE+"Casts a fake lightning bolt in the current world at the specified location."); sender.sendMessage(ChatColor.GREEN+"/"+label+" fake "+ChatColor.LIGHT_PURPLE+""+ChatColor.GREEN+" - "+ChatColor.WHITE+"Casts a fake lightning bolt on a player."); sender.sendMessage(ChatColor.GREEN+"/"+label+" fake "+ChatColor.GREEN+" - "+ChatColor.WHITE+"Casts a fake lightning bolt where you are looking."); } } }