StructureToCsv icon

StructureToCsv -----

Copies a Structure to a Csv file that can be pasted at a later time



Small little plugin I made for myself that I thought others might find useful.

Use
to create a tab delimited csv file in this plugins resources directory.

Then if you want, you can do
to paste it somewhere.

But if you're like me, and need to be dynamically loading the structures in a different plugin, you can copy this class and load the csv programmatically:

Code (Text):
public class CsvLoader {

    public static void loadCsv(World w, String pathToCsvFile, Integer startX, Integer startY, Integer startZ) {
        List<List<String>> blocks;
        try {
            blocks = loadBlockList(new FileReader(pathToCsvFile));
        } catch (FileNotFoundException e) {
            throw new RuntimeException(e);
        }
        for (List<String> blockRecord : blocks) {
            int xOffset = Integer.parseInt(blockRecord.get(0)), yOffset = Integer.parseInt(blockRecord.get(1)), zOffset = Integer.parseInt(blockRecord.get(2));
            Material blockType = Material.getMaterial(blockRecord.get(3));
            String blockDataSerialized = blockRecord.get(4);
            Block block = w.getBlockAt(startX + xOffset, startY + yOffset, startZ + zOffset);
            block.setType(blockType);
            block.setBlockData(Bukkit.createBlockData(blockDataSerialized));
        }
    }

    private static List<List<String>> loadBlockList(FileReader structureFileReader) {
        List<List<String>> blocks = new ArrayList<>();
        try (BufferedReader br = new BufferedReader(structureFileReader)) {
            String line;
            while ((line = br.readLine()) != null) {
                String[] values = line.split("\t");
                blocks.add(Arrays.asList(values));
            }
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        return blocks;
    }
}


My discord: https://discord.gg/s4F8VEHegN
Resource Information
Author:
----------
Total Downloads: 41
First Release: Apr 7, 2024
Last Update: Jul 6, 2024
Category: ---------------
All-Time Rating:
0 ratings
Find more info at discord.gg...
Version -----
Released: --------------------
Downloads: ------
Version Rating:
----------------------
-- ratings