Small little plugin I made for myself that I thought others might find useful.
Use
/createcsv <filename> <starting_location> <ending_location>
to create a tab delimited csv file in this plugins resources directory.
Then if you want, you can do
/loadcsv <filename> <starting_location>
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:
CsvLoader.java
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
Similar projects
Plugin →Let Me Despawn
Improves performance by tweaking mob despawn rules. Say bye to pesky unintentional persistent mobs.
25MSueta
JourneyMap
Real-time map used for mapping in-game or your browser as you explore.
14.7MSueta
Emotecraft
Create your own emotes in Minecraft.
7.5MSueta
Simple Tpa
A simple tpa plugin which sends requests
5.4MSueta
Common Network
Forge and Fabric Unified Networking Solution
3.9MSueta
Set Home
A lightweight plugin for players to set their homes.
3.8MSueta