Replace target string only once

This commit is contained in:
TheMode 2021-06-06 06:35:19 +02:00
parent 641ca02120
commit cec08fae1f

View File

@ -23,73 +23,73 @@ public class Generators {
LOGGER.error("Usage: <MC version> <source folder> <target folder>"); LOGGER.error("Usage: <MC version> <source folder> <target folder>");
return; return;
} }
String targetVersion = args[0]; String targetVersion = args[0].replace(".", "_");
File inputFolder = new File(args[1]); File inputFolder = new File(args[1]);
File outputFolder = new File(args[2]); File outputFolder = new File(args[2]);
// Generate blocks // Generate blocks
new BlockGenerator( new BlockGenerator(
new File(inputFolder, targetVersion.replaceAll("\\.", "_") + "_blocks.json"), new File(inputFolder, targetVersion + "_blocks.json"),
new File(inputFolder, targetVersion.replaceAll("\\.", "_") + "_block_properties.json"), new File(inputFolder, targetVersion + "_block_properties.json"),
outputFolder outputFolder
).generate(); ).generate();
// Generate fluids // Generate fluids
new FluidGenerator( new FluidGenerator(
new File(inputFolder, targetVersion.replaceAll("\\.", "_") + "_fluids.json"), new File(inputFolder, targetVersion + "_fluids.json"),
outputFolder outputFolder
).generate(); ).generate();
// Generate entities // Generate entities
new EntityTypeGenerator( new EntityTypeGenerator(
new File(inputFolder, targetVersion.replaceAll("\\.", "_") + "_entities.json"), new File(inputFolder, targetVersion + "_entities.json"),
outputFolder outputFolder
).generate(); ).generate();
// Generate items // Generate items
new MaterialGenerator( new MaterialGenerator(
new File(inputFolder, targetVersion.replaceAll("\\.", "_") + "_items.json"), new File(inputFolder, targetVersion + "_items.json"),
outputFolder outputFolder
).generate(); ).generate();
// Generate enchantments // Generate enchantments
new EnchantmentGenerator( new EnchantmentGenerator(
new File(inputFolder, targetVersion.replaceAll("\\.", "_") + "_enchantments.json"), new File(inputFolder, targetVersion + "_enchantments.json"),
outputFolder outputFolder
).generate(); ).generate();
// TODO: Generate attributes // TODO: Generate attributes
// new AttributeGenerator( // new AttributeGenerator(
// new File(inputFolder, targetVersion.replaceAll("\\.", "_") + "_attributes.json"), // new File(inputFolder, targetVersion + "_attributes.json"),
// outputFolder // outputFolder
// ).generate(); // ).generate();
// Generate potion effects // Generate potion effects
new PotionEffectGenerator( new PotionEffectGenerator(
new File(inputFolder, targetVersion.replaceAll("\\.", "_") + "_potion_effects.json"), new File(inputFolder, targetVersion + "_potion_effects.json"),
outputFolder outputFolder
).generate(); ).generate();
// Generate potions // Generate potions
new PotionTypeGenerator( new PotionTypeGenerator(
new File(inputFolder, targetVersion.replaceAll("\\.", "_") + "_potions.json"), new File(inputFolder, targetVersion + "_potions.json"),
outputFolder outputFolder
).generate(); ).generate();
// Generate particles // Generate particles
new ParticleGenerator( new ParticleGenerator(
new File(inputFolder, targetVersion.replaceAll("\\.", "_") + "_particles.json"), new File(inputFolder, targetVersion + "_particles.json"),
outputFolder outputFolder
).generate(); ).generate();
// Generate sounds // Generate sounds
new SoundEventGenerator( new SoundEventGenerator(
new File(inputFolder, targetVersion.replaceAll("\\.", "_") + "_sounds.json"), new File(inputFolder, targetVersion + "_sounds.json"),
outputFolder outputFolder
).generate(); ).generate();
// TODO: Generate villager professions // TODO: Generate villager professions
// new VillagerProfessionGenerator( // new VillagerProfessionGenerator(
// new File(inputFolder, targetVersion.replaceAll("\\.", "_") + "_villager_professions.json"), // new File(inputFolder, targetVersion + "_villager_professions.json"),
// outputFolder // outputFolder
// ).generate(); // ).generate();
// TODO: Generate villager types // TODO: Generate villager types
// new VillagerTypeGenerator( // new VillagerTypeGenerator(
// new File(inputFolder, targetVersion.replaceAll("\\.", "_") + "_villager_types.json"), // new File(inputFolder, targetVersion + "_villager_types.json"),
// outputFolder // outputFolder
// ).generate(); // ).generate();
// Generate statistics // Generate statistics
new StatisticGenerator( new StatisticGenerator(
new File(inputFolder, targetVersion.replaceAll("\\.", "_") + "_custom_statistics.json"), new File(inputFolder, targetVersion + "_custom_statistics.json"),
outputFolder outputFolder
).generate(); ).generate();
LOGGER.info("Finished generating code"); LOGGER.info("Finished generating code");