[SOLVED] Checking for Configuration

Discussion in 'Plugin Development' started by number1_Master, Aug 23, 2012.

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

    number1_Master

    I'm trying to create a plugin where when you type a command, it gets the portal you are looking at, then creates some configuration, but I'm having trouble checking if the configuration exists.

    My config (by default) looks like this:
    Code:
    Links: ''
    As soon as a world is added, it should look like this:
    Code:
    Links:
      world1: x y z world2
    I've had many attempts. Here is my last attempt (under onCommand).
    Code:java
    1. Location loc = player.getTargetBlock(null, 200).getLocation();
    2. String portalLoc = Math.round(loc.getX()) + " " + Math.round(loc.getY()) + " " + Math.round(loc.getZ()) + " " + args[0];
    3. if(plugin.getConfig().getConfigurationSection("Link").contains(loc.getWorld().getName()))
    4. {
    5. plugin.getConfig().createSection("Link." + loc.getWorld().getName());
    6. }
    7. plugin.getConfig().set("Link." + loc.getWorld().getName(), portalLoc);

    The error always occurs on 3 (of the above code).


    Please help!
     
  2. Offline

    Jnorr44

  3. Offline

    number1_Master

    Wow ... I forgot to watch the tread ... so I ended up figuring this entire thing out myself ...

    But thanks!

    EDIT: What I was looking for was to add a configuration node when the command was executed ... but first I needed to find out how to check if it already exists!
     
  4. Offline

    Jnorr44

    Alright, good job though!
     
Thread Status:
Not open for further replies.

Share This Page