mirror of
https://github.com/Minestom/Minestom.git
synced 2024-12-30 21:17:53 +01:00
Merge pull request #311 from Minestom/fix-data
Remove git submodule and gradle copy task.
This commit is contained in:
commit
1aa9343dfc
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -1,3 +0,0 @@
|
||||
[submodule "MinestomDataGenerator"]
|
||||
path = MinestomDataGenerator
|
||||
url = https://github.com/Minestom/MinestomDataGenerator
|
@ -1 +0,0 @@
|
||||
Subproject commit ed814de6d727a6f4fdb16a23e10d53e9fe357f85
|
18
build.gradle
18
build.gradle
@ -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/"))
|
||||
}
|
||||
|
@ -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"))
|
||||
}
|
||||
|
303
code-generators/minestom_checks.xml
Normal file
303
code-generators/minestom_checks.xml
Normal file
@ -0,0 +1,303 @@
|
||||
<?xml version="1.0"?>
|
||||
<!DOCTYPE module PUBLIC
|
||||
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
|
||||
"https://checkstyle.org/dtds/configuration_1_3.dtd">
|
||||
|
||||
<module name = "Checker">
|
||||
|
||||
<property name="charset" value="UTF-8"/>
|
||||
|
||||
<property name="severity" value="warning"/>
|
||||
|
||||
<property name="fileExtensions" value="java, properties, xml"/>
|
||||
|
||||
<module name="SuppressWarningsFilter" />
|
||||
<module name="SuppressionSingleFilter">
|
||||
<property name="files" value="autogenerated"/>
|
||||
<property name="checks" value=".*"/>
|
||||
</module>
|
||||
|
||||
<!-- Excludes all 'module-info.java' files -->
|
||||
<!-- See https://checkstyle.org/config_filefilters.html -->
|
||||
<module name="BeforeExecutionExclusionFileFilter">
|
||||
<property name="fileNamePattern" value="module\-info\.java$"/>
|
||||
</module>
|
||||
<!-- Checks for whitespace -->
|
||||
<!-- See http://checkstyle.sf.net/config_whitespace.html -->
|
||||
<module name="FileTabCharacter">
|
||||
<property name="eachLine" value="true"/>
|
||||
</module>
|
||||
|
||||
<!-- Checks whether files end with a new line. -->
|
||||
<!-- See https://checkstyle.org/config_misc.html#NewlineAtEndOfFile -->
|
||||
<module name="NewlineAtEndOfFile"/>
|
||||
|
||||
<!-- Miscellaneous other checks. -->
|
||||
<!-- See https://checkstyle.org/config_misc.html -->
|
||||
<module name="RegexpSingleline">
|
||||
<property name="format" value="\s+$"/>
|
||||
<property name="minimum" value="0"/>
|
||||
<property name="maximum" value="0"/>
|
||||
<property name="message" value="Line has trailing spaces."/>
|
||||
</module>
|
||||
|
||||
<module name="LineLength">
|
||||
<property name="fileExtensions" value="java"/>
|
||||
<property name="max" value="120"/>
|
||||
<property name="ignorePattern" value="^package.*|^import.*|^ *\* *.+$|a href|href|http://|https://|ftp://"/>
|
||||
</module>
|
||||
|
||||
<module name="TreeWalker">
|
||||
|
||||
<module name="SuppressWarningsHolder" />
|
||||
<module name="SuppressionCommentFilter">
|
||||
<property name="onCommentFormat" value="\@formatter\:on" />
|
||||
<property name="offCommentFormat" value="\@formatter\:off" />
|
||||
</module>
|
||||
|
||||
<module name="OuterTypeFilename"/>
|
||||
<module name="IllegalTokenText">
|
||||
<property name="tokens" value="STRING_LITERAL, CHAR_LITERAL"/>
|
||||
<property name="format"
|
||||
value="\\u00(09|0(a|A)|0(c|C)|0(d|D)|22|27|5(C|c))|\\(0(10|11|12|14|15|42|47)|134)"/>
|
||||
<property name="message"
|
||||
value="Consider using special escape sequence instead of octal value or Unicode escaped value."/>
|
||||
</module>
|
||||
<module name="AvoidEscapedUnicodeCharacters">
|
||||
<property name="allowEscapesForControlCharacters" value="true"/>
|
||||
<property name="allowByTailComment" value="true"/>
|
||||
<property name="allowNonPrintableEscapes" value="true"/>
|
||||
</module>
|
||||
|
||||
<!-- Checks for imports -->
|
||||
<!-- See https://checkstyle.org/config_import.html -->
|
||||
<module name="AvoidStarImport"/>
|
||||
<module name="IllegalImport"/> <!-- defaults to sun.* packages -->
|
||||
<module name="RedundantImport"/>
|
||||
<module name="UnusedImports">
|
||||
<property name="processJavadoc" value="true"/>
|
||||
</module>
|
||||
<module name="CustomImportOrder">
|
||||
<property name="sortImportsInGroupAlphabetically" value="true"/>
|
||||
<property name="separateLineBetweenGroups" value="true"/>
|
||||
<property name="customImportOrderRules" value="STATIC###THIRD_PARTY_PACKAGE"/>
|
||||
</module>
|
||||
|
||||
<!-- Modifier Checks -->
|
||||
<!-- See https://checkstyle.org/config_modifiers.html -->
|
||||
<module name="ModifierOrder"/>
|
||||
<module name="RedundantModifier"/>
|
||||
|
||||
<module name="FinalClass"/>
|
||||
<module name="TodoComment">
|
||||
<property name="severity" value="info" />
|
||||
<property name="format" value="(TODO)|(FIXME)"/>
|
||||
</module>
|
||||
|
||||
<module name="OneTopLevelClass"/>
|
||||
<module name="NoLineWrap"/>
|
||||
<module name="EmptyBlock">
|
||||
<property name="option" value="TEXT"/>
|
||||
<property name="tokens"
|
||||
value="LITERAL_TRY, LITERAL_FINALLY, LITERAL_IF, LITERAL_ELSE, LITERAL_SWITCH"/>
|
||||
</module>
|
||||
<module name="NeedBraces"/>
|
||||
<module name="LeftCurly"/>
|
||||
<module name="RightCurly">
|
||||
<property name="id" value="RightCurlySame"/>
|
||||
<property name="tokens"
|
||||
value="LITERAL_TRY, LITERAL_CATCH, LITERAL_FINALLY, LITERAL_IF, LITERAL_ELSE,
|
||||
LITERAL_DO"/>
|
||||
</module>
|
||||
<module name="RightCurly">
|
||||
<property name="id" value="RightCurlyAlone"/>
|
||||
<property name="option" value="alone"/>
|
||||
<property name="tokens"
|
||||
value="CLASS_DEF, METHOD_DEF, CTOR_DEF, LITERAL_FOR, LITERAL_WHILE, STATIC_INIT,
|
||||
INSTANCE_INIT"/>
|
||||
</module>
|
||||
<module name="WhitespaceAround">
|
||||
<property name="allowEmptyConstructors" value="true"/>
|
||||
<property name="allowEmptyLambdas" value="true"/>
|
||||
<property name="allowEmptyMethods" value="true"/>
|
||||
<property name="allowEmptyTypes" value="true"/>
|
||||
<property name="allowEmptyLoops" value="true"/>
|
||||
<message key="ws.notFollowed"
|
||||
value="WhitespaceAround: ''{0}'' is not followed by whitespace. Empty blocks may only be represented as '{}' when not part of a multi-block statement (4.1.3)"/>
|
||||
<message key="ws.notPreceded"
|
||||
value="WhitespaceAround: ''{0}'' is not preceded with whitespace."/>
|
||||
</module>
|
||||
<module name="OneStatementPerLine"/>
|
||||
<module name="MultipleVariableDeclarations"/>
|
||||
<module name="ArrayTypeStyle"/>
|
||||
<module name="MissingSwitchDefault"/>
|
||||
<module name="FallThrough"/>
|
||||
<module name="UpperEll"/>
|
||||
<module name="EmptyLineSeparator">
|
||||
<property name="allowNoEmptyLineBetweenFields" value="true"/>
|
||||
</module>
|
||||
<module name="SeparatorWrap">
|
||||
<property name="id" value="SeparatorWrapDot"/>
|
||||
<property name="tokens" value="DOT"/>
|
||||
<property name="option" value="nl"/>
|
||||
</module>
|
||||
<module name="SeparatorWrap">
|
||||
<property name="id" value="SeparatorWrapComma"/>
|
||||
<property name="tokens" value="COMMA"/>
|
||||
<property name="option" value="EOL"/>
|
||||
</module>
|
||||
<module name="SeparatorWrap">
|
||||
<!-- ELLIPSIS is EOL until https://github.com/google/styleguide/issues/258 -->
|
||||
<property name="id" value="SeparatorWrapEllipsis"/>
|
||||
<property name="tokens" value="ELLIPSIS"/>
|
||||
<property name="option" value="EOL"/>
|
||||
</module>
|
||||
<module name="SeparatorWrap">
|
||||
<!-- ARRAY_DECLARATOR is EOL until https://github.com/google/styleguide/issues/259 -->
|
||||
<property name="id" value="SeparatorWrapArrayDeclarator"/>
|
||||
<property name="tokens" value="ARRAY_DECLARATOR"/>
|
||||
<property name="option" value="EOL"/>
|
||||
</module>
|
||||
<module name="SeparatorWrap">
|
||||
<property name="id" value="SeparatorWrapMethodRef"/>
|
||||
<property name="tokens" value="METHOD_REF"/>
|
||||
<property name="option" value="nl"/>
|
||||
</module>
|
||||
<module name="PackageName">
|
||||
<property name="format" value="^[a-z]+(\.[a-z][a-z0-9]*)*$"/>
|
||||
<message key="name.invalidPattern"
|
||||
value="Package name ''{0}'' must match pattern ''{1}''."/>
|
||||
</module>
|
||||
<module name="TypeName">
|
||||
<message key="name.invalidPattern"
|
||||
value="Type name ''{0}'' must match pattern ''{1}''."/>
|
||||
</module>
|
||||
<module name="MemberName">
|
||||
<property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9]*$"/>
|
||||
<message key="name.invalidPattern"
|
||||
value="Member name ''{0}'' must match pattern ''{1}''."/>
|
||||
</module>
|
||||
<module name="ParameterName">
|
||||
<property name="format" value="^[a-z]([a-z0-9][a-zA-Z0-9]*)?$"/>
|
||||
<message key="name.invalidPattern"
|
||||
value="Parameter name ''{0}'' must match pattern ''{1}''."/>
|
||||
</module>
|
||||
<module name="LambdaParameterName">
|
||||
<property name="format" value="^[a-z]([a-z0-9][a-zA-Z0-9]*)?$"/>
|
||||
<message key="name.invalidPattern"
|
||||
value="Lambda parameter name ''{0}'' must match pattern ''{1}''."/>
|
||||
</module>
|
||||
<module name="CatchParameterName">
|
||||
<property name="format" value="^[a-z]([a-z0-9][a-zA-Z0-9]*)?$"/>
|
||||
<message key="name.invalidPattern"
|
||||
value="Catch parameter name ''{0}'' must match pattern ''{1}''."/>
|
||||
</module>
|
||||
<module name="LocalVariableName">
|
||||
<property name="tokens" value="VARIABLE_DEF"/>
|
||||
<property name="format" value="^[a-z]([a-z0-9][a-zA-Z0-9]*)?$"/>
|
||||
<message key="name.invalidPattern"
|
||||
value="Local variable name ''{0}'' must match pattern ''{1}''."/>
|
||||
</module>
|
||||
<module name="ClassTypeParameterName">
|
||||
<property name="format" value="(^[A-Z][0-9]?)$|([A-Z][a-zA-Z0-9]*[T]$)"/>
|
||||
<message key="name.invalidPattern"
|
||||
value="Class type name ''{0}'' must match pattern ''{1}''."/>
|
||||
</module>
|
||||
<module name="MethodTypeParameterName">
|
||||
<property name="format" value="(^[A-Z][0-9]?)$|([A-Z][a-zA-Z0-9]*[T]$)"/>
|
||||
<message key="name.invalidPattern"
|
||||
value="Method type name ''{0}'' must match pattern ''{1}''."/>
|
||||
</module>
|
||||
<module name="InterfaceTypeParameterName">
|
||||
<property name="format" value="(^[A-Z][0-9]?)$|([A-Z][a-zA-Z0-9]*[T]$)"/>
|
||||
<message key="name.invalidPattern"
|
||||
value="Interface type name ''{0}'' must match pattern ''{1}''."/>
|
||||
</module>
|
||||
<module name="NoFinalizer"/>
|
||||
<module name="GenericWhitespace">
|
||||
<message key="ws.followed"
|
||||
value="GenericWhitespace ''{0}'' is followed by whitespace."/>
|
||||
<message key="ws.preceded"
|
||||
value="GenericWhitespace ''{0}'' is preceded with whitespace."/>
|
||||
<message key="ws.illegalFollow"
|
||||
value="GenericWhitespace ''{0}'' should followed by whitespace."/>
|
||||
<message key="ws.notPreceded"
|
||||
value="GenericWhitespace ''{0}'' is not preceded with whitespace."/>
|
||||
</module>
|
||||
<module name="Indentation">
|
||||
<property name="basicOffset" value="4"/>
|
||||
<property name="braceAdjustment" value="0"/>
|
||||
<property name="caseIndent" value="4"/>
|
||||
<property name="throwsIndent" value="8"/>
|
||||
<property name="lineWrappingIndentation" value="8"/>
|
||||
<property name="arrayInitIndent" value="4"/>
|
||||
</module>
|
||||
<module name="AbbreviationAsWordInName">
|
||||
<property name="ignoreFinal" value="false"/>
|
||||
<property name="allowedAbbreviationLength" value="1"/>
|
||||
</module>
|
||||
<module name="OverloadMethodsDeclarationOrder"/>
|
||||
<module name="VariableDeclarationUsageDistance"/>
|
||||
<module name="MethodParamPad"/>
|
||||
<module name="NoWhitespaceBefore">
|
||||
<property name="tokens"
|
||||
value="COMMA, SEMI, POST_INC, POST_DEC, DOT, ELLIPSIS, METHOD_REF"/>
|
||||
<property name="allowLineBreaks" value="true"/>
|
||||
</module>
|
||||
<module name="ParenPad"/>
|
||||
<module name="OperatorWrap">
|
||||
<property name="option" value="NL"/>
|
||||
<property name="tokens"
|
||||
value="BAND, BOR, BSR, BXOR, DIV, EQUAL, GE, GT, LAND, LE, LITERAL_INSTANCEOF, LOR,
|
||||
LT, MINUS, MOD, NOT_EQUAL, PLUS, QUESTION, SL, SR, STAR, METHOD_REF "/>
|
||||
</module>
|
||||
<module name="AnnotationLocation">
|
||||
<property name="id" value="AnnotationLocationMostCases"/>
|
||||
<property name="tokens"
|
||||
value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF, METHOD_DEF, CTOR_DEF"/>
|
||||
</module>
|
||||
<module name="AnnotationLocation">
|
||||
<property name="id" value="AnnotationLocationVariables"/>
|
||||
<property name="tokens" value="VARIABLE_DEF"/>
|
||||
<property name="allowSamelineMultipleAnnotations" value="true"/>
|
||||
</module>
|
||||
<module name="NonEmptyAtclauseDescription"/>
|
||||
<module name="InvalidJavadocPosition"/>
|
||||
<module name="JavadocTagContinuationIndentation" />
|
||||
<module name="SummaryJavadoc">
|
||||
<property name="forbiddenSummaryFragments"
|
||||
value="^@return the *|^This method returns |^A [{]@code [a-zA-Z0-9]+[}]( is a )"/>
|
||||
</module>
|
||||
<module name="JavadocParagraph">
|
||||
<property name="allowNewlineParagraph" value="false" />
|
||||
</module>
|
||||
<module name="AtclauseOrder">
|
||||
<property name="tagOrder" value="@param, @return, @throws, @deprecated"/>
|
||||
<property name="target"
|
||||
value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF, METHOD_DEF, CTOR_DEF, VARIABLE_DEF"/>
|
||||
</module>
|
||||
<module name="JavadocMethod">
|
||||
<property name="accessModifiers" value="public"/>
|
||||
<property name="allowMissingParamTags" value="true"/>
|
||||
<property name="allowMissingReturnTag" value="true"/>
|
||||
<property name="allowedAnnotations" value="Override, Test"/>
|
||||
</module>
|
||||
<module name="MissingJavadocMethod">
|
||||
<property name="scope" value="public"/>
|
||||
<property name="minLineCount" value="2"/>
|
||||
<property name="allowedAnnotations" value="Override, Test"/>
|
||||
</module>
|
||||
<module name="MethodName">
|
||||
<property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9_]*$"/>
|
||||
<message key="name.invalidPattern"
|
||||
value="Method name ''{0}'' must match pattern ''{1}''."/>
|
||||
</module>
|
||||
<module name="SingleLineJavadoc">
|
||||
<property name="ignoreInlineTags" value="false"/>
|
||||
</module>
|
||||
<module name="EmptyCatchBlock">
|
||||
<property name="exceptionVariableName" value="expected"/>
|
||||
</module>
|
||||
<module name="CommentsIndentation"/>
|
||||
</module>
|
||||
</module>
|
@ -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");
|
||||
|
@ -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");
|
||||
|
@ -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<>();
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user