Solved This loop doesnt works perfectly

Discussion in 'Plugin Development' started by user_91277742, Jul 4, 2018.

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

    user_91277742

    Hello there! , so the problem is, When i want to run the command, just Im teleported and not the other people in the hashmap.

    Here the command
    Code:
                        if(args[0].equalsIgnoreCase("terminar")) {
                                if(isStarted == true){
                                    for (Player asd: Bukkit.getOnlinePlayers()) {
                                        if(main.oldLoc.containsKey(player.getUniqueId())){
                                            main.leave(asd);
                                            clase.sendMessage(ChatColor.RED + "Finished");
                                            isStarted = false;
                                            isCreated = false;
                                        }
                                    }
                                }
                            }
                        }
    
    Here the method in mainClass
    Code:
        public void leave(Player p){
            if(oldLoc.containsKey(p.getUniqueId())){
                Location loc = oldLoc.get(p.getUniqueId());
                p.teleport(loc);
                oldLoc.remove(p.getUniqueId());
            }
        }
    
     
  2. Offline

    Zombie_Striker

    @Ahrigumi
    Try printing out statements within the loop. Print out which players are being looped through. Print out if the player is in oldLoc. Print out if main.leave is ever called.
     
  3. Offline

    Tabuu_

    I asume you ment to do main.oldLoc.containsKey(asd.getUniqueId())
     
  4. Offline

    user_91277742

    @Tabuu_ Omg.. Im so stupid, Was that yes, Thank you ^^
     
  5. Offline

    KarimAKL

    @Ahrigumi Remember to change the title prefix to solved.
     
Thread Status:
Not open for further replies.

Share This Page