This commit is contained in:
Lulu13022002 2024-05-10 23:21:08 +02:00
parent 4fa3ae8f31
commit ae9a93ca99
No known key found for this signature in database
GPG Key ID: 491C8F0B8ACDEB01
55 changed files with 6539 additions and 6655 deletions

View File

@ -23,16 +23,26 @@ dependencies {
testImplementation(testData.output)
}
val generatedApiPath = file("generated");
val generatedServerPath = file("generatedServerTest");
tasks.register<JavaExec>("generate") {
dependsOn(tasks.check)
mainClass.set("io.papermc.generator.Main")
classpath(sourceSets.main.map { it.runtimeClasspath })
args(file("generated").toString(),
args(generatedApiPath.toString(),
project(":paper-api").sourceSets["main"].java.srcDirs.first().toString(),
file("generatedServerTest").toString(),
generatedServerPath.toString(),
project(":paper-server").sourceSets["main"].java.srcDirs.first().toString())
}
tasks.register<JavaExec>("scanOldGeneratedSourceCode") {
mainClass.set("io.papermc.generator.rewriter.OldGeneratedCodeTest")
classpath(sourceSets.test.map { it.runtimeClasspath })
args(generatedApiPath.toString(),
generatedServerPath.toString())
}
tasks {
test {
useJUnitPlatform {

File diff suppressed because it is too large Load Diff

View File

@ -806,6 +806,15 @@ public interface Tag<T extends Keyed> extends Keyed {
*/
@Deprecated
Tag<Material> FOX_FOOD = ITEMS_FOX_FOOD;
/**
* Vanilla item tag representing all tools.
*
* @deprecated removed in Minecraft 1.20.5. Do not use. Will be removed at a later date. Until then,
* this constant now acts as a reference to {@link #ITEMS_BREAKS_DECORATED_POTS} which largely shares
* the same contents of the old "minecraft:tools" tag.
*/
@Deprecated(forRemoval = true)
Tag<Material> ITEMS_TOOLS = ITEMS_BREAKS_DECORATED_POTS;
/**
* Vanilla item tag representing all items which tempt axolotls.
*

File diff suppressed because it is too large Load Diff

View File

@ -120,7 +120,7 @@ public interface DamageType extends Keyed, Translatable {
@NotNull
private static DamageType getDamageType(@NotNull String key) {
NamespacedKey namespacedKey = NamespacedKey.minecraft(key);
return Preconditions.checkNotNull(Registry.DAMAGE_TYPE.get(namespacedKey), "No DamageType found for %s. This is a bug.", namespacedKey);
return Registry.DAMAGE_TYPE.get(namespacedKey);
}
/**

File diff suppressed because it is too large Load Diff

View File

@ -13,27 +13,32 @@ public interface TrimMaterial extends Keyed, Translatable {
// Paper start - Generated/TrimMaterial
// @GeneratedFrom 1.20.6
TrimMaterial AMETHYST = Registry.TRIM_MATERIAL.get(NamespacedKey.minecraft("amethyst"));
TrimMaterial AMETHYST = getTrimMaterial("amethyst");
TrimMaterial COPPER = Registry.TRIM_MATERIAL.get(NamespacedKey.minecraft("copper"));
TrimMaterial COPPER = getTrimMaterial("copper");
TrimMaterial DIAMOND = Registry.TRIM_MATERIAL.get(NamespacedKey.minecraft("diamond"));
TrimMaterial DIAMOND = getTrimMaterial("diamond");
TrimMaterial EMERALD = Registry.TRIM_MATERIAL.get(NamespacedKey.minecraft("emerald"));
TrimMaterial EMERALD = getTrimMaterial("emerald");
TrimMaterial GOLD = Registry.TRIM_MATERIAL.get(NamespacedKey.minecraft("gold"));
TrimMaterial GOLD = getTrimMaterial("gold");
TrimMaterial IRON = Registry.TRIM_MATERIAL.get(NamespacedKey.minecraft("iron"));
TrimMaterial IRON = getTrimMaterial("iron");
TrimMaterial LAPIS = Registry.TRIM_MATERIAL.get(NamespacedKey.minecraft("lapis"));
TrimMaterial LAPIS = getTrimMaterial("lapis");
TrimMaterial NETHERITE = Registry.TRIM_MATERIAL.get(NamespacedKey.minecraft("netherite"));
TrimMaterial NETHERITE = getTrimMaterial("netherite");
TrimMaterial QUARTZ = Registry.TRIM_MATERIAL.get(NamespacedKey.minecraft("quartz"));
TrimMaterial QUARTZ = getTrimMaterial("quartz");
TrimMaterial REDSTONE = Registry.TRIM_MATERIAL.get(NamespacedKey.minecraft("redstone"));
TrimMaterial REDSTONE = getTrimMaterial("redstone");
// Paper end - Generated/TrimMaterial
private static TrimMaterial getTrimMaterial(String name) {
NamespacedKey key = NamespacedKey.minecraft(name);
return io.papermc.paper.registry.RegistryAccess.registryAccess().getRegistry(io.papermc.paper.registry.RegistryKey.TRIM_MATERIAL).get(key);
}
// Paper start - adventure
/**
* Get the description of this {@link TrimMaterial}.

View File

@ -15,45 +15,50 @@ public interface TrimPattern extends Keyed, Translatable {
// @GeneratedFrom 1.20.6
@org.bukkit.MinecraftExperimental(org.bukkit.MinecraftExperimental.Requires.UPDATE_1_21)
@org.jetbrains.annotations.ApiStatus.Experimental
TrimPattern BOLT = Registry.TRIM_PATTERN.get(NamespacedKey.minecraft("bolt"));
TrimPattern BOLT = getTrimPattern("bolt");
TrimPattern COAST = Registry.TRIM_PATTERN.get(NamespacedKey.minecraft("coast"));
TrimPattern COAST = getTrimPattern("coast");
TrimPattern DUNE = Registry.TRIM_PATTERN.get(NamespacedKey.minecraft("dune"));
TrimPattern DUNE = getTrimPattern("dune");
TrimPattern EYE = Registry.TRIM_PATTERN.get(NamespacedKey.minecraft("eye"));
TrimPattern EYE = getTrimPattern("eye");
@org.bukkit.MinecraftExperimental(org.bukkit.MinecraftExperimental.Requires.UPDATE_1_21)
@org.jetbrains.annotations.ApiStatus.Experimental
TrimPattern FLOW = Registry.TRIM_PATTERN.get(NamespacedKey.minecraft("flow"));
TrimPattern FLOW = getTrimPattern("flow");
TrimPattern HOST = Registry.TRIM_PATTERN.get(NamespacedKey.minecraft("host"));
TrimPattern HOST = getTrimPattern("host");
TrimPattern RAISER = Registry.TRIM_PATTERN.get(NamespacedKey.minecraft("raiser"));
TrimPattern RAISER = getTrimPattern("raiser");
TrimPattern RIB = Registry.TRIM_PATTERN.get(NamespacedKey.minecraft("rib"));
TrimPattern RIB = getTrimPattern("rib");
TrimPattern SENTRY = Registry.TRIM_PATTERN.get(NamespacedKey.minecraft("sentry"));
TrimPattern SENTRY = getTrimPattern("sentry");
TrimPattern SHAPER = Registry.TRIM_PATTERN.get(NamespacedKey.minecraft("shaper"));
TrimPattern SHAPER = getTrimPattern("shaper");
TrimPattern SILENCE = Registry.TRIM_PATTERN.get(NamespacedKey.minecraft("silence"));
TrimPattern SILENCE = getTrimPattern("silence");
TrimPattern SNOUT = Registry.TRIM_PATTERN.get(NamespacedKey.minecraft("snout"));
TrimPattern SNOUT = getTrimPattern("snout");
TrimPattern SPIRE = Registry.TRIM_PATTERN.get(NamespacedKey.minecraft("spire"));
TrimPattern SPIRE = getTrimPattern("spire");
TrimPattern TIDE = Registry.TRIM_PATTERN.get(NamespacedKey.minecraft("tide"));
TrimPattern TIDE = getTrimPattern("tide");
TrimPattern VEX = Registry.TRIM_PATTERN.get(NamespacedKey.minecraft("vex"));
TrimPattern VEX = getTrimPattern("vex");
TrimPattern WARD = Registry.TRIM_PATTERN.get(NamespacedKey.minecraft("ward"));
TrimPattern WARD = getTrimPattern("ward");
TrimPattern WAYFINDER = Registry.TRIM_PATTERN.get(NamespacedKey.minecraft("wayfinder"));
TrimPattern WAYFINDER = getTrimPattern("wayfinder");
TrimPattern WILD = Registry.TRIM_PATTERN.get(NamespacedKey.minecraft("wild"));
TrimPattern WILD = getTrimPattern("wild");
// Paper end - Generated/TrimPattern
private static TrimPattern getTrimPattern(String name) {
NamespacedKey key = NamespacedKey.minecraft(name);
return io.papermc.paper.registry.RegistryAccess.registryAccess().getRegistry(io.papermc.paper.registry.RegistryKey.TRIM_PATTERN).get(key);
}
// Paper start - adventure
/**
* Get the description of this {@link TrimPattern}.

View File

@ -294,7 +294,7 @@ public final class CraftBlockStates {
}
// See BlockStateFactory#createBlockState(World, BlockPosition, IBlockData, TileEntity)
public static CraftBlockState getBlockState(World world, BlockPos blockPosition, net.minecraft.world.level.block.state.BlockState blockData, BlockEntity tileEntity) {
private static CraftBlockState getBlockState(World world, BlockPos blockPosition, net.minecraft.world.level.block.state.BlockState blockData, BlockEntity tileEntity) {
Material material = CraftBlockType.minecraftToBukkit(blockData.getBlock());
BlockStateFactory<?> factory;
// For some types of TileEntity blocks (eg. moving pistons), Minecraft may in some situations (eg. when using Block#setType or the

View File

@ -29,6 +29,7 @@ import org.bukkit.SoundGroup;
import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockState;
import org.bukkit.block.BlockSupport;
import org.bukkit.block.BlockType;
import org.bukkit.block.PistonMoveReaction;
import org.bukkit.block.data.BlockData;
import org.bukkit.block.structure.Mirror;
@ -563,12 +564,11 @@ public class CraftBlockData implements BlockData {
}
// Paper end - cache block data strings
public static CraftBlockData newData(Material material, String data) {
Preconditions.checkArgument(material == null || material.isBlock(), "Cannot get data for not block %s", material);
public static CraftBlockData newData(BlockType blockType, String data) {
// Paper start - cache block data strings
if (material != null) {
Block block = CraftBlockType.bukkitToMinecraft(material);
if (blockType != null) {
Block block = CraftBlockType.bukkitToMinecraftNew(blockType);
if (block != null) {
net.minecraft.resources.ResourceLocation key = BuiltInRegistries.BLOCK.getKey(block);
data = data == null ? key.toString() : key + data;
@ -579,10 +579,10 @@ public class CraftBlockData implements BlockData {
return (CraftBlockData) cached.clone();
}
private static CraftBlockData createNewData(Material material, String data) {
private static CraftBlockData createNewData(BlockType blockType, String data) {
// Paper end - cache block data strings
net.minecraft.world.level.block.state.BlockState blockData;
Block block = CraftBlockType.bukkitToMinecraft(material);
Block block = blockType == null ? null : ((CraftBlockType<?>) blockType).getHandle();
Map<Property<?>, Comparable<?>> parsed = null;
// Data provided, use it

View File

@ -0,0 +1,104 @@
package org.bukkit.craftbukkit.potion;
import com.google.common.base.Preconditions;
import com.google.common.collect.BiMap;
import com.google.common.collect.ImmutableBiMap;
import net.minecraft.core.Holder;
import net.minecraft.world.effect.MobEffect;
import net.minecraft.world.effect.MobEffectInstance;
import org.bukkit.potion.PotionData;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.potion.PotionType;
public class CraftPotionUtil {
private static final BiMap<PotionType, PotionType> upgradeable = ImmutableBiMap.<PotionType, PotionType>builder()
// Paper start - Generated/CraftPotionUtil#upgradeable
// @GeneratedFrom 1.20.6
.put(PotionType.HARMING, PotionType.STRONG_HARMING)
.put(PotionType.HEALING, PotionType.STRONG_HEALING)
.put(PotionType.LEAPING, PotionType.STRONG_LEAPING)
.put(PotionType.POISON, PotionType.STRONG_POISON)
.put(PotionType.REGENERATION, PotionType.STRONG_REGENERATION)
.put(PotionType.SLOWNESS, PotionType.STRONG_SLOWNESS)
.put(PotionType.STRENGTH, PotionType.STRONG_STRENGTH)
.put(PotionType.SWIFTNESS, PotionType.STRONG_SWIFTNESS)
.put(PotionType.TURTLE_MASTER, PotionType.STRONG_TURTLE_MASTER)
// Paper end - Generated/CraftPotionUtil#upgradeable
.build();
private static final BiMap<PotionType, PotionType> extendable = ImmutableBiMap.<PotionType, PotionType>builder()
// Paper start - Generated/CraftPotionUtil#extendable
// @GeneratedFrom 1.20.6
.put(PotionType.FIRE_RESISTANCE, PotionType.LONG_FIRE_RESISTANCE)
.put(PotionType.INVISIBILITY, PotionType.LONG_INVISIBILITY)
.put(PotionType.LEAPING, PotionType.LONG_LEAPING)
.put(PotionType.NIGHT_VISION, PotionType.LONG_NIGHT_VISION)
.put(PotionType.POISON, PotionType.LONG_POISON)
.put(PotionType.REGENERATION, PotionType.LONG_REGENERATION)
.put(PotionType.SLOW_FALLING, PotionType.LONG_SLOW_FALLING)
.put(PotionType.SLOWNESS, PotionType.LONG_SLOWNESS)
.put(PotionType.STRENGTH, PotionType.LONG_STRENGTH)
.put(PotionType.SWIFTNESS, PotionType.LONG_SWIFTNESS)
.put(PotionType.TURTLE_MASTER, PotionType.LONG_TURTLE_MASTER)
.put(PotionType.WATER_BREATHING, PotionType.LONG_WATER_BREATHING)
.put(PotionType.WEAKNESS, PotionType.LONG_WEAKNESS)
// Paper end - Generated/CraftPotionUtil#extendable
.build();
public static PotionType fromBukkit(PotionData data) {
if (data == null) {
return null;
}
PotionType type;
if (data.isUpgraded()) {
type = CraftPotionUtil.upgradeable.get(data.getType());
} else if (data.isExtended()) {
type = CraftPotionUtil.extendable.get(data.getType());
} else {
type = data.getType();
}
Preconditions.checkNotNull(type, "Unknown potion type from data " + data);
return type;
}
public static PotionData toBukkit(PotionType type) {
if (type == null) {
return null;
}
PotionType potionType;
potionType = CraftPotionUtil.extendable.inverse().get(type);
if (potionType != null) {
return new PotionData(potionType, true, false);
}
potionType = CraftPotionUtil.upgradeable.inverse().get(type);
if (potionType != null) {
return new PotionData(potionType, false, true);
}
return new PotionData(type, false, false);
}
public static MobEffectInstance fromBukkit(PotionEffect effect) {
Holder<MobEffect> type = CraftPotionEffectType.bukkitToMinecraftHolder(effect.getType());
// Paper - Note: do not copy over the hidden effect, as this method is only used for applying to entities which we do not want to convert over.
return new MobEffectInstance(type, effect.getDuration(), effect.getAmplifier(), effect.isAmbient(), effect.hasParticles(), effect.hasIcon()); // Paper
}
public static PotionEffect toBukkit(MobEffectInstance effect) {
PotionEffectType type = CraftPotionEffectType.minecraftHolderToBukkit(effect.getEffect());
int amp = effect.getAmplifier();
int duration = effect.getDuration();
boolean ambient = effect.isAmbient();
boolean particles = effect.isVisible();
return new PotionEffect(type, duration, amp, ambient, particles, effect.showIcon(), effect.hiddenEffect == null ? null : toBukkit(effect.hiddenEffect)); // Paper
}
public static boolean equals(Holder<MobEffect> mobEffect, PotionEffectType type) {
PotionEffectType typeV = CraftPotionEffectType.minecraftHolderToBukkit(mobEffect);
return typeV.equals(type);
}
}

View File

@ -4,10 +4,12 @@ import io.papermc.generator.rewriter.replace.CompositeRewriter;
import io.papermc.generator.rewriter.SourceRewriter;
import io.papermc.generator.rewriter.types.EnumCloneRewriter;
import io.papermc.generator.rewriter.types.EnumRegistryRewriter;
import io.papermc.generator.rewriter.types.simple.BlockTypeRewriter;
import io.papermc.generator.rewriter.types.simple.CraftBlockDataMapping;
import io.papermc.generator.rewriter.types.simple.CraftBlockEntityStateMapping;
import io.papermc.generator.rewriter.types.simple.CraftPotionUtilRewriter;
import io.papermc.generator.rewriter.types.simple.EntityTypeRewriter;
import io.papermc.generator.rewriter.types.simple.ItemTypeRewriter;
import io.papermc.generator.rewriter.types.simple.MapPaletteRewriter;
import io.papermc.generator.rewriter.types.RegistryFieldRewriter;
import io.papermc.generator.rewriter.types.TagRewriter;
@ -184,13 +186,15 @@ public interface Generators {
),
new RegistryFieldRewriter<>(Structure.class, Registries.STRUCTURE, "Structure", "getStructure"),
new RegistryFieldRewriter<>(StructureType.class, Registries.STRUCTURE_TYPE, "StructureType", "getStructureType"),
new RegistryFieldRewriter<>(TrimPattern.class, Registries.TRIM_PATTERN, "TrimPattern", null),
new RegistryFieldRewriter<>(TrimMaterial.class, Registries.TRIM_MATERIAL, "TrimMaterial", null),
new RegistryFieldRewriter<>(TrimPattern.class, Registries.TRIM_PATTERN, "TrimPattern", "getTrimPattern"),
new RegistryFieldRewriter<>(TrimMaterial.class, Registries.TRIM_MATERIAL, "TrimMaterial", "getTrimMaterial"),
new RegistryFieldRewriter<>(DamageType.class, Registries.DAMAGE_TYPE, "DamageType", "getDamageType"),
new RegistryFieldRewriter<>(GameEvent.class, Registries.GAME_EVENT, "GameEvent", "getEvent"),
new RegistryFieldRewriter<>(MusicInstrument.class, Registries.INSTRUMENT, "MusicInstrument", "getInstrument"),
new RegistryFieldRewriter<>(Wolf.Variant.class, Registries.WOLF_VARIANT, "WolfVariant", "getVariant"),
new MemoryKeyRewriter("MemoryKey"),
new ItemTypeRewriter("ItemType"),
new BlockTypeRewriter("BlockType"),
new TagRewriter(Tag.class, "Tag"),
new MapPaletteRewriter("MapPalette#colors")
};

View File

@ -2,7 +2,6 @@ package io.papermc.generator;
import com.google.common.util.concurrent.MoreExecutors;
import com.mojang.logging.LogUtils;
import io.papermc.generator.rewriter.SourceRewriter;
import io.papermc.generator.types.SourceGenerator;
import io.papermc.generator.types.craftblockdata.CraftBlockDataGenerators;
import io.papermc.generator.utils.experimental.TagCollector;
@ -79,16 +78,13 @@ public final class Main {
PathUtils.deleteDirectory(output);
}
for (final SourceGenerator generator : generators) {
generator.writeToFile(output);
}
apply(output, generators);
LOGGER.info("Files written to {}", output.toAbsolutePath());
}
private static void apply(Path output, SourceRewriter[] rewriters) throws IOException {
for (final SourceRewriter rewriter : rewriters) {
rewriter.writeToFile(output);
private static void apply(Path output, SourceWriter[] writers) throws IOException {
for (final SourceWriter writer : writers) {
writer.writeToFile(output);
}
}
@ -96,6 +92,7 @@ public final class Main {
if (Files.exists(output)) {
PathUtils.deleteDirectory(output);
}
CraftBlockDataGenerators.generate(output);
LOGGER.info("Files written to {}", output.toAbsolutePath());
}

View File

@ -0,0 +1,14 @@
package io.papermc.generator;
import java.io.IOException;
import java.nio.file.Path;
public interface SourceWriter {
String INDENT_UNIT = " ";
int INDENT_SIZE = INDENT_UNIT.length();
char INDENT_CHAR = INDENT_UNIT.charAt(0);
void writeToFile(Path parent) throws IOException;
}

View File

@ -1,7 +1,7 @@
package io.papermc.generator.rewriter;
import io.papermc.generator.utils.ClassHelper;
import org.jetbrains.annotations.Nullable;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.Objects;
public record ClassNamed(String packageName, String simpleName, String dottedNestedName, @Nullable Class<?> knownClass) {

View File

@ -1,10 +1,12 @@
package io.papermc.generator.rewriter;
import java.io.IOException;
import java.nio.file.Path;
import io.papermc.generator.SourceWriter;
public interface SourceRewriter {
public interface SourceRewriter extends SourceWriter {
void writeToFile(Path parent) throws IOException;
String PAPER_START_FORMAT = "Paper start";
String PAPER_END_FORMAT = "Paper end";
String SEARCH_COMMENT_MARKER_FORMAT = "// %s - Generated/%s"; // {0} = PAPER_START_FORMAT|PAPER_END_FORMAT {1} = pattern
void dump(StringBuilder into);
}

View File

@ -9,9 +9,9 @@ import io.papermc.generator.rewriter.parser.step.IterativeStep;
import io.papermc.generator.rewriter.parser.step.StepManager;
import io.papermc.generator.rewriter.parser.step.model.AnnotationSkipSteps;
import io.papermc.generator.rewriter.parser.step.model.ImportStatementSteps;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.List;
@ApiStatus.Internal
@ -28,7 +28,7 @@ public class LineParser {
// internal use only or when nearestClosure = null
// doesn't support leaf closure char escape
public boolean tryAdvanceStartClosure(@NotNull ClosureType type, @NotNull StringReader line) {
public boolean tryAdvanceStartClosure(@NonNull ClosureType type, @NonNull StringReader line) {
if (line.trySkipString(type.start)) { // closure has been consumed
Closure previousNearestClosure = this.nearestClosure;
this.nearestClosure = Closure.create(type);
@ -45,7 +45,7 @@ public class LineParser {
}
// for all closure, leaf closure type should use the other similar method after this one if possible
public ClosureAdvanceResult tryAdvanceEndClosure(@NotNull Closure closure, @NotNull StringReader line) {
public ClosureAdvanceResult tryAdvanceEndClosure(@NonNull Closure closure, @NonNull StringReader line) {
Preconditions.checkState(this.nearestClosure != null && this.nearestClosure.hasUpperClosure(closure), "Need to be in an upper closure of " + closure + " to find its end identifier");
boolean directClosureFound = this.nearestClosure == closure;
if (!directClosureFound) {
@ -73,7 +73,7 @@ public class LineParser {
}
// computedTypes list order matters here
public boolean trySkipNestedClosures(@NotNull Closure inClosure, @NotNull StringReader line, @NotNull List<ClosureType> computedTypes) {
public boolean trySkipNestedClosures(@NonNull Closure inClosure, @NonNull StringReader line, @NonNull List<ClosureType> computedTypes) {
boolean directClosureFound = this.nearestClosure == inClosure;
boolean isLeaf = this.nearestClosure != null && ClosureType.LEAFS.contains(this.nearestClosure.getType());
if (this.nearestClosure != null && !directClosureFound) {
@ -98,7 +98,7 @@ public class LineParser {
return false;
}
public ClosureAdvanceResult tryAdvanceEndLeafClosure(@NotNull ClosureType type, @NotNull StringReader line) {
public ClosureAdvanceResult tryAdvanceEndLeafClosure(@NonNull ClosureType type, @NonNull StringReader line) {
Preconditions.checkArgument(ClosureType.LEAFS.contains(type), "Only leaf closure can be advanced using its type only, for other types use the closure equivalent method to take in account nested closures");
Preconditions.checkState(this.nearestClosure != null && this.nearestClosure.getType() == type, "Need a direct upper closure of " + type);
@ -121,7 +121,7 @@ public class LineParser {
}
// generic usage that check other leaf closure
private boolean skipLeafClosure(@NotNull ClosureType type, @NotNull StringReader line) {
private boolean skipLeafClosure(@NonNull ClosureType type, @NonNull StringReader line) {
final boolean isInClosure;
if (this.nearestClosure != null) {
isInClosure = this.nearestClosure.getType() == type;
@ -148,11 +148,11 @@ public class LineParser {
return false;
}
public boolean skipComment(@NotNull StringReader line) {
public boolean skipComment(@NonNull StringReader line) {
return this.skipLeafClosure(ClosureType.COMMENT, line);
}
public boolean skipCommentOrWhitespace(@NotNull StringReader line) {
public boolean skipCommentOrWhitespace(@NonNull StringReader line) {
boolean skipped = false;
while (this.skipComment(line) || line.skipWhitespace() > 0) {
skipped = true;
@ -160,7 +160,7 @@ public class LineParser {
return skipped;
}
public boolean trySkipCommentOrWhitespaceUntil(@NotNull StringReader line, char terminator) {
public boolean trySkipCommentOrWhitespaceUntil(@NonNull StringReader line, char terminator) {
int previousCursor = line.getCursor();
boolean skipped = this.skipCommentOrWhitespace(line);
if (skipped && line.canRead() && line.peek() != terminator) {
@ -172,11 +172,11 @@ public class LineParser {
}
// note: always check single line comment AFTER multi line comment unless exception
public boolean peekSingleLineComment(@NotNull StringReader line) {
public boolean peekSingleLineComment(@NonNull StringReader line) {
return line.canRead(2) && line.peek() == '/' && line.peek(1) == '/';
}
public boolean consumeImports(@NotNull StringReader line, @NotNull ImportCollector collector) {
public boolean consumeImports(@NonNull StringReader line, @NonNull ImportCollector collector) {
outerLoop:
while (line.canRead()) {
IterativeStep step;
@ -213,8 +213,7 @@ public class LineParser {
return false;
}
@NotNull
public StepManager getSteps() {
public @NonNull StepManager getSteps() {
return this.stepManager;
}
}

View File

@ -1,7 +1,7 @@
package io.papermc.generator.rewriter.parser;
import com.mojang.brigadier.ImmutableStringReader;
import org.jetbrains.annotations.Nullable;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.function.Predicate;

View File

@ -2,7 +2,7 @@ package io.papermc.generator.rewriter.parser.closure;
import io.papermc.generator.rewriter.parser.ParserException;
import io.papermc.generator.rewriter.parser.StringReader;
import org.jetbrains.annotations.Nullable;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.function.Supplier;
public interface Closure {

View File

@ -4,6 +4,7 @@ import com.google.common.base.Preconditions;
import io.papermc.generator.rewriter.ClassNamed;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
@ -35,6 +36,13 @@ public class CompositeRewriter extends SearchReplaceRewriter {
return false;
}
@Override
public void dump(StringBuilder content) {
for (SearchReplaceRewriter rewriter : this.getRewriters()) {
rewriter.dump(content);
}
}
@Override
protected SearchReplaceRewriter getRewriterFor(String pattern) {
return this.rewriterByPattern.get(pattern);
@ -42,11 +50,11 @@ public class CompositeRewriter extends SearchReplaceRewriter {
@Override
public Set<String> getPatterns() {
return this.rewriterByPattern.keySet();
return Collections.unmodifiableSet(this.rewriterByPattern.keySet());
}
public Collection<SearchReplaceRewriter> getRewriters() {
return this.rewriterByPattern.values();
return Collections.unmodifiableCollection(this.rewriterByPattern.values());
}
public static CompositeRewriter bind(SearchReplaceRewriter... rewriters) {

View File

@ -1,6 +1,7 @@
package io.papermc.generator.rewriter.replace;
import com.google.common.base.Preconditions;
import com.mojang.logging.LogUtils;
import io.papermc.generator.Main;
import io.papermc.generator.rewriter.ClassNamed;
import io.papermc.generator.rewriter.SourceRewriter;
@ -12,9 +13,9 @@ import io.papermc.generator.rewriter.parser.StringReader;
import io.papermc.generator.utils.Formatting;
import io.papermc.paper.generated.GeneratedFrom;
import net.minecraft.SharedConstants;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.VisibleForTesting;
import org.slf4j.Logger;
import java.io.BufferedReader;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
@ -27,17 +28,7 @@ import static io.papermc.generator.rewriter.replace.CommentMarker.EMPTY_MARKER;
public class SearchReplaceRewriter implements SourceRewriter {
protected static final String INDENT_UNIT = " ";
@VisibleForTesting
public static final int INDENT_SIZE = INDENT_UNIT.length();
@VisibleForTesting
public static final char INDENT_CHAR = INDENT_UNIT.charAt(0);
@VisibleForTesting
public static final String PAPER_START_FORMAT = "Paper start";
private static final String PAPER_END_FORMAT = "Paper end";
@VisibleForTesting
public static final String GENERATED_COMMENT_FORMAT = "// %s - Generated/%s"; // {0} = PAPER_START_FORMAT|PAPER_END_FORMAT {1} = pattern
private static final Logger LOGGER = LogUtils.getLogger();
protected final ClassNamed rewriteClass;
protected final String pattern;
@ -196,22 +187,66 @@ public class SearchReplaceRewriter implements SourceRewriter {
String filePath = this.getRelativeFilePath();
Path path = parent.resolve(filePath);
final Path createdPath;
StringBuilder content = new StringBuilder();
try (BufferedReader buffer = Files.newBufferedReader(path, StandardCharsets.UTF_8)) {
this.searchAndReplace(buffer, content);
if (Files.isRegularFile(path)) {
try (BufferedReader buffer = Files.newBufferedReader(path, StandardCharsets.UTF_8)) {
this.searchAndReplace(buffer, content);
}
} else if (!this.exactReplacement) {
LOGGER.warn("Target source file '{}' doesn't exists, dumping rewriters data instead...", filePath);
this.dumpAll(content);
filePath += ".dump";
path = parent.resolve(filePath);
}
// Files.writeString(path, content.toString(), StandardCharsets.UTF_8); // todo
Path createdPath;
if (this.rewriteClass.knownClass() != null) {
if (path.toString().contains("Paper/Paper-API/src/")) {
createdPath = Main.generatedPath.resolve(filePath);
} else {
createdPath = Main.generatedServerPath.resolve(filePath);
}
Files.createDirectories(createdPath.getParent());
Files.writeString(createdPath, content, StandardCharsets.UTF_8);
}
@Override
public void dump(StringBuilder content) {
content.append('\n');
content.append(this.pattern);
content.append('\n');
content.append("Start comment marker : ").append(SEARCH_COMMENT_MARKER_FORMAT.formatted(PAPER_START_FORMAT, this.pattern));
content.append('\n');
content.append("End comment marker : ").append(SEARCH_COMMENT_MARKER_FORMAT.formatted(PAPER_END_FORMAT, this.pattern));
content.append('\n');
content.append('\n');
content.append(">".repeat(30));
content.append('\n');
this.insert(new SearchMetadata(ImportCollector.NO_OP, INDENT_UNIT, "", -1), content);
content.append("<".repeat(30));
content.append('\n');
}
public void dumpAll(StringBuilder content) {
content.append("Dump of the rewriters that apply to the file : ").append(this.getRelativeFilePath());
content.append('\n');
content.append('\n');
content.append("Configuration :");
content.append('\n');
content.append("Indent unit : \"").append(INDENT_UNIT).append("\" (").append(INDENT_SIZE).append(" char)");
content.append('\n');
content.append("Indent char : '").append(INDENT_CHAR).append("' (").append(INDENT_UNIT.codePointAt(0)).append(")");
content.append('\n');
this.dump(content);
}
private void appendGeneratedComment(StringBuilder builder, String indent) {
builder.append(indent).append("// %s %s".formatted(
Annotations.annotationStyle(GeneratedFrom.class),
@ -232,8 +267,8 @@ public class SearchReplaceRewriter implements SourceRewriter {
indentSize = lineIterator.skipChars(INDENT_CHAR);
}
boolean foundStart = lineIterator.trySkipString(GENERATED_COMMENT_FORMAT.formatted(PAPER_START_FORMAT, ""));
boolean foundEnd = !foundStart && lineIterator.trySkipString(GENERATED_COMMENT_FORMAT.formatted(PAPER_END_FORMAT, ""));
boolean foundStart = lineIterator.trySkipString(SEARCH_COMMENT_MARKER_FORMAT.formatted(PAPER_START_FORMAT, ""));
boolean foundEnd = !foundStart && lineIterator.trySkipString(SEARCH_COMMENT_MARKER_FORMAT.formatted(PAPER_END_FORMAT, ""));
if (!foundStart && !foundEnd) {
return EMPTY_MARKER;
}

View File

@ -65,8 +65,7 @@ public class EnumRegistryRewriter<T, A extends Enum<A>> extends EnumRewriter<Hol
}
}
@Nullable
protected FeatureFlagSet getRequiredFeatures(Holder.Reference<T> reference) {
protected @Nullable FeatureFlagSet getRequiredFeatures(Holder.Reference<T> reference) {
if (this.isFilteredRegistry && reference.value() instanceof FeatureElement element && FeatureFlags.isExperimental(element.requiredFeatures())) {
return element.requiredFeatures();
}

View File

@ -3,6 +3,7 @@ package io.papermc.generator.rewriter.types;
import com.google.common.base.Preconditions;
import com.google.common.base.Suppliers;
import io.papermc.generator.Main;
import io.papermc.generator.rewriter.ClassNamed;
import io.papermc.generator.rewriter.replace.SearchMetadata;
import io.papermc.generator.rewriter.replace.SearchReplaceRewriter;
import io.papermc.generator.rewriter.utils.Annotations;
@ -15,14 +16,8 @@ import net.minecraft.resources.ResourceKey;
import net.minecraft.world.flag.FeatureElement;
import net.minecraft.world.flag.FeatureFlagSet;
import net.minecraft.world.flag.FeatureFlags;
import org.bukkit.NamespacedKey;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.lang.reflect.ParameterizedType;
import java.util.IdentityHashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.function.Supplier;
@ -31,45 +26,29 @@ import static javax.lang.model.element.Modifier.FINAL;
import static javax.lang.model.element.Modifier.PUBLIC;
import static javax.lang.model.element.Modifier.STATIC;
public class RegistryFieldRewriter<T, A> extends SearchReplaceRewriter {
private static final Map<Class<?>, String> REGISTRY_FIELD_NAMES;
static {
final Map<Class<?>, String> map = new IdentityHashMap<>();
for (final Field field : org.bukkit.Registry.class.getDeclaredFields()) {
if (field.isAnnotationPresent(Deprecated.class) || field.getType() != org.bukkit.Registry.class) {
continue;
}
int mod = field.getModifiers();
if (Modifier.isPublic(mod) & Modifier.isStatic(mod) & Modifier.isFinal(mod)) {
map.put((Class<?>) ((ParameterizedType) field.getGenericType()).getActualTypeArguments()[0], field.getName());
}
}
REGISTRY_FIELD_NAMES = Map.copyOf(map);
}
public class RegistryFieldRewriter<T> extends SearchReplaceRewriter {
private final Registry<T> registry;
private final Supplier<Set<ResourceKey<T>>> experimentalKeys;
private final boolean isFilteredRegistry;
private final String fetchMethod;
private final boolean isInterface;
private final String fetchMethod;
public RegistryFieldRewriter(final Class<A> rewriteClass, final ResourceKey<? extends Registry<T>> registryKey, final String pattern, final @Nullable String fetchMethod) {
public RegistryFieldRewriter(final ClassNamed rewriteClass, final ResourceKey<? extends Registry<T>> registryKey, final String pattern, final boolean isInterface, final String fetchMethod) {
super(rewriteClass, pattern, false);
this.registry = Main.REGISTRY_ACCESS.registryOrThrow(registryKey);
this.experimentalKeys = Suppliers.memoize(() -> RegistryUtils.collectExperimentalDataDrivenKeys(this.registry));
this.isFilteredRegistry = FeatureElement.FILTERED_REGISTRIES.contains(registryKey);
this.isInterface = rewriteClass.isInterface();
this.isInterface = isInterface;
this.fetchMethod = fetchMethod;
}
public RegistryFieldRewriter(final Class<?> rewriteClass, final ResourceKey<? extends Registry<T>> registryKey, final String pattern, final @Nullable String fetchMethod) {
this(new ClassNamed(rewriteClass), registryKey, pattern, rewriteClass.isInterface() && !rewriteClass.isAnnotation(), fetchMethod);
}
@Override
protected void beginSearch() {
if (this.fetchMethod == null) {
return;
}
Preconditions.checkState(this.rewriteClass.knownClass() != null, "This rewriter can't check the integrity of the fetch method since it doesn't know the rewritten class!");
try {
this.rewriteClass.knownClass().getDeclaredMethod(this.fetchMethod, String.class);
@ -96,13 +75,10 @@ public class RegistryFieldRewriter<T, A> extends SearchReplaceRewriter {
if (!this.isInterface) {
builder.append("%s %s %s ".formatted(PUBLIC, STATIC, FINAL));
}
builder.append(this.rewriteClass.simpleName()).append(' ').append(this.rewriteFieldName(reference));
builder.append(this.rewriteFieldType(reference)).append(' ').append(this.rewriteFieldName(reference));
builder.append(" = ");
if (this.fetchMethod == null) {
builder.append("%s.%s.get(%s.minecraft(%s))".formatted(org.bukkit.Registry.class.getSimpleName(), REGISTRY_FIELD_NAMES.get(this.rewriteClass.knownClass()), NamespacedKey.class.getSimpleName(), quoted(pathKey)));
} else {
builder.append("%s(%s)".formatted(this.fetchMethod, quoted(pathKey)));
}
builder.append("%s(%s)".formatted(this.fetchMethod, quoted(pathKey)));
builder.append(';');
builder.append('\n');
@ -112,12 +88,15 @@ public class RegistryFieldRewriter<T, A> extends SearchReplaceRewriter {
}
}
protected String rewriteFieldType(Holder.Reference<T> reference) {
return this.rewriteClass.simpleName();
}
protected String rewriteFieldName(Holder.Reference<T> reference) {
return Formatting.formatKeyAsField(reference.key().location().getPath());
}
@Nullable
protected FeatureFlagSet getRequiredFeatures(Holder.Reference<T> reference) {
protected @Nullable FeatureFlagSet getRequiredFeatures(Holder.Reference<T> reference) {
if (this.isFilteredRegistry && reference.value() instanceof FeatureElement element && FeatureFlags.isExperimental(element.requiredFeatures())) {
return element.requiredFeatures();
}

View File

@ -0,0 +1,5 @@
@DefaultQualifier(NonNull.class)
package io.papermc.generator.rewriter.types;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.framework.qual.DefaultQualifier;

View File

@ -0,0 +1,28 @@
package io.papermc.generator.rewriter.types.simple;
import io.papermc.generator.rewriter.types.RegistryFieldRewriter;
import io.papermc.generator.utils.BlockStateMapping;
import io.papermc.generator.utils.ClassHelper;
import net.minecraft.core.Holder;
import net.minecraft.core.registries.Registries;
import net.minecraft.world.level.block.Block;
import org.bukkit.block.BlockType;
import org.bukkit.block.data.BlockData;
import org.checkerframework.checker.nullness.qual.Nullable;
public class BlockTypeRewriter extends RegistryFieldRewriter<Block> {
public BlockTypeRewriter(final String pattern) {
super(BlockType.class, Registries.BLOCK, pattern, "getBlockType");
}
@Override
protected String rewriteFieldType(Holder.Reference<Block> reference) {
@Nullable Class<?> blockData = BlockStateMapping.getBestSuitedApiClass(reference.value().getClass());
if (blockData == null) {
blockData = BlockData.class;
}
return "%s<%s>".formatted(ClassHelper.retrieveFullNestedName(BlockType.Typed.class), blockData.getSimpleName());
}
}

View File

@ -31,5 +31,4 @@ public class CraftPotionUtilRewriter extends SearchReplaceRewriter {
builder.append('\n');
});
}
}

View File

@ -0,0 +1,40 @@
package io.papermc.generator.rewriter.types.simple;
import io.papermc.generator.rewriter.types.RegistryFieldRewriter;
import io.papermc.generator.utils.ClassHelper;
import io.papermc.generator.utils.experimental.ExperimentalHelper.FlagSets;
import net.minecraft.core.Holder;
import net.minecraft.core.registries.Registries;
import net.minecraft.world.flag.FeatureFlagSet;
import net.minecraft.world.item.BundleItem;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.Items;
import org.bukkit.inventory.ItemType;
import org.bukkit.inventory.meta.ItemMeta;
import org.checkerframework.checker.nullness.qual.Nullable;
@Deprecated // bad generic
public class ItemTypeRewriter extends RegistryFieldRewriter<Item> {
public ItemTypeRewriter(final String pattern) {
super(ItemType.class, Registries.ITEM, pattern, "getItemType");
}
@Override
protected String rewriteFieldType(Holder.Reference<Item> reference) {
if (reference.value().equals(Items.AIR)) {
return super.rewriteFieldType(reference);
}
return "%s<%s>".formatted(ClassHelper.retrieveFullNestedName(ItemType.Typed.class), ItemMeta.class.getSimpleName());
}
@Override
protected @Nullable FeatureFlagSet getRequiredFeatures(Holder.Reference<Item> reference) {
if (reference.value() instanceof BundleItem) {
return FlagSets.BUNDLE.get(); // special case since the item is not locked itself just in the creative menu
} else {
return super.getRequiredFeatures(reference);
}
}
}

View File

@ -24,6 +24,7 @@ import net.minecraft.world.level.block.WallSignBlock;
import org.bukkit.Material;
import org.bukkit.block.data.BlockData;
import org.bukkit.inventory.EquipmentSlot;
import org.checkerframework.checker.nullness.qual.Nullable;
@Deprecated(forRemoval = true)
public class MaterialRewriter {
@ -56,7 +57,7 @@ public class MaterialRewriter {
equivalentItem = Optional.of(block.asItem());
}
Class<?> blockData = BlockStateMapping.getBestSuitedApiClass(block.getClass());
@Nullable Class<?> blockData = BlockStateMapping.getBestSuitedApiClass(block.getClass());
if (blockData == null) {
blockData = BlockData.class;
}
@ -118,7 +119,7 @@ public class MaterialRewriter {
}
@Override
protected FeatureFlagSet getRequiredFeatures(Holder.Reference<Item> reference) {
protected @Nullable FeatureFlagSet getRequiredFeatures(Holder.Reference<Item> reference) {
if (reference.value() instanceof BundleItem) {
return FlagSets.BUNDLE.get(); // special case since the item is not locked itself just in the creative menu
} else {

View File

@ -0,0 +1,5 @@
@DefaultQualifier(NonNull.class)
package io.papermc.generator.rewriter.types.simple;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.framework.qual.DefaultQualifier;

View File

@ -2,10 +2,13 @@ package io.papermc.generator.types;
import com.squareup.javapoet.JavaFile;
import com.squareup.javapoet.TypeSpec;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.framework.qual.DefaultQualifier;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
@DefaultQualifier(NonNull.class)
public abstract class SimpleGenerator implements SourceGenerator {
protected final String className;
@ -26,7 +29,7 @@ public abstract class SimpleGenerator implements SourceGenerator {
public void writeToFile(Path parent) throws IOException {
JavaFile.Builder builder = JavaFile.builder(this.packageName, this.getTypeSpec());
this.file(builder)
.indent(" ")
.indent(INDENT_UNIT)
.skipJavaLangImports(true);
builder.build().writeTo(parent, StandardCharsets.UTF_8);

View File

@ -1,9 +1,6 @@
package io.papermc.generator.types;
import java.io.IOException;
import java.nio.file.Path;
import io.papermc.generator.SourceWriter;
public interface SourceGenerator {
void writeToFile(Path parent) throws IOException;
public interface SourceGenerator extends SourceWriter {
}

View File

@ -3,12 +3,15 @@ package io.papermc.generator.types;
import com.mojang.logging.LogUtils;
import com.squareup.javapoet.MethodSpec;
import io.papermc.generator.utils.Annotations;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.framework.qual.DefaultQualifier;
import org.slf4j.Logger;
import java.util.Arrays;
import static javax.lang.model.element.Modifier.PUBLIC;
@DefaultQualifier(NonNull.class)
public abstract class StructuredGenerator<T> extends SimpleGenerator {
private static final Logger LOGGER = LogUtils.getLogger();

View File

@ -1,7 +1,10 @@
package io.papermc.generator.types;
import com.squareup.javapoet.ClassName;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.framework.qual.DefaultQualifier;
@DefaultQualifier(NonNull.class)
public final class Types {
public static final String BASE_PACKAGE = "org.bukkit.craftbukkit";

View File

@ -10,11 +10,14 @@ import net.minecraft.world.entity.monster.RangedAttackMob;
import org.apache.commons.lang3.math.NumberUtils;
import org.bukkit.NamespacedKey;
import org.bukkit.entity.*;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.framework.qual.DefaultQualifier;
import java.lang.reflect.Constructor;
import java.util.HashMap;
import java.util.Map;
@DefaultQualifier(NonNull.class)
public final class MobGoalNames { // todo sync with MobGoalHelper ideally this should not be duplicated
private static final Map<Class<? extends Goal>, Class<? extends Mob>> entityClassCache = new HashMap<>();

View File

@ -23,14 +23,11 @@ import net.minecraft.world.flag.FeatureFlags;
import org.bukkit.Keyed;
import org.bukkit.MinecraftExperimental;
import org.bukkit.NamespacedKey;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.checkerframework.framework.qual.DefaultQualifier;
import static javax.lang.model.element.Modifier.FINAL;
import static javax.lang.model.element.Modifier.PRIVATE;
@DefaultQualifier(NonNull.class)
public abstract class EnumRegistryGenerator<T> extends SimpleGenerator {
private final Registry<T> registry;

View File

@ -26,9 +26,7 @@ import net.minecraft.resources.ResourceKey;
import net.minecraft.world.flag.FeatureElement;
import net.minecraft.world.flag.FeatureFlagSet;
import net.minecraft.world.flag.FeatureFlags;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.checkerframework.framework.qual.DefaultQualifier;
import static com.squareup.javapoet.TypeSpec.classBuilder;
import static io.papermc.generator.utils.Annotations.EXPERIMENTAL_API_ANNOTATION;
@ -40,7 +38,6 @@ import static javax.lang.model.element.Modifier.PRIVATE;
import static javax.lang.model.element.Modifier.PUBLIC;
import static javax.lang.model.element.Modifier.STATIC;
@DefaultQualifier(NonNull.class)
public class GeneratedKeyType<T, A> extends SimpleGenerator {
private static final String CREATE_JAVADOC = """

View File

@ -27,9 +27,7 @@ import net.minecraft.world.flag.FeatureFlags;
import org.bukkit.Keyed;
import org.bukkit.MinecraftExperimental;
import org.bukkit.NamespacedKey;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.checkerframework.framework.qual.DefaultQualifier;
import static com.squareup.javapoet.TypeSpec.classBuilder;
import static com.squareup.javapoet.TypeSpec.interfaceBuilder;
@ -41,7 +39,6 @@ import static javax.lang.model.element.Modifier.PRIVATE;
import static javax.lang.model.element.Modifier.PUBLIC;
import static javax.lang.model.element.Modifier.STATIC;
@DefaultQualifier(NonNull.class)
public abstract class RegistryGenerator<T, A> extends SimpleGenerator {
private final ClassName apiType;

View File

@ -31,8 +31,6 @@ import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.Tag;
import org.bukkit.entity.EntityType;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.framework.qual.DefaultQualifier;
import static com.squareup.javapoet.TypeSpec.interfaceBuilder;
import static io.papermc.generator.utils.Annotations.NOT_NULL;
@ -43,7 +41,6 @@ import static javax.lang.model.element.Modifier.FINAL;
import static javax.lang.model.element.Modifier.PUBLIC;
import static javax.lang.model.element.Modifier.STATIC;
@DefaultQualifier(NonNull.class)
public class TagGenerator extends SimpleGenerator {
public static String CLASS_HEADER_JAVADOC = """

View File

@ -0,0 +1,5 @@
@DefaultQualifier(NonNull.class)
package io.papermc.generator.types.registry;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.framework.qual.DefaultQualifier;

View File

@ -8,9 +8,9 @@ import net.minecraft.SharedConstants;
import net.minecraft.world.flag.FeatureFlag;
import net.minecraft.world.flag.FeatureFlagSet;
import org.bukkit.MinecraftExperimental;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public final class Annotations {

View File

@ -103,7 +103,7 @@ import org.bukkit.block.data.type.TechnicalPiston;
import org.bukkit.block.data.type.TrialSpawner;
import org.bukkit.block.data.type.Vault;
import org.bukkit.block.data.type.Wall;
import org.jetbrains.annotations.Nullable;
import org.checkerframework.checker.nullness.qual.Nullable;
public final class BlockStateMapping {

View File

@ -5,8 +5,8 @@ import java.util.Optional;
import java.util.function.Predicate;
import java.util.regex.Pattern;
import io.papermc.generator.rewriter.parser.ProtoTypeName;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.Nullable;
import javax.lang.model.SourceVersion;
public class NamingManager {
@ -15,7 +15,7 @@ public class NamingManager {
private final String baseName;
private final String lowerCamelName, upperCamelName;
public NamingManager(@Nullable NamingManager.AccessKeyword accessKeyword, CaseFormat format, String baseName) {
public NamingManager(NamingManager.@Nullable AccessKeyword accessKeyword, CaseFormat format, String baseName) {
this.accessKeyword = accessKeyword; // this is a little bit too restrictive for extra data hmm
this.baseName = baseName;
this.upperCamelName = format.to(CaseFormat.UPPER_CAMEL, baseName);

View File

@ -17,31 +17,31 @@ import java.nio.file.Files;
import java.nio.file.Path;
import static io.papermc.generator.rewriter.replace.CommentMarker.EMPTY_MARKER;
import static io.papermc.generator.rewriter.replace.SearchReplaceRewriter.INDENT_CHAR;
import static io.papermc.generator.rewriter.replace.SearchReplaceRewriter.INDENT_SIZE;
import static io.papermc.generator.SourceWriter.INDENT_CHAR;
import static io.papermc.generator.SourceWriter.INDENT_SIZE;
import static org.junit.jupiter.api.Assertions.assertEquals;
@Disabled("This test should run at a different lifecycle") // todo
public class OldGeneratedCodeTest {
private static final String API_CONTAINER = System.getProperty("paper.generator.rewriter.container.api");
private static final String SERVER_CONTAINER = System.getProperty("paper.generator.rewriter.container.server");
private static final String CURRENT_VERSION;
private static String CURRENT_VERSION;
@BeforeAll
public static void initializeVersion() {
static {
SharedConstants.tryDetectVersion();
CURRENT_VERSION = SharedConstants.getCurrentVersion().getName();
}
private void checkOutdated(String container, SourceRewriter[] rewriters) throws IOException {
public static void main(String[] args) throws IOException {
checkOutdated(Path.of(args[0]), Generators.API_REWRITE);
checkOutdated(Path.of(args[1]), Generators.SERVER_REWRITE);
}
private static void checkOutdated(Path container, SourceRewriter[] rewriters) throws IOException {
for (SourceRewriter rewriter : rewriters) {
if (!(rewriter instanceof SearchReplaceRewriter srt) || !srt.isVersionDependant()) {
continue;
}
Path path = Path.of(container, srt.getRelativeFilePath());
Path path = container.resolve(srt.getRelativeFilePath());
if (Files.notExists(path)) { // todo (softspoon): remove after
continue;
}
@ -96,10 +96,4 @@ public class OldGeneratedCodeTest {
}
}
}
@Test
public void testOutdatedCode() throws IOException {
checkOutdated(API_CONTAINER, Generators.API_REWRITE);
checkOutdated(SERVER_CONTAINER, Generators.SERVER_REWRITE);
}
}

View File

@ -7,7 +7,7 @@ Currently includes generated key holder classes for types
used in the Registry Modification API
diff --git a/build.gradle.kts b/build.gradle.kts
index 768024b2b4584fd7dd86f068c0e79c89ffc5faa1..f11a22ab01e97e51619c96f2d8a78a99297efc59 100644
index 768024b2b4584fd7dd86f068c0e79c89ffc5faa1..c86a00865337377a3ebf5ff3fdba382b5fa64cc9 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -1,6 +1,7 @@
@ -41,7 +41,7 @@ index 768024b2b4584fd7dd86f068c0e79c89ffc5faa1..f11a22ab01e97e51619c96f2d8a78a99
configure<PublishingExtension> {
publications.create<MavenPublication>("maven") {
from(components["java"])
@@ -121,3 +138,14 @@ tasks.check {
@@ -121,3 +138,15 @@ tasks.check {
dependsOn(scanJar)
}
// Paper end
@ -54,6 +54,7 @@ index 768024b2b4584fd7dd86f068c0e79c89ffc5faa1..f11a22ab01e97e51619c96f2d8a78a99
+}
+tasks.check {
+ dependsOn(scanJarForOldGeneratedCode)
+ dependsOn(":paper-api-generator:scanOldGeneratedSourceCode")
+}
+// Paper end
diff --git a/src/main/java/io/papermc/paper/generated/GeneratedFrom.java b/src/main/java/io/papermc/paper/generated/GeneratedFrom.java

View File

@ -183,10 +183,10 @@ index 6c9689baca1763e2ef79495d38618d587e792434..3073fe5929650076f99d2ea04ebd2265
/**
* Returns a {@link GameEvent} by a {@link NamespacedKey}.
diff --git a/src/main/java/org/bukkit/Material.java b/src/main/java/org/bukkit/Material.java
index 82d009c0bbe4b3026a535e02d6e0ed20c7bd525d..489f1bf244d040a8b599e03351665472b3ae5a12 100644
index 81f9ad99699a78b97e4accaaf1a98eacf29493ce..54fab6f0bd7c33ef63b7d08ac813e92ca952f562 100644
--- a/src/main/java/org/bukkit/Material.java
+++ b/src/main/java/org/bukkit/Material.java
@@ -128,6 +128,7 @@ import org.jetbrains.annotations.Nullable;
@@ -131,6 +131,7 @@ import org.jetbrains.annotations.Nullable;
@SuppressWarnings({"DeprecatedIsStillUsed", "deprecation"}) // Paper
public enum Material implements Keyed, Translatable, net.kyori.adventure.translation.Translatable { // Paper
//<editor-fold desc="Materials" defaultstate="collapsed">
@ -194,7 +194,7 @@ index 82d009c0bbe4b3026a535e02d6e0ed20c7bd525d..489f1bf244d040a8b599e03351665472
AIR(9648, 0),
STONE(22948),
GRANITE(21091),
@@ -3811,6 +3812,9 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla
@@ -3818,6 +3819,9 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla
BIG_DRIPLEAF_STEM(13167, Dripleaf.class),
POTTED_AZALEA_BUSH(20430),
POTTED_FLOWERING_AZALEA_BUSH(10609),
@ -204,83 +204,7 @@ index 82d009c0bbe4b3026a535e02d6e0ed20c7bd525d..489f1bf244d040a8b599e03351665472
// ----- Legacy Separator -----
@Deprecated
LEGACY_AIR(0, 0),
@@ -5005,6 +5009,7 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla
// Paper end
switch (this) {
//<editor-fold defaultstate="collapsed" desc="isBlock">
+ // Paper start - Generated/Material#isBlock
case ACACIA_BUTTON:
case ACACIA_DOOR:
case ACACIA_FENCE:
@@ -6065,6 +6070,7 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla
case YELLOW_WOOL:
case ZOMBIE_HEAD:
case ZOMBIE_WALL_HEAD:
+ // Paper end - Generated/Material#isBlock
//</editor-fold>
return true;
default:
@@ -6080,6 +6086,7 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla
public boolean isEdible() {
switch (this) {
//<editor-fold defaultstate="collapsed" desc="isEdible">
+ // Paper start - Generated/Material#isEdible
case APPLE:
case BAKED_POTATO:
case BEEF:
@@ -6121,6 +6128,7 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla
case SUSPICIOUS_STEW:
case SWEET_BERRIES:
case TROPICAL_FISH:
+ // Paper end - Generated/Material#isEdible
// ----- Legacy Separator -----
case LEGACY_BREAD:
case LEGACY_CARROT_ITEM:
@@ -6257,6 +6265,7 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla
public boolean isRecord() {
switch (this) {
//<editor-fold defaultstate="collapsed" desc="isRecord">
+ // Paper start - Generated/Material#isRecord
case MUSIC_DISC_5:
case MUSIC_DISC_11:
case MUSIC_DISC_13:
@@ -6273,6 +6282,7 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla
case MUSIC_DISC_STRAD:
case MUSIC_DISC_WAIT:
case MUSIC_DISC_WARD:
+ // Paper end - Generated/Material#isRecord
//</editor-fold>
return true;
default:
@@ -6291,6 +6301,7 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla
}
switch (this) {
//<editor-fold defaultstate="collapsed" desc="isSolid">
+ // Paper start - Generated/Material#isSolid
case ACACIA_DOOR:
case ACACIA_FENCE:
case ACACIA_FENCE_GATE:
@@ -7125,6 +7136,7 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla
case YELLOW_TERRACOTTA:
case YELLOW_WALL_BANNER:
case YELLOW_WOOL:
+ // Paper end - Generated/Material#isSolid
// ----- Legacy Separator -----
case LEGACY_STONE:
case LEGACY_GRASS:
@@ -7340,9 +7352,11 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla
public boolean isAir() {
switch (this) {
//<editor-fold defaultstate="collapsed" desc="isAir">
+ // Paper start - Generated/Material#isAir
case AIR:
case CAVE_AIR:
case VOID_AIR:
+ // Paper end - Generated/Material#isAir
// ----- Legacy Separator -----
case LEGACY_AIR:
//</editor-fold>
@@ -7366,6 +7380,7 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla
@@ -5150,6 +5154,7 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla
}
switch (this) {
//<editor-fold defaultstate="collapsed" desc="isTransparent">
@ -288,7 +212,7 @@ index 82d009c0bbe4b3026a535e02d6e0ed20c7bd525d..489f1bf244d040a8b599e03351665472
case ACACIA_BUTTON:
case ACACIA_SAPLING:
case ACTIVATOR_RAIL:
@@ -7493,6 +7508,7 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla
@@ -5277,6 +5282,7 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla
case YELLOW_CARPET:
case ZOMBIE_HEAD:
case ZOMBIE_WALL_HEAD:
@ -296,183 +220,7 @@ index 82d009c0bbe4b3026a535e02d6e0ed20c7bd525d..489f1bf244d040a8b599e03351665472
// ----- Legacy Separator -----
case LEGACY_AIR:
case LEGACY_SAPLING:
@@ -7562,6 +7578,7 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla
}
switch (this) {
//<editor-fold defaultstate="collapsed" desc="isFlammable">
+ // Paper start - Generated/Material#isFlammable
case ACACIA_DOOR:
case ACACIA_FENCE:
case ACACIA_FENCE_GATE:
@@ -7836,6 +7853,7 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla
case YELLOW_CARPET:
case YELLOW_WALL_BANNER:
case YELLOW_WOOL:
+ // Paper end - Generated/Material#isFlammable
// ----- Legacy Separator -----
case LEGACY_WOOD:
case LEGACY_LOG:
@@ -7910,6 +7928,7 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla
}
switch (this) {
//<editor-fold defaultstate="collapsed" desc="isBurnable">
+ // Paper start - Generated/Material#isBurnable
case ACACIA_FENCE:
case ACACIA_FENCE_GATE:
case ACACIA_LEAVES:
@@ -8084,6 +8103,7 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla
case WITHER_ROSE:
case YELLOW_CARPET:
case YELLOW_WOOL:
+ // Paper end - Generated/Material#isBurnable
// ----- Legacy Separator -----
case LEGACY_WOOD:
case LEGACY_LOG:
@@ -8137,6 +8157,7 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla
public boolean isFuel() {
switch (this) {
//<editor-fold defaultstate="collapsed" desc="isFuel">
+ // Paper start - Generated/Material#isFuel
case ACACIA_BOAT:
case ACACIA_BUTTON:
case ACACIA_CHEST_BOAT:
@@ -8385,6 +8406,7 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla
case YELLOW_BANNER:
case YELLOW_CARPET:
case YELLOW_WOOL:
+ // Paper end - Generated/Material#isFuel
// ----- Legacy Separator -----
case LEGACY_LAVA_BUCKET:
case LEGACY_COAL_BLOCK:
@@ -8480,6 +8502,7 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla
}
switch (this) {
//<editor-fold defaultstate="collapsed" desc="isOccluding">
+ // Paper start - Generated/Material#isOccluding
case ACACIA_LOG:
case ACACIA_PLANKS:
case ACACIA_WOOD:
@@ -8851,6 +8874,7 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla
case YELLOW_SHULKER_BOX:
case YELLOW_TERRACOTTA:
case YELLOW_WOOL:
+ // Paper end - Generated/Material#isOccluding
// ----- Legacy Separator -----
case LEGACY_STONE:
case LEGACY_GRASS:
@@ -8966,6 +8990,7 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla
}
switch (this) {
//<editor-fold defaultstate="collapsed" desc="hasGravity">
+ // Paper start - Generated/Material#hasGravity
case ANVIL:
case BLACK_CONCRETE_POWDER:
case BLUE_CONCRETE_POWDER:
@@ -8989,6 +9014,7 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla
case SAND:
case WHITE_CONCRETE_POWDER:
case YELLOW_CONCRETE_POWDER:
+ // Paper end - Generated/Material#hasGravity
// ----- Legacy Separator -----
case LEGACY_SAND:
case LEGACY_GRAVEL:
@@ -9009,6 +9035,7 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla
public boolean isItem() {
switch (this) {
//<editor-fold defaultstate="collapsed" desc="isItem">
+ // Paper start - Generated/Material#isItem
case ACACIA_WALL_HANGING_SIGN:
case ACACIA_WALL_SIGN:
case ATTACHED_MELON_STEM:
@@ -9156,6 +9183,7 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla
case YELLOW_CANDLE_CAKE:
case YELLOW_WALL_BANNER:
case ZOMBIE_WALL_HEAD:
+ // Paper end - Generated/Material#isItem
// ----- Legacy Separator -----
case LEGACY_ACACIA_DOOR:
case LEGACY_BED_BLOCK:
@@ -9239,6 +9267,7 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla
public boolean isInteractable() {
switch (this) {
// <editor-fold defaultstate="collapsed" desc="isInteractable">
+ // Paper start - Generated/Material#isInteractable
case ACACIA_BUTTON:
case ACACIA_DOOR:
case ACACIA_FENCE:
@@ -9523,6 +9552,7 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla
case YELLOW_CANDLE:
case YELLOW_CANDLE_CAKE:
case YELLOW_SHULKER_BOX:
+ // Paper end - Generated/Material#isInteractable
// </editor-fold>
return true;
default:
@@ -9543,6 +9573,7 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla
Preconditions.checkArgument(isBlock(), "The Material is not a block!");
switch (this) {
// <editor-fold defaultstate="collapsed" desc="getBlockHardness">
+ // Paper start - Generated/Material#getHardness
case BARRIER:
case BEDROCK:
case CHAIN_COMMAND_BLOCK:
@@ -10476,6 +10507,7 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla
return 100.0F;
default:
return 0F;
+ // Paper end - Generated/Material#getHardness
// </editor-fold>
}
}
@@ -10494,6 +10526,7 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla
Preconditions.checkArgument(isBlock(), "The Material is not a block!");
switch (this) {
// <editor-fold defaultstate="collapsed" desc="getBlastResistance">
+ // Paper start - Generated/Material#getBlastResistance
case BIG_DRIPLEAF:
case BIG_DRIPLEAF_STEM:
case BLACK_CANDLE:
@@ -11426,6 +11459,7 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla
return 3600000.8F;
default:
return 0;
+ // Paper end - Generated/Material#getBlastResistance
// </editor-fold>
}
}
@@ -11446,6 +11480,7 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla
Preconditions.checkArgument(isBlock(), "The Material is not a block!");
switch (this) {
// <editor-fold defaultstate="collapsed" desc="getSlipperiness">
+ // Paper start - Generated/Material#getSlipperiness
default:
return 0.6F;
case SLIME_BLOCK:
@@ -11456,6 +11491,7 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla
return 0.98F;
case BLUE_ICE:
return 0.989F;
+ // Paper end - Generated/Material#getSlipperiness
// </editor-fold>
}
}
@@ -11473,6 +11509,7 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla
Preconditions.checkArgument(isItem(), "The Material is not an item!");
switch (this) {
// <editor-fold defaultstate="collapsed" desc="getCraftingRemainingItem">
+ // Paper start - Generated/Material#getCraftingRemainingItem
case WATER_BUCKET:
case LAVA_BUCKET:
case MILK_BUCKET:
@@ -11482,6 +11519,7 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla
return GLASS_BOTTLE;
default:
return null;
+ // Paper end - Generated/Material#getCraftingRemainingItem
// </editor-fold>
}
}
@@ -11498,6 +11536,7 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla
@@ -5507,6 +5513,7 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla
Preconditions.checkArgument(isItem(), "The Material is not an item!");
switch (this) {
// <editor-fold defaultstate="collapsed" desc="getEquipmentSlot">
@ -480,7 +228,7 @@ index 82d009c0bbe4b3026a535e02d6e0ed20c7bd525d..489f1bf244d040a8b599e03351665472
case CARVED_PUMPKIN:
case CHAINMAIL_HELMET:
case CREEPER_HEAD:
@@ -11562,6 +11601,7 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla
@@ -5571,6 +5578,7 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla
return EquipmentSlot.BODY;
default:
return EquipmentSlot.HAND;
@ -509,7 +257,7 @@ index 704dba92f9246ef398ed8d162ebee3cf305960e1..da5f0b9f6b1f065999c60144a6aca75d
/**
* Returns a {@link MusicInstrument} by a {@link NamespacedKey}.
diff --git a/src/main/java/org/bukkit/Sound.java b/src/main/java/org/bukkit/Sound.java
index 7c39a281a38b412a989dbdf3d12e826ee6eda714..100e19006c268d222b2b7d50b2f8779620b4bf44 100644
index e31e7b6624ff9da7bec5d3b0548a4fa38812daca..02fca6081dcf948764912ac683815f06c356ccb3 100644
--- a/src/main/java/org/bukkit/Sound.java
+++ b/src/main/java/org/bukkit/Sound.java
@@ -13,6 +13,7 @@ import org.jetbrains.annotations.NotNull;
@ -520,7 +268,7 @@ index 7c39a281a38b412a989dbdf3d12e826ee6eda714..100e19006c268d222b2b7d50b2f87796
AMBIENT_BASALT_DELTAS_ADDITIONS("ambient.basalt_deltas.additions"),
AMBIENT_BASALT_DELTAS_LOOP("ambient.basalt_deltas.loop"),
AMBIENT_BASALT_DELTAS_MOOD("ambient.basalt_deltas.mood"),
@@ -1812,6 +1813,7 @@ public enum Sound implements Keyed, net.kyori.adventure.sound.Sound.Type { // Pa
@@ -1810,6 +1811,7 @@ public enum Sound implements Keyed, net.kyori.adventure.sound.Sound.Type { // Pa
UI_TOAST_OUT("ui.toast.out"),
WEATHER_RAIN("weather.rain"),
WEATHER_RAIN_ABOVE("weather.rain.above");
@ -552,7 +300,7 @@ index 4ce888688d04eb0c4b2261a6474df870e7d2bb00..9e6d231b783fcb54c63cb80f12b598e6
private final Type type;
private final NamespacedKey key;
diff --git a/src/main/java/org/bukkit/Tag.java b/src/main/java/org/bukkit/Tag.java
index 511980c6d190fb80e23d0015dee5ee170bb673ac..5decb296e11ac3df472c518095f229ed3bb0ed1c 100644
index 4b037863bde8e3a167cfd94b0df0b357025dcf27..4cbbc0a31550757082c2fd8e9ec32bf5025a5179 100644
--- a/src/main/java/org/bukkit/Tag.java
+++ b/src/main/java/org/bukkit/Tag.java
@@ -19,6 +19,7 @@ import org.jetbrains.annotations.NotNull;
@ -575,7 +323,7 @@ index 511980c6d190fb80e23d0015dee5ee170bb673ac..5decb296e11ac3df472c518095f229ed
/**
* Vanilla block tag representing all wooden doors.
*/
@@ -799,24 +795,10 @@ public interface Tag<T extends Keyed> extends Keyed {
@@ -801,24 +797,10 @@ public interface Tag<T extends Keyed> extends Keyed {
* Vanilla item tag representing all piglin food.
*/
Tag<Material> ITEMS_PIGLIN_FOOD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("piglin_food"), Material.class);
@ -600,7 +348,23 @@ index 511980c6d190fb80e23d0015dee5ee170bb673ac..5decb296e11ac3df472c518095f229ed
/**
* Vanilla item tag representing all cow food.
*/
@@ -1147,13 +1129,6 @@ public interface Tag<T extends Keyed> extends Keyed {
@@ -1056,15 +1038,6 @@ public interface Tag<T extends Keyed> extends Keyed {
* Vanilla item tag representing all items which break decorated pots.
*/
Tag<Material> ITEMS_BREAKS_DECORATED_POTS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("breaks_decorated_pots"), Material.class);
- /**
- * Vanilla item tag representing all tools.
- *
- * @deprecated removed in Minecraft 1.20.5. Do not use. Will be removed at a later date. Until then,
- * this constant now acts as a reference to {@link #ITEMS_BREAKS_DECORATED_POTS} which largely shares
- * the same contents of the old "minecraft:tools" tag.
- */
- @Deprecated(forRemoval = true)
- Tag<Material> ITEMS_TOOLS = ITEMS_BREAKS_DECORATED_POTS;
/**
* Vanilla item tag representing all seeds planteable by villagers.
*/
@@ -1156,13 +1129,6 @@ public interface Tag<T extends Keyed> extends Keyed {
* the wearer.
*/
Tag<Material> FREEZE_IMMUNE_WEARABLES = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("freeze_immune_wearables"), Material.class);
@ -614,9 +378,9 @@ index 511980c6d190fb80e23d0015dee5ee170bb673ac..5decb296e11ac3df472c518095f229ed
/**
* Vanilla item tag representing all items which are preferred for
* harvesting clusters (unused).
@@ -1236,12 +1211,6 @@ public interface Tag<T extends Keyed> extends Keyed {
*/
@org.jetbrains.annotations.ApiStatus.Experimental @MinecraftExperimental(value = MinecraftExperimental.Requires.UPDATE_1_21) // Paper - add missing annotation
@@ -1246,12 +1212,6 @@ public interface Tag<T extends Keyed> extends Keyed {
@MinecraftExperimental(MinecraftExperimental.Requires.UPDATE_1_21) // Paper - add missing annotation
@org.jetbrains.annotations.ApiStatus.Experimental // Paper - add missing annotation
Tag<EntityType> ENTITY_TYPES_DEFLECTS_PROJECTILES = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("deflects_projectiles"), EntityType.class);
- /**
- * Vanilla tag representing entities which deflect arrows.
@ -627,7 +391,7 @@ index 511980c6d190fb80e23d0015dee5ee170bb673ac..5decb296e11ac3df472c518095f229ed
/**
* Vanilla tag representing entities which can turn in boats.
*/
@@ -1326,6 +1295,39 @@ public interface Tag<T extends Keyed> extends Keyed {
@@ -1343,6 +1303,48 @@ public interface Tag<T extends Keyed> extends Keyed {
*/
Tag<GameEvent> GAME_EVENT_ALLAY_CAN_LISTEN = Bukkit.getTag(REGISTRY_GAME_EVENTS, NamespacedKey.minecraft("allay_can_listen"), GameEvent.class);
// Paper end
@ -652,6 +416,15 @@ index 511980c6d190fb80e23d0015dee5ee170bb673ac..5decb296e11ac3df472c518095f229ed
+ @Deprecated
+ Tag<Material> FOX_FOOD = ITEMS_FOX_FOOD;
+ /**
+ * Vanilla item tag representing all tools.
+ *
+ * @deprecated removed in Minecraft 1.20.5. Do not use. Will be removed at a later date. Until then,
+ * this constant now acts as a reference to {@link #ITEMS_BREAKS_DECORATED_POTS} which largely shares
+ * the same contents of the old "minecraft:tools" tag.
+ */
+ @Deprecated(forRemoval = true)
+ Tag<Material> ITEMS_TOOLS = ITEMS_BREAKS_DECORATED_POTS;
+ /**
+ * Vanilla item tag representing all items which tempt axolotls.
+ *
+ * @deprecated use {@link #ITEMS_AXOLOTL_FOOD}
@ -707,8 +480,29 @@ index 5d8fa5b39a5d50cca48ba63af3a84b80f279b649..c6ea69c0d05aef5a29b758dbd3ea4c84
/**
* Represents a custom Biome
*/
diff --git a/src/main/java/org/bukkit/block/BlockType.java b/src/main/java/org/bukkit/block/BlockType.java
index 95cedd536fed5a195fb2dd76da1c451598250f53..d8ecdc9e104955ee79144cbdcd12ceb88154b894 100644
--- a/src/main/java/org/bukkit/block/BlockType.java
+++ b/src/main/java/org/bukkit/block/BlockType.java
@@ -179,6 +179,7 @@ public interface BlockType extends Keyed, Translatable {
}
//<editor-fold desc="BlockTypes" defaultstate="collapsed">
+ // Paper start - Generated/BlockType
BlockType.Typed<BlockData> AIR = getBlockType("air");
BlockType.Typed<BlockData> STONE = getBlockType("stone");
BlockType.Typed<BlockData> GRANITE = getBlockType("granite");
@@ -3405,7 +3406,7 @@ public interface BlockType extends Keyed, Translatable {
@MinecraftExperimental(Requires.UPDATE_1_21)
@ApiStatus.Experimental
BlockType.Typed<TrialSpawner> TRIAL_SPAWNER = getBlockType("trial_spawner");
-
+ // Paper end - Generated/BlockType
//</editor-fold>
@NotNull
diff --git a/src/main/java/org/bukkit/block/banner/PatternType.java b/src/main/java/org/bukkit/block/banner/PatternType.java
index 1b958b2024ec3f7729605fce70074c5c0208b6cc..13de6f36cfe035e496509ff4e3ced9f78039ac36 100644
index 2a245735ac902d55681880dc80b12ddef65c0124..6b1d65f4e550bdafcbf54f2380cd6a675e1626a2 100644
--- a/src/main/java/org/bukkit/block/banner/PatternType.java
+++ b/src/main/java/org/bukkit/block/banner/PatternType.java
@@ -12,6 +12,7 @@ import org.jetbrains.annotations.NotNull;
@ -719,16 +513,16 @@ index 1b958b2024ec3f7729605fce70074c5c0208b6cc..13de6f36cfe035e496509ff4e3ced9f7
BASE("b", "base"),
SQUARE_BOTTOM_LEFT("bl", "square_bottom_left"),
SQUARE_BOTTOM_RIGHT("br", "square_bottom_right"),
@@ -57,6 +58,7 @@ public enum PatternType implements Keyed {
FLOW("flw", "flow"),
@@ -59,6 +60,7 @@ public enum PatternType implements Keyed {
@MinecraftExperimental(Requires.UPDATE_1_21)
@org.jetbrains.annotations.ApiStatus.Experimental // Paper - add missing annotation
GUSTER("gus", "guster");
+ // Paper end - Generated/PatternType
private final String identifier;
private final NamespacedKey key;
diff --git a/src/main/java/org/bukkit/damage/DamageType.java b/src/main/java/org/bukkit/damage/DamageType.java
index 9f2d80a91e12f09407d737668f4178e81811fe14..d25c128789ea49dd63428624956bdc93451f8c74 100644
index e1367e86c21a1c733c8db45b357e9a95e093644a..ca0819614e6f5e49a47540346e37518ed9630650 100644
--- a/src/main/java/org/bukkit/damage/DamageType.java
+++ b/src/main/java/org/bukkit/damage/DamageType.java
@@ -20,6 +20,7 @@ import org.jetbrains.annotations.NotNull;
@ -739,14 +533,31 @@ index 9f2d80a91e12f09407d737668f4178e81811fe14..d25c128789ea49dd63428624956bdc93
public static final DamageType IN_FIRE = getDamageType("in_fire");
public static final DamageType LIGHTNING_BOLT = getDamageType("lightning_bolt");
public static final DamageType ON_FIRE = getDamageType("on_fire");
@@ -65,6 +66,7 @@ public interface DamageType extends Keyed, Translatable {
public static final DamageType BAD_RESPAWN_POINT = getDamageType("bad_respawn_point");
public static final DamageType OUTSIDE_BORDER = getDamageType("outside_border");
public static final DamageType GENERIC_KILL = getDamageType("generic_kill");
@@ -69,21 +70,16 @@ public interface DamageType extends Keyed, Translatable {
@org.bukkit.MinecraftExperimental(org.bukkit.MinecraftExperimental.Requires.UPDATE_1_21)
@ApiStatus.Experimental
@org.jetbrains.annotations.Nullable
- DamageType WIND_CHARGE = getExperimentalDamageType("wind_charge");
+ DamageType WIND_CHARGE = getDamageType("wind_charge");
// Paper end
+ // Paper end - Generated/DamageType
@NotNull
private static DamageType getDamageType(@NotNull String key) {
NamespacedKey namespacedKey = NamespacedKey.minecraft(key);
- return Preconditions.checkNotNull(Registry.DAMAGE_TYPE.get(namespacedKey), "No DamageType found for %s. This is a bug.", namespacedKey);
+ return Registry.DAMAGE_TYPE.get(namespacedKey);
}
- // Paper start
- private static @org.jetbrains.annotations.Nullable DamageType getExperimentalDamageType(@NotNull String key) {
- return Registry.DAMAGE_TYPE.get(NamespacedKey.minecraft(key));
- }
- // Paper end
-
/**
* {@inheritDoc}
* <p>
diff --git a/src/main/java/org/bukkit/entity/Boat.java b/src/main/java/org/bukkit/entity/Boat.java
index 2ac685fb1817f3ce06ebe6391cc863712d68367c..056d44476b2118b124ad2f7262aee8631d1fc0aa 100644
--- a/src/main/java/org/bukkit/entity/Boat.java
@ -1034,8 +845,29 @@ index cbce835ed6d44e5b8c9aaae4e36a77f8e5bed45f..4bac8e092bc59405a9bba15e62b513cc
// Paper start - improve ItemRarity
private final net.kyori.adventure.text.format.NamedTextColor color;
ItemRarity(final net.kyori.adventure.text.format.NamedTextColor color) {
diff --git a/src/main/java/org/bukkit/inventory/ItemType.java b/src/main/java/org/bukkit/inventory/ItemType.java
index aa0f66b7187c800cd22905bfa43af3ffb53edb5f..8c76c4c7353bc9684ceb318672544490ac952d0d 100644
--- a/src/main/java/org/bukkit/inventory/ItemType.java
+++ b/src/main/java/org/bukkit/inventory/ItemType.java
@@ -91,6 +91,7 @@ public interface ItemType extends Keyed, Translatable {
}
//<editor-fold desc="ItemTypes" defaultstate="collapsed">
+ // Paper start - Generated/ItemType
/**
* Air does not have any ItemMeta
*/
@@ -2253,7 +2254,7 @@ public interface ItemType extends Keyed, Translatable {
@ApiStatus.Experimental
ItemType.Typed<ItemMeta> BREEZE_ROD = getItemType("breeze_rod");
-
+ // Paper end - Generated/ItemType
//</editor-fold>
@NotNull
diff --git a/src/main/java/org/bukkit/inventory/meta/trim/TrimMaterial.java b/src/main/java/org/bukkit/inventory/meta/trim/TrimMaterial.java
index 74816d6da4d7c8d2fa8a7b93fdc4bf29c8d12803..cf879afd1cb77611f417d35e3bf7009d509ceaa4 100644
index 74816d6da4d7c8d2fa8a7b93fdc4bf29c8d12803..e17314154b36db6cae0b84b7097bbfc2aef07eed 100644
--- a/src/main/java/org/bukkit/inventory/meta/trim/TrimMaterial.java
+++ b/src/main/java/org/bukkit/inventory/meta/trim/TrimMaterial.java
@@ -11,6 +11,7 @@ import org.bukkit.Translatable;
@ -1046,16 +878,21 @@ index 74816d6da4d7c8d2fa8a7b93fdc4bf29c8d12803..cf879afd1cb77611f417d35e3bf7009d
/**
* {@link Material#QUARTZ}.
*/
@@ -51,6 +52,7 @@ public interface TrimMaterial extends Keyed, Translatable {
@@ -51,6 +52,12 @@ public interface TrimMaterial extends Keyed, Translatable {
* {@link Material#AMETHYST_SHARD}.
*/
public static final TrimMaterial AMETHYST = Registry.TRIM_MATERIAL.get(NamespacedKey.minecraft("amethyst"));
+ // Paper end - Generated/TrimMaterial
+
+ private static TrimMaterial getTrimMaterial(String name) {
+ NamespacedKey key = NamespacedKey.minecraft(name);
+ return io.papermc.paper.registry.RegistryAccess.registryAccess().getRegistry(io.papermc.paper.registry.RegistryKey.TRIM_MATERIAL).get(key);
+ }
// Paper start - adventure
/**
diff --git a/src/main/java/org/bukkit/inventory/meta/trim/TrimPattern.java b/src/main/java/org/bukkit/inventory/meta/trim/TrimPattern.java
index 087e99ed281c0b282d91345067bfca80762faa0b..5d3c5d467c34c32dfc6addb7054887d48d08acd6 100644
index 6079bd05a056153c9d66f37396c96dbad9dca7a1..128d5afd32698101233c0d5b7565602718976646 100644
--- a/src/main/java/org/bukkit/inventory/meta/trim/TrimPattern.java
+++ b/src/main/java/org/bukkit/inventory/meta/trim/TrimPattern.java
@@ -11,6 +11,7 @@ import org.bukkit.Translatable;
@ -1066,11 +903,16 @@ index 087e99ed281c0b282d91345067bfca80762faa0b..5d3c5d467c34c32dfc6addb7054887d4
/**
* {@link Material#SENTRY_ARMOR_TRIM_SMITHING_TEMPLATE}.
*/
@@ -83,6 +84,7 @@ public interface TrimPattern extends Keyed, Translatable {
* {@link Material#BOLT_ARMOR_TRIM_SMITHING_TEMPLATE}.
*/
@@ -87,6 +88,12 @@ public interface TrimPattern extends Keyed, Translatable {
@org.bukkit.MinecraftExperimental(org.bukkit.MinecraftExperimental.Requires.UPDATE_1_21) // Paper - add missing annotation
@org.jetbrains.annotations.ApiStatus.Experimental // Paper - add missing annotation
public static final TrimPattern BOLT = Registry.TRIM_PATTERN.get(NamespacedKey.minecraft("bolt"));
+ // Paper end - Generated/TrimPattern
+
+ private static TrimPattern getTrimPattern(String name) {
+ NamespacedKey key = NamespacedKey.minecraft(name);
+ return io.papermc.paper.registry.RegistryAccess.registryAccess().getRegistry(io.papermc.paper.registry.RegistryKey.TRIM_PATTERN).get(key);
+ }
// Paper start - adventure
/**

View File

@ -5,10 +5,10 @@ Subject: [PATCH] cleanup block data
diff --git a/src/main/java/org/bukkit/Material.java b/src/main/java/org/bukkit/Material.java
index 489f1bf244d040a8b599e03351665472b3ae5a12..bcc2ddde4c4f3d9319afb679f647b58c44ef019b 100644
index 54fab6f0bd7c33ef63b7d08ac813e92ca952f562..01bbfc4353ed042aac1a2090a6b804156ab9de59 100644
--- a/src/main/java/org/bukkit/Material.java
+++ b/src/main/java/org/bukkit/Material.java
@@ -97,6 +97,8 @@ import org.bukkit.block.data.type.SculkShrieker;
@@ -98,6 +98,8 @@ import org.bukkit.block.data.type.SculkShrieker;
import org.bukkit.block.data.type.SculkVein;
import org.bukkit.block.data.type.SeaPickle;
import org.bukkit.block.data.type.Sign;
@ -17,7 +17,7 @@ index 489f1bf244d040a8b599e03351665472b3ae5a12..bcc2ddde4c4f3d9319afb679f647b58c
import org.bukkit.block.data.type.Slab;
import org.bukkit.block.data.type.SmallDripleaf;
import org.bukkit.block.data.type.Snow;
@@ -2818,33 +2820,33 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla
@@ -2821,33 +2823,33 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla
MAP(21655),
GOLDEN_CARROT(5300),
/**
@ -65,7 +65,7 @@ index 489f1bf244d040a8b599e03351665472b3ae5a12..bcc2ddde4c4f3d9319afb679f647b58c
NETHER_STAR(12469),
PUMPKIN_PIE(28725),
FIREWORK_ROCKET(23841),
@@ -3554,33 +3556,33 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla
@@ -3561,33 +3563,33 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla
*/
POTATOES(10879, Ageable.class),
/**
@ -113,6 +113,93 @@ index 489f1bf244d040a8b599e03351665472b3ae5a12..bcc2ddde4c4f3d9319afb679f647b58c
/**
* BlockData: {@link Directional}
*/
diff --git a/src/main/java/org/bukkit/block/BlockType.java b/src/main/java/org/bukkit/block/BlockType.java
index d8ecdc9e104955ee79144cbdcd12ceb88154b894..e1c5dc78a0354ca2065d15a6ebbc6c0e2cb4e3d6 100644
--- a/src/main/java/org/bukkit/block/BlockType.java
+++ b/src/main/java/org/bukkit/block/BlockType.java
@@ -96,6 +96,8 @@ import org.bukkit.block.data.type.SculkShrieker;
import org.bukkit.block.data.type.SculkVein;
import org.bukkit.block.data.type.SeaPickle;
import org.bukkit.block.data.type.Sign;
+import org.bukkit.block.data.type.Skull;
+import org.bukkit.block.data.type.SkullWall;
import org.bukkit.block.data.type.Slab;
import org.bukkit.block.data.type.SmallDripleaf;
import org.bukkit.block.data.type.Snow;
@@ -1252,59 +1254,59 @@ public interface BlockType extends Keyed, Translatable {
/**
* BlockData: {@link Rotatable}
*/
- BlockType.Typed<Rotatable> SKELETON_SKULL = getBlockType("skeleton_skull");
+ BlockType.Typed<Skull> SKELETON_SKULL = getBlockType("skeleton_skull");
/**
* BlockData: {@link Directional}
*/
- BlockType.Typed<Directional> SKELETON_WALL_SKULL = getBlockType("skeleton_wall_skull");
+ BlockType.Typed<SkullWall> SKELETON_WALL_SKULL = getBlockType("skeleton_wall_skull");
/**
* BlockData: {@link Rotatable}
*/
- BlockType.Typed<Rotatable> WITHER_SKELETON_SKULL = getBlockType("wither_skeleton_skull");
+ BlockType.Typed<Skull> WITHER_SKELETON_SKULL = getBlockType("wither_skeleton_skull");
/**
* BlockData: {@link Directional}
*/
- BlockType.Typed<Directional> WITHER_SKELETON_WALL_SKULL = getBlockType("wither_skeleton_wall_skull");
+ BlockType.Typed<SkullWall> WITHER_SKELETON_WALL_SKULL = getBlockType("wither_skeleton_wall_skull");
/**
* BlockData: {@link Rotatable}
*/
- BlockType.Typed<Rotatable> ZOMBIE_HEAD = getBlockType("zombie_head");
+ BlockType.Typed<Skull> ZOMBIE_HEAD = getBlockType("zombie_head");
/**
* BlockData: {@link Directional}
*/
- BlockType.Typed<Directional> ZOMBIE_WALL_HEAD = getBlockType("zombie_wall_head");
+ BlockType.Typed<SkullWall> ZOMBIE_WALL_HEAD = getBlockType("zombie_wall_head");
/**
* BlockData: {@link Rotatable}
*/
- BlockType.Typed<Rotatable> PLAYER_HEAD = getBlockType("player_head");
+ BlockType.Typed<Skull> PLAYER_HEAD = getBlockType("player_head");
/**
* BlockData: {@link Directional}
*/
- BlockType.Typed<Directional> PLAYER_WALL_HEAD = getBlockType("player_wall_head");
+ BlockType.Typed<SkullWall> PLAYER_WALL_HEAD = getBlockType("player_wall_head");
/**
* BlockData: {@link Rotatable}
*/
- BlockType.Typed<Rotatable> CREEPER_HEAD = getBlockType("creeper_head");
+ BlockType.Typed<Skull> CREEPER_HEAD = getBlockType("creeper_head");
/**
* BlockData: {@link Directional}
*/
- BlockType.Typed<Directional> CREEPER_WALL_HEAD = getBlockType("creeper_wall_head");
+ BlockType.Typed<SkullWall> CREEPER_WALL_HEAD = getBlockType("creeper_wall_head");
/**
* BlockData: {@link Rotatable}
*/
- BlockType.Typed<Rotatable> DRAGON_HEAD = getBlockType("dragon_head");
+ BlockType.Typed<Skull> DRAGON_HEAD = getBlockType("dragon_head");
/**
* BlockData: {@link Directional}
*/
- BlockType.Typed<Directional> DRAGON_WALL_HEAD = getBlockType("dragon_wall_head");
+ BlockType.Typed<SkullWall> DRAGON_WALL_HEAD = getBlockType("dragon_wall_head");
/**
* BlockData: {@link Rotatable}
*/
- BlockType.Typed<Rotatable> PIGLIN_HEAD = getBlockType("piglin_head");
+ BlockType.Typed<Skull> PIGLIN_HEAD = getBlockType("piglin_head");
/**
* BlockData: {@link Directional}
*/
- BlockType.Typed<Directional> PIGLIN_WALL_HEAD = getBlockType("piglin_wall_head");
+ BlockType.Typed<SkullWall> PIGLIN_WALL_HEAD = getBlockType("piglin_wall_head");
/**
* BlockData: {@link Directional}
*/
diff --git a/src/main/java/org/bukkit/block/Orientation.java b/src/main/java/org/bukkit/block/Orientation.java
new file mode 100644
index 0000000000000000000000000000000000000000..f6b25ac08db75d4ddec498295b932d8efccdcfd4

View File

@ -337,6 +337,18 @@ index 0000000000000000000000000000000000000000..6cbf11c898439834cffb99ef84e5df14
+public @interface MethodParameterSource {
+ String[] value() default {};
+}
diff --git a/src/test/java/org/bukkit/MaterialTest.java b/src/test/java/org/bukkit/MaterialTest.java
index 40b540a382f8c64a59a8df637e2c4c0b60ab3af9..c0d576d7cacf2a71a5922f9e959b5e15db2cfcc6 100644
--- a/src/test/java/org/bukkit/MaterialTest.java
+++ b/src/test/java/org/bukkit/MaterialTest.java
@@ -51,6 +51,7 @@ public class MaterialTest extends AbstractTestingBase {
}
@Test
+ @org.junit.jupiter.api.Disabled // Paper - order is now alphabetically
public void verifyMaterialOrder() {
List<Material> expectedOrder = new ArrayList<>(Material.values().length);
diff --git a/src/test/java/org/bukkit/registry/RegistryConstantsTest.java b/src/test/java/org/bukkit/registry/RegistryConstantsTest.java
index 1b1e55f70b3c9f922bd1cc63209816f50d7d29d1..c75cfdfc3dc07b922d8943b67a59cfffbbb9a214 100644
--- a/src/test/java/org/bukkit/registry/RegistryConstantsTest.java
@ -350,20 +362,8 @@ index 1b1e55f70b3c9f922bd1cc63209816f50d7d29d1..c75cfdfc3dc07b922d8943b67a59cfff
}
@Test
diff --git a/src/test/java/org/bukkit/MaterialTest.java b/src/test/java/org/bukkit/MaterialTest.java
index 40b540a382f8c64a59a8df637e2c4c0b60ab3af9..c0d576d7cacf2a71a5922f9e959b5e15db2cfcc6 100644
--- a/src/test/java/org/bukkit/MaterialTest.java
+++ b/src/test/java/org/bukkit/MaterialTest.java
@@ -51,6 +51,7 @@ public class MaterialTest extends AbstractTestingBase {
}
@Test
+ @org.junit.jupiter.api.Disabled // Paper - order is now alphabetically
public void verifyMaterialOrder() {
List<Material> expectedOrder = new ArrayList<>(Material.values().length);
diff --git a/src/test/java/org/bukkit/support/DummyServer.java b/src/test/java/org/bukkit/support/DummyServer.java
index ee0cff84379bc0539b2c611a4904aff9f5843814..02a8e6b45bf304b6e0f88043a25188aa16b3d6bf 100644
index 4153866f3e630e54a23dc085aaac5e804344aa43..b8fe92fc75c611ee1efb82a8ab7089f28bf338ea 100644
--- a/src/test/java/org/bukkit/support/DummyServer.java
+++ b/src/test/java/org/bukkit/support/DummyServer.java
@@ -50,6 +50,15 @@ public final class DummyServer {

View File

@ -5,7 +5,7 @@ Subject: [PATCH] Implement Mob Goal API
diff --git a/build.gradle.kts b/build.gradle.kts
index 0d757b4a1b5d1bb68a48ec0a398019bf1f64c6a4..cab6f19bb69da3b51bf05fac7075675b2a55564b 100644
index 158779a3590f089c4224b2b128c2e653aef42a94..4f8b8839f4d345f448d30de21ad9f3ad7422f98b 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -40,6 +40,7 @@ dependencies {
@ -18,7 +18,7 @@ index 0d757b4a1b5d1bb68a48ec0a398019bf1f64c6a4..cab6f19bb69da3b51bf05fac7075675b
testImplementation("org.mockito:mockito-core:5.11.0")
diff --git a/src/main/java/com/destroystokyo/paper/entity/ai/MobGoalHelper.java b/src/main/java/com/destroystokyo/paper/entity/ai/MobGoalHelper.java
new file mode 100644
index 0000000000000000000000000000000000000000..ff2790b57cfd1977020c11912d229930bb7b6cc2
index 0000000000000000000000000000000000000000..07a20ffc5a87993aeac3fbb5965f11a013be77a1
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/entity/ai/MobGoalHelper.java
@@ -0,0 +1,240 @@
@ -233,7 +233,7 @@ index 0000000000000000000000000000000000000000..ff2790b57cfd1977020c11912d229930
+ }
+
+ public static <T extends Mob> GoalKey<T> getKey(Class<? extends Goal> goalClass) {
+ String name = getPathName(ObfHelper.INSTANCE.deobfClassName(goalClass.getName()));
+ String name = getPathName(io.papermc.paper.util.MappingEnvironment.reobf() ? ObfHelper.INSTANCE.deobfClassName(goalClass.getName()) : goalClass.getName());
+ return GoalKey.of(getEntity(goalClass), NamespacedKey.minecraft(name));
+ }
+
@ -635,7 +635,7 @@ index 6667ecc4b7eded4e20a415cef1e1b1179e6710b8..16f9a98b8a939e5ca7e2dc04f87134a7
LOOK,
JUMP,
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index c7d95adbd675af54dcd32773ab88c79e829df745..8fa6496605c3f2ac7f16abd0e32190a189d6549a 100644
index 5de7a7ec3d4aa6b5a2b50175c1eed95ba0c370b7..0d96bb371e555cb384d03f0c49f4082150d30974 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -2908,5 +2908,11 @@ public final class CraftServer implements Server {

View File

@ -5,7 +5,7 @@ Subject: [PATCH] move spigot scrap
diff --git a/build.gradle.kts b/build.gradle.kts
index 5d448d8a7cf6626a11791f30ad52baf41a099272..75194254bc0ca416fb4590ca0886e4c1136cb8e1 100644
index 87bb3fd9b97506f61734ae7f2e6860610ba794e7..2e9820330df75757007cfc70ad35bdcad957adaf 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -2,6 +2,7 @@ import io.papermc.paperweight.util.*
@ -16,7 +16,7 @@ index 5d448d8a7cf6626a11791f30ad52baf41a099272..75194254bc0ca416fb4590ca0886e4c1
`maven-publish`
}
@@ -174,6 +175,20 @@ fun TaskContainer.registerRunTask(
@@ -173,6 +174,20 @@ fun TaskContainer.registerRunTask(
block(this)
}

View File

@ -5,10 +5,10 @@ Subject: [PATCH] cleanup block data
diff --git a/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java b/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java
index d6c4ddd3a4a57c92380672336aa1146810cf892b..14cba0fb59dadc2a85fba7b2a78bfbd852fabf45 100644
index 162e10ce5481d1f94afae595114920ef9df51c61..a0d5515d70d5476930cd2be6a31f51d1823cd6b8 100644
--- a/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java
+++ b/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java
@@ -353,6 +353,13 @@ public class CraftBlockData implements BlockData {
@@ -354,6 +354,13 @@ public class CraftBlockData implements BlockData {
return state.max;
}
@ -22,7 +22,7 @@ index d6c4ddd3a4a57c92380672336aa1146810cf892b..14cba0fb59dadc2a85fba7b2a78bfbd8
//
private static final Map<Class<? extends Block>, Function<net.minecraft.world.level.block.state.BlockState, CraftBlockData>> MAP = new HashMap<>();
@@ -362,9 +369,9 @@ public class CraftBlockData implements BlockData {
@@ -363,9 +370,9 @@ public class CraftBlockData implements BlockData {
register(net.minecraft.world.level.block.BigDripleafBlock.class, org.bukkit.craftbukkit.block.impl.CraftBigDripleaf::new);
register(net.minecraft.world.level.block.BigDripleafStemBlock.class, org.bukkit.craftbukkit.block.impl.CraftBigDripleafStem::new);
register(net.minecraft.world.level.block.AnvilBlock.class, org.bukkit.craftbukkit.block.impl.CraftAnvil::new);
@ -34,7 +34,7 @@ index d6c4ddd3a4a57c92380672336aa1146810cf892b..14cba0fb59dadc2a85fba7b2a78bfbd8
register(net.minecraft.world.level.block.BarrelBlock.class, org.bukkit.craftbukkit.block.impl.CraftBarrel::new);
register(net.minecraft.world.level.block.BarrierBlock.class, org.bukkit.craftbukkit.block.impl.CraftBarrier::new);
register(net.minecraft.world.level.block.BedBlock.class, org.bukkit.craftbukkit.block.impl.CraftBed::new);
@@ -374,52 +381,52 @@ public class CraftBlockData implements BlockData {
@@ -375,52 +382,52 @@ public class CraftBlockData implements BlockData {
register(net.minecraft.world.level.block.BlastFurnaceBlock.class, org.bukkit.craftbukkit.block.impl.CraftBlastFurnace::new);
register(net.minecraft.world.level.block.BrewingStandBlock.class, org.bukkit.craftbukkit.block.impl.CraftBrewingStand::new);
register(net.minecraft.world.level.block.BubbleColumnBlock.class, org.bukkit.craftbukkit.block.impl.CraftBubbleColumn::new);
@ -105,7 +105,7 @@ index d6c4ddd3a4a57c92380672336aa1146810cf892b..14cba0fb59dadc2a85fba7b2a78bfbd8
register(net.minecraft.world.level.block.KelpBlock.class, org.bukkit.craftbukkit.block.impl.CraftKelp::new);
register(net.minecraft.world.level.block.LadderBlock.class, org.bukkit.craftbukkit.block.impl.CraftLadder::new);
register(net.minecraft.world.level.block.LanternBlock.class, org.bukkit.craftbukkit.block.impl.CraftLantern::new);
@@ -427,62 +434,62 @@ public class CraftBlockData implements BlockData {
@@ -428,62 +435,62 @@ public class CraftBlockData implements BlockData {
register(net.minecraft.world.level.block.LecternBlock.class, org.bukkit.craftbukkit.block.impl.CraftLectern::new);
register(net.minecraft.world.level.block.LeverBlock.class, org.bukkit.craftbukkit.block.impl.CraftLever::new);
register(net.minecraft.world.level.block.LoomBlock.class, org.bukkit.craftbukkit.block.impl.CraftLoom::new);
@ -200,7 +200,7 @@ index d6c4ddd3a4a57c92380672336aa1146810cf892b..14cba0fb59dadc2a85fba7b2a78bfbd8
register(net.minecraft.world.level.block.BrushableBlock.class, org.bukkit.craftbukkit.block.impl.CraftBrushable::new);
register(net.minecraft.world.level.block.CalibratedSculkSensorBlock.class, org.bukkit.craftbukkit.block.impl.CraftCalibratedSculkSensor::new);
register(net.minecraft.world.level.block.CandleBlock.class, org.bukkit.craftbukkit.block.impl.CraftCandle::new);
@@ -528,9 +535,9 @@ public class CraftBlockData implements BlockData {
@@ -529,9 +536,9 @@ public class CraftBlockData implements BlockData {
register(net.minecraft.world.level.block.WeatheringCopperSlabBlock.class, org.bukkit.craftbukkit.block.impl.CraftWeatheringCopperSlab::new);
register(net.minecraft.world.level.block.WeatheringCopperStairBlock.class, org.bukkit.craftbukkit.block.impl.CraftWeatheringCopperStair::new);
register(net.minecraft.world.level.block.WeatheringCopperTrapDoorBlock.class, org.bukkit.craftbukkit.block.impl.CraftWeatheringCopperTrapDoor::new);
@ -3493,7 +3493,7 @@ index 67b212d9395335f59b6f33741aac7a57c823c966..ca232ba24a66d234155fbb706c5b30c6
}
}
diff --git a/src/main/java/org/bukkit/craftbukkit/util/Commodore.java b/src/main/java/org/bukkit/craftbukkit/util/Commodore.java
index a815e9f3db30c33d69e7b8b862c84e5849b1bfea..de4c4a574cf5585da87c001ca24916fe2c8f3241 100644
index b2f58a57906eeea52be1aa9408c5748c8c64213a..6964beb5e29a91890093cdbe3866f8277760aa5c 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/Commodore.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/Commodore.java
@@ -62,7 +62,9 @@ public class Commodore {

View File

@ -5,10 +5,10 @@ Subject: [PATCH] server gen test
diff --git a/build.gradle.kts b/build.gradle.kts
index 75194254bc0ca416fb4590ca0886e4c1136cb8e1..557be470c33e5c249daa4f9702efcf676b9e0f2f 100644
index 2e9820330df75757007cfc70ad35bdcad957adaf..6535f20cb17766885090eee4025f77fe75ca2d6d 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -176,14 +176,18 @@ fun TaskContainer.registerRunTask(
@@ -175,14 +175,18 @@ fun TaskContainer.registerRunTask(
}
// Paper start

View File

@ -28,7 +28,7 @@ index 52f3765a13024544e677b16788ced59542be93b8..172196ca8e05bb21ac8f8a299782b01c
private final org.bukkit.Statistic bukkit;
private static final BiMap<ResourceLocation, org.bukkit.Statistic> statistics;
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockStates.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockStates.java
index 6a25916aec7c8e0bc5cc18e3e06c6e07e0804380..9b12d234232f4335f11be41e9fad2ffa663c0e97 100644
index 411c2de93c71e480f95229c882cdf43b8801edc8..2df0e15b93e83b212dc1ac30522e1d14c7def7f3 100644
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockStates.java
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockStates.java
@@ -132,7 +132,7 @@ public final class CraftBlockStates {
@ -50,10 +50,10 @@ index 6a25916aec7c8e0bc5cc18e3e06c6e07e0804380..9b12d234232f4335f11be41e9fad2ffa
private static void register(Material blockType, BlockStateFactory<?> factory) {
diff --git a/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java b/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java
index 14cba0fb59dadc2a85fba7b2a78bfbd852fabf45..a6eaf8f699c143b6bc627c88818d33354b573f30 100644
index a0d5515d70d5476930cd2be6a31f51d1823cd6b8..fbb4a055ab03c10c408fbaa4f1c13f819fecf196 100644
--- a/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java
+++ b/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java
@@ -365,6 +365,7 @@ public class CraftBlockData implements BlockData {
@@ -366,6 +366,7 @@ public class CraftBlockData implements BlockData {
static {
//<editor-fold desc="CraftBlockData Registration" defaultstate="collapsed">
@ -61,7 +61,7 @@ index 14cba0fb59dadc2a85fba7b2a78bfbd852fabf45..a6eaf8f699c143b6bc627c88818d3335
register(net.minecraft.world.level.block.AmethystClusterBlock.class, org.bukkit.craftbukkit.block.impl.CraftAmethystCluster::new);
register(net.minecraft.world.level.block.BigDripleafBlock.class, org.bukkit.craftbukkit.block.impl.CraftBigDripleaf::new);
register(net.minecraft.world.level.block.BigDripleafStemBlock.class, org.bukkit.craftbukkit.block.impl.CraftBigDripleafStem::new);
@@ -538,6 +539,7 @@ public class CraftBlockData implements BlockData {
@@ -539,6 +540,7 @@ public class CraftBlockData implements BlockData {
register(net.minecraft.world.level.block.piston.PistonBaseBlock.class, org.bukkit.craftbukkit.block.impl.CraftPistonBase::new);
register(net.minecraft.world.level.block.piston.PistonHeadBlock.class, org.bukkit.craftbukkit.block.impl.CraftPistonHead::new);
register(net.minecraft.world.level.block.piston.MovingPistonBlock.class, org.bukkit.craftbukkit.block.impl.CraftMovingPiston::new);
@ -69,3 +69,34 @@ index 14cba0fb59dadc2a85fba7b2a78bfbd852fabf45..a6eaf8f699c143b6bc627c88818d3335
//</editor-fold>
}
diff --git a/src/main/java/org/bukkit/craftbukkit/potion/CraftPotionUtil.java b/src/main/java/org/bukkit/craftbukkit/potion/CraftPotionUtil.java
index cb11f0624e4e65aa06bfaaec90729ee536cd53a0..aa3a923a61146702736c9ffb5bdea64b1552efa5 100644
--- a/src/main/java/org/bukkit/craftbukkit/potion/CraftPotionUtil.java
+++ b/src/main/java/org/bukkit/craftbukkit/potion/CraftPotionUtil.java
@@ -14,6 +14,7 @@ import org.bukkit.potion.PotionType;
public class CraftPotionUtil {
private static final BiMap<PotionType, PotionType> upgradeable = ImmutableBiMap.<PotionType, PotionType>builder()
+ // Paper start - Generated/CraftPotionUtil#upgradeable
.put(PotionType.LEAPING, PotionType.STRONG_LEAPING)
.put(PotionType.SWIFTNESS, PotionType.STRONG_SWIFTNESS)
.put(PotionType.HEALING, PotionType.STRONG_HEALING)
@@ -23,8 +24,10 @@ public class CraftPotionUtil {
.put(PotionType.STRENGTH, PotionType.STRONG_STRENGTH)
.put(PotionType.SLOWNESS, PotionType.STRONG_SLOWNESS)
.put(PotionType.TURTLE_MASTER, PotionType.STRONG_TURTLE_MASTER)
+ // Paper end - Generated/CraftPotionUtil#upgradeable
.build();
private static final BiMap<PotionType, PotionType> extendable = ImmutableBiMap.<PotionType, PotionType>builder()
+ // Paper start - Generated/CraftPotionUtil#extendable
.put(PotionType.NIGHT_VISION, PotionType.LONG_NIGHT_VISION)
.put(PotionType.INVISIBILITY, PotionType.LONG_INVISIBILITY)
.put(PotionType.LEAPING, PotionType.LONG_LEAPING)
@@ -38,6 +41,7 @@ public class CraftPotionUtil {
.put(PotionType.WEAKNESS, PotionType.LONG_WEAKNESS)
.put(PotionType.TURTLE_MASTER, PotionType.LONG_TURTLE_MASTER)
.put(PotionType.SLOW_FALLING, PotionType.LONG_SLOW_FALLING)
+ // Paper end - Generated/CraftPotionUtil#extendable
.build();
public static PotionType fromBukkit(PotionData data) {