Getting errors on parentheses

Discussion in 'Plugin Help/Development/Requests' started by PerezHD, Jan 24, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    PerezHD

  2. Offline

    Skionz

    @PerezHD Your casting before checking? Cast after you check, not before.
     
  3. Offline

    PerezHD

    Not 100% sure what you meant by that, but I did this
    Code:
        @Override
        public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
            Player p = (Player) sender;
            PageInventory inv = new PageInventory(p);
            Collection<Player> players = Bukkit.getOnlinePlayers();
            ItemStack[] items = new ItemStack[players.size()];
            if (!(sender instanceof Player)){
                sender.sendMessage("You must be a player to type that.");
            }
            if (cmd.getName().equalsIgnoreCase("help")){
                for (int i=0; i<players.size(); i++) {
                    items[i] = new ItemBuilder(Material.SKULL_ITEM).setTitle("Player: " + players.get(i).getName()).build();
                }
                inv.setPages(items);
                inv.setTitle("Players online");
                inv.openInventory();
            }
    
            return false;
        }
    And I am still getting those errors on parenthasis
     
  4. Offline

    Skionz

    @PerezHD Are you using Bukkit, or CraftBukkit?
     
  5. Offline

    PerezHD

    Spigot 1.8. I just like asking here due to you guys actually replying quick.
     
  6. Offline

    bwfcwalshy Retired Staff

    Bukkit to Bukkit Alternates.


    @PerezHD In your original code,
    By that he means you are casting Player before checking if they are a player.
     
  7. Offline

    PerezHD

    Ok, I fixed that, but what about the parengtheses
     
Thread Status:
Not open for further replies.

Share This Page