Solved for loop error?

Discussion in 'Plugin Development' started by GijsCo, Mar 22, 2017.

Thread Status:
Not open for further replies.
  1. Hey thanks for clicking on my post! I was working on a plugin but than i came across a problem.
    My for loop does not work.

    Code:
    public class BMKLists
    {
    
        public static HashMap<UUID, Long> BANTIME = new HashMap<UUID, Long>();
        public static HashMap<UUID, Long> MUTETIME = new HashMap<UUID, Long>();
    
        public void load()
        {
    
            BMKYml.get().createSection("ban");
            BMKYml.get().createSection("mute");
    
            for (String s : BMKYml.get().getConfigurationSection("ban").getKeys(false))
            {
                Bukkit.broadcastMessage("test");
    
                UUID uuid = UUID.fromString(s);
                long time = BMKYml.get().getInt("ban." + s);
                BANTIME.put(uuid, time);
            }
    
            for (String s : BMKYml.get().getConfigurationSection("mute").getKeys(false))
            {
                UUID uuid = UUID.fromString(s);
                long time = BMKYml.get().getInt("mute." + s);
                MUTETIME.put(uuid, time);
            }
        }
    }
    
    my yml file
    Code:
    ban:
      1edf7356-1f89-4605-bd09-1f2c7a8c7050: 1490183963167
      1edf7356-1f89-4605-bd09-1dfc7a8c7050: 1490183963167
      1edf7356-1f89-4605-bd09-8dfn7a8c7050: 1490183963167
    mute: {}
    

    i was wondering maybe you guys could find out what is wrong.
    it just doesn't do anything

    and yes this method is called in my onEnable
     
  2. Offline

    mine-care

    @GijsCo Is the problem really solved? If yes please provide the solution to the problem for future reference. ;)
    also I see :
    are those attempts to make constant variables or is it 'static for easy access'?
     
  3. @mine-care
    those are constant variables.
    And i fixed btw.
    BMKYml.get().createSection("ban");
    BMKYml.get().createSection("mute");
    those 2 lines where the problem i don't really know why it wouldn't wotk with these lines. But i just putted an if statement if the sections didn't exist than create the sections.
     
  4. Offline

    mine-care

    Well static variables =/= constant variables. A constant is a static and final variable ;)
     
Thread Status:
Not open for further replies.

Share This Page