Package com.sijobe.spc.wrapper

Examples of com.sijobe.spc.wrapper.CommandException


    * @see com.sijobe.spc.wrapper.CommandBase#execute(com.sijobe.spc.wrapper.CommandSender, java.util.List)
    */
   @Override
   public void execute(CommandSender sender, List<?> params) throws CommandException {
      if (params.size() != 0 && params.size() < 3) {
         throw new CommandException("Usage: " + getUsage(sender));
      }
      Player player = getSenderAsPlayer(sender);
      if (params.size() == 0) {
         player.getWorld().setSpawn(player.getPosition());
      } else {
View Full Code Here


      } else if (type.equalsIgnoreCase("nether")) {
         player.changeDimension(DIMENSION_NETHER);
      } else if (type.equalsIgnoreCase("end")) {
         player.changeDimension(DIMENSION_END);
      } else {
         throw new CommandException("Unknown dimension specified");
      }
   }
View Full Code Here

         if (args[0].equalsIgnoreCase("air")) {
            block = 0;
         }

         if (!player.getWorld().isValidBlockType(block) && block != 0) { // isValidBlockType should be static
            throw new CommandException("Unknown block: " + args[0]);
         }
        
         if(args.length > 1) {
            try {
               meta = Integer.parseInt(args[1]);
            } catch (NumberFormatException e) {
               sender.sendMessageToPlayer("Invalid metadata value specified, using default.");
               meta = 0;
            }
            if(meta < 0 || meta > 15) {
               sender.sendMessageToPlayer("Using default metadata value.");
               meta = 0;
            }
         }
        
         if (params.size() > 1) {
            size = (Integer)params.get(1);
            if(size < 1) {
               throw new CommandException("Size must be at least 1.");
            }
            if(size > 50) {
               sender.sendMessageToPlayer("Clamping path size.");
               size = 50;
            }
         }

         if(playerConfig.containsKey(playerName)) {
            int[] plrData = playerConfig.get(playerName);
            if(plrData[0] == block && plrData[1] == meta && plrData[2] == size) {
               throw new CommandException("Already making specified type of path!");
            }
         }
        
         sender.sendMessageToPlayer("Path mode enabled.");
         playerConfig.put(playerName, new int[]{block, meta, size, -1, -1, -1});
      } else if(playerConfig.containsKey(playerName) && playerConfig.get(playerName)[0] > -1) {
         sender.sendMessageToPlayer("Path mode disabled.");
         playerConfig.get(playerName)[0] = -1;
      } else {
         throw new CommandException("Must specify block.");
      }

   }
View Full Code Here

    */
   @Override
   public void execute(CommandSender sender, List<?> params) throws CommandException {
      Player player = getSenderAsPlayer(sender);
      if(!(player.getMinecraftPlayer() instanceof EntityPlayerMP)) {
         throw new CommandException("Command must be executed by non-client player.");
      }
      EntityPlayerMP playerEntity = (EntityPlayerMP)player.getMinecraftPlayer();
      if(params.size() == 0) {
         sender.sendMessageToPlayer("Current block reach distance: " +
            ForgeHelper.getBlockReachDistance(playerEntity.theItemInWorldManager));
      } else {
         double newReach = (Double)params.get(0);
         if(newReach < 4.5D || newReach > 255.0D) {
            throw new CommandException("Reach distance must be between 4.5 and 255.");
         }
         ForgeHelper.setBlockReachDistance(playerEntity.theItemInWorldManager, newReach);
         Minecraft.getMinecraft().thePlayer.setClientReach(newReach);
         sender.sendMessageToPlayer("Set block reach distance to: " + newReach);
      }
View Full Code Here

         argument = Entity.getLoadedEntities().get((int)(Math.random() * Entity.getLoadedEntities().size()));
      }
      try {
         argument = Entity.getEntityName(Integer.parseInt(argument));
         if (argument == null) {
            throw new CommandException("Invalid ID specified " + params.get(0));
         }
      } catch (Exception e) {
      }
      int quantity = 1;
      if (params.size() > 1) {
         quantity = (Integer)params.get(1);
      }
      Player player = super.getSenderAsPlayer(sender);
      Coordinate coord = player.trace(128);
      if (coord == null) {
         coord = player.getPosition();
         coord = new Coordinate(coord.getX() + (Math.random() * 10) - 5, coord.getY(), coord.getZ() + (Math.random() * 10) - 5);
      }
      for (int i = 0; i < quantity; i++) {
         if (!Entity.spawnEntity(argument, coord, player.getWorld())) {
            throw new CommandException("Could not spawn entity named " + argument);
         }
      }
   }
