Solved Saving Objects to Config Storing Unnecessary Data

Discussion in 'Plugin Development' started by zachoooo, Aug 14, 2013.

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

    zachoooo

    So I'm creating this Keypad plugin, basically you can turn any block into a keypad and it will send out a redstone signal if the correct key is entered.

    Whenever I try and save a keypad to my keypad list, it contains much more data than is necessary:
    Code:
    keypads:
    - !!us.zsugano.keypad.KeypadBlock
      location:
        pitch: 0.0
        world: !!org.bukkit.craftbukkit.v1_6_R2.CraftWorld
          PVP: true
          ambientSpawnLimit: 15
          animalSpawnLimit: 15
          autoSave: true
          difficulty: EASY
          environment: NORMAL
          fullTime: 18385339
          keepSpawnInMemory: true
          monsterSpawnLimit: 70
          thunderDuration: 89202
          thundering: false
          time: 1339
          waterAnimalSpawnLimit: 5
          weatherDuration: 100377
        x: -27.0
        y: 66.0
        yaw: 0.0
        z: 6.0
      owner: zachoooo
      password: null
    
    For some reason it's saving pitch, yaw, and all this other information.
    It should only be saving
    x,y,z,world(which is a string!) and password.

    Here is my code for saving the keypad:
    https://github.com/zachoooo/Keypad/blob/master/src/us/zsugano/keypad/config/KeypadConfig.java
    EDIT: My code also seems to not identify the location properly when I right click on the keypad

    EDIT EDIT:
    After attempting to save some more keypads, I'm getting this:
    Code:
    - !!us.zsugano.keypad.KeypadBlock
      location:
        pitch: 0.0
        world: *id001
        x: -30.0
        y: 66.0
        yaw: 0.0
        z: 6.0
      owner: zachoooo
      password: null
    This still isn't the right world name and its still including pitch and yaw for some reason
     
  2. Offline

    Chinwe

    For location, you should have a method to split it up into the useful parts that you want:
    Code:
        public static String friendlyLocation(Location loc)
        {
     
            return (int) loc.getX() + ", " + (int) loc.getY() + ", " + (int) loc.getZ();
     
        }
    That would return, for example, 100, 64, 200 instead of everything with yaw and pitch etc
     
  3. Offline

    zachoooo

    I don't get how that would help considering I'm using my own variant of location class.
    https://github.com/zachoooo/Keypad/blob/master/src/us/zsugano/keypad/utils/SerializableLocation.java

    Fixed by implementing ConfigurationSerializable

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 3, 2016
Thread Status:
Not open for further replies.

Share This Page