Solved Issue saving block to file

Discussion in 'Plugin Development' started by shades161, Jul 27, 2015.

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

    shades161

    Im trying to make a minigame plugin, and I need to save blocks and their location to a yml file to restore them later. However, when I do so, it saves the proper location, but if I save the block type its always AIR even if there is another type of block at that location. I tried the deprecated method of TypeId() with just saved the integer as 0 for air. Anyone able to help?
    Code for saving the data:
    Code:
        public static void saveRegenBlocks(String Id, Cuboid original) { //Saves blocks to file.
            FileConfiguration regionCache = ArenaFiles.getRegionCacheYml(Id);
            File regionCacheFile = ArenaFiles.getRegionCacheFile(Id);
            for (Block originalBlock : original.getBlocks()) {
                String orBlockLocString = originalBlock.getLocation().toString();
                int orBlockType = originalBlock.getTypeId();
                regionCache.set(Id + "." + orBlockLocString + ".Type", orBlockType);
                Main.plugin.saveCustomConfig(regionCache, regionCacheFile);
            }
        }
    Example of what it looks like saved:
    Code:
      Location{world=CraftWorld{name=LavaWall},x=12:
        0,y=64:
          0,z=0:
            0,pitch=0:
              0,yaw=0:
                0}:
                  Type: 0
        0,y=65:
          0,z=0:
            0,pitch=0:
              0,yaw=0:
                0}:
                  Type: 0
        0,y=66:
          0,z=0:
            0,pitch=0:
              0,yaw=0:
                0}:
                  Type: 0
        0,y=67:
          0,z=0:
            0,pitch=0:
              0,yaw=0:
                0}:
                  Type: 0
      Location{world=CraftWorld{name=LavaWall},x=13:
        0,y=64:
          0,z=0:
            0,pitch=0:
              0,yaw=0:
                0}:
                  Type: 0
        0,y=65:
          0,z=0:
            0,pitch=0:
              0,yaw=0:
                0}:
                  Type: 0
        0,y=66:
          0,z=0:
            0,pitch=0:
              0,yaw=0:
                0}:
                  Type: 0
        0,y=67:
          0,z=0:
            0,pitch=0:
              0,yaw=0:
                0}:
                  Type: 0
    Ps: I have already tried ArrayLists and HashMaps, nether seemed to work.
     
  2. Offline

    Lolmewn

    You know what you get when you do location.toString()? Tip: It has dots. You know what also has dots? That's right! YML paths!
     
  3. Offline

    shades161

    @Lolmewn I feel very stupid now, but thank you for pointing it out.
     
Thread Status:
Not open for further replies.

Share This Page