Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void command(String command) {
- try {
- if (etc.getInstance().isLogging())
- log.info("Command used by " + getName() + " " + command);
- String[] split = command.split(" ");
- String cmd = split[0];
- if ((Boolean) etc.getLoader().callHook(PluginLoader.Hook.COMMAND, new Object[] { this, split }))
- return; // No need to go on, commands were parsed.
- if (!canUseCommand(cmd) && !cmd.startsWith("/#")) {
- if (etc.getInstance().showUnknownCommand())
- sendMessage(Colors.Rose + "Unknown command.");
- return;
- }
- // Remove '/' before checking.
- if (ServerConsoleCommands.parseServerConsoleCommand(this, cmd.substring(1), split)) {
- // Command parsed successfully...
- } else if (PlayerCommands.parseCommand(this, cmd, split)){/*else if (cmd.equalsIgnoreCase("/help")) {
- // Meh, not the greatest way, but not the worst either.
- List<String> availableCommands = new ArrayList<String>();
- for (Entry<String, String> entry : etc.getInstance().getCommands().entrySet())
- if (canUseCommand(entry.getKey())) {
- if (entry.getKey().equals("/kit") && !etc.getDataSource().hasKits())
- continue;
- if (entry.getKey().equals("/listwarps") && !etc.getDataSource().hasWarps())
- continue;
- availableCommands.add(entry.getKey() + " " + entry.getValue());
- }
- sendMessage(Colors.Blue + "Available commands (Page " + (split.length == 2 ? split[1] : "1") + " of " + (int) Math.ceil((double) availableCommands.size() / (double) 7) + ") [] = required <> = optional:");
- if (split.length == 2)
- try {
- int amount = Integer.parseInt(split[1]);
- if (amount > 0)
- amount = (amount - 1) * 7;
- else
- amount = 0;
- for (int i = amount; i < amount + 7; i++)
- if (availableCommands.size() > i)
- sendMessage(Colors.Rose + availableCommands.get(i));
- } catch (NumberFormatException ex) {
- sendMessage(Colors.Rose + "Not a valid page number.");
- }
- else
- for (int i = 0; i < 7; i++)
- if (availableCommands.size() > i)
- sendMessage(Colors.Rose + availableCommands.get(i));
- } else if (cmd.equalsIgnoreCase("/mute")) {
- if (split.length != 2) {
- sendMessage(Colors.Rose + "Correct usage is: /mute [player]");
- return;
- }
- Player player = etc.getServer().matchPlayer(split[1]);
- if (player != null) {
- if (player.toggleMute())
- sendMessage(Colors.Rose + "player was muted");
- else
- sendMessage(Colors.Rose + "player was unmuted");
- } else
- sendMessage(Colors.Rose + "Can't find player " + split[1]);
- } else if ((cmd.equalsIgnoreCase("/msg") || cmd.equalsIgnoreCase("/tell")) || cmd.equalsIgnoreCase("/m")) {
- if (split.length < 3) {
- sendMessage(Colors.Rose + "Correct usage is: /msg [player] [message]");
- return;
- }
- if (isMuted()) {
- sendMessage(Colors.Rose + "You are currently muted.");
- return;
- }
- Player player = etc.getServer().matchPlayer(split[1]);
- if (player != null) {
- if (player.getName().equals(getName())) {
- sendMessage(Colors.Rose + "You can't message yourself!");
- return;
- }
- player.sendMessage("(MSG) " + getColor() + "<" + getName() + "> " + Colors.White + etc.combineSplit(2, split, " "));
- sendMessage("(MSG) " + getColor() + "<" + getName() + "> " + Colors.White + etc.combineSplit(2, split, " "));
- } else
- sendMessage(Colors.Rose + "Couldn't find player " + split[1]);
- } else if (cmd.equalsIgnoreCase("/kit") && etc.getDataSource().hasKits()) {
- if (split.length != 2 && split.length != 3) {
- sendMessage(Colors.Rose + "Available kits" + Colors.White + ": " + etc.getDataSource().getKitNames(this));
- return;
- }
- Player toGive = this;
- if (split.length > 2 && canIgnoreRestrictions())
- toGive = etc.getServer().matchPlayer(split[2]);
- Kit kit = etc.getDataSource().getKit(split[1]);
- if (toGive != null) {
- if (kit != null) {
- if (!isInGroup(kit.Group) && !kit.Group.equals(""))
- sendMessage(Colors.Rose + "That kit does not exist.");
- else if (onlyOneUseKits.contains(kit.Name))
- sendMessage(Colors.Rose + "You can only get this kit once per login.");
- else if (MinecraftServer.b.containsKey(getName() + " " + kit.Name))
- sendMessage(Colors.Rose + "You can't get this kit again for a while.");
- else {
- if (!canIgnoreRestrictions())
- if (kit.Delay >= 0)
- MinecraftServer.b.put(getName() + " " + kit.Name, kit.Delay);
- else
- onlyOneUseKits.add(kit.Name);
- log.info(getName() + " got a kit!");
- toGive.sendMessage(Colors.Rose + "Enjoy this kit!");
- for (Map.Entry<String, Integer> entry : kit.IDs.entrySet())
- try {
- int itemId = 0;
- try {
- itemId = Integer.parseInt(entry.getKey());
- } catch (NumberFormatException n) {
- itemId = etc.getDataSource().getItem(entry.getKey());
- }
- toGive.giveItem(itemId, kit.IDs.get(entry.getKey()));
- } catch (Exception e1) {
- log.info("Got an exception while giving out a kit (Kit name \"" + kit.Name + "\"). Are you sure all the Ids are numbers?");
- sendMessage(Colors.Rose + "The server encountered a problem while giving the kit :(");
- }
- }
- } else
- sendMessage(Colors.Rose + "That kit does not exist.");
- } else
- sendMessage(Colors.Rose + "That user does not exist.");
- } else if (cmd.equalsIgnoreCase("/tp")) {
- if (split.length < 2) {
- sendMessage(Colors.Rose + "Correct usage is: /tp [player]");
- return;
- }
- Player player = etc.getServer().matchPlayer(split[1]);
- if (player != null) {
- if (getName().equalsIgnoreCase(player.getName())) {
- sendMessage(Colors.Rose + "You're already here!");
- return;
- }
- log.info(getName() + " teleported to " + player.getName());
- teleportTo(player);
- } else
- sendMessage(Colors.Rose + "Can't find user " + split[1] + ".");
- } else if ((cmd.equalsIgnoreCase("/tphere") || cmd.equalsIgnoreCase("/s"))) {
- if (split.length < 2) {
- sendMessage(Colors.Rose + "Correct usage is: /tphere [player]");
- return;
- }
- Player player = etc.getServer().matchPlayer(split[1]);
- if (player != null) {
- if (getName().equalsIgnoreCase(player.getName())) {
- sendMessage(Colors.Rose + "Wow look at that! You teleported yourself to yourself!");
- return;
- }
- log.info(getName() + " teleported " + player.getName() + " to their self.");
- player.teleportTo(this);
- } else
- sendMessage(Colors.Rose + "Can't find user " + split[1] + ".");
- } else if (cmd.equalsIgnoreCase("/playerlist") || cmd.equalsIgnoreCase("/who"))
- sendMessage(Colors.Rose + "Player list (" + etc.getMCServer().f.b.size() + "/" + etc.getInstance().getPlayerLimit() + "): " + Colors.White + etc.getMCServer().f.c());
- else if (cmd.equalsIgnoreCase("/item") || cmd.equalsIgnoreCase("/i") || cmd.equalsIgnoreCase("/give")) {
- if (split.length < 2) {
- if (canIgnoreRestrictions())
- sendMessage(Colors.Rose + "Correct usage is: /item [itemid] <amount> <damage> <player> (optional)");
- else
- sendMessage(Colors.Rose + "Correct usage is: /item [itemid] <amount> <damage>");
- return;
- }
- Player toGive = this;
- int itemId = 0, amount = 1, damage = 0;
- try {
- if (split.length > 1)
- try {
- itemId = Integer.parseInt(split[1]);
- } catch (NumberFormatException n) {
- itemId = etc.getDataSource().getItem(split[1]);
- }
- if (split.length > 2) {
- amount = Integer.parseInt(split[2]);
- if (amount <= 0 && !isAdmin())
- amount = 1;
- if (amount > 64 && !canIgnoreRestrictions())
- amount = 64;
- if (amount > 1024)
- amount = 1024; // 16 stacks worth. More than enough.
- }
- if (split.length == 4) {
- int temp = -1;
- try {
- temp = Integer.parseInt(split[3]);
- } catch (NumberFormatException n) {
- if (canIgnoreRestrictions())
- toGive = etc.getServer().matchPlayer(split[3]);
- }
- if (temp > -1 && temp < 50)
- damage = temp;
- } else if (split.length == 5) {
- damage = Integer.parseInt(split[3]);
- if (damage < 0 && damage > 49)
- damage = 0;
- if (canIgnoreRestrictions())
- toGive = etc.getServer().matchPlayer(split[4]);
- }
- } catch (NumberFormatException localNumberFormatException) {
- sendMessage(Colors.Rose + "Improper ID and/or amount.");
- return;
- }
- if (toGive != null) {
- boolean allowedItem = etc.getInstance().getAllowedItems().isEmpty() || etc.getInstance().getAllowedItems().contains(itemId);
- if (!etc.getInstance().getDisallowedItems().isEmpty() && etc.getInstance().getDisallowedItems().contains(itemId))
- allowedItem = false;
- if (Item.isValidItem(itemId)) {
- if (allowedItem || canIgnoreRestrictions()) {
- Item i = new Item(itemId, amount, -1, damage);
- log.log(Level.INFO, "Giving " + toGive.getName() + " some " + i.toString());
- // toGive.giveItem(itemId, amount);
- Inventory inv = toGive.getInventory();
- ArrayList<Item> list = new ArrayList<Item>();
- for (Item it : inv.getContents())
- if (it != null && it.getItemId() == i.getItemId() && it.getDamage() == i.getDamage())
- list.add(it);
- for (Item it : list) {
- if (it.getAmount() < 64) {
- if (amount >= 64 - it.getAmount()) {
- amount -= 64 - it.getAmount();
- it.setAmount(64);
- toGive.giveItem(it);
- } else {
- it.setAmount(it.getAmount() + amount);
- amount = 0;
- toGive.giveItem(it);
- }
- }
- }
- if (amount != 0) {
- i.setAmount(64);
- while (amount > 64) {
- amount -= 64;
- toGive.giveItem(i);
- i.setSlot(-1);
- }
- i.setAmount(amount);
- toGive.giveItem(i);
- }
- if (toGive.getName().equalsIgnoreCase(getName()))
- sendMessage(Colors.Rose + "There you go " + getName() + ".");
- else {
- sendMessage(Colors.Rose + "Gift given! :D");
- toGive.sendMessage(Colors.Rose + "Enjoy your gift! :D");
- }
- } else if (!allowedItem && !canIgnoreRestrictions())
- sendMessage(Colors.Rose + "You are not allowed to spawn that item.");
- } else
- sendMessage(Colors.Rose + "No item with ID " + split[1]);
- } else
- sendMessage(Colors.Rose + "Can't find user " + split[3]);
- } else if (cmd.equalsIgnoreCase("/cloth") || cmd.equalsIgnoreCase("/dye")) {
- if (split.length < 3) {
- sendMessage(Colors.Rose + "Correct usage is: " + cmd + " [amount] [color]");
- return;
- }
- try {
- int amount = Integer.parseInt(split[1]);
- if (amount <= 0 && !isAdmin())
- amount = 1;
- if (amount > 64 && !canIgnoreRestrictions())
- amount = 64;
- if (amount > 1024)
- amount = 1024; // 16 stacks worth. More than enough.
- String color = split[2];
- if (split.length > 3)
- color += " " + split[3];
- Cloth.Color c = Cloth.Color.getColor(color.toLowerCase());
- if (c == null) {
- sendMessage(Colors.Rose + "Invalid color name!");
- return;
- }
- Item i = c.getItem();
- if (cmd.equalsIgnoreCase("/dye")) {
- i.setType(Item.Type.InkSack);
- // some1 had fun inverting this i guess .....
- i.setDamage(15 - i.getDamage());
- }
- i.setAmount(amount);
- log.log(Level.INFO, "Giving " + getName() + " some " + i.toString());
- Inventory inv = getInventory();
- ArrayList<Item> list = new ArrayList<Item>();
- for (Item it : inv.getContents())
- if (it != null && it.getItemId() == i.getItemId() && it.getDamage() == i.getDamage())
- list.add(it);
- for (Item it : list) {
- if (it.getAmount() < 64) {
- if (amount >= 64 - it.getAmount()) {
- amount -= 64 - it.getAmount();
- it.setAmount(64);
- giveItem(it);
- } else {
- it.setAmount(it.getAmount() + amount);
- amount = 0;
- giveItem(it);
- }
- }
- }
- if (amount != 0) {
- i.setAmount(64);
- while (amount > 64) {
- amount -= 64;
- giveItem(i);
- i.setSlot(-1);
- }
- i.setAmount(amount);
- giveItem(i);
- }
- sendMessage(Colors.Rose + "There you go " + getName() + ".");
- } catch (NumberFormatException localNumberFormatException) {
- sendMessage(Colors.Rose + "Improper ID and/or amount.");
- }
- } else if (cmd.equalsIgnoreCase("/tempban")) {
- // /tempban MINUTES HOURS DAYS
- if (split.length == 1)
- return;
- int minutes = 0, hours = 0, days = 0;
- if (split.length >= 2)
- minutes = Integer.parseInt(split[1]);
- if (split.length >= 3)
- hours = Integer.parseInt(split[2]);
- if (split.length >= 4)
- days = Integer.parseInt(split[3]);
- Date date = new Date();
- // date.
- } else if (cmd.equalsIgnoreCase("/banlist")) {
- byte type = 0;
- if (split.length == 2)
- if (split[1].equalsIgnoreCase("ips"))
- type = 1;
- if (type == 0)
- sendMessage(Colors.Blue + "Ban list:" + Colors.White + " " + etc.getMCServer().f.getBans());
- else
- sendMessage(Colors.Blue + "IP Ban list:" + Colors.White + " " + etc.getMCServer().f.getIpBans());
- } else if (cmd.equalsIgnoreCase("/banip")) {
- if (split.length < 2) {
- sendMessage(Colors.Rose + "Correct usage is: /banip [player] <reason> (optional) NOTE: this permabans IPs.");
- return;
- }
- Player player = etc.getServer().matchPlayer(split[1]);
- if (player != null) {
- if (!hasControlOver(player)) {
- sendMessage(Colors.Rose + "You can't ban that user.");
- return;
- }
- // adds player to ban list
- etc.getMCServer().f.c(player.getIP());
- etc.getLoader().callHook(PluginLoader.Hook.IPBAN, new Object[] { this, player, split.length >= 3 ? etc.combineSplit(2, split, " ") : "" });
- log.log(Level.INFO, "IP Banning " + player.getName() + " (IP: " + player.getIP() + ")");
- sendMessage(Colors.Rose + "IP Banning " + player.getName() + " (IP: " + player.getIP() + ")");
- if (split.length > 2)
- player.kick("IP Banned by " + getName() + ": " + etc.combineSplit(2, split, " "));
- else
- player.kick("IP Banned by " + getName() + ".");
- } else
- sendMessage(Colors.Rose + "Can't find user " + split[1] + ".");
- } else if (cmd.equalsIgnoreCase("/ban")) {
- if (split.length < 2) {
- sendMessage(Colors.Rose + "Correct usage is: /ban [player] <reason> (optional)");
- return;
- }
- Player player = etc.getServer().matchPlayer(split[1]);
- if (player != null) {
- if (!hasControlOver(player)) {
- sendMessage(Colors.Rose + "You can't ban that user.");
- return;
- }
- // adds player to ban list
- etc.getServer().ban(player.getName());
- etc.getLoader().callHook(PluginLoader.Hook.BAN, new Object[] { this, player, split.length >= 3 ? etc.combineSplit(2, split, " ") : "" });
- if (split.length > 2)
- player.kick("Banned by " + getName() + ": " + etc.combineSplit(2, split, " "));
- else
- player.kick("Banned by " + getName() + ".");
- log.log(Level.INFO, "Banning " + player.getName());
- sendMessage(Colors.Rose + "Banning " + player.getName());
- } else {
- // sendMessage(Colors.Rose + "Can't find user " + split[1] +
- // ".");
- etc.getServer().ban(split[1]);
- log.log(Level.INFO, "Banning " + split[1]);
- sendMessage(Colors.Rose + "Banning " + split[1]);
- }
- } else if (cmd.equalsIgnoreCase("/unban")) {
- if (split.length != 2) {
- sendMessage(Colors.Rose + "Correct usage is: /unban [player]");
- return;
- }
- etc.getServer().unban(split[1]);
- sendMessage(Colors.Rose + "Unbanned " + split[1]);
- } else if (cmd.equalsIgnoreCase("/unbanip")) {
- if (split.length != 2) {
- sendMessage(Colors.Rose + "Correct usage is: /unbanip [ip]");
- return;
- }
- etc.getMCServer().f.d(split[1]);
- sendMessage(Colors.Rose + "Unbanned " + split[1]);
- } else if (cmd.equalsIgnoreCase("/kick")) {
- if (split.length < 2) {
- sendMessage(Colors.Rose + "Correct usage is: /kick [player] <reason> (optional)");
- return;
- }
- Player player = etc.getServer().matchPlayer(split[1]);
- if (player != null) {
- if (!hasControlOver(player)) {
- sendMessage(Colors.Rose + "You can't kick that user.");
- return;
- }
- etc.getLoader().callHook(PluginLoader.Hook.KICK, new Object[] { this, player, split.length >= 3 ? etc.combineSplit(2, split, " ") : "" });
- if (split.length > 2)
- player.kick("Kicked by " + getName() + ": " + etc.combineSplit(2, split, " "));
- else
- player.kick("Kicked by " + getName() + ".");
- log.log(Level.INFO, "Kicking " + player.getName());
- sendMessage(Colors.Rose + "Kicking " + player.getName());
- } else
- sendMessage(Colors.Rose + "Can't find user " + split[1] + ".");
- } else if (cmd.equalsIgnoreCase("/me")) {
- if (isMuted()) {
- sendMessage(Colors.Rose + "You are currently muted.");
- return;
- }
- if (split.length == 1)
- return;
- String paramString2 = "* " + getColor() + getName() + Colors.White + " " + command.substring(command.indexOf(" ")).trim();
- log.info("* " + getName() + " " + command.substring(command.indexOf(" ")).trim());
- etc.getServer().messageAll(paramString2);
- } else if (cmd.equalsIgnoreCase("/sethome")) {
- // player.k, player.l, player.m
- // x, y, z
- Warp home = new Warp();
- home.Location = getLocation();
- home.Group = ""; // no group neccessary, lol.
- home.Name = getName();
- etc.getInstance().changeHome(home);
- sendMessage(Colors.Rose + "Your home has been set.");
- } else if (cmd.equalsIgnoreCase("/spawn"))
- teleportTo(etc.getServer().getSpawnLocation());
- else if (cmd.equalsIgnoreCase("/setspawn")) {
- // New system in beta 1.3: WorldInfo.
- OWorldInfo info = etc.getMCServer().e.s;
- info.a((int) getX(), info.d(), (int) getZ());
- log.info("Spawn position changed.");
- sendMessage(Colors.Rose + "You have set the spawn to your current position.");
- } else if (cmd.equalsIgnoreCase("/home")) {
- Warp home = null;
- if (split.length > 1 && isAdmin())
- home = etc.getDataSource().getHome(split[1]);
- else
- home = etc.getDataSource().getHome(getName());
- if (home != null)
- teleportTo(home.Location);
- else if (split.length > 1 && isAdmin())
- sendMessage(Colors.Rose + "That player home does not exist");
- else
- teleportTo(etc.getServer().getSpawnLocation());
- } else if (cmd.equalsIgnoreCase("/warp")) {
- if (split.length < 2) {
- sendMessage(Colors.Rose + "Correct usage is: /warp [warpname]");
- return;
- }
- Player toWarp = this;
- Warp warp = null;
- if (split.length == 3 && canIgnoreRestrictions()) {
- warp = etc.getDataSource().getWarp(split[1]);
- toWarp = etc.getServer().matchPlayer(split[2]);
- } else
- warp = etc.getDataSource().getWarp(split[1]);
- if (toWarp != null) {
- if (warp != null) {
- if (!isInGroup(warp.Group) && !warp.Group.equals(""))
- sendMessage(Colors.Rose + "Warp not found.");
- else {
- toWarp.teleportTo(warp.Location);
- toWarp.sendMessage(Colors.Rose + "Woosh!");
- }
- } else
- sendMessage(Colors.Rose + "Warp not found");
- } else
- sendMessage(Colors.Rose + "Player not found.");
- } else if (cmd.equalsIgnoreCase("/listwarps") && etc.getDataSource().hasWarps()) {
- if (split.length != 2 && split.length != 3) {
- sendMessage(Colors.Rose + "Available warps: " + Colors.White + etc.getDataSource().getWarpNames(this));
- return;
- }
- } else if (cmd.equalsIgnoreCase("/setwarp")) {
- if (split.length < 2) {
- if (canIgnoreRestrictions())
- sendMessage(Colors.Rose + "Correct usage is: /setwarp [warpname] [group]");
- else
- sendMessage(Colors.Rose + "Correct usage is: /setwarp [warpname]");
- return;
- }
- if (split[1].contains(":")) {
- sendMessage("You can't set a warp with \":\" in its name");
- return;
- }
- Warp warp = new Warp();
- warp.Name = split[1];
- warp.Location = getLocation();
- if (split.length == 3)
- warp.Group = split[2];
- else
- warp.Group = "";
- etc.getInstance().setWarp(warp);
- sendMessage(Colors.Rose + "Created warp point " + split[1] + ".");
- } else if (cmd.equalsIgnoreCase("/removewarp")) {
- if (split.length < 2) {
- sendMessage(Colors.Rose + "Correct usage is: /removewarp [warpname]");
- return;
- }
- Warp warp = etc.getDataSource().getWarp(split[1]);
- if (warp != null) {
- etc.getDataSource().removeWarp(warp);
- sendMessage(Colors.Blue + "Warp removed.");
- } else
- sendMessage(Colors.Rose + "That warp does not exist");
- } else if (cmd.equalsIgnoreCase("/lighter")) {
- if (MinecraftServer.b.containsKey(getName() + " lighter")) {
- log.info(getName() + " failed to iron!");
- sendMessage(Colors.Rose + "You can't create another lighter again so soon");
- } else {
- if (!canIgnoreRestrictions())
- MinecraftServer.b.put(getName() + " lighter", Integer.valueOf(6000));
- log.info(getName() + " created a lighter!");
- giveItem(259, 1);
- }
- } else if ((command.startsWith("/#")) && (etc.getMCServer().f.h(getName()))) {
- String str = command.substring(2);
- log.info(getName() + " issued server command: " + str);
- etc.getMCServer().a(str, getEntity().a);
- } else if (cmd.equalsIgnoreCase("/time")) {
- if (split.length == 2) {
- if (split[1].equalsIgnoreCase("day"))
- etc.getServer().setRelativeTime(0);
- else if (split[1].equalsIgnoreCase("night"))
- etc.getServer().setRelativeTime(13000);
- else if (split[1].equalsIgnoreCase("check"))
- sendMessage(Colors.Rose + "The time is " + etc.getServer().getRelativeTime() + "! (RAW: " + etc.getServer().getTime() + ")");
- else
- try {
- etc.getServer().setRelativeTime(Long.parseLong(split[1]));
- } catch (NumberFormatException ex) {
- sendMessage(Colors.Rose + "Please enter numbers, not letters.");
- }
- } else if (split.length == 3) {
- if (split[1].equalsIgnoreCase("raw"))
- try {
- etc.getServer().setTime(Long.parseLong(split[2]));
- } catch (NumberFormatException ex) {
- sendMessage(Colors.Rose + "Please enter numbers, not letters.");
- }
- } else {
- sendMessage(Colors.Rose + "Correct usage is: /time [time|'day|night|check|raw'] (rawtime)");
- return;
- }
- } else if (cmd.equalsIgnoreCase("/getpos")) {
- sendMessage("Pos X: " + getX() + " Y: " + getY() + " Z: " + getZ());
- sendMessage("Rotation: " + getRotation() + " Pitch: " + getPitch());
- double degreeRotation = ((getRotation() - 90) % 360);
- if (degreeRotation < 0)
- degreeRotation += 360.0;
- sendMessage("Compass: " + etc.getCompassPointForDirection(degreeRotation) + " (" + (Math.round(degreeRotation * 10) / 10.0) + ")");
- } else if (cmd.equalsIgnoreCase("/compass")) {
- double degreeRotation = ((getRotation() - 90) % 360);
- if (degreeRotation < 0)
- degreeRotation += 360.0;
- sendMessage(Colors.Rose + "Compass: " + etc.getCompassPointForDirection(degreeRotation));
- } else if (cmd.equalsIgnoreCase("/motd"))
- for (String str : etc.getInstance().getMotd())
- sendMessage(str);
- else if (cmd.equalsIgnoreCase("/spawnmob")) {
- if (split.length == 1) {
- sendMessage(Colors.Rose + "Correct usage is: /spawnmob [name] <amount>");
- return;
- }
- if (!Mob.isValid(split[1])) {
- sendMessage(Colors.Rose + "Invalid mob. Name has to start with a capital like so: Pig");
- return;
- }
- if (split.length == 2) {
- Mob mob = new Mob(split[1], getLocation());
- mob.spawn();
- } else if (split.length == 3)
- try {
- int mobnumber = Integer.parseInt(split[2]);
- for (int i = 0; i < mobnumber; i++) {
- Mob mob = new Mob(split[1], getLocation());
- mob.spawn();
- }
- } catch (NumberFormatException nfe) {
- if (!Mob.isValid(split[2])) {
- sendMessage(Colors.Rose + "Invalid mob name or number of mobs.");
- sendMessage(Colors.Rose + "Mob names have to start with a capital like so: Pig");
- } else {
- Mob mob = new Mob(split[1], getLocation());
- mob.spawn(new Mob(split[2]));
- }
- }
- else if (split.length == 4)
- try {
- int mobnumber = Integer.parseInt(split[3]);
- if (!Mob.isValid(split[2]))
- sendMessage(Colors.Rose + "Invalid rider. Name has to start with a capital like so: Pig");
- else
- for (int i = 0; i < mobnumber; i++) {
- Mob mob = new Mob(split[1], getLocation());
- mob.spawn(new Mob(split[2]));
- }
- } catch (NumberFormatException nfe) {
- sendMessage(Colors.Rose + "Invalid number of mobs.");
- }
- } else if (cmd.equalsIgnoreCase("/clearinventory")) {
- Player target = this;
- if (split.length >= 2 && isAdmin())
- target = etc.getServer().matchPlayer(split[1]);
- if (target != null) {
- Inventory inv = target.getInventory();
- inv.clearContents();
- inv.update();
- if (!target.getName().equals(getName()))
- sendMessage(Colors.Rose + "Cleared " + target.getName() + "'s inventory.");
- } else
- sendMessage(Colors.Rose + "Target not found");
- } else if (cmd.equals("/mspawn")) {
- if (split.length != 2) {
- sendMessage(Colors.Rose + "You must specify what to change the mob spawner to.");
- return;
- }
- if (!Mob.isValid(split[1])) {
- sendMessage(Colors.Rose + "Invalid mob specified.");
- return;
- }
- HitBlox hb = new HitBlox(this);
- Block block = hb.getTargetBlock();
- if (block.getType() == 52) { // mob spawner
- MobSpawner ms = (MobSpawner) etc.getServer().getComplexBlock(block.getX(), block.getY(), block.getZ());
- if (ms != null)
- ms.setSpawn(split[1]);
- } else
- sendMessage(Colors.Rose + "You are not targeting a mob spawner.");
- } else if (cmd.equals("/update")){
- if (Main.onlineVersion == etc.getInstance().getVersion())
- sendMessage(Colors.Rose + "You have the latest version of Canary.");
- else
- sendMessage(Colors.Rose + "You need to update your version of Canary.");
- } else {
- log.info(getName() + " tried command " + command);
- if (etc.getInstance().showUnknownCommand())
- sendMessage(Colors.Rose + "Unknown command");*/
- }
- } catch (Throwable ex) { // Might as well try and catch big exceptions
- // before the server crashes from a stack
- // overflow or something
- log.log(Level.SEVERE, "Exception in command handler (Report this on github unless you did something dumb like enter letters as numbers):", ex);
- if (isAdmin())
- sendMessage(Colors.Rose + "Exception occured. Check the server for more info.");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment