Remove git submodule and gradle copy task.

This commit is contained in:
Articdive 2021-06-06 14:22:32 +02:00
parent aee429add3
commit 9165e19c30
No known key found for this signature in database
GPG Key ID: B069585F0F7D90DE
19 changed files with 120 additions and 225 deletions

3
.gitmodules vendored
View File

@ -1,3 +0,0 @@
[submodule "MinestomDataGenerator"]
path = MinestomDataGenerator
url = https://github.com/Minestom/MinestomDataGenerator

@ -1 +0,0 @@
Subproject commit ed814de6d727a6f4fdb16a23e10d53e9fe357f85

View File

@ -39,6 +39,9 @@ allprojects {
maven {
url "https://repo.velocitypowered.com/snapshots/"
}
maven {
url "https://repo.minestom.com/repository/maven-public/"
}
}
javadoc {
options {
@ -171,6 +174,9 @@ dependencies {
}
}
// This is the data Minestom uses. from https://github.com/Minestom/MinestomDataGenerator
api "net.minestom:minestom-data-customizable:${rootProject.properties.get("mcVersion")}"
api "com.github.Minestom:DependencyGetter:v1.0.1"
// Adventure, for user-interface
@ -200,10 +206,6 @@ configurations.all {
exclude group: "org.checkerframework", module: "checker-qual"
}
processResources {
dependsOn("copyData")
}
publishing {
publications {
mavenJava(MavenPublication) {
@ -211,11 +213,3 @@ publishing {
}
}
}
// UPDATE: Update the data to the required version
// This task just copies the json data from the submodule to the src/main/resources/minecraft_data folder
// TODO: Make sure to delete old data from previous versions
task copyData(type: Copy) {
from("MinestomDataGenerator/Minestom-Data/$mcVersion/")
into(new File(project.projectDir, "/src/main/resources/minecraft_data/"))
}

View File

@ -21,23 +21,20 @@ dependencies {
implementation 'org.apache.logging.log4j:log4j-core:2.14.0'
// SLF4J is the base logger for most libraries, therefore we can hook it into log4j2.
implementation 'org.apache.logging.log4j:log4j-slf4j-impl:2.14.0'
// Kotlin stuff
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:${project.kotlinVersion}"
implementation "org.jetbrains.kotlin:kotlin-reflect:${project.kotlinVersion}"
// This is the data Minestom uses. from https://github.com/Minestom/MinestomDataGenerator
implementation "net.minestom:minestom-data-customizable:${rootProject.properties.get("mcVersion")}"
}
run {
// Update version
setArgs(
[
// Point to gradle.properties "mcVersion"
project.rootProject.properties["mcVersion"],
// Points to src/main/resources/minecraft_data
project.rootProject.projectDir.getPath() + "${File.separatorChar}src${File.separatorChar}main${File.separatorChar}resources${File.separatorChar}minecraft_data",
// Points to src/autogenerated/java
project.rootProject.projectDir.getPath() + "${File.separatorChar}src${File.separatorChar}autogenerated${File.separatorChar}java"
]
setArgs(List.of(
// Point to gradle.properties "mcVersion"
rootProject.properties.get("mcVersion"),
// If the source is 'classes' it will load from the dependency "net.minestom:minestom-data-customizable:version"
"resources",
// Points to src/autogenerated/java
project.rootProject.projectDir.getPath() + "${File.separatorChar}src${File.separatorChar}autogenerated${File.separatorChar}java"
) as List<String>
)
dependsOn(project.rootProject.tasks.getByName("copyData"))
}

View File

@ -14,42 +14,48 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
public class Generators {
private static final Logger LOGGER = LoggerFactory.getLogger(Generators.class);
public static void main(String[] args) {
public static void main(String[] args) throws FileNotFoundException {
if (args.length < 3) {
LOGGER.error("Usage: <MC version> <source folder> <target folder>");
LOGGER.error("Usage: <MC version> <source folder | 'resources'> <target folder>");
return;
}
String targetVersion = args[0].replace(".", "_");
File inputFolder = new File(args[1]);
boolean resourceMode = false;
if (args[1].equals("resources")) {
resourceMode = true;
}
File inputFolder = new File(args[1]); // This will be ignored if resourceMode = true
File outputFolder = new File(args[2]);
// Generate blocks
new BlockGenerator(
new File(inputFolder, targetVersion + "_blocks.json"),
new File(inputFolder, targetVersion + "_block_properties.json"),
resourceMode ? Generators.class.getResourceAsStream("/" + targetVersion + "_blocks.json") : new FileInputStream(new File(inputFolder, targetVersion + "_blocks.json")),
resourceMode ? Generators.class.getResourceAsStream("/" + targetVersion + "_block_properties.json") : new FileInputStream(new File(inputFolder, targetVersion + "_block_properties.json")),
outputFolder
).generate();
// Generate fluids
new FluidGenerator(
new File(inputFolder, targetVersion + "_fluids.json"),
resourceMode ? Generators.class.getResourceAsStream("/" + targetVersion + "_fluids.json") : new FileInputStream(new File(inputFolder, targetVersion + "_fluids.json")),
outputFolder
).generate();
// Generate entities
new EntityTypeGenerator(
new File(inputFolder, targetVersion + "_entities.json"),
resourceMode ? Generators.class.getResourceAsStream("/" + targetVersion + "_entities.json") : new FileInputStream(new File(inputFolder, targetVersion + "_entities.json")),
outputFolder
).generate();
// Generate items
new MaterialGenerator(
new File(inputFolder, targetVersion + "_items.json"),
resourceMode ? Generators.class.getResourceAsStream("/" + targetVersion + "_items.json") : new FileInputStream(new File(inputFolder, targetVersion + "_items.json")),
outputFolder
).generate();
// Generate enchantments
new EnchantmentGenerator(
new File(inputFolder, targetVersion + "_enchantments.json"),
resourceMode ? Generators.class.getResourceAsStream("/" + targetVersion + "_enchantments.json") : new FileInputStream(new File(inputFolder, targetVersion + "_enchantments.json")),
outputFolder
).generate();
// TODO: Generate attributes
@ -59,22 +65,22 @@ public class Generators {
// ).generate();
// Generate potion effects
new PotionEffectGenerator(
new File(inputFolder, targetVersion + "_potion_effects.json"),
resourceMode ? Generators.class.getResourceAsStream("/" + targetVersion + "_potion_effects.json") : new FileInputStream(new File(inputFolder, targetVersion + "_potion_effects.json")),
outputFolder
).generate();
// Generate potions
new PotionTypeGenerator(
new File(inputFolder, targetVersion + "_potions.json"),
resourceMode ? Generators.class.getResourceAsStream("/" + targetVersion + "_potions.json") : new FileInputStream(new File(inputFolder, targetVersion + "_potions.json")),
outputFolder
).generate();
// Generate particles
new ParticleGenerator(
new File(inputFolder, targetVersion + "_particles.json"),
resourceMode ? Generators.class.getResourceAsStream("/" + targetVersion + "_particles.json") : new FileInputStream(new File(inputFolder, targetVersion + "_particles.json")),
outputFolder
).generate();
// Generate sounds
new SoundEventGenerator(
new File(inputFolder, targetVersion + "_sounds.json"),
resourceMode ? Generators.class.getResourceAsStream("/" + targetVersion + "_sounds.json") : new FileInputStream(new File(inputFolder, targetVersion + "_sounds.json")),
outputFolder
).generate();
// TODO: Generate villager professions
@ -89,7 +95,7 @@ public class Generators {
// ).generate();
// Generate statistics
new StatisticGenerator(
new File(inputFolder, targetVersion + "_custom_statistics.json"),
resourceMode ? Generators.class.getResourceAsStream("/" + targetVersion + "_custom_statistics.json") : new FileInputStream(new File(inputFolder, targetVersion + "_custom_statistics.json")),
outputFolder
).generate();
LOGGER.info("Finished generating code");

View File

@ -4,32 +4,41 @@ import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.stream.JsonReader;
import com.squareup.javapoet.*;
import com.squareup.javapoet.ClassName;
import com.squareup.javapoet.CodeBlock;
import com.squareup.javapoet.FieldSpec;
import com.squareup.javapoet.JavaFile;
import com.squareup.javapoet.MethodSpec;
import com.squareup.javapoet.ParameterSpec;
import com.squareup.javapoet.ParameterizedTypeName;
import com.squareup.javapoet.TypeName;
import com.squareup.javapoet.TypeSpec;
import net.minestom.codegen.MinestomCodeGenerator;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.lang.model.element.Modifier;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
public final class AttributeGenerator extends MinestomCodeGenerator {
private static final Logger LOGGER = LoggerFactory.getLogger(AttributeGenerator.class);
private final File attributesFile;
private final InputStream attributesFile;
private final File outputFolder;
public AttributeGenerator(@NotNull File attributesFile, @NotNull File outputFolder) {
public AttributeGenerator(@Nullable InputStream attributesFile, @NotNull File outputFolder) {
this.attributesFile = attributesFile;
this.outputFolder = outputFolder;
}
@Override
public void generate() {
if (!attributesFile.exists()) {
if (attributesFile == null) {
LOGGER.error("Failed to find attributes.json.");
LOGGER.error("Stopped code generation for attributes.");
return;
@ -42,14 +51,7 @@ public final class AttributeGenerator extends MinestomCodeGenerator {
ClassName namespaceIDClassName = ClassName.get("net.minestom.server.utils", "NamespaceID");
ClassName registryClassName = ClassName.get("net.minestom.server.registry", "Registry");
JsonArray attributes;
try {
attributes = GSON.fromJson(new JsonReader(new FileReader(attributesFile)), JsonArray.class);
} catch (FileNotFoundException e) {
LOGGER.error("Failed to find attributes.json.");
LOGGER.error("Stopped code generation for attributes.");
return;
}
JsonArray attributes = GSON.fromJson(new JsonReader(new InputStreamReader(attributesFile)), JsonArray.class);
List<JavaFile> filesToWrite = new ArrayList<>();
ClassName attributeClassName = ClassName.get("net.minestom.server.attribute", "Attribute");

View File

@ -14,8 +14,8 @@ import org.slf4j.LoggerFactory;
import javax.lang.model.element.Modifier;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@ -23,11 +23,11 @@ import java.util.Map;
public final class BlockGenerator extends MinestomCodeGenerator {
private static final Logger LOGGER = LoggerFactory.getLogger(BlockGenerator.class);
private final File blocksFile;
private final File blockPropertyFile;
private final InputStream blocksFile;
private final InputStream blockPropertyFile;
private final File outputFolder;
public BlockGenerator(@NotNull File blocksFile, @NotNull File blockPropertyFile, @NotNull File outputFolder) {
public BlockGenerator(@Nullable InputStream blocksFile, @Nullable InputStream blockPropertyFile, @NotNull File outputFolder) {
this.blocksFile = blocksFile;
this.blockPropertyFile = blockPropertyFile;
this.outputFolder = outputFolder;
@ -35,12 +35,12 @@ public final class BlockGenerator extends MinestomCodeGenerator {
@Override
public void generate() {
if (!blocksFile.exists()) {
if (blocksFile == null) {
LOGGER.error("Failed to find blocks.json.");
LOGGER.error("Stopped code generation for blocks.");
return;
}
if (!blockPropertyFile.exists()) {
if (blockPropertyFile == null) {
LOGGER.error("Failed to find block_properties.json.");
LOGGER.error("Stopped code generation for block properties.");
return;
@ -58,14 +58,8 @@ public final class BlockGenerator extends MinestomCodeGenerator {
ClassName namespaceIDClassName = ClassName.get("net.minestom.server.utils", "NamespaceID");
ClassName registriesClassName = ClassName.get("net.minestom.server.registry", "Registries");
JsonArray blocks;
try {
blocks = GSON.fromJson(new JsonReader(new FileReader(blocksFile)), JsonArray.class);
} catch (FileNotFoundException e) {
LOGGER.error("Failed to find blocks.json.");
LOGGER.error("Stopped code generation for blocks.");
return;
}
JsonArray blocks = GSON.fromJson(new JsonReader(new InputStreamReader(blocksFile)), JsonArray.class);
ClassName blockClassName = ClassName.get("net.minestom.server.instance.block", "Block");
ClassName blockAltClassName = ClassName.get("net.minestom.server.instance.block", "BlockAlternative");
List<JavaFile> filesToWrite = new ArrayList<>();

View File

@ -14,8 +14,8 @@ import org.slf4j.LoggerFactory;
import javax.lang.model.element.Modifier;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
@ -173,17 +173,17 @@ public final class EntityTypeGenerator extends MinestomCodeGenerator {
put("Player", "net.minestom.server.entity.metadata");
}};
private final File entitiesFile;
private final InputStream entitiesFile;
private final File outputFolder;
public EntityTypeGenerator(@NotNull File entitiesFile, @NotNull File outputFolder) {
public EntityTypeGenerator(@Nullable InputStream entitiesFile, @NotNull File outputFolder) {
this.entitiesFile = entitiesFile;
this.outputFolder = outputFolder;
}
@Override
public void generate() {
if (!entitiesFile.exists()) {
if (entitiesFile == null) {
LOGGER.error("Failed to find entities.json.");
LOGGER.error("Stopped code generation for entities.");
return;
@ -196,14 +196,7 @@ public final class EntityTypeGenerator extends MinestomCodeGenerator {
ClassName namespaceIDClassName = ClassName.get("net.minestom.server.utils", "NamespaceID");
ClassName registriesClassName = ClassName.get("net.minestom.server.registry", "Registries");
JsonArray entities;
try {
entities = GSON.fromJson(new JsonReader(new FileReader(entitiesFile)), JsonArray.class);
} catch (FileNotFoundException e) {
LOGGER.error("Failed to find entities.json.");
LOGGER.error("Stopped code generation for entities.");
return;
}
JsonArray entities = GSON.fromJson(new JsonReader(new InputStreamReader(entitiesFile)), JsonArray.class);
ClassName entityClassName = ClassName.get("net.minestom.server.entity", "EntityType");
// Particle

View File

@ -12,26 +12,24 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.lang.model.element.Modifier;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.*;
import java.util.Collections;
import java.util.List;
public final class VillagerProfessionGenerator extends MinestomCodeGenerator {
private static final Logger LOGGER = LoggerFactory.getLogger(VillagerProfessionGenerator.class);
private final File villagerProfessionsFile;
private final InputStream villagerProfessionsFile;
private final File outputFolder;
public VillagerProfessionGenerator(@NotNull File villagerProfessionsFile, @NotNull File outputFolder) {
public VillagerProfessionGenerator(@Nullable InputStream villagerProfessionsFile, @NotNull File outputFolder) {
this.villagerProfessionsFile = villagerProfessionsFile;
this.outputFolder = outputFolder;
}
@Override
public void generate() {
if (!villagerProfessionsFile.exists()) {
if (villagerProfessionsFile == null) {
LOGGER.error("Failed to find villager_professions.json.");
LOGGER.error("Stopped code generation for villager professions.");
return;
@ -45,14 +43,7 @@ public final class VillagerProfessionGenerator extends MinestomCodeGenerator {
ClassName rawVillagerProfessionDataClassName = ClassName.get("net.minestom.server.raw_data", "RawVillagerProfessionData");
ClassName registryClassName = ClassName.get("net.minestom.server.registry", "Registry");
JsonArray villagerProfessions;
try {
villagerProfessions = GSON.fromJson(new JsonReader(new FileReader(villagerProfessionsFile)), JsonArray.class);
} catch (FileNotFoundException e) {
LOGGER.error("Failed to find villager_professions.json.");
LOGGER.error("Stopped code generation for villager professions.");
return;
}
JsonArray villagerProfessions = GSON.fromJson(new JsonReader(new InputStreamReader(villagerProfessionsFile)), JsonArray.class);
ClassName villagerProfessionClassName = ClassName.get("net.minestom.server.entity.metadata.villager", "VillagerProfession");
// Particle

View File

@ -12,25 +12,23 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.lang.model.element.Modifier;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.*;
import java.util.Collections;
import java.util.List;
public final class VillagerTypeGenerator extends MinestomCodeGenerator {
private static final Logger LOGGER = LoggerFactory.getLogger(VillagerTypeGenerator.class);
private final File villagerTypesFile;
private final InputStream villagerTypesFile;
private final File outputFolder;
public VillagerTypeGenerator(@NotNull File villagerTypesFile, @NotNull File outputFolder) {
public VillagerTypeGenerator(@Nullable InputStream villagerTypesFile, @NotNull File outputFolder) {
this.villagerTypesFile = villagerTypesFile;
this.outputFolder = outputFolder;
}
@Override
public void generate() {
if (!villagerTypesFile.exists()) {
if (villagerTypesFile == null) {
LOGGER.error("Failed to find villager_types.json.");
LOGGER.error("Stopped code generation for villager types.");
return;
@ -43,14 +41,7 @@ public final class VillagerTypeGenerator extends MinestomCodeGenerator {
ClassName namespaceIDClassName = ClassName.get("net.minestom.server.utils", "NamespaceID");
ClassName registryClassName = ClassName.get("net.minestom.server.registry", "Registry");
JsonArray villagerTypes;
try {
villagerTypes = GSON.fromJson(new JsonReader(new FileReader(villagerTypesFile)), JsonArray.class);
} catch (FileNotFoundException e) {
LOGGER.error("Failed to find villager_types.json.");
LOGGER.error("Stopped code generation for villager types.");
return;
}
JsonArray villagerTypes = GSON.fromJson(new JsonReader(new InputStreamReader(villagerTypesFile)), JsonArray.class);
ClassName villagerTypeClassName = ClassName.get("net.minestom.server.entity.metadata.villager", "VillagerType");
// Particle

View File

@ -12,24 +12,22 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.lang.model.element.Modifier;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.*;
import java.util.Collections;
public final class FluidGenerator extends MinestomCodeGenerator {
private static final Logger LOGGER = LoggerFactory.getLogger(FluidGenerator.class);
private final File fluidsFile;
private final InputStream fluidsFile;
private final File outputFolder;
public FluidGenerator(@NotNull File fluidsFile, @NotNull File outputFolder) {
public FluidGenerator(@Nullable InputStream fluidsFile, @NotNull File outputFolder) {
this.fluidsFile = fluidsFile;
this.outputFolder = outputFolder;
}
@Override
public void generate() {
if (!fluidsFile.exists()) {
if (fluidsFile == null) {
LOGGER.error("Failed to find fluids.json.");
LOGGER.error("Stopped code generation for fluids.");
return;
@ -42,14 +40,7 @@ public final class FluidGenerator extends MinestomCodeGenerator {
ClassName namespaceIDClassName = ClassName.get("net.minestom.server.utils", "NamespaceID");
ClassName registriesClassName = ClassName.get("net.minestom.server.registry", "Registries");
JsonArray fluids;
try {
fluids = GSON.fromJson(new JsonReader(new FileReader(fluidsFile)), JsonArray.class);
} catch (FileNotFoundException e) {
LOGGER.error("Failed to find fluids.json.");
LOGGER.error("Stopped code generation for fluids.");
return;
}
JsonArray fluids = GSON.fromJson(new JsonReader(new InputStreamReader(fluidsFile)), JsonArray.class);
ClassName fluidClassName = ClassName.get("net.minestom.server.fluid", "Fluid");
// Particle

View File

@ -12,24 +12,22 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.lang.model.element.Modifier;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.*;
import java.util.Collections;
public final class EnchantmentGenerator extends MinestomCodeGenerator {
private static final Logger LOGGER = LoggerFactory.getLogger(EnchantmentGenerator.class);
private final File enchantmentsFile;
private final InputStream enchantmentsFile;
private final File outputFolder;
public EnchantmentGenerator(@NotNull File enchantmentsFile, @NotNull File outputFolder) {
public EnchantmentGenerator(@Nullable InputStream enchantmentsFile, @NotNull File outputFolder) {
this.enchantmentsFile = enchantmentsFile;
this.outputFolder = outputFolder;
}
@Override
public void generate() {
if (!enchantmentsFile.exists()) {
if (enchantmentsFile == null) {
LOGGER.error("Failed to find enchantments.json.");
LOGGER.error("Stopped code generation for enchantments.");
return;
@ -42,14 +40,7 @@ public final class EnchantmentGenerator extends MinestomCodeGenerator {
ClassName namespaceIDClassName = ClassName.get("net.minestom.server.utils", "NamespaceID");
ClassName registriesClassName = ClassName.get("net.minestom.server.registry", "Registries");
JsonArray enchantments;
try {
enchantments = GSON.fromJson(new JsonReader(new FileReader(enchantmentsFile)), JsonArray.class);
} catch (FileNotFoundException e) {
LOGGER.error("Failed to find enchantments.json.");
LOGGER.error("Stopped code generation for enchantments.");
return;
}
JsonArray enchantments = GSON.fromJson(new JsonReader(new InputStreamReader(enchantmentsFile)), JsonArray.class);
ClassName enchantmentClassName = ClassName.get("net.minestom.server.item", "Enchantment");
// Enchantment

View File

@ -12,25 +12,23 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.lang.model.element.Modifier;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.*;
import java.util.Collections;
import java.util.function.Supplier;
public final class MaterialGenerator extends MinestomCodeGenerator {
private static final Logger LOGGER = LoggerFactory.getLogger(MaterialGenerator.class);
private final File itemsFile;
private final InputStream itemsFile;
private final File outputFolder;
public MaterialGenerator(@NotNull File itemsFile, @NotNull File outputFolder) {
public MaterialGenerator(@Nullable InputStream itemsFile, @NotNull File outputFolder) {
this.itemsFile = itemsFile;
this.outputFolder = outputFolder;
}
@Override
public void generate() {
if (!itemsFile.exists()) {
if (itemsFile == null) {
LOGGER.error("Failed to find items.json.");
LOGGER.error("Stopped code generation for items.");
return;
@ -45,14 +43,7 @@ public final class MaterialGenerator extends MinestomCodeGenerator {
ClassName blockCN = ClassName.get("net.minestom.server.instance.block", "Block");
ParameterizedTypeName blocksCNSupplier = ParameterizedTypeName.get(ClassName.get(Supplier.class), blockCN);
JsonArray items;
try {
items = GSON.fromJson(new JsonReader(new FileReader(itemsFile)), JsonArray.class);
} catch (FileNotFoundException e) {
LOGGER.error("Failed to find items.json.");
LOGGER.error("Stopped code generation for items.");
return;
}
JsonArray items = GSON.fromJson(new JsonReader(new InputStreamReader(itemsFile)), JsonArray.class);
ClassName itemClassName = ClassName.get("net.minestom.server.item", "Material");
// Item

View File

@ -12,24 +12,22 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.lang.model.element.Modifier;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.*;
import java.util.Collections;
public final class ParticleGenerator extends MinestomCodeGenerator {
private static final Logger LOGGER = LoggerFactory.getLogger(ParticleGenerator.class);
private final File particlesFile;
private final InputStream particlesFile;
private final File outputFolder;
public ParticleGenerator(@NotNull File particlesFile, @NotNull File outputFolder) {
public ParticleGenerator(@Nullable InputStream particlesFile, @NotNull File outputFolder) {
this.particlesFile = particlesFile;
this.outputFolder = outputFolder;
}
@Override
public void generate() {
if (!particlesFile.exists()) {
if (particlesFile == null) {
LOGGER.error("Failed to find particles.json.");
LOGGER.error("Stopped code generation for particles.");
return;
@ -42,14 +40,7 @@ public final class ParticleGenerator extends MinestomCodeGenerator {
ClassName namespaceIDClassName = ClassName.get("net.minestom.server.utils", "NamespaceID");
ClassName registriesClassName = ClassName.get("net.minestom.server.registry", "Registries");
JsonArray particles;
try {
particles = GSON.fromJson(new JsonReader(new FileReader(particlesFile)), JsonArray.class);
} catch (FileNotFoundException e) {
LOGGER.error("Failed to find particles.json.");
LOGGER.error("Stopped code generation for particles.");
return;
}
JsonArray particles = GSON.fromJson(new JsonReader(new InputStreamReader(particlesFile)), JsonArray.class);
ClassName particleClassName = ClassName.get("net.minestom.server.particle", "Particle");
// Particle

View File

@ -12,24 +12,22 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.lang.model.element.Modifier;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.*;
import java.util.Collections;
public final class PotionEffectGenerator extends MinestomCodeGenerator {
private static final Logger LOGGER = LoggerFactory.getLogger(PotionEffectGenerator.class);
private final File potionEffectsFile;
private final InputStream potionEffectsFile;
private final File outputFolder;
public PotionEffectGenerator(@NotNull File potionEffectsFile, @NotNull File outputFolder) {
public PotionEffectGenerator(@Nullable InputStream potionEffectsFile, @NotNull File outputFolder) {
this.potionEffectsFile = potionEffectsFile;
this.outputFolder = outputFolder;
}
@Override
public void generate() {
if (!potionEffectsFile.exists()) {
if (potionEffectsFile == null) {
LOGGER.error("Failed to find potionEffects.json.");
LOGGER.error("Stopped code generation for potion effects.");
return;
@ -42,14 +40,7 @@ public final class PotionEffectGenerator extends MinestomCodeGenerator {
ClassName namespaceIDClassName = ClassName.get("net.minestom.server.utils", "NamespaceID");
ClassName registriesClassName = ClassName.get("net.minestom.server.registry", "Registries");
JsonArray potionEffects;
try {
potionEffects = GSON.fromJson(new JsonReader(new FileReader(potionEffectsFile)), JsonArray.class);
} catch (FileNotFoundException e) {
LOGGER.error("Failed to find potionEffects.json.");
LOGGER.error("Stopped code generation for potion effects.");
return;
}
JsonArray potionEffects = GSON.fromJson(new JsonReader(new InputStreamReader(potionEffectsFile)), JsonArray.class);
ClassName potionEffectClassName = ClassName.get("net.minestom.server.potion", "PotionEffect");
// Particle

View File

@ -12,24 +12,22 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.lang.model.element.Modifier;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.*;
import java.util.Collections;
public final class PotionTypeGenerator extends MinestomCodeGenerator {
private static final Logger LOGGER = LoggerFactory.getLogger(PotionTypeGenerator.class);
private final File potionsFile;
private final InputStream potionsFile;
private final File outputFolder;
public PotionTypeGenerator(@NotNull File potionsFile, @NotNull File outputFolder) {
public PotionTypeGenerator(@Nullable InputStream potionsFile, @NotNull File outputFolder) {
this.potionsFile = potionsFile;
this.outputFolder = outputFolder;
}
@Override
public void generate() {
if (!potionsFile.exists()) {
if (potionsFile == null) {
LOGGER.error("Failed to find potions.json.");
LOGGER.error("Stopped code generation for potions.");
return;
@ -42,14 +40,7 @@ public final class PotionTypeGenerator extends MinestomCodeGenerator {
ClassName namespaceIDClassName = ClassName.get("net.minestom.server.utils", "NamespaceID");
ClassName registriesClassName = ClassName.get("net.minestom.server.registry", "Registries");
JsonArray potions;
try {
potions = GSON.fromJson(new JsonReader(new FileReader(potionsFile)), JsonArray.class);
} catch (FileNotFoundException e) {
LOGGER.error("Failed to find potions.json.");
LOGGER.error("Stopped code generation for potions.");
return;
}
JsonArray potions = GSON.fromJson(new JsonReader(new InputStreamReader(potionsFile)), JsonArray.class);
ClassName potionTypeClassName = ClassName.get("net.minestom.server.potion", "PotionType");
// Particle

View File

@ -12,24 +12,22 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.lang.model.element.Modifier;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.*;
import java.util.Collections;
public final class SoundEventGenerator extends MinestomCodeGenerator {
private static final Logger LOGGER = LoggerFactory.getLogger(SoundEventGenerator.class);
private final File soundsFile;
private final InputStream soundsFile;
private final File outputFolder;
public SoundEventGenerator(@NotNull File itemsFile, @NotNull File outputFolder) {
public SoundEventGenerator(@Nullable InputStream itemsFile, @NotNull File outputFolder) {
this.soundsFile = itemsFile;
this.outputFolder = outputFolder;
}
@Override
public void generate() {
if (!soundsFile.exists()) {
if (soundsFile == null) {
LOGGER.error("Failed to find sounds.json.");
LOGGER.error("Stopped code generation for sounds.");
return;
@ -42,14 +40,7 @@ public final class SoundEventGenerator extends MinestomCodeGenerator {
ClassName namespaceIDClassName = ClassName.get("net.minestom.server.utils", "NamespaceID");
ClassName registriesClassName = ClassName.get("net.minestom.server.registry", "Registries");
JsonArray sounds;
try {
sounds = GSON.fromJson(new JsonReader(new FileReader(soundsFile)), JsonArray.class);
} catch (FileNotFoundException e) {
LOGGER.error("Failed to find sounds.json.");
LOGGER.error("Stopped code generation for sounds.");
return;
}
JsonArray sounds = GSON.fromJson(new JsonReader(new InputStreamReader(soundsFile)), JsonArray.class);
ClassName soundClassName = ClassName.get("net.minestom.server.sound", "SoundEvent");
// Sound
TypeSpec.Builder soundClass = TypeSpec.enumBuilder(soundClassName)

View File

@ -13,23 +13,23 @@ import org.slf4j.LoggerFactory;
import javax.lang.model.element.Modifier;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Collections;
public final class StatisticGenerator extends MinestomCodeGenerator {
private static final Logger LOGGER = LoggerFactory.getLogger(StatisticGenerator.class);
private final File statisticsFile;
private final InputStream statisticsFile;
private final File outputFolder;
public StatisticGenerator(@NotNull File statisticsFile, @NotNull File outputFolder) {
public StatisticGenerator(@Nullable InputStream statisticsFile, @NotNull File outputFolder) {
this.statisticsFile = statisticsFile;
this.outputFolder = outputFolder;
}
@Override
public void generate() {
if (!statisticsFile.exists()) {
if (statisticsFile == null) {
LOGGER.error("Failed to find statistics.json.");
LOGGER.error("Stopped code generation for statistics.");
return;
@ -42,14 +42,7 @@ public final class StatisticGenerator extends MinestomCodeGenerator {
ClassName namespaceIDClassName = ClassName.get("net.minestom.server.utils", "NamespaceID");
ClassName registriesClassName = ClassName.get("net.minestom.server.registry", "Registries");
JsonArray statistics;
try {
statistics = GSON.fromJson(new JsonReader(new FileReader(statisticsFile)), JsonArray.class);
} catch (FileNotFoundException e) {
LOGGER.error("Failed to find statistics.json.");
LOGGER.error("Stopped code generation for statistics.");
return;
}
JsonArray statistics = GSON.fromJson(new JsonReader(new InputStreamReader(statisticsFile)), JsonArray.class);
ClassName statisticClassName = ClassName.get("net.minestom.server.statistic", "StatisticType");
// Particle

View File

@ -1,5 +1,6 @@
# Update with every release
# Update this version with every release. It is purely used for the code generator and data dependency.
mcVersion = 1.16.5
asmVersion=9.0
mixinVersion=0.8.1
hephaistosVersion=v1.1.8