For loop not working?

Discussion in 'Spigot Plugin Development' started by xguysprison, Aug 6, 2018.

  1. Hey guys for some reason this is not working when im on red team but it works when im on blue team if i click on the ready button while being on the red team nothing happens and i just pickup the ready button glass thing but if i click on the ready button while being on the blue team it works fine what have i done wrong?
    This is the GUI: https://gyazo.com/717ba4d20a6c3c1f0a9588a6710a6b67

    code:
    Code (Java):
                if (Clicked.equals(KitSelector.ready())) {
                    if (Main.getInstance().getTeamManager().isInBlueTeam(player)
                            || Main.getInstance().getTeamManager().isinReadTeam(player)) {
                        int slots = 8;

                        for (int i = 0; i < slots; i++) {
                            if (KitSelector.teamSelector.getItem(i) == null) {
                                player.sendMessage("yeet1");
                                return;
                            }
                            if (KitSelector.teamSelector.getItem(i).getType() != Material.SKULL_ITEM) {
                                player.sendMessage("yeet2");
                                return;
                            }
                            if (!KitSelector.teamSelector.getItem(i).hasItemMeta()) {
                                player.sendMessage("yeet3");
                                return;
                            }
                            if (!KitSelector.teamSelector.getItem(i).getItemMeta().hasDisplayName()) {
                                player.sendMessage("yeet4");
                                return;
                            }
                            if (KitSelector.teamSelector.getItem(i).getItemMeta().getDisplayName()
                                    .equals(ChatColor.RED + player.getName())
                                    || KitSelector.teamSelector.getItem(i).getItemMeta().getDisplayName()
                                            .equals(ChatColor.BLUE + player.getName())) {
                                int number = (9 + i);
                                player.sendMessage(String.valueOf(number));
                                KitSelector.teamSelector.setItem(number, KitSelector.isReady());
                                player.playSound(player.getLocation(), Sound.GHAST_MOAN, 10, 10);
                                event.setCancelled(true);

                            }
                        }
                    } else {
                        player.sendMessage(ChatUtilties.chat("&8[&c*&8] &7Select a team!"));
                        event.setCancelled(true);
                    }
                }
     
  2. debug all the results. Debug the player's name so as to see if the if statement you have put in the very bottom is correctly set.
     
    • Agree Agree x 1