for (item : friskedInv.getContents()) Syntax error on token "item" Identifier expected after this t

Discussion in 'Plugin Development' started by OutbackCanadian, Jan 16, 2017.

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

    OutbackCanadian

    Trying to update a plugin but I cant figure out this one error im making
    for (item : friskedInv.getContents()) Syntax error on token "item" Identifier expected after this t



    Code:
    /*     */   public void friskPlayer(final Player frisked, final Player cop, boolean bypassComplianceWaiting)
    /*     */   {
    /*  48 */     if (!bypassComplianceWaiting) {
    /*  49 */       waitForCompliance(frisked, cop);
    /*     */     }
    /*     */
    /*  52 */     new BukkitRunnable()
    /*     */     {
    /*     */       public void run()
    /*     */       {
    /*  57 */         if (Frisk.this.complied)
    /*     */         {
    /*  59 */           List materialsFrisked = new ArrayList();
    /*  60 */           List dataOfMaterialsFrisked = new ArrayList();
    /*     */
    /*  62 */           PlayerInventory friskedInv = frisked.getInventory();
    /*     */
    /*  64 */           boolean friskSuccessful = false;
    /*     */
    /*  66 */           List drugs = new ArrayList();
    /*     */           ItemStack item;
    /*  69 */           for (item : friskedInv.getContents())
    /*     */           {
    /*  71 */             if (item != null)
    /*     */             {
    /*  74 */               for (String drug : Frisk.this.plugin.getConfig().getStringList("drugs"))
    /*     */               {
    /*  77 */                 if (!drug.contains(" "))
    /*     */                 {
    /*  80 */                   if (item.getType() == Material.matchMaterial(drug))
    /*     */                   {
    /*  83 */                     friskedInv.remove(item);
    /*  84 */                     drugs.add(item);
    /*     */
    /*  87 */                     if (!materialsFrisked.contains(item.getType()))
    /*     */                     {
    /*  89 */                       frisked.sendMessage(Frisk.this.plugin.getConfig().getString("frisk-success-player-msg").replaceAll("&", "§").replaceAll("%cop%", cop.getName()).replaceAll("%drugname%", (String)Frisk.this.plugin.getConfig().getStringList("drug-names").get(Frisk.this.plugin.getConfig().getStringList("drugs").indexOf(drug))));
    /*     */
    /*  92 */                       cop.sendMessage(Frisk.this.plugin.getConfig().getString("frisk-success-cop-msg").replaceAll("&", "§").replaceAll("%player%", frisked.getName()).replaceAll("%drugname%", (String)Frisk.this.plugin.getConfig().getStringList("drug-names").get(Frisk.this.plugin.getConfig().getStringList("drugs").indexOf(drug))));
    /*     */                     }
    /*     */
    /*  97 */                     materialsFrisked.add(item.getType());
    /*     */
    /*  99 */                     friskSuccessful = true;
    /*     */                   }
    /*     */
    /*     */                 }
    /*     */                 else
    /*     */                 {
    /* 107 */                   String[] drugSplit = drug.split(" ");
    /*     */
    /* 110 */                   MaterialData materialData = item.getData();
    /*     */
    /* 113 */                   if ((materialData.getItemType() == Material.matchMaterial(drugSplit[0])) && (materialData.getData() == Byte.parseByte(drugSplit[1])))
    /*     */                   {
    /* 116 */                     friskedInv.remove(item);
    /* 117 */                     drugs.add(item);
    /*     */
    /* 120 */                     if ((!materialsFrisked.contains(item.getType())) || (!dataOfMaterialsFrisked.contains(Byte.valueOf(materialData.getData()))))
    /*     */                     {
    /* 122 */                       frisked.sendMessage(Frisk.this.plugin.getConfig().getString("frisk-success-player-msg").replaceAll("&", "§").replaceAll("%cop%", cop.getName()).replaceAll("%drugname%", (String)Frisk.this.plugin.getConfig().getStringList("drug-names").get(Frisk.this.plugin.getConfig().getStringList("drugs").indexOf(drug))));
    /*     */
    /* 125 */                       cop.sendMessage(Frisk.this.plugin.getConfig().getString("frisk-success-cop-msg").replaceAll("&", "§").replaceAll("%player%", frisked.getName()).replaceAll("%drugname%", (String)Frisk.this.plugin.getConfig().getStringList("drug-names").get(Frisk.this.plugin.getConfig().getStringList("drugs").indexOf(drug))));
    /*     */                     }
    /*     */
    /* 130 */                     materialsFrisked.add(item.getType());
    /* 131 */                     dataOfMaterialsFrisked.add(Byte.valueOf(materialData.getData()));
    /*     */
    /* 133 */                     friskSuccessful = true;
    /*     */                   }
    /*     */
    /*     */                 }
    /*     */
    /*     */               }
    /*     */
    /*     */             }
    /*     */
    /*     */           }
    /*     */
    /* 145 */           Frisk.this.addDrugsToInv(cop, drugs);
    /*     */
    /* 148 */           if ((friskSuccessful) && (cop.hasPermission("friskstick.jail")) && (Frisk.this.plugin.getServer().getPluginManager().isPluginEnabled("Essentials")) && (Frisk.this.plugin.getConfig().getBoolean("enable-auto-jailing")))
    /*     */           {
    /* 150 */             Random random = new Random();
    /*     */
    /* 153 */             List jails = Frisk.this.plugin.getConfig().getStringList("jails");
    /*     */
    /* 156 */             boolean infiniteTimeInJail = Frisk.this.plugin.getConfig().getInt("time-in-jail") == -1;
    /*     */
    /* 159 */             if (!infiniteTimeInJail) {
    /* 160 */               Frisk.this.plugin.getServer().dispatchCommand(Frisk.this.plugin.getServer().getConsoleSender(), "jail " + frisked.getName() + " " + (String)jails.get(random.nextInt(jails.size())) + " " + Frisk.this.plugin.getConfig().getInt("time-in-jail"));
    /*     */             }
    /*     */             else
    /*     */             {
    /* 165 */               Frisk.this.plugin.getServer().dispatchCommand(Frisk.this.plugin.getServer().getConsoleSender(), "jail " + frisked.getName() + " " + (String)jails.get(random.nextInt(jails.size())));
    /*     */             }
    /*     */
    /* 168 */             cop.sendMessage(ChatColor.GOLD + "Player jailed.");
    /*     */           }
    /* 171 */           else if (!friskSuccessful)
    /*     */           {
    /* 174 */             frisked.sendMessage(Frisk.this.plugin.getConfig().getString("frisk-failure-player-msg").replaceAll("&", "§").replaceAll("%cop%", cop.getName()));
    /*     */
    /* 176 */             cop.sendMessage(Frisk.this.plugin.getConfig().getString("frisk-failure-cop-msg").replaceAll("&", "§").replaceAll("%player%", frisked.getName()));
    /*     */
    /* 179 */             cop.damage(Frisk.this.plugin.getConfig().getDouble("frisk-failure-dmg"));
    /*     */           }
    /*     */         }
    /*     */       }
    /*     */     }
    /*  52 */     .runTaskLater(this.plugin, bypassComplianceWaiting ? 0L : this.plugin.getConfig().getInt("time-before-frisking") * 20 + 5);
    /*     */   }
     
    Last edited by a moderator: Jan 16, 2017
  2. Offline

    Zombie_Striker

    @OutbackCanadian
    Please use the code/code tags, and remove the unnecessary comments/ line numbers. Post the raw code.

    You're missing an identifier. Add it.
     
    Last edited: Jan 16, 2017
  3. Offline

    mythbusterma

    @OutbackCanadian

    The issue is that the enhanced for loop doesn't have a type for the variable "item," which is required in the context.

    Just out of curiosity, whose plugin are you stealing?
     
Thread Status:
Not open for further replies.

Share This Page