Get button name from config using x y z

Discussion in 'Plugin Development' started by Sahee, Feb 24, 2013.

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

    Sahee

    Hello! How can i get name from this config using just x, y, z?

    Code:
    Buttons:
    name:
      x: 10
      y: 10
      z: 10
      range-min: 100
      range-max: 1000
    because i have to create remove command. And i dont have any idea how i can do this lol.
     
  2. Offline

    sirkarpfen

    Well i dont think, this is possible. Usually you need a section to get a key from. I dont think, there is a way to do this from the other side.
     
  3. Offline

    TomTheDeveloper

    Fileconfiguration config;
    .....

    namex =config.getInt(Buttons.name.x);
    ...
    (do the same for y and z)
    Then

    Location name = new location(namex, namey, namez);
     
  4. Offline

    Sahee

    But i don't know name. I just know x y z

    Code:
        Player player = (Player) s;
        Location lokacja = player.getTargetBlock(null, 50).getLocation();
       
        x = lokacja.getBlockX();
        y = lokacja.getBlockY();
        z = lokacja.getBlockZ();
    and i have to get name to delete this from config file
     
  5. Offline

    TomTheDeveloper

    I think that you should know the name, otherwise it is impossble to get the x,y,z coordinates
     
  6. Offline

    Neodork

    Instead of giving it a name you can use the X-Y-Z as "name" and put name underneath the X-Y-Z memory section. Or you could scroll trough all names and check the X-Y-Z until you found the corresponding co-ordinates.
     
    Sahee likes this.
  7. Offline

    jtjj222

    Say the config was like this:
    Code:
    someotherconfigvalue: value
    buttons:
      buttonname1:
        x:
        y:
        z:
      buttonname2:
        ...and so on
    
    You would do this:
    Code:java
    1.  
    2. ConfigurationSection buttons = getConfig().getConfigurationSection("buttons");
    3. for (String buttonname : buttons.getKeys()) {
    4. ...the rest from here
    5. }
    6.  
     
    Sahee likes this.
  8. Offline

    Sahee

    Thanks Neodork :)!
     
Thread Status:
Not open for further replies.

Share This Page