diff options
author | Lulu13022002 <[email protected]> | 2024-12-12 18:27:01 +0100 |
---|---|---|
committer | Lulu13022002 <[email protected]> | 2024-12-12 18:27:01 +0100 |
commit | d4de04ceb01422307d9f3cd252b313dd896454aa (patch) | |
tree | 5565fcfdcef31a7c7dbb4e8de5e9b14b492dba3b | |
parent | f7a6263ce6458ed580edab5fe8f647325ba740c3 (diff) | |
download | Paper-generators.tar.gz Paper-generators.zip |
keep formatting around javadocsgenerators
6 files changed, 25 insertions, 44 deletions
diff --git a/paper-generator/generatedApi/io/papermc/paper/datacomponent/DataComponentTypes.java b/paper-generator/generatedApi/io/papermc/paper/datacomponent/DataComponentTypes.java index bc2ea58794..b1664fd911 100644 --- a/paper-generator/generatedApi/io/papermc/paper/datacomponent/DataComponentTypes.java +++ b/paper-generator/generatedApi/io/papermc/paper/datacomponent/DataComponentTypes.java @@ -222,7 +222,7 @@ public final class DataComponentTypes { * <li>can't be changed or removed in Anvil</li> * <li>is not styled with italics when displayed to player</li> * <li>does not show labels where applicable - * (for example: banner markers, names in item frames)</li> + * (for example: banner markers, names in item frames)</li> * </ul> * * @see #CUSTOM_NAME diff --git a/paper-generator/generatedApi/org/bukkit/block/Biome.java b/paper-generator/generatedApi/org/bukkit/block/Biome.java index c59ab8f194..28e6f9110c 100644 --- a/paper-generator/generatedApi/org/bukkit/block/Biome.java +++ b/paper-generator/generatedApi/org/bukkit/block/Biome.java @@ -165,7 +165,7 @@ public interface Biome extends OldEnum<Biome>, Keyed, net.kyori.adventure.transl @NotNull private static Biome getBiome(@NotNull String key) { - return Registry.BIOME.get(NamespacedKey.minecraft(key)); + return Registry.BIOME.getOrThrow(NamespacedKey.minecraft(key)); } /** diff --git a/paper-generator/src/main/java/io/papermc/generator/rewriter/types/registry/RegistryFieldRewriter.java b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/registry/RegistryFieldRewriter.java index c2ca350571..b54233c402 100644 --- a/paper-generator/src/main/java/io/papermc/generator/rewriter/types/registry/RegistryFieldRewriter.java +++ b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/registry/RegistryFieldRewriter.java @@ -74,7 +74,7 @@ public class RegistryFieldRewriter<T> extends SearchReplaceRewriter { while (referenceIterator.hasNext()) { Holder.Reference<T> reference = referenceIterator.next(); - this.rewriteJavadocs(reference, metadata.indent(), builder); + this.rewriteJavadocs(reference, metadata.replacedContent(), metadata.indent(), builder); SingleFlagHolder requiredFeature = this.getRequiredFeature(reference); if (requiredFeature != null) { @@ -98,7 +98,7 @@ public class RegistryFieldRewriter<T> extends SearchReplaceRewriter { } } - protected void rewriteJavadocs(Holder.Reference<T> reference, String indent, StringBuilder builder) { + protected void rewriteJavadocs(Holder.Reference<T> reference, String replacedContent, String indent, StringBuilder builder) { } protected boolean canPrintField(Holder.Reference<T> reference) { diff --git a/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/trial/ConstantInfo.java b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/trial/ConstantInfo.java index 910b0528bb..db14ef4a6b 100644 --- a/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/trial/ConstantInfo.java +++ b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/trial/ConstantInfo.java @@ -1,30 +1,30 @@ package io.papermc.generator.rewriter.types.simple.trial; -import java.util.List; +import io.papermc.typewriter.parser.token.CharSequenceBlockToken; import org.checkerframework.checker.nullness.qual.MonotonicNonNull; class ConstantInfo { private @MonotonicNonNull String constantName; - private @MonotonicNonNull List<String> javadocs; + private @MonotonicNonNull CharSequenceBlockToken token; public void constantName(String name) { this.constantName = name; } - public void javadocs(List<String> javadocs) { - this.javadocs = javadocs; + public void javadocs(CharSequenceBlockToken token) { + this.token = token; } public String constantName() { return this.constantName; } - public List<String> javadocs() { - return this.javadocs; + public CharSequenceBlockToken javadocs() { + return this.token; } public boolean isComplete() { - return this.constantName != null && this.javadocs != null; + return this.constantName != null && this.token != null; } } diff --git a/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/trial/DataComponentTypesRewriter.java b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/trial/DataComponentTypesRewriter.java index 3291e78943..6e1e0019e9 100644 --- a/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/trial/DataComponentTypesRewriter.java +++ b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/trial/DataComponentTypesRewriter.java @@ -65,10 +65,10 @@ public class DataComponentTypesRewriter extends RegistryFieldRewriter<DataCompon TokenType.SINGLE_COMMENT ); - private @MonotonicNonNull Map<String, List<String>> javadocsPerConstant; + private @MonotonicNonNull Map<String, CharSequenceBlockToken> javadocsPerConstant; - private Map<String, List<String>> parseConstantJavadocs(String content) { - Map<String, List<String>> map = new HashMap<>(); + private Map<String, CharSequenceBlockToken> parseConstantJavadocs(String content) { + Map<String, CharSequenceBlockToken> map = new HashMap<>(); Lexer lex = new Lexer(content.toCharArray()); SequenceTokens.wrap(lex, FORMAT_TOKENS) @@ -76,7 +76,7 @@ public class DataComponentTypesRewriter extends RegistryFieldRewriter<DataCompon ConstantInfo info = new ConstantInfo(); action .map(TokenType.JAVADOC, token -> { - info.javadocs(((CharSequenceBlockToken) token).value()); + info.javadocs(((CharSequenceBlockToken) token)); }, TokenTaskBuilder::asOptional) .skip(TokenType.PUBLIC).skip(TokenType.STATIC).skip(TokenType.FINAL) .skipQualifiedName(Predicate.isEqual(TokenType.JAVADOC)) @@ -144,20 +144,11 @@ public class DataComponentTypesRewriter extends RegistryFieldRewriter<DataCompon } @Override - protected void rewriteJavadocs(Holder.Reference<DataComponentType<?>> reference, String indent, StringBuilder builder) { + protected void rewriteJavadocs(Holder.Reference<DataComponentType<?>> reference, String replacedContent, String indent, StringBuilder builder) { String constantName = this.rewriteFieldName(reference); if (this.javadocsPerConstant.containsKey(constantName)) { - builder.append(indent).append("/**"); - builder.append('\n'); - for (String line : this.javadocsPerConstant.get(constantName)) { - builder.append(indent).append(" *"); - if (!line.isEmpty()) { - builder.append(' ').append(line); - } - builder.append('\n'); - } - builder.append(indent).append(" */"); - builder.append('\n'); + CharSequenceBlockToken token = this.javadocsPerConstant.get(constantName); + builder.append(indent).append(replacedContent, token.pos(), token.endPos()).append('\n'); } } diff --git a/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/trial/VillagerProfessionRewriter.java b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/trial/VillagerProfessionRewriter.java index 4ea601fbe1..b973d3fe6c 100644 --- a/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/trial/VillagerProfessionRewriter.java +++ b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/trial/VillagerProfessionRewriter.java @@ -10,7 +10,6 @@ import io.papermc.typewriter.parser.token.TokenType; import io.papermc.typewriter.replace.SearchMetadata; import java.util.EnumSet; import java.util.HashMap; -import java.util.List; import java.util.Map; import java.util.Set; import java.util.function.Predicate; @@ -30,10 +29,10 @@ public class VillagerProfessionRewriter extends RegistryFieldRewriter<VillagerPr TokenType.SINGLE_COMMENT ); - private @MonotonicNonNull Map<String, List<String>> javadocsPerConstant; + private @MonotonicNonNull Map<String, CharSequenceBlockToken> javadocsPerConstant; - private Map<String, List<String>> parseConstantJavadocs(String content) { - Map<String, List<String>> map = new HashMap<>(); + private Map<String, CharSequenceBlockToken> parseConstantJavadocs(String content) { + Map<String, CharSequenceBlockToken> map = new HashMap<>(); Lexer lex = new Lexer(content.toCharArray()); SequenceTokens.wrap(lex, FORMAT_TOKENS) @@ -41,7 +40,7 @@ public class VillagerProfessionRewriter extends RegistryFieldRewriter<VillagerPr ConstantInfo info = new ConstantInfo(); action .map(TokenType.JAVADOC, token -> { - info.javadocs(((CharSequenceBlockToken) token).value()); + info.javadocs(((CharSequenceBlockToken) token)); }, TokenTaskBuilder::asOptional) .skipQualifiedName(Predicate.isEqual(TokenType.JAVADOC)) .map(TokenType.IDENTIFIER, token -> { @@ -91,20 +90,11 @@ public class VillagerProfessionRewriter extends RegistryFieldRewriter<VillagerPr } @Override - protected void rewriteJavadocs(Holder.Reference<VillagerProfession> reference, String indent, StringBuilder builder) { + protected void rewriteJavadocs(Holder.Reference<VillagerProfession> reference, String replacedContent, String indent, StringBuilder builder) { String constantName = this.rewriteFieldName(reference); if (this.javadocsPerConstant.containsKey(constantName)) { - builder.append(indent).append("/**"); - builder.append('\n'); - for (String line : this.javadocsPerConstant.get(constantName)) { - builder.append(indent).append(" *"); - if (!line.isEmpty()) { - builder.append(' ').append(line); - } - builder.append('\n'); - } - builder.append(indent).append(" */"); - builder.append('\n'); + CharSequenceBlockToken token = this.javadocsPerConstant.get(constantName); + builder.append(indent).append(replacedContent, token.pos(), token.endPos()).append('\n'); } } } |