@Command(aliases = "clear", usage = "[player]", desc = "Clears your inventory", min = 0, max = 1)
 @CommandPermissions("vanilla.command.clear")
 public void clear(CommandContext args, CommandSource source) throws CommandException {
   if (args.length() == 0) {
     if (!(source instanceof Player)) {
       throw new CommandException("You must be a player to clear your own inventory.");
     }
     PlayerInventory inv = ((Player) source).get(PlayerInventory.class);
     if (inv == null) {
       source.sendMessage(plugin.getPrefix(), ChatStyle.RED, "You have no inventory!");
       return;
     }
     inv.clear();
   }
   if (args.length() == 1) {
     Player player = args.getPlayer(0, false);
     if (player == null) {
       source.sendMessage(plugin.getPrefix(), ChatStyle.RED, "Player is not online!");
       return;
     }
     PlayerInventory inv = player.get(PlayerInventory.class);
     if (inv == null) {
       source.sendMessage(plugin.getPrefix(), ChatStyle.RED, "Player has no inventory!");
       return;
     }
     player.sendMessage(
         plugin.getPrefix(), ChatStyle.BRIGHT_GREEN, "Your inventory has been cleared.");
     if (source instanceof Player && source.equals(player)) {
       return;
     }
   }
   source.sendMessage(plugin.getPrefix(), ChatStyle.BRIGHT_GREEN, "Inventory cleared.");
 }
  @Command(
      aliases = "xp",
      usage = "[player] <amount>",
      desc = "Give/take experience from a player",
      min = 1,
      max = 2)
  @CommandPermissions("vanilla.command.xp")
  public void xp(CommandContext args, CommandSource source) throws CommandException {
    // If source is player
    if (args.length() == 1) {
      if (source instanceof Player) {
        @SuppressWarnings("unused")
        Player sender = (Player) source;
        int amount = args.getInteger(0);
        source.sendMessage(
            plugin.getPrefix(),
            ChatStyle.BRIGHT_GREEN,
            "You have been given ",
            ChatStyle.WHITE,
            amount,
            ChatStyle.BRIGHT_GREEN,
            " xp.");
        // TODO: Give player 'amount' of xp.
      } else {
        throw new CommandException("You must be a player to give yourself xp.");
      }
    } else {
      if (Spout.getEngine() instanceof Client) {
        throw new CommandException("You cannot search for players unless you are in server mode.");
      }
      Player player = ((Server) Spout.getEngine()).getPlayer(args.getString(0), true);
      if (player != null) {
        short amount = (short) args.getInteger(1);
        LevelComponent level = player.get(LevelComponent.class);

        if (level == null) {
          return;
        }

        if (amount > 0) {
          level.addExperience(amount);
        } else {
          level.removeExperience(amount);
        }
        player.sendMessage(
            plugin.getPrefix(),
            ChatStyle.BRIGHT_GREEN,
            "Your experience has been set to ",
            ChatStyle.WHITE,
            amount,
            ChatStyle.BRIGHT_GREEN,
            ".");
      } else {
        throw new CommandException(args.getString(0) + " is not online.");
      }
    }
  }
    @Command(
        aliases = {"create", "make", "mk"},
        desc = "Creates a new waypoint",
        min = 1,
        max = 1)
    @Permissible("plugintest.waypoint.create")
    public void create(CommandSource source, CommandArguments args) throws CommandException {
      if (!(source instanceof Player)) {
        throw new CommandException("Only players may create waypoints.");
      }

      String name = args.getString(0);
      Player player = (Player) source;

      if (this.waypoints.containsKey(name)) {
        throw new CommandException("The \"" + name + "\" waypoint already exists.");
      }

      this.waypoints.put(name, player.getScene().getPosition());
      player.sendMessage("Waypoint \"" + name + "\" has been created.");
    }
  @Command(
      aliases = {"op"},
      usage = "<player>",
      desc = "Make a player an operator",
      min = 1,
      max = 1)
  @CommandPermissions("vanilla.command.op")
  public void op(CommandContext args, CommandSource source) throws CommandException {
    if (Spout.getEngine() instanceof Client) {
      throw new CommandException("You cannot search for players unless you are in server mode.");
    }

    String playerName = args.getString(0);
    OpConfiguration ops = VanillaConfiguration.OPS;
    ops.setOp(playerName, true);
    source.sendMessage(plugin.getPrefix(), ChatStyle.RED, playerName, " is now an operator!");
    Player player = Spout.getEngine().getPlayer(playerName, true);
    if (player != null && !source.equals(player)) {
      player.sendMessage(plugin.getPrefix(), ChatStyle.YELLOW, "You are now an operator!");
    }
  }
    @Command(
        aliases = {"teleportto", "tpto"},
        desc = "Teleports the player to the waypoint",
        min = 1,
        max = 1)
    @Permissible("plugintest.waypoint.tpto")
    public void tpto(CommandSource source, CommandArguments args) throws CommandException {
      if (!(source instanceof Player)) {
        throw new CommandException("Only players may teleport to waypoints, silly.");
      }

      String name = args.getString(0);
      Player player = (Player) source;
      Point destination = this.waypoints.get(name);

      if (destination == null) {
        throw new CommandException("The \"" + name + "\" waypoint does not exist.");
      }

      player.teleport(destination);
      player.sendMessage("Teleported to waypoint.");
    }
  @Command(
      aliases = "weather",
      usage = "<0|1|2> (0 = CLEAR, 1 = RAIN/SNOW, 2 = THUNDERSTORM) [world]",
      desc = "Changes the weather",
      min = 1,
      max = 2)
  @CommandPermissions("vanilla.command.weather")
  public void weather(CommandContext args, CommandSource source) throws CommandException {
    World world;
    if (source instanceof Player && args.length() == 1) {
      world = ((Player) source).getWorld();
    } else if (args.length() == 2) {
      world = plugin.getEngine().getWorld(args.getString(1));

      if (world == null) {
        throw new CommandException("Invalid world '" + args.getString(1) + "'.");
      }
    } else {
      throw new CommandException("You need to specify a world.");
    }

    Weather weather;
    try {
      if (args.isInteger(0)) {
        weather = Weather.get(args.getInteger(0));
      } else {
        weather = Weather.get(args.getString(0).replace("snow", "rain"));
      }
    } catch (Exception e) {
      throw new CommandException(
          "Weather must be a mode between 0 and 2, 'CLEAR', 'RAIN', 'SNOW', or 'THUNDERSTORM'");
    }

    VanillaSky sky = VanillaSky.getSky(world);
    if (sky == null) {
      throw new CommandException("The sky of world '" + world.getName() + "' is not availible.");
    }

    sky.setWeather(weather);
    ChatArguments message;

    switch (weather) {
      case RAIN:
        message =
            new ChatArguments(
                plugin.getPrefix(),
                ChatStyle.BRIGHT_GREEN,
                "Weather set to ",
                ChatStyle.WHITE,
                "RAIN/SNOW",
                ChatStyle.BRIGHT_GREEN,
                ".");
        break;
      default:
        message =
            new ChatArguments(
                plugin.getPrefix(),
                ChatStyle.BRIGHT_GREEN,
                "Weather set to ",
                ChatStyle.WHITE,
                weather.name(),
                ChatStyle.BRIGHT_GREEN,
                ".");
        break;
    }
    if (Spout.getEngine() instanceof Client) {
      source.sendMessage(message);
    } else {
      for (Player player : ((Server) Spout.getEngine()).getOnlinePlayers()) {
        if (player.getWorld().equals(world)) {
          player.sendMessage(message);
        }
      }
    }
  }