Config not writing world correctly.

Discussion in 'Plugin Development' started by canemonster15, Aug 20, 2013.

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

    canemonster15

    This is what it looks like in the config.
    Code:
    Knock-Off:
      X: -203.27357918129775
      Y: 70.0
      Z: 4.293470052672335
      World: &id001 !!org.bukkit.craftbukkit.v1_6_R2.CraftWorld
        PVP: true
        ambientSpawnLimit: 15
        animalSpawnLimit: 15
        autoSave: true
        difficulty: EASY
        environment: NORMAL
        fullTime: 124835
        keepSpawnInMemory: true
        monsterSpawnLimit: 70
        thunderDuration: 123632
        thundering: false
        time: 4835
        waterAnimalSpawnLimit: 5
        weatherDuration: 61403
    Why does it put all of that random stuff?

    Here is my java.
    Code:java
    1. if(cmd.getName().equalsIgnoreCase("knockoff")){
    2. if(args.length == 0){
    3. sender.sendMessage(prefix + "Please specify a command.");
    4. }else if(args.length == 1){
    5. if(args[0].equalsIgnoreCase("create")){
    6. if(!sender.hasPermission("knockoff.create")){
    7. sender.sendMessage(prefix + "Insufficient Permission!");
    8. }else{
    9. double x = player.getLocation().getX();
    10. double y = player.getLocation().getY();
    11. double z = player.getLocation().getZ();
    12. World w = Bukkit.getServer().getPlayer(player.getName()).getLocation().getWorld();
    13. this.getConfig().set("Knock-Off.X", x);
    14. this.getConfig().set("Knock-Off.Y", y);
    15. this.getConfig().set("Knock-Off.Z", z);
    16. this.getConfig().set("Knock-Off.World", w);
    17. this.saveConfig();
    18. player.sendMessage(prefix + "Arena Created!");
    19. }
     
  2. Offline

    Polaris29

    canemonster15 It actually is writing the world correctly. You're setting a world object to a config value, that includes it's attributes (difficulty, PVP, etc.).

    It looks like you're saving a location, so couldn't you just save the world name instead of the world, then use "Bukkit.getWorld(String name)" on that config value?
     
    Samthelord1 likes this.
  3. Offline

    canemonster15

  4. Offline

    Saposhiente

    world.getName()
    that's all you need to save
     
Thread Status:
Not open for further replies.

Share This Page