Package com.sijobe.spc.wrapper

Examples of com.sijobe.spc.wrapper.CommandException


                  FontColour.WHITE + " for more information.");
         sender.sendMessageToPlayer(MESSAGE_FOOTER);
      } else { //-------------------Specific Help
         String command = (String)params.get(0);
         if (!CommandManager.doesCommandExist(command) || !CommandManager.isCommandEnabled(command)) {
            throw new CommandException("Specified command name " + command +
                     " does not exist or is not enabled.");
         }
         String description = CommandManager.getCommandDescription(command);
         String example = CommandManager.getCommandExample(command);
         String usage = CommandManager.getCommandUsage(command, sender);
View Full Code Here


      Coordinate c = player.getPosition();
      int distance = 0;
      try {
         distance = Integer.parseInt((String)params.get(0));
      } catch (NumberFormatException e) {
         throw new CommandException("Could not parse disance specified as integer: " + params.get(0));
      }
     
      if (((String)params.get(1)).toUpperCase().startsWith("N")) {
         player.setPosition(new Coordinate(player.getPosition().getX(), player.getPosition().getY(), player.getPosition().getZ() - distance));
      } else if (((String)params.get(1)).toUpperCase().startsWith("E")) {
         player.setPosition(new Coordinate(player.getPosition().getX() + distance, player.getPosition().getY(), player.getPosition().getZ()));
      } else if (((String)params.get(1)).toUpperCase().startsWith("S")) {
         player.setPosition(new Coordinate(player.getPosition().getX(), player.getPosition().getY(), player.getPosition().getZ() + distance));
      } else if (((String)params.get(1)).toUpperCase().startsWith("W")) {
         player.setPosition(new Coordinate(player.getPosition().getX() - distance, player.getPosition().getY(), player.getPosition().getZ()));
      } else if (((String)params.get(1)).toUpperCase().startsWith("U")) {
         player.setPosition(new Coordinate(player.getPosition().getX(), player.getPosition().getY() + distance, player.getPosition().getZ()));
      } else if (((String)params.get(1)).toUpperCase().startsWith("D")) {
         player.setPosition(new Coordinate(player.getPosition().getX(), player.getPosition().getY() - distance, player.getPosition().getZ() - distance));
      } else {
         throw new CommandException("Invalid direction specified.");
      }

      sender.sendMessageToPlayer("Moved from " +
               FontColour.AQUA + c.getBlockX() + FontColour.WHITE + ", " +
               FontColour.AQUA + c.getBlockX() + FontColour.WHITE + ", " +
View Full Code Here

            }
            method.setAccessible(true);
            method.invoke(entityDragon, new Object[]{x, z});
         } catch (Throwable t) {
            t.printStackTrace();
            throw new CommandException("End portal generation is currently unsupported.");
         }
      } else if (portalType.equalsIgnoreCase("nether")) {
         EntityPlayerMP playerEntity;
         if(player.getMinecraftPlayer() instanceof EntityPlayerMP) {
            playerEntity = (EntityPlayerMP)player.getMinecraftPlayer();
         } else {
            throw new CommandException("SPC should *NOT* be processing commands client-side!");
         }
         (new Teleporter(playerEntity.getServerForPlayer())).makePortal(playerEntity);
      } else {
         throw new CommandException("Invalid portal type specified.");
      }
   }
View Full Code Here

      String split[] = ((String)params.get(0)).split("(\\^|:)");
      if (split.length == 2) {
         try {
            damage = Integer.parseInt(split[1]);
         } catch (NumberFormatException e) {
            throw new CommandException("Could not parse damage value of " + split[1]);
         }
      }
     
      // Get the item id
      int code = -1;
      try {
         code = Integer.parseInt(split[0]);
      } catch (NumberFormatException e) {
         code = -1;
      }
      if (code <= 0) {
         code = Item.getItemId((split[0]).replace('_', ' '));
      }
      if (!Item.isValidItem(code)) {
         throw new CommandException("Cannot find specified item: " + split[0]);
      }
     
      // Get the quantity and damage and give player the item
      int quantity = params.size() > 1 ? (Integer)params.get(1) : 0;
      damage = params.size() > 2 ? (Integer)params.get(2) : damage;
View Full Code Here

         player.sendChatMessage("Waypoint was set at " + FontColour.AQUA + getLocationAsString(player.getPosition()));
      } else if (getName().equalsIgnoreCase("rem")) {
         if (removeWaypoint((String)params.get(0), player)) {
            player.sendChatMessage("Waypoint was removed.");
         } else {
            throw new CommandException("Waypoint does not exist.");
         }
      } else if (getName().equalsIgnoreCase("goto")) {
         if (gotoWaypoint((String)params.get(0), player)) {
            player.sendChatMessage("Whoosh");
         } else {
            throw new CommandException("Waypoint does not exist.");
         }
      } else {
         assert false : "Unexpected call not being handled: " + params.get(0);
      }
      super.loadSettings(player).save();
