Using Player Lists

Discussion in 'Plugin Development' started by BlazingBroGamer, May 3, 2014.

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

    BlazingBroGamer

    So I was trying to find out why this wasn't working. So I added a player into a list when they joined, and then later on, checked if the player was in the list, but for some reason, it returned false, even though there was absolutely no way it got removed. I checked the whole code for it. So this is part of the code I used, and checked:
    Code:
    //PlayerJoinEvent
        @EventHandler
        public void pje(PlayerJoinEvent e){
            Player p = e.getPlayer();
            tributes.add(p);
        }
    //Checking for player
    if(bl.tributes.contains((CraftPlayer)p) == true){
                    int seconds = countdown.get(p) % 60;
                    int minutes = countdown.get(p) / 60;
                    obj.setDisplaySlot(DisplaySlot.SIDEBAR);
                    if(plugin.bl.started == true){
                    if(seconds < 10){
                        String displayTime = minutes + ":0" + seconds;
                        obj.setDisplayName(ChatColor.AQUA.toString() + ChatColor.BOLD + "Remaining Time: " + ChatColor.GRAY + displayTime);
                        countdown.put(p, countdown.get(p) - 1);
                        return;
                    }else if(seconds >= 10){
                        String displayTime = minutes + ":" + seconds;
                        obj.setDisplayName(ChatColor.AQUA.toString() + ChatColor.BOLD + "Remaining Time: " + ChatColor.GRAY + displayTime);
                        countdown.put(p, countdown.get(p) - 1);
                        return;
                    }if(countdown.get(p) == 0){
                        for(Player p : Bukkit.getOnlinePlayers()){
                            p.setHealth(0.0);
                        }
                        Bukkit.getServer().broadcastMessage(ChatColor.GRAY + "[" + ChatColor.AQUA + "GSG" + ChatColor.GRAY + "]" + ChatColor.GOLD + "Times Up! Everyone died.");
                    }
                    }else if(!plugin.bl.started){
                        obj.setDisplayName(ChatColor.AQUA.toString() + ChatColor.BOLD + "Pre - Game");
                    }
    
    So... Any help? I imported all from Bukkit. I checked
     
  2. Try using their name, rather than the Player object. It prevents Memory Leaks, and their name will never change while they are in-game.
     
  3. Offline

    Rocoty

    Post the whole class and main class please.
     
Thread Status:
Not open for further replies.

Share This Page