Solved ArrayList.size() not 0 after removal of player name??

Discussion in 'Plugin Development' started by Edvio, Oct 8, 2016.

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

    Edvio

    EDIT: I figured it out


    I've been working on a point system with a capzone. It works the first time, but when I remove the player from the arraylist it doens't seem like the arraylist size goes back to 0.

    Code:
    Code:
        @EventHandler
        public void onCapEnter(RegionEnterEvent e) {
            Player p = e.getPlayer();
            if(e.getRegionName().equalsIgnoreCase("capzone")) {
                if(capper.size() == 0) {
                if(Teams.blueteam.contains(p.getName())) {
                Bukkit.broadcastMessage(ChatColor.translateAlternateColorCodes('&', "&9" + p.getName() + " &ehas started capping!"));
                }
                else if(Teams.redteam.contains(p.getName())) {
                    Bukkit.broadcastMessage(ChatColor.translateAlternateColorCodes('&', "&c" + p.getName() + " &ehas started capping!"));
                }
                i = new BukkitRunnable() {
                public void run() {
                    capper.add(p.getName());
                    Bukkit.broadcastMessage(ChatColor.BLUE + String.valueOf(Points.points.get("blue")));
                    Bukkit.broadcastMessage(ChatColor.RED + String.valueOf(Points.points.get("red")));
                    if(Teams.blueteam.contains(p.getName())) {
                        if(Points.points.get("blue") == null) {
                            Points.points.put("blue", 1);
                        }else {
                    Points.points.put("blue", Points.points.get("blue") + 1);
                    }
                        }else if(Teams.redteam.contains(p.getName())) {
                            if(Points.points.get("red") == null) {
                                Points.points.put("red", 1);
                            }else {
                        Points.points.put("red", Points.points.get("red") + 1);
                        }
                        }
                }
                }
                .runTaskTimer(this, 20L, 20L);
        }
        }
        }
            @EventHandler
            public void onCapLeave(RegionLeaveEvent e) {
                Player p = e.getPlayer();
                if(e.getRegionName().equalsIgnoreCase("capzone")) {
                    if(capper.contains(p.getName())) {
                      
                        if(Teams.blueteam.contains(p.getName())) {
                            Bukkit.broadcastMessage(ChatColor.translateAlternateColorCodes('&', "&9" + p.getName() + " &cis no longer capping!"));
                            }
                            else if(Teams.redteam.contains(p.getName())) {
                                Bukkit.broadcastMessage(ChatColor.translateAlternateColorCodes('&', "&c" + p.getName() + " &cis no longer capping!"));
                            }
            }
            }
        }
     
    Last edited: Oct 8, 2016
  2. Offline

    Firestar311

    Just a suggestion, if you could provide worth the way you solved for others who might have a similar problem
     
Thread Status:
Not open for further replies.

Share This Page