final File file = new File(getGenerationFolder(), "IC-Pages/");
if(!file.exists())
file.mkdir();
BlockState oldState = Bukkit.getWorlds().get(0).getBlockAt(0, 255, 0).getState();
Bukkit.getWorlds().get(0).getBlockAt(0, 255, 0).setType(Material.WALL_SIGN);
CraftBookPlugin.inst().createDefaultConfiguration(new File(getGenerationFolder(), "ic-config.yml"), "ic-config.yml");
ICConfiguration icConfiguration = new ICConfiguration(new YAMLProcessor(new File(getGenerationFolder(), "ic-config.yml"), true, YAMLFormat.EXTENDED), CraftBookPlugin.logger());
icConfiguration.load();
int missingComments = 0;
final Set<String> missingDocuments = new HashSet<String>();
for(RegisteredICFactory ric : ICManager.inst().getICList()) {
PrintWriter writer = new PrintWriter(new File(file, ric.getId() + ".txt"), "UTF-8");
IC ic = ric.getFactory().create(null);
writer.println("[[../Integrated_circuits#IC_Types_List|< Return to ICs]]");
writer.println();
for(ICFamily family : ric.getFamilies()) {
if(family instanceof FamilyAISO) continue;
writer.println("{{" + family.getName() + "|id=" + ric.getId() + "|name=" + ic.getTitle() + "}}");
}
if(ric.getFactory().getLongDescription() == null || ric.getFactory().getLongDescription().length == 0 || ric.getFactory().getLongDescription()[0].equals("Missing Description")) {
CraftBookPlugin.logger().info("Missing Long Description for: " + ric.getId());
missingDocuments.add(ric.getId());
}
for(String line : ric.getFactory().getLongDescription())
writer.println(line);
writer.println();
writer.println("== Sign parameters ==");
writer.println("# " + ic.getSignTitle());
writer.println("# [" + ric.getId() + "]");
for(String line : ric.getFactory().getLineHelp()) {
if(line == null) line = "Blank";
if(line.contains("{") && line.contains("}")) line = StringUtils.replace(StringUtils.replace(line, "}", "</span>''"), "{", "''<span style='color:#808080'>"); //Optional Syntax.
if(line.contains("SearchArea")) line = StringUtils.replace(line, "SearchArea", "[[../Search_Area|Search Area]]");
if(line.contains("ItemSyntax")) line = StringUtils.replace(line, "ItemSyntax", "[[../Item_Syntax|Item Syntax]]");
if(line.contains("PlayerType")) line = StringUtils.replace(line, "PlayerType", "[[../Player_Type|Player Type]]");
writer.println("# " + line);
}
writer.println();
writer.println("== Pins ==");
writer.println();
writer.println("=== Input ===");
int pins = 0;
ChipState state = ric.getFamilies()[0].detect(BukkitUtil.toWorldVector(Bukkit.getWorlds().get(0).getBlockAt(0, 255, 0)), BukkitUtil.toChangedSign(Bukkit.getWorlds().get(0).getBlockAt(0, 255, 0)));
for(String pin : ric.getFactory().getPinDescription(state)) {
if(pins == state.getInputCount()) {
writer.println();
writer.println("=== Output ===");
}
writer.println("# " + (pin == null ? "Nothing" : pin));
if(pin == null) {
CraftBookPlugin.logger().info("Missing pin: " + pins + " for IC: " + ric.getId());
missingDocuments.add(ric.getId());
}
pins++;
}
writer.println();
if(ric.getFactory() instanceof ConfigurableIC) {
writer.println("== Configuration ==");
writer.println();
writer.println("{| class=\"wiki-table sortable\"");
writer.println("|-");
writer.println("! Configuration Node and Path");
writer.println("! Default Value");
writer.println("! Effect");
String path = "ics." + ric.getId();
for(String key : icConfiguration.config.getKeys(path)) {
if(icConfiguration.config.getProperty(path + "." + key) != null && !(icConfiguration.config.getProperty(path + "." + key) instanceof Map)) {
writer.println("|-");
writer.println("| " + path + "." + key);
writer.println("| " + String.valueOf(icConfiguration.config.getProperty(path + "." + key)));
String comment = icConfiguration.config.getComment(path + "." + key);
if(comment == null) {
System.out.println("[WARNING] Key " + path + "." + key + " is missing a comment!");
missingComments++;
missingDocuments.add(ric.getId());
comment = "";
}
if(!comment.trim().isEmpty()) comment = comment.trim().substring(2);
writer.println("| " + comment);
}
}
writer.println("|}");
writer.println();
}
if(ric.getFactory() instanceof CommandIC) {
writer.println("== Commands ==");
writer.println();
writer.println("{| class=\"wiki-table\"");
writer.println("! Command");
writer.println("! Permission");
writer.println("! Description");
for(String[] bits : ((CommandIC) ric.getFactory()).getCommandInformation()) {
writer.println("|-");
writer.println("| /ic ic " + ric.getId().toLowerCase() + " " + bits[0]);
for(int i = 1; i < bits.length; i++)
writer.println("| " + bits[i]);
}
writer.println("|}");
writer.println();
}
writer.print("[[Category:IC]]");
for(ICFamily family : ric.getFamilies())
writer.print("[[Category:" + family.getName() + "]]");
writer.close();
}
System.out.println(missingComments + " Comments Are Missing");
oldState.update(true);
if(upload) {
Bukkit.getScheduler().runTaskAsynchronously(CraftBookPlugin.inst(), new Runnable() {