Cant load/check locations in config.

Discussion in 'Plugin Development' started by Mitchh53, Sep 20, 2018.

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

    Mitchh53

    Hi all I have been working on a plugin to set a block where the player is looking, the location gets saved to that block in a config file. then whenever a player walks over this block it acts as a jumppad. However... It wont load the location from the config after a reload. Please help

    Main > https://pastebin.com/0MAsQBtn

    Listener > https://pastebin.com/kJ2giJtP

    create/remove pad > https://pastebin.com/TcNbexWP

    Btw i have a lot of unused stuff, just leaving it for now but i just need help with the location loading and checking
     
  2. Try adding saveConfig(); in the onDiable
     
  3. Offline

    KarimAKL

    @Mitchh53 I’m on my phone at the moment so i can’t see the code that well but i don’t see you saving it to the config anywhere, anyway when you do remember to save the config after changing it.
     
  4. Offline

    Mitchh53

    @danichef @KarimAKL Nah it does save,
    Code:
    block:
      Test2:
        location:
          ==: org.bukkit.Location
          world: world
          x: 866.0
          y: 83.0
          z: 278.0
          pitch: 0.0
          yaw: 0.0
      Test3:
        location:
          ==: org.bukkit.Location
          world: world
          x: 862.0
          y: 83.0
          z: 281.0
          pitch: 0.0
          yaw: 0.0
    
    Thats what it looks like in its config file, But i just need to know how to check for the block the player is on and if it equals the same as one of the blocks under config then do the launchboost thing.
     
    Last edited by a moderator: Sep 22, 2018
  5. Offline

    KarimAKL

    @Mitchh53 You are saving the location object, just save the World, X, Y, Z, Pitch and Yaw.
     
  6. Offline

    Mitchh53

    how do i pull these out of config and check for that block?
     
  7. Offline

    KarimAKL

    @Mitchh53 I would probably do something like this:
    Code:Java
    1. //Saving to the config
    2. getConfig().set("block.test.location.world", location.getWorld().getName());
    3. getConfig().set("block.test.location.x", location.getBlockX());
    4. getConfig().set("block.test.location.y", location.getBlockY());
    5. getConfig().set("block.test.location.z", location.getBlockZ());
    6. saveConfig();
    7.  
    8.  
    9. //Getting and using location
    10. World world = Bukkit.getWorld(getConfig().getString("block.test.location.world"));
    11. int x = getConfig().getInt("block.test.location.x");
    12. int y = getConfig().getInt("block.test.location.y");
    13. int z = getConfig().getInt("block.test.location.z");
    14. Block block = world.getBlockAt(x,y,z);
    15. //check if the block the player is standing on equals 'block'

    Please let me know if i misunderstood something.
     
Thread Status:
Not open for further replies.

Share This Page