[IMPORTANT] I need help, fast.

Discussion in 'Spigot Plugin Development' started by Compilable, May 17, 2015.

  1. Here are my errors:
    PHP:

      }
      players.remove(p);
      for (Player player : players)
      player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 100, 100, true));
      }
     
    On for (Player player: players), it throws an error:
    "Cannot convert from element type Object to Player"
    PHP:

      }

      for (BlockData d : input) {
      if (!data.contains(d)) {
      data.add(d);
      }
      }
     
    On for (BlockData d: input) { , it throws an error:
    "Cannot convert from element type Object to BlockData"
    PHP:

      @SuppressWarnings("rawtypes")
       Set redPlayers = this.red.getPlayers();
      for (OfflinePlayer player : redPlayers) {
      this.red.removePlayer(player);
      }
      @SuppressWarnings("rawtypes")
       Set bluePlayers = this.blue.getPlayers();
      for (OfflinePlayer player : bluePlayers) {
      this.blue.removePlayer(player);
      }
      @SuppressWarnings("rawtypes")
       Set greenPlayers = this.green.getPlayers();
      for (OfflinePlayer player : greenPlayers) {
      this.green.removePlayer(player);
      }
      @SuppressWarnings("rawtypes")
       Set yellowPlayers = this.yellow.getPlayers();
      for (OfflinePlayer player : yellowPlayers) {
      this.yellow.removePlayer(player);
      }
      @SuppressWarnings("rawtypes")
       Set spectatePlayers = this.spectate.getPlayers();
      for (OfflinePlayer player : spectatePlayers) {
      this.spectate.removePlayer(player);
      }
     
    On:

    for (OfflinePlayer player : redPlayers) {
    for (OfflinePlayer player : bluePlayers) {
    for (OfflinePlayer player : greenPlayers) {
    for (OfflinePlayer player : yellowPlayers) {
    for (OfflinePlayer player : spectatePlayers) {

    It throws an error:
    "Cannot convert from element type Object to OfflinePlayer"
    PHP:

      for (String cmd : wCommand) {
      boolean match = false;
      if (event.getMessage().startsWith(cmd)) {
      match = true;
      }
     
    On "for (String cmd: wCommand){" it throws an error:
    "Cannot convert from element type Object to String"

    FIXED "getTargetBlock"
    PHP:

    public void createLobbySign(Player p, Game game) {
      if (!p.getTargetBlock(null, 10).getType().equals(Material.WALL_SIGN)) {
      MessageManager.getInstance().sendFMessage("error.notsign", p, new String[0]);
      return;
      }
     
    On this thing "getTargetBlock", it throws an error:
    "The method getTargetBlock(HashSet<Byte>, int) is ambiguous for the type Player"

    How can these all be fixed with changing anything in the aspect of the game?
    Thanks for the help.
     
    #1 Compilable, May 17, 2015
    Last edited: May 17, 2015
  2. For the getTargetBlock anyway, you need to cast null to a set, as there two methods doing the same task; by casting you will specifically define which of the two you are using.
     
  3. Changed the null to a set, works now.
    Thanks.
     
  4. I am guessing you are using ArrayLists to store the information for the players and blockdata? If so, make sure you are using ArrayList<Player> or ArrayList<BlockData> and not ArrayList<Object>.

    Edit: Didn't notice you said it was fixed :p