Checking which arena is enabled?

Discussion in 'Plugin Development' started by bcohen9685, Aug 4, 2016.

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

    bcohen9685

    Hi, I'm not sure if I'm missing a basic method or something I could use to make this a lot simpler, because I would hate to overcomplicate this.

    Currently, I have to use this:
    Code:
    if(plugin.getConfig().getString("enabledMap.Arena1").equals("true")){
              
            } else if(plugin.getConfig().getString("enabledMap.Arena2").equals("true")){
              
            } else if(plugin.getConfig().getString("enabledMap.Arena3").equals("true")){
              
            } else if(plugin.getConfig().getString("enabledMap.Arena4").equals("true")){
              
            }
    
    I select a random arena on startup and change the specific line to true. Perhaps I'm missing out on something?
     
  2. Offline

    ArsenArsen

    for loop through arenas, and also use getBoolean(i think it is)
     
  3. Offline

    bcohen9685

    Yeah, I switched it all to booleans last night.

    So you want me to iterate through every single key, how would I go about doing that?
     
  4. Offline

    x_Jake_s

    so this is a guess based on how you have set yourself up. you are checking that when the game starts a specific map is checked to true. while all other maps are checked false. I would create a Boolean called arena1 - arena4 then in the //blah blach do this... area I would check that specific Boolean to true and then in any other function containing the arena just check that the arena you want is true

    Code:
    
    public void isEnabled() {
    
    [code]if(plugin.getConfig().getString("enabledMap.Arena1").equals("true")) {
    
    //blah blach do this,
    
    return;
    
    
            } else if(plugin.getConfig().getString("enabledMap.Arena2").equals("true")) {
    
    //blah blach do this,
    
    return;
    
            } else if(plugin.getConfig().getString("enabledMap.Arena3").equals("true")) {
    
    //blah blach do this,
    
    return;
    
            } else if(plugin.getConfig().getString("enabledMap.Arena4").equals("true")) {
    
    //blah blach do this,
    
    return;
    
            }
    
    }
    I don't know if that is any better or help at all but that's the best I can explain it if this doesn't help I'm sorry.
     
Thread Status:
Not open for further replies.

Share This Page