ConfigurationSections help required

Discussion in 'Plugin Development' started by MordorKing78, Nov 19, 2016.

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

    MordorKing78

    Heyo! Okay so I am making this plugin right that needs to access to different sections of the configuration, this is how I store it:

    Code:
    Generators:
      '1':
        owner: 80a50df1-ca2b-4293-ad15-1b4f36f723e4
        type: gold
        level: 1
        speed: 1
        cap: 1
        location:
          X: -225.0
          Y: 78.0
          Z: -6.0
          World: world
      '2':
        owner: 80a50df1-ca2b-4293-ad15-1b4f36f723e4
        type: iron
        level: 1
        speed: 5
        cap: 1
        location:
          X: -228.0
          Y: 78.0
          Z: -6.0
          World: world
      '3':
        owner: 80a50df1-ca2b-4293-ad15-1b4f36f723e4
        type: diamond
        level: 1
        speed: 10
        cap: 1
        location:
          X: -231.0
          Y: 78.0
          Z: -6.0
          World: world
    
    What I need, I need to get the speed of an integer and then if the integer has a higher speed then the others it should drop the item faster.

    Code (I do understand why it's not working, I just don't understand how I WOULD make it working.)

    PHP:
    new BukkitRunnable(){                                                                    
                public 
    void run(){
                    for(
    String key gen.getConfigurationSection("Generators").getKeys(false)){
                        
    Location loc GeneratorManager.getGeneratorLocation(key).add(0,1,0);
                       
                        
    String type gen.getString("Generators." key ".type");
                        
    Integer speed gen.getInt("Generators." key ".speed");

                        
    int standTime 20*60//1200 ticks (1 minuut)
                        
    int ticksRequired standTime/speed;
                       
                        if(
    math >= ticksRequired){                                           
                            
    GeneratorManager.dropItem();
                           
                            
    math=0;
                        }else{
                            
    math++;                           
                        }
                                       
                    }
                }
            }.
    runTaskTimer(this01);    
     
  2. Offline

    Zombie_Striker

  3. Offline

    MordorKing78

    @Zombie_Striker Well, Sorry but I'm finding this very hard to explain.
    What I'm trying to do is have different speeds for different generators. So it should check what speed level an generator is and then it should check if it has reached the right amount of ticks to drop 1 item on the location of the generator, I can make it so it drops for every generator but I can't seem to do it for every generator seperately.
     
  4. Offline

    ipodtouch0218

    Can you output what
    Code:
    Integer speed = gen.getInt("Generators." + key + ".speed")
    is returning?
     
  5. Offline

    MordorKing78

    @ipodtouch0218 I tried that before and it returns the levels in the following format:
    Code:
    1
    5
    10
     
  6. Offline

    ipodtouch0218

    @MordorKing78
    Looking at your code again, why are you using "Integer" instead of "int"?
    "Integer" is a class/wrapper (which is why you can do Integer.parseInt()), and int is a primitive (data storing) type.

    (Autoboxing may make my statement invalid)
     
  7. Offline

    MordorKing78

    @ipodtouch0218 Well, I don't know actually I tend to switch between them a lot, whenever I feel like typing Integer I type integer, but still tho. That wouldn't solve my problem.

    Anyone?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Nov 20, 2016
Thread Status:
Not open for further replies.

Share This Page