Go trough coordinates and spawn x

Discussion in 'Plugin Development' started by jebbo, May 26, 2014.

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

    jebbo

    Hey, i dont really work with stuff like this, so my question is,

    how can i make a "loop" or something like that, wich goes through all setted spawns,
    and spawns a mob at the coordinates / location

    a spawnpoint is build up like this:
    Code:
      '1':
        x: 163.69999998807907
        y: 74.0
        z: 125.30000001192093
        world: world
    maybe something like this, found on google

    Code:java
    1. ArrayList<Integer> list = new ArrayList<Integer>();
    2. for (Iterator i = list.iterator(); i.hasNext();) {
    3.  
    4. //i can check whether this is last item
    5. if(i.hasNextItem()){
    6. }
    7.  
    8. }


    but how would i get all my setted spawns in the array list?

    thank you
     
  2. Offline

    MCForger

    jebbo
    You can create a configurationsection called spawns then save the spawnpoints under that.
    Then when you want to load them do this:
    Code:java
    1. ConfigurationSection section = config.createSection("spawnpoints");

    Code:java
    1. for (String rawIndex : section.getKeys(false))
    2. {
    3. ConfigurationSection rawLocation = section.getConfigurationSection(rawIndex);
    4. String worldName = rawLocation.getString("world");
    5. int x = rawLocation.getInt("x");
    6. int y = rawLocation.getInt("y");
    7. int z = rawLocation.getInt("z");
    8. // Do whatever
    9. }

    Please keep in mine if there is any spelling issues, I just coded this on my phone.
     
    jebbo likes this.
Thread Status:
Not open for further replies.

Share This Page