Solved Not getting x, z of chunk

Discussion in 'Plugin Development' started by xXMaTTHDXx, Jul 30, 2014.

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

    xXMaTTHDXx

    Ok, so my config is organized like this:
    Code:
    T:
      chunks:
        '1':
          x: 16
          z: 6
      mayors: &id001
      - 4b591e4d-7d12-4d2d-b091-935a0a7b1290
      - 4b591e4d-7d12-4d2d-b091-935a0a7b1290
      claimedChunks: 1
    Town_List:
    - T
    - Z
    I have 2 methods to get the X and Z from the list:
    Code:java
    1. public double getX(String townName, int chunkID) {
    2. return getTowns().getDouble(townName + ".chunks." + chunkID + ".x");
    3. }
    4.  
    5. public double getZ(String townName, int ChunkID) {
    6. return getTowns().getDouble(townName + ".chunks." + ChunkID + ".z");
    7. }


    When creating a town I use this code to ensure that the chunk isnt already claimed:
    Code:java
    1. for (String s : plugin.getTowns().getKeys(true)) {
    2. for(int i = 1; i < plugin.getChunksClaimed(s); i++){
    3. Chunk loopChunk = p.getWorld().getChunkAt((int)plugin.getX(s, i), (int)plugin.getZ(s, i));
    4. if(chunk == loopChunk){
    5. p.sendMessage(ChatColor.RED
    6. + "You cant create a town inside "
    7. + ChatColor.WHITE + s);
    8. System.out.println(plugin.getX(s, i));
    9. i++;
    10. return true;
    11. }
    12. }
    13. }

    But the problem with this is it is still letting me create a town inside of another owned chunk, which obviously isnt going to work. Please help me out!

    EDIT: I also forgot to mention that it worked before I tried adding multiple chunks(Chunk list).
     
  2. Offline

    Totom3

    xXMaTTHDXx Do you get the "You can't create a town inside [...]" message when you enter the command/execute this code ? Did you try to compare the chunks with .equals() or by checking if their X and Z coordinates are the same ?
     
  3. Offline

    xXMaTTHDXx

    Totom3 Sorry, I solved this a long while ago!
     
    Totom3 likes this.
Thread Status:
Not open for further replies.

Share This Page