Пример #1
0
 @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.");
 }
Пример #2
0
  @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!");
    }
  }