Solved for loop isnt couting

Discussion in 'Spigot Plugin Development' started by narcostic, Mar 23, 2020.

Thread Status:
Not open for further replies.
  1. Why the for Loop isnt counting?
    For Loop stays at 0.
    Code (Java):
     else if(sign.getLine(0).equals("§c[Master Chest]")) {
                            int x = 2;
                            int d = 0;
                            int bx = c1.getInt(p.getUniqueId() + "." + "Slave." + "Koordinaten." + x + "." + "x");
                            int by = c1.getInt(p.getUniqueId() + "." + "Slave." + "Koordinaten." + x + "." + "y");
                            int bz = c1.getInt(p.getUniqueId() + "." + "Slave." + "Koordinaten." + x + "." + "z");
                            String bid = c1.getString(p.getUniqueId() + "." + "Slave." + "Koordinaten." + x + "." + "ID");
                       
                            BlockState bs = e.getPlayer().getWorld().getBlockAt(bx - 1, by , bz).getState();
                            Chest chest = (Chest) bs;
                            Material m = Material.matchMaterial(bid);
                            for(; d <= 54 ;) {
                                p.sendMessage(d + "");
                                //ItemStack i = new ItemStack(m);
                                if(!(m == c.getInventory().getItem(d).getType())) {
                                    d++;
                                } else {
                                    ItemStack stick = new ItemStack(Material.STICK);
                                    chest.getInventory().addItem(stick);
                                    p.sendMessage("Right");
                                    return;
                                }
                            }
                     } else {
                         p.sendMessage("Wrong sign");
                     }
     
  2. Code (Java):
    for(int d = 0; d != 54; d++) {
    //code
    }
     
  3. I have the same code?
     
  4. Nope you have
    Code (Java):
    for(; d <= 54 ;) {
    // code
    }
     
  5. Yeah but i set d as 0 and have d++. But your version isnt working too
     
  6. Code (Text):
    while(d<=54){
      //code
    }
     
  7. Make sure m is not null...
     
  8. Yeah sorry this was the problem. I realised this to late.
     
    • Like Like x 1
Thread Status:
Not open for further replies.