use of net.silentchaos512.gear.api.part.IGearPart in project Silent-Gear by SilentChaos512.
the class PartsCommand method runDump.
private static int runDump(CommandContext<CommandSourceStack> context) {
String fileName = "part_export.tsv";
String dirPath = "output/silentgear";
File output = new File(dirPath, fileName);
File directory = output.getParentFile();
if (!directory.exists() && !directory.mkdirs()) {
context.getSource().sendFailure(new TextComponent("Could not create directory: " + output.getParent()));
return 0;
}
try (Writer writer = new OutputStreamWriter(new FileOutputStream(output), StandardCharsets.UTF_8)) {
StringBuilder builder = new StringBuilder("Name\tID\tType\tTier\t");
ItemStats.allStatsOrdered().forEach(s -> builder.append(s.getDisplayName().getString()).append("\t"));
builder.append("Traits");
writer.write(builder.toString());
for (IGearPart part : PartManager.getValues()) {
writer.write(partToTsvLine(part) + "\n");
}
} catch (IOException e) {
e.printStackTrace();
} finally {
context.getSource().sendSuccess(new TextComponent("Wrote to " + output.getAbsolutePath()), true);
}
return 1;
}
Aggregations