View Full Code Here

         potions = potions.substring(0, potions.length() - 2);
         sender.sendMessageToPlayer("Potion effects [name (" + FontColour.AQUA + "ID" + FontColour.WHITE + ")]: ");
         sender.sendMessageToPlayer(potions);
      }
      if (params.size() < 2) {
         throw new CommandException("Not enough parameters.");
      }
      // Gets the specified potion
      String args[] = ((String)params.get(1)).split(" ");
      Integer id = null;
      try {
         id = Integer.parseInt(args[0]);
      } catch (NumberFormatException e) {
         id = Potion.getPotions().get(args[0].toLowerCase());
      }
      if (id == null && !(args[0].equalsIgnoreCase("all"))) {
         throw new CommandException("Could not find specified effect.");
      }
      if (id != null && id < 1) {
         throw new CommandException("Invalid effect specified.");
      }
      Player player = super.getSenderAsPlayer(sender);
      // Removes the specified effect
      if (((String)params.get(0)).equalsIgnoreCase("remove")) {
         if (id == null) {
            player.removeAllPotionEffects();
         } else {
            player.removePotionEffect(id);
         }
         // Adds the specified effect
      } else if (((String)params.get(0)).equalsIgnoreCase("add")) {
         int duration = 1;
         int strength = 1;
         if (args.length > 1) {
            try {
               duration = Integer.parseInt(args[1]);
            } catch (NumberFormatException e) {
               throw new CommandException("Could not parse duration argument.");
            }
         }
         if (args.length > 2) {
            try {
               strength = Integer.parseInt(args[2]);
            } catch (NumberFormatException e) {
               throw new CommandException("Could not parse strength argument.");
            }
         }
         if (id == null) {
            for (Integer i : Potion.getPotions().values()) {
               player.addPotionEffect(i, duration * 20, strength);
            }
         } else {
            player.addPotionEffect(id, duration * 20, strength);
         }
      } else {
         throw new CommandException("Invalid argument specified.");
      }
   }
View Full Code Here

            try {
               radius = Double.parseDouble((String)params.get(0));
               sender.sendMessageToPlayer("Setting radius to: " + radius);
               entityType = "item";
            } catch (NumberFormatException nfe) {
               throw new CommandException("Unknown entity specified.");
            }
         }
         if(params.size() > 1) {
            radius = (Integer)params.get(1);
         }
      }
      if(radius <=0 || radius > 256) {
         throw new CommandException("Radius should be between 0 and 256.");
      }
      List<net.minecraft.src.Entity> foundEntities = Entity.findEntities(entityType, player.getPosition(), player.getWorld(), radius);
      net.minecraft.src.Vec3 vec3d = player.getMinecraftPlayer().getLook(1.0F);
      double d = 5.0D;
      double offsetY = player.getMinecraftPlayer().posY + player.getMinecraftPlayer().getEyeHeight();
View Full Code Here

      System.out.println(player.getUsername() + " " + MinecraftServer.getServer().getServerOwner());
      /*if(!player.getUsername().equals(MinecraftServer.getServer().getServerOwner())) {
         throw new CommandException("Must be server host");
      }*/
      if(!player.getMinecraftPlayer().capabilities.isFlying && !player.getMinecraftPlayer().noClip) {
         throw new CommandException("Must be flying");
      }

      if (params.size() == 0) {
         player.getMinecraftPlayer().noClip ^= true;
      } else {
         player.getMinecraftPlayer().noClip = (Boolean)params.get(0);
      }

      // replace server handler
      if(player.getMinecraftPlayer() instanceof EntityPlayerMP) {
         updateServerHandler((EntityPlayerMP)player.getMinecraftPlayer());
      } else {
         player.getMinecraftPlayer().noClip = false;
         throw new CommandException("Noclip unavailable");
      }

      if(player.getMinecraftPlayer().noClip == false) {
         ascendPlayer(player);
      }
View Full Code Here

    */
   @Override
   public void execute(CommandSender sender, List<?> params) throws CommandException {
      File macro = new File(MACRO_DIR, (String)params.get(0) + MACRO_EXTENSION);
      if (!macro.exists()) {
         throw new CommandException("Specified macro does not exist.");
      }

      try {
         BufferedReader br = new BufferedReader(new FileReader(macro));
         String split[] = null;
         if (params.size() == 1) {
            split = new String[] { (String)params.get(0) };
         } else {
            split = (((String)params.get(0)) + " " + ((String)params.get(1))).split(" ");
         }
         String line = null;
         while ((line = br.readLine()) != null) {
            // Adds arguments to the line
            for (int i = 0; i < split.length; i++) {
               line = line.replaceAll("\\$_" + i, split[i]);
            }

            // Remove all unspecified arguments from line
            line = line.replaceAll("\\$_[0-9]+", "");

            // Executes the line
            CommandManager.runCommand(sender, line);
         }
      } catch (Exception e) {
         throw new CommandException(e);
      }
   }
View Full Code Here

            try {
               radius = Double.parseDouble((String)params.get(0));
               sender.sendMessageToPlayer("Setting radius to: " + radius);
               entityType = "mob";
            } catch (NumberFormatException nfe) {
               throw new CommandException("Unknown entity specified.");
            }
         }
         if(params.size() > 1) {
            radius = (Integer)params.get(1);
         }
      }
      if(radius <=0 || radius > 256) {
         throw new CommandException("Radius should be between 0 and 256.");
      }
      List<net.minecraft.src.Entity> removedEntities =
         Entity.killEntities(entityType, player.getPosition(), player.getWorld(), radius);
      sender.sendMessageToPlayer(removedEntities.size() + " entity(s) 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.