Why doesnt this update?

Discussion in 'Spigot Plugin Development' started by Kyllian, Apr 15, 2017.

  1. Hey.

    When I enter something in my hashmap it works fine. But my runnable dont seem to update it?

    This gets succesfully called:
    data.timeLeft.put(uuid, main.getConfig().getInt("Delay"));
    Bukkit.broadcastMessage(data.timeLeft.get(uuid).toString());

    But my runnable:

    Code (Text):
    public void runnableRunner() {
            new BukkitRunnable() {
                @Override
                public void run() {
                    if (data.timeLeft.isEmpty()) {
                        Bukkit.broadcastMessage("empty");
                        return;
                    }
                    if (!data.timeLeft.isEmpty()) {
                        for (String uuid : data.timeLeft.keySet()) {

                            int timeLeftOld = data.timeLeft.get(uuid);
                            data.timeLeft.remove(uuid);
                            data.timeLeft.put(uuid, timeLeftOld - 1);
                            Bukkit.broadcastMessage(data.timeLeft.get(uuid).toString());

                            if (data.timeLeft.get(uuid) == 0) {
                                data.timeLeft.remove(uuid);
                                // close things
                                // execute commands
                            }
                        }
                    }
                }
            }.runTaskTimer(this, 0, 20);
    Keeps saying empty. What is wrong?
     
  2. Basic debugging steps. First of all check for null values. Print the values you put inside of the map to the console. Second thing, look at the scopes of your variables. If this is another method, make sure you pass it correctly or assign it to a field.