View Full Code Here

   @Override
   public void execute(CommandSender sender, List<?> params) throws CommandException {
      Player player = getSenderAsPlayer(sender);
      Coordinate block = player.trace(128);
      if (block == null) {
         throw new CommandException("No block within range.");
      }
      Coordinate fire = new Coordinate(block.getBlockX(), block.getBlockY() + 1, block.getBlockZ());
      if (player.getWorld().getBlockId(fire) == 0) {
         player.getWorld().setBlock(fire, BLOCK_FIRE);
      }
View Full Code Here

  public void execute(CommandSender sender, List<?> params)
      throws CommandException {
    Player player = super.getSenderAsPlayer(sender);
    Coordinate c = player.trace(128D);
    if (c == null) {
      throw new CommandException("No block within range.");
    }
   
    Entity.spawnEntity("EnderCrystal", c, player.getWorld());
  }
View Full Code Here

         setCurrentTime(world,TIME_DAY);
      } else if (((String)params.get(0)).equalsIgnoreCase("night")) {
         setCurrentTime(world,TIME_NIGHT);
      } else if (((String)params.get(0)).equalsIgnoreCase("set")) {
         if (params.size() == 1) {
            throw new CommandException("Must specify what time to set it to.");
         }
         setCurrentTime(world,(String)params.get(1));
      } else {
         throw new CommandException(FontColour.RED + getUsage(sender));
      }
      outputCurrentTime(sender);
   }
View Full Code Here

      try {
         if (time.matches("[0-2][0-9]:[0-5][0-9]")) { // HH:MM
            String parts[] = time.split(":");
            hour = Integer.parseInt(parts[0]);
            if (hour > 23) {
               throw new CommandException("Hour out of range");
            }
            hour -= OFFSET_HOUR;
            minute = Integer.parseInt(parts[1]) - OFFSET_MINUTE;
         } else if (time.matches("[0-9]{0,19}")) {
            long ticks = Long.parseLong(time);
            world.setTime(ticks);
            return;
         } else {
            throw new CommandException("Unknown date format");
         }
         long newTime = ((world.getTime() / 1000) / 24); // Gets the current day
         newTime += 1; // Makes it the next day
         newTime *= 24000; // Converts it to days
         newTime += (hour % 24) * 1000; // Adds the hours on
         newTime += ((minute % 60) / 60.0) * 1000; // Adds the minutes on
         world.setTime(newTime);
      } catch (Exception e) {
         throw new CommandException("Could not parse date.");
      }
   }
View Full Code Here

            keycode = Keyboard.getKeyIndex(key.toUpperCase());
         } else {
            keycode = (Integer)params.get(0);
         }
         if (keycode == Keyboard.KEY_NONE) {
            throw new CommandException("Unknown keycode " + params.get(0));
         }
         String command = (String)params.get(1);
         String param = "";
         if (params.size() > 2) {
            param = (String)params.get(2);
         }
         if (BINDINGS.get(keycode + "") == null) {
            bind(keycode);
         }
         BINDINGS.set(keycode + "", command + " " + param);
         BINDINGS.save();
         sender.sendMessageToPlayer("Key " + FontColour.AQUA + params.get(0) +
                  FontColour.WHITE + " was successfully bound.");
      } else if (getName().equalsIgnoreCase("unbind") || getName().equalsIgnoreCase("unbindid")) {
         int keycode = Keyboard.KEY_NONE;
         if (getName().equalsIgnoreCase("unbind")) {
            String key = (String)params.get(0);
            if (key.equalsIgnoreCase("all")) {
               BINDINGS.clear();
               BINDINGS.save();
               sender.sendMessageToPlayer("All bindings removed.");
               return;
            }
            keycode = Keyboard.getKeyIndex(key.toUpperCase());
         } else {
            keycode = (Integer)params.get(0);
         }
         if (keycode == Keyboard.KEY_NONE) {
            throw new CommandException("Unknown keycode " + params.get(0));
         }
         unbind(keycode);
         if (BINDINGS.remove(keycode + "") == null) {
            throw new CommandException("No binding was found for key " + FontColour.AQUA + (String)params.get(0));
         } else {
            BINDINGS.save();
            sender.sendMessageToPlayer("Binding " + FontColour.AQUA + params.get(0) +
                     FontColour.WHITE + " was successfully removed.");
         }
View Full Code Here

TOP

Related Classes of com.sijobe.spc.wrapper.CommandException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.