Package org.spout.api.exception

Examples of org.spout.api.exception.CommandException


    String name = player.getName();
    player.sendMessage("Creating team...");

    Scoreboard scoreboard = player.get(Scoreboard.class);
    if (scoreboard == null) {
      throw new CommandException("You do not have an active scoreboard.");
    }

    Team t = scoreboard.createTeam("spoutdev");
    t.setDisplayName(ChatStyle.DARK_AQUA + "Spout", false);
    t.setPrefix(ChatStyle.GREEN.toString(), true);
View Full Code Here


  public void chunkLight(Player player, CommandArguments args) throws CommandException {
    args.assertCompletelyParsed();

    Chunk c = player.getChunk();
    if (c == null) {
      throw new CommandException("You are somenow in a null chunk. This is probably bad.");
    }
    LightingVerification.checkChunk(c, false);
  }
View Full Code Here

    Point p = args.popPoint("loc", source);
    args.assertCompletelyParsed();

    Chunk c = p.getChunk(LoadOption.NO_LOAD);
    if (c == null) {
      throw new CommandException("Chunk not loaded");
    }
    int blockState = c.getBlockFullState(p.getBlockX(), p.getBlockY(), p.getBlockZ());
    BlockMaterial m = BlockMaterial.get(blockState);
    source.sendMessage("Material at " + p.getBlockX() + ", " + p.getBlockY() + ", " + p.getBlockZ() + " is " + m.getClass().getSimpleName());
  }
View Full Code Here

  @Filter (PlayerFilter.class)
  public void mapDraw(Player player, CommandArguments args) throws CommandException {
    args.assertCompletelyParsed();
    PlayerInventory inventory = player.get(PlayerInventory.class);
    if (inventory == null) {
      throw new CommandException("Player has no inventory.");
    }
    ItemStack i = inventory.getQuickbar().getSelectedSlot().get();
    if (i == null || !(i.getMaterial() instanceof Map)) {
      throw new CommandException("Held item is not a map");
    }
    Map m = (Map) i.getMaterial();
    int bx = args.popInteger("bx");
    int by = args.popInteger("by");
    int tx = args.popInteger("tx");
    int ty = args.popInteger("ty");
    int col = args.popInteger("col");
    args.assertCompletelyParsed();

    if (bx < 0 || bx >= m.getWidth()) {
      throw new CommandException("bx component is out of range");
    }
    if (by < 0 || by >= m.getHeight()) {
      throw new CommandException("by component is out of range");
    }
    if (tx < 0 || tx >= m.getWidth()) {
      throw new CommandException("tx component is out of range");
    }
    if (ty < 0 || ty >= m.getHeight()) {
      throw new CommandException("ty component is out of range");
    }
    if (bx > tx) {
      throw new CommandException("bx cannot be greater than tx");
    }
    if (by > ty) {
      throw new CommandException("by cannot be greater than ty");
    }
    for (ProtocolEvent e : m.drawRectangle(i, bx, by, tx, ty, col)) {
      player.getNetwork().callProtocolEvent(e);
    }
  }
View Full Code Here

  @Filter (PlayerFilter.class)
  public void mapFlood(Player player, CommandArguments args) throws CommandException {
    args.assertCompletelyParsed();
    PlayerInventory inventory = player.get(PlayerInventory.class);
    if (inventory == null) {
      throw new CommandException("Player has no inventory.");
    }
    ItemStack i = inventory.getQuickbar().getSelectedSlot().get();
    if (i == null || !(i.getMaterial() instanceof Map)) {
      throw new CommandException("Held item is not a map");
    }
    Map m = (Map) i.getMaterial();
    int col = args.popInteger("col");
    for (ProtocolEvent e : m.flood(i, col)) {
      player.getNetwork().callProtocolEvent(e);
View Full Code Here

        break;
      case VILLAGER:
        player.get(WindowHolder.class).openWindow(new VillagerWindow(player, new VillagerInventory()));
        break;
      default:
        throw new CommandException("Window not supported.");
    }
  }
View Full Code Here

      player.sendMessage("Pitch = " + axesAngles.getX());
    } else if (action.contains("packets")) {
      player.add(ForceMessages.class);
    } else {
      if (getEngine() instanceof Client) {
        throw new CommandException("You cannot resend chunks in client mode.");
      }
      if (action.contains("resendall")) {
        Set<Chunk> chunks = player.getNetwork().getActiveChunks();
        for (Chunk c : chunks) {
          player.getNetwork().callProtocolEvent(new ChunkSendEvent(c, true));
View Full Code Here

    } catch (Exception e1) {
      try {
        //Living failed? Try object
        clazz = ObjectType.valueOf(name.toUpperCase()).getComponentType();
      } catch (Exception e2) {
        throw new CommandException(name + " is neither a living or substance entity!");
      }
    }
    //if (!player.hasPermission("vanilla.command.spawn." + clazz.getName().toLowerCase())) {
    //  throw new CommandException("You do not have permission to spawn a(n) " + clazz.getSimpleName().toLowerCase());
    //}
    //TODO ServerEntityPrefab!
    //How about some client support?
    final Entity entity;
    if (getEngine() instanceof Client) {
      final EntityPrefab prefab = getEngine().getFileSystem().getResource("entity://Vanilla/entities/" + clazz.getSimpleName().toLowerCase() + "/" + clazz.getSimpleName().toLowerCase() + ".sep");
      entity = prefab.createEntity(player.getPhysics().getPosition());
    } else {
      entity = player.getWorld().createEntity(player.getPhysics().getPosition(), clazz);
    }
    //Optional param was provided (ie the block material for a falling block).
    if (args.length() == 2) {
      //Now we know its either a living or substance. Lets figure out which.
      if (Living.class.isAssignableFrom(clazz)) {
        final Living living = entity.get(Living.class);
        if (name.equalsIgnoreCase("human")) {
          ((Human) living).setName(args.popString("disp_name"));
        }
      } else if (Substance.class.isAssignableFrom(clazz)) {
        final Substance substance = entity.get(Substance.class);
        switch (ObjectType.valueOf(name.toUpperCase())) {
          case ITEM:
            Material item = VanillaArgumentTypes.popMaterial("item", args);
            ((Item) substance).setItemStack(new ItemStack(item, 1));
            break;
          case FALLING_OBJECT:
            Material block = VanillaArgumentTypes.popMaterial("block", args);
            if (!(block instanceof BlockMaterial)) {
              throw new CommandException("Material " + block.getDisplayName() + " is not a block!");
            }
            ((FallingBlock) substance).setMaterial((BlockMaterial) block);
            break;
        }
      }
View Full Code Here

    Integer data = args.popInteger("data");
    args.assertCompletelyParsed();

    PlayerInventory inv = player.get(PlayerInventory.class);
    if (inv == null) {
      throw new CommandException(player.getName() + " doesn't have a inventory!");
    } else {
      // Count the items and clear the inventory
      Inventory[] inventories = new Inventory[] {inv.getMain(), inv.getQuickbar(), inv.getArmor()};
      int cleared = 0;
      for (int k = 0; k < inventories.length; k++) {
        for (int i = 0; i < inventories[k].size(); i++) {
          if (inventories[k].get(i) != null && (filter == null || inventories[k].get(i).isMaterial(filter)) && (data == null || inventories[k].get(i).getData() == data)) {
            cleared += inventories[k].get(i).getAmount();
            inventories[k].set(i, null);
          }
        }
      }

      if (cleared == 0) {
        throw new CommandException("Inventory is already empty");
      }

      source.sendMessage(plugin.getPrefix() + ChatStyle.GREEN + "Cleared the inventory of " + player.getName() + ", removing " + cleared + " items.");
    }
  }
View Full Code Here

      inventory.add(new ItemStack(material, data, quantity));
      source.sendMessage(plugin.getPrefix() + ChatStyle.GREEN + "Gave "
          + ChatStyle.WHITE + player.getName() + " " + quantity + ChatStyle.GREEN + " of " + ChatStyle.WHITE
          + material.getDisplayName());
    } else {
      throw new CommandException(player.getName() + " doesn't have a inventory!");
    }
  }
View Full Code Here

TOP

Related Classes of org.spout.api.exception.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.