mirror of
https://github.com/PaperMC/Paper.git
synced 2025-05-19 05:30:23 -07:00
print removed fields from Tag while updating the game
This commit is contained in:
parent
df331de809
commit
19bcec40a2
@ -19,10 +19,14 @@ import org.jetbrains.annotations.NotNull;
|
||||
*/
|
||||
public interface Tag<T extends Keyed> extends Keyed {
|
||||
|
||||
String REGISTRY_BLOCKS = "blocks";
|
||||
String REGISTRY_ITEMS = "items";
|
||||
String REGISTRY_FLUIDS = "fluids";
|
||||
String REGISTRY_ENTITY_TYPES = "entity_types";
|
||||
String REGISTRY_GAME_EVENTS = "game_events";
|
||||
|
||||
// Start generate - Tag
|
||||
// @GeneratedFrom 1.21.5
|
||||
String REGISTRY_BLOCKS = "blocks";
|
||||
|
||||
Tag<Material> ACACIA_LOGS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("acacia_logs"), Material.class);
|
||||
|
||||
Tag<Material> AIR = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("air"), Material.class);
|
||||
@ -405,8 +409,6 @@ public interface Tag<T extends Keyed> extends Keyed {
|
||||
|
||||
Tag<Material> WOOL_CARPETS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("wool_carpets"), Material.class);
|
||||
|
||||
String REGISTRY_ITEMS = "items";
|
||||
|
||||
Tag<Material> ITEMS_ACACIA_LOGS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("acacia_logs"), Material.class);
|
||||
|
||||
Tag<Material> ITEMS_ANVIL = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("anvil"), Material.class);
|
||||
@ -759,14 +761,10 @@ public interface Tag<T extends Keyed> extends Keyed {
|
||||
|
||||
Tag<Material> ITEMS_WOOL_CARPETS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("wool_carpets"), Material.class);
|
||||
|
||||
String REGISTRY_FLUIDS = "fluids";
|
||||
|
||||
Tag<Fluid> FLUIDS_LAVA = Bukkit.getTag(REGISTRY_FLUIDS, NamespacedKey.minecraft("lava"), Fluid.class);
|
||||
|
||||
Tag<Fluid> FLUIDS_WATER = Bukkit.getTag(REGISTRY_FLUIDS, NamespacedKey.minecraft("water"), Fluid.class);
|
||||
|
||||
String REGISTRY_ENTITY_TYPES = "entity_types";
|
||||
|
||||
Tag<EntityType> ENTITY_TYPES_AQUATIC = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("aquatic"), EntityType.class);
|
||||
|
||||
Tag<EntityType> ENTITY_TYPES_ARROWS = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("arrows"), EntityType.class);
|
||||
@ -841,8 +839,6 @@ public interface Tag<T extends Keyed> extends Keyed {
|
||||
|
||||
Tag<EntityType> ENTITY_TYPES_ZOMBIES = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("zombies"), EntityType.class);
|
||||
|
||||
String REGISTRY_GAME_EVENTS = "game_events";
|
||||
|
||||
Tag<GameEvent> GAME_EVENT_ALLAY_CAN_LISTEN = Bukkit.getTag(REGISTRY_GAME_EVENTS, NamespacedKey.minecraft("allay_can_listen"), GameEvent.class);
|
||||
|
||||
Tag<GameEvent> GAME_EVENT_IGNORE_VIBRATIONS_SNEAKING = Bukkit.getTag(REGISTRY_GAME_EVENTS, NamespacedKey.minecraft("ignore_vibrations_sneaking"), GameEvent.class);
|
||||
|
@ -7,6 +7,7 @@ import io.papermc.generator.types.goal.MobGoalGenerator;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import io.papermc.generator.utils.BasePackage;
|
||||
import net.minecraft.Util;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@ -15,7 +16,7 @@ public interface Generators {
|
||||
|
||||
List<SourceGenerator> API = Collections.unmodifiableList(Util.make(new ArrayList<>(), list -> {
|
||||
RegistryBootstrapper.bootstrap(list);
|
||||
list.add(new MobGoalGenerator("VanillaGoal", "com.destroystokyo.paper.entity.ai"));
|
||||
list.add(new MobGoalGenerator("VanillaGoal", BasePackage.PAPER_LEGACY.api() + ".entity.ai"));
|
||||
// todo extract fields for registry based api
|
||||
}));
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
package io.papermc.generator;
|
||||
|
||||
import com.google.common.util.concurrent.MoreExecutors;
|
||||
import com.mojang.logging.LogUtils;
|
||||
import io.papermc.generator.rewriter.registration.PaperPatternSourceSetRewriter;
|
||||
import io.papermc.generator.rewriter.registration.PatternSourceSetRewriter;
|
||||
@ -64,15 +63,16 @@ public class Main implements Callable<Integer> {
|
||||
public static @MonotonicNonNull Path ROOT_DIR;
|
||||
public static RegistryAccess.@MonotonicNonNull Frozen REGISTRY_ACCESS;
|
||||
public static @MonotonicNonNull Map<TagKey<?>, String> EXPERIMENTAL_TAGS;
|
||||
public static final boolean IS_UPDATING = Boolean.getBoolean("paper.updatingMinecraft");
|
||||
|
||||
public static CompletableFuture<Void> bootStrap(boolean withTags) {
|
||||
SharedConstants.tryDetectVersion();
|
||||
Bootstrap.bootStrap();
|
||||
Bootstrap.validate();
|
||||
|
||||
PackRepository resourceRepository = ServerPacksSource.createVanillaTrustedRepository();
|
||||
resourceRepository.reload();
|
||||
MultiPackResourceManager resourceManager = new MultiPackResourceManager(PackType.SERVER_DATA, resourceRepository.getAvailablePacks().stream().map(Pack::open).toList());
|
||||
PackRepository packRepository = ServerPacksSource.createVanillaTrustedRepository();
|
||||
packRepository.reload();
|
||||
MultiPackResourceManager resourceManager = new MultiPackResourceManager(PackType.SERVER_DATA, packRepository.getAvailablePacks().stream().map(Pack::open).toList());
|
||||
LayeredRegistryAccess<RegistryLayer> layers = RegistryLayer.createRegistryAccess();
|
||||
List<Registry.PendingTags<?>> pendingTags = TagLoader.loadTagsForExistingRegistries(resourceManager, layers.getLayer(RegistryLayer.STATIC));
|
||||
List<HolderLookup.RegistryLookup<?>> worldGenLayer = TagLoader.buildUpdatedLookups(layers.getAccessForLoading(RegistryLayer.WORLDGEN), pendingTags);
|
||||
@ -84,11 +84,11 @@ public class Main implements Callable<Integer> {
|
||||
resourceManager,
|
||||
layers,
|
||||
pendingTags,
|
||||
FeatureFlags.VANILLA_SET,
|
||||
FeatureFlags.REGISTRY.allFlags(),
|
||||
Commands.CommandSelection.DEDICATED,
|
||||
0,
|
||||
MoreExecutors.directExecutor(),
|
||||
MoreExecutors.directExecutor()
|
||||
Commands.LEVEL_GAMEMASTERS,
|
||||
Runnable::run,
|
||||
Runnable::run
|
||||
).whenComplete((result, ex) -> {
|
||||
if (ex != null) {
|
||||
resourceManager.close();
|
||||
|
@ -8,13 +8,14 @@ import io.papermc.generator.types.SourceGenerator;
|
||||
import io.papermc.generator.types.registry.GeneratedKeyType;
|
||||
import io.papermc.generator.types.registry.GeneratedTagKeyType;
|
||||
import java.util.List;
|
||||
import io.papermc.generator.utils.BasePackage;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@NullMarked
|
||||
public class RegistryBootstrapper {
|
||||
|
||||
private static final String PAPER_REGISTRY_PACKAGE = "io.papermc.paper.registry";
|
||||
private static final String PAPER_REGISTRY_PACKAGE = BasePackage.PAPER.impl() + ".registry";
|
||||
|
||||
public static void bootstrap(List<SourceGenerator> generators) {
|
||||
// typed/tag keys
|
||||
|
@ -4,11 +4,11 @@ import com.google.common.base.Suppliers;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.squareup.javapoet.ClassName;
|
||||
import io.github.classgraph.ClassGraph;
|
||||
import io.github.classgraph.ScanResult;
|
||||
import io.papermc.generator.registry.RegistryEntries;
|
||||
import io.papermc.generator.registry.RegistryEntry;
|
||||
import io.papermc.generator.utils.BasePackage;
|
||||
import io.papermc.generator.utils.ClassHelper;
|
||||
import io.papermc.generator.utils.Formatting;
|
||||
import io.papermc.generator.utils.SourceCodecs;
|
||||
@ -137,7 +137,7 @@ public class DataFileLoader {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
},
|
||||
missingType -> ClassName.get("org.bukkit.block.data.type", missingType.getSimpleName()),
|
||||
missingType -> BasePackage.BUKKIT.relativeClass("block.data.type", missingType.getSimpleName()),
|
||||
Comparator.comparing(Class::getCanonicalName))
|
||||
));
|
||||
|
||||
@ -169,7 +169,7 @@ public class DataFileLoader {
|
||||
missingType -> {
|
||||
Class<?> genericType = ENTITY_TYPE_GENERICS.get().get(missingType);
|
||||
|
||||
String packageName = "org.bukkit.entity";
|
||||
String packageName = BasePackage.BUKKIT.api().concat(".entity");
|
||||
if (AbstractBoat.class.isAssignableFrom(genericType)) {
|
||||
packageName += ".boat";
|
||||
} else if (AbstractMinecart.class.isAssignableFrom(genericType)) {
|
||||
@ -195,7 +195,7 @@ public class DataFileLoader {
|
||||
return Collections.unmodifiableSet(classes);
|
||||
}
|
||||
},
|
||||
missingType -> ClassName.get("org.bukkit.entity", missingType.getSimpleName()),
|
||||
missingType -> BasePackage.BUKKIT.relativeClass("entity", missingType.getSimpleName()),
|
||||
Comparator.comparing(Class::getCanonicalName))
|
||||
));
|
||||
}
|
||||
|
@ -6,19 +6,20 @@ import org.jspecify.annotations.NullMarked;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static io.papermc.generator.utils.BasePackage.BUKKIT;
|
||||
import static io.papermc.generator.utils.BasePackage.PAPER;
|
||||
import static io.papermc.generator.utils.BasePackage.PAPER_LEGACY;
|
||||
|
||||
@NullMarked
|
||||
public final class Types {
|
||||
|
||||
public static final String API_PACKAGE = "org.bukkit";
|
||||
public static final String PAPER_PACKAGE = "io.papermc.paper";
|
||||
public static final ClassNamed BUKKIT_CLASS = BUKKIT.classNamed("Bukkit");
|
||||
|
||||
public static final ClassNamed BUKKIT = ClassNamed.of(API_PACKAGE, "Bukkit");
|
||||
public static final ClassNamed FEATURE_FLAG = BUKKIT.classNamed("FeatureFlag");
|
||||
|
||||
public static final ClassNamed FEATURE_FLAG = ClassNamed.of(API_PACKAGE, "FeatureFlag");
|
||||
public static final ClassNamed REGISTRY = BUKKIT.classNamed("Registry");
|
||||
|
||||
public static final ClassNamed REGISTRY = ClassNamed.of(API_PACKAGE, "Registry");
|
||||
|
||||
public static final ClassNamed TAG = ClassNamed.of(API_PACKAGE, "Tag");
|
||||
public static final ClassNamed TAG = BUKKIT.classNamed("Tag");
|
||||
|
||||
public static final ClassNamed NAMESPACED_KEY = typed(io.papermc.generator.types.Types.NAMESPACED_KEY);
|
||||
|
||||
@ -26,93 +27,91 @@ public final class Types {
|
||||
public static final ClassNamed MINECRAFT_EXPERIMENTAL_REQUIRES = typed(io.papermc.generator.types.Types.MINECRAFT_EXPERIMENTAL_REQUIRES);
|
||||
|
||||
@Deprecated
|
||||
public static final ClassNamed STATISTIC = ClassNamed.of(API_PACKAGE, "Statistic");
|
||||
public static final ClassNamed STATISTIC = BUKKIT.classNamed("Statistic");
|
||||
|
||||
public static final ClassNamed STATISTIC_TYPE = ClassNamed.of(API_PACKAGE, "Statistic", "Type");
|
||||
public static final ClassNamed STATISTIC_TYPE = BUKKIT.classNamed("Statistic", "Type");
|
||||
|
||||
public static final ClassNamed BLOCK_TYPE_TYPED = ClassNamed.of(API_PACKAGE + ".block", "BlockType", "Typed");
|
||||
public static final ClassNamed BLOCK_TYPE_TYPED = BUKKIT.relativeClassName("block", "BlockType", "Typed");
|
||||
|
||||
public static final ClassNamed ITEM_TYPE_TYPED = ClassNamed.of(API_PACKAGE + ".inventory", "ItemType", "Typed"); // todo add nested util to ClassNamed and get it from registry entries
|
||||
public static final ClassNamed ITEM_TYPE_TYPED = BUKKIT.relativeClassName("inventory", "ItemType", "Typed");
|
||||
|
||||
public static final ClassNamed ITEM_META = ClassNamed.of(API_PACKAGE + ".inventory.meta", "ItemMeta");
|
||||
public static final ClassNamed ITEM_META = BUKKIT.relativeClassName("inventory.meta", "ItemMeta");
|
||||
|
||||
public static final ClassNamed LOCATION = ClassNamed.of(API_PACKAGE, "Location");
|
||||
public static final ClassNamed LOCATION = BUKKIT.classNamed("Location");
|
||||
|
||||
public static final ClassNamed MATERIAL = ClassNamed.of(API_PACKAGE, "Material");
|
||||
public static final ClassNamed MATERIAL = BUKKIT.classNamed("Material");
|
||||
|
||||
public static final ClassNamed POSE = ClassNamed.of(API_PACKAGE + ".entity", "Pose");
|
||||
public static final ClassNamed POSE = BUKKIT.relativeClassName("entity", "Pose");
|
||||
|
||||
@Deprecated
|
||||
public static final ClassNamed VILLAGER = ClassNamed.of(API_PACKAGE + ".entity", "Villager");
|
||||
public static final ClassNamed VILLAGER = BUKKIT.relativeClassName("entity", "Villager");
|
||||
|
||||
public static final ClassNamed SNIFFER_STATE = ClassNamed.of(API_PACKAGE + ".entity", "Sniffer", "State");
|
||||
public static final ClassNamed SNIFFER_STATE = BUKKIT.relativeClassName("entity", "Sniffer", "State");
|
||||
|
||||
public static final ClassNamed TROPICAL_FISH_PATTERN = ClassNamed.of(API_PACKAGE + ".entity", "TropicalFish", "Pattern");
|
||||
public static final ClassNamed TROPICAL_FISH_PATTERN = BUKKIT.relativeClassName("entity", "TropicalFish", "Pattern");
|
||||
|
||||
public static final ClassNamed FOX_TYPE = ClassNamed.of(API_PACKAGE + ".entity", "Fox", "Type");
|
||||
public static final ClassNamed FOX_TYPE = BUKKIT.relativeClassName("entity", "Fox", "Type");
|
||||
|
||||
public static final ClassNamed SALMON_VARIANT = ClassNamed.of(API_PACKAGE + ".entity", "Salmon", "Variant");
|
||||
public static final ClassNamed SALMON_VARIANT = BUKKIT.relativeClassName("entity", "Salmon", "Variant");
|
||||
|
||||
public static final ClassNamed PANDA_GENE = ClassNamed.of(API_PACKAGE + ".entity", "Panda", "Gene");
|
||||
public static final ClassNamed PANDA_GENE = BUKKIT.relativeClassName("entity", "Panda", "Gene");
|
||||
|
||||
public static final ClassNamed BOAT_STATUS = ClassNamed.of(API_PACKAGE + ".entity", "Boat", "Status");
|
||||
public static final ClassNamed BOAT_STATUS = BUKKIT.relativeClassName("entity", "Boat", "Status");
|
||||
|
||||
public static final ClassNamed ITEM_RARITY = ClassNamed.of(API_PACKAGE + ".inventory", "ItemRarity");
|
||||
public static final ClassNamed ITEM_RARITY = BUKKIT.relativeClassName("inventory", "ItemRarity");
|
||||
|
||||
public static final ClassNamed COOKING_BOOK_CATEGORY = ClassNamed.of(API_PACKAGE + ".inventory.recipe", "CookingBookCategory");
|
||||
public static final ClassNamed COOKING_BOOK_CATEGORY = BUKKIT.relativeClassName("inventory.recipe", "CookingBookCategory");
|
||||
|
||||
public static final ClassNamed CRAFTING_BOOK_CATEGORY = ClassNamed.of(API_PACKAGE + ".inventory.recipe", "CraftingBookCategory");
|
||||
public static final ClassNamed CRAFTING_BOOK_CATEGORY = BUKKIT.relativeClassName("inventory.recipe", "CraftingBookCategory");
|
||||
|
||||
public static final ClassNamed MAP_PALETTE = ClassNamed.of(API_PACKAGE + ".map", "MapPalette");
|
||||
public static final ClassNamed MAP_PALETTE = BUKKIT.relativeClassName("map", "MapPalette");
|
||||
|
||||
public static final ClassNamed DISPLAY_SLOT = ClassNamed.of(API_PACKAGE + ".scoreboard", "DisplaySlot");
|
||||
public static final ClassNamed DISPLAY_SLOT = BUKKIT.relativeClassName("scoreboard", "DisplaySlot");
|
||||
|
||||
public static final ClassNamed DAMAGE_TYPE_TAGS = ClassNamed.of(API_PACKAGE + ".tag", "DamageTypeTags");
|
||||
public static final ClassNamed DAMAGE_TYPE_TAGS = BUKKIT.relativeClassName("tag", "DamageTypeTags");
|
||||
|
||||
public static final ClassNamed BLOCK_DATA = ClassNamed.of(API_PACKAGE + ".block.data", "BlockData");
|
||||
public static final ClassNamed BLOCK_DATA = BUKKIT.relativeClassName("block.data", "BlockData");
|
||||
|
||||
public static final ClassNamed BLOCK_DATA_REDSTONE_WIRE = ClassNamed.of(API_PACKAGE + ".block.data.type", "RedstoneWire");
|
||||
public static final ClassNamed BLOCK_DATA_REDSTONE_WIRE = BUKKIT.relativeClassName("block.data.type", "RedstoneWire");
|
||||
|
||||
public static final ClassNamed BLOCK_DATA_MULTIPLE_FACING = ClassNamed.of(API_PACKAGE + ".block.data", "MultipleFacing");
|
||||
public static final ClassNamed BLOCK_DATA_MULTIPLE_FACING = BUKKIT.relativeClassName("block.data", "MultipleFacing");
|
||||
|
||||
public static final ClassNamed NAMED_TEXT_COLOR = ClassNamed.of("net.kyori.adventure.text.format", "NamedTextColor");
|
||||
|
||||
public static final ClassNamed REGISTRY_KEY = typed(io.papermc.generator.types.Types.REGISTRY_KEY);
|
||||
|
||||
public static final ClassNamed REGISTRY_EVENTS = ClassNamed.of(PAPER_PACKAGE + ".registry.event", "RegistryEvents");
|
||||
public static final ClassNamed REGISTRY_EVENTS = PAPER.relativeClassName("registry.event", "RegistryEvents");
|
||||
|
||||
public static final ClassNamed REGISTRY_EVENT_PROVIDER = ClassNamed.of(PAPER_PACKAGE + ".registry.event", "RegistryEventProvider");
|
||||
public static final ClassNamed REGISTRY_EVENT_PROVIDER = PAPER.relativeClassName("registry.event", "RegistryEventProvider");
|
||||
|
||||
public static final ClassNamed ITEM_USE_ANIMATION = ClassNamed.of(PAPER_PACKAGE + ".datacomponent.item.consumable", "ItemUseAnimation");
|
||||
public static final ClassNamed ITEM_USE_ANIMATION = PAPER.relativeClassName("datacomponent.item.consumable", "ItemUseAnimation");
|
||||
|
||||
public static final ClassNamed GENERATED_FROM = typed(io.papermc.generator.types.Types.GENERATED_FROM);
|
||||
|
||||
|
||||
public static final String IMPL_PACKAGE = "org.bukkit.craftbukkit";
|
||||
|
||||
public static final ClassNamed CRAFT_BLOCK_DATA = typed(io.papermc.generator.types.Types.CRAFT_BLOCK_DATA);
|
||||
|
||||
public static final ClassNamed CRAFT_BLOCK_STATES = ClassNamed.of(IMPL_PACKAGE + ".block", "CraftBlockStates");
|
||||
public static final ClassNamed CRAFT_BLOCK_STATES = BUKKIT.relativeImpClassName("block", "CraftBlockStates");
|
||||
|
||||
public static final ClassNamed CRAFT_ITEM_METAS = ClassNamed.of(IMPL_PACKAGE + ".inventory", "CraftItemMetas");
|
||||
public static final ClassNamed CRAFT_ITEM_METAS = BUKKIT.relativeImpClassName("inventory", "CraftItemMetas");
|
||||
|
||||
public static final ClassNamed CRAFT_STATISTIC = ClassNamed.of(IMPL_PACKAGE, "CraftStatistic");
|
||||
public static final ClassNamed CRAFT_STATISTIC = BUKKIT.relativeImpClassName(null, "CraftStatistic");
|
||||
|
||||
public static final ClassNamed CRAFT_POTION_UTIL = ClassNamed.of(IMPL_PACKAGE + ".potion", "CraftPotionUtil");
|
||||
public static final ClassNamed CRAFT_POTION_UTIL = BUKKIT.relativeImpClassName("potion", "CraftPotionUtil");
|
||||
|
||||
public static final ClassNamed FIELD_RENAME = ClassNamed.of(IMPL_PACKAGE + ".legacy", "FieldRename");
|
||||
public static final ClassNamed FIELD_RENAME = BUKKIT.relativeImpClassName("legacy", "FieldRename");
|
||||
|
||||
public static final ClassNamed REGISTRIES_ARGUMENT_PROVIDER = ClassNamed.of("org.bukkit.support.provider" , "RegistriesArgumentProvider");
|
||||
public static final ClassNamed REGISTRIES_ARGUMENT_PROVIDER = BUKKIT.relativeClassName("support.provider" , "RegistriesArgumentProvider");
|
||||
|
||||
public static final ClassNamed REGISTRY_CONVERSION_TEST = ClassNamed.of("org.bukkit.registry" , "RegistryConversionTest");
|
||||
public static final ClassNamed REGISTRY_CONVERSION_TEST = BUKKIT.relativeClassName("registry", "RegistryConversionTest");
|
||||
|
||||
public static final ClassNamed PAPER_REGISTRIES = ClassNamed.of(PAPER_PACKAGE + ".registry", "PaperRegistries");
|
||||
public static final ClassNamed PAPER_REGISTRIES = PAPER.relativeClassName("registry", "PaperRegistries");
|
||||
|
||||
public static final ClassNamed PAPER_FEATURE_FLAG_PROVIDER_IMPL = ClassNamed.of(PAPER_PACKAGE + ".world.flag", "PaperFeatureFlagProviderImpl");
|
||||
public static final ClassNamed PAPER_FEATURE_FLAG_PROVIDER_IMPL = PAPER.relativeClassName("world.flag", "PaperFeatureFlagProviderImpl");
|
||||
|
||||
public static final ClassNamed PAPER_SIMPLE_REGISTRY = ClassNamed.of(PAPER_PACKAGE + ".registry", "PaperSimpleRegistry");
|
||||
public static final ClassNamed PAPER_SIMPLE_REGISTRY = PAPER.relativeClassName("registry", "PaperSimpleRegistry");
|
||||
|
||||
public static final ClassNamed MOB_GOAL_HELPER = ClassNamed.of("com.destroystokyo.paper.entity.ai", "MobGoalHelper");
|
||||
public static final ClassNamed MOB_GOAL_HELPER = PAPER_LEGACY.relativeClassName("entity.ai", "MobGoalHelper");
|
||||
|
||||
public static ClassNamed typed(ClassName name) {
|
||||
List<String> names = new ArrayList<>(name.simpleNames());
|
||||
|
@ -2,12 +2,12 @@ package io.papermc.generator.rewriter.types.registry;
|
||||
|
||||
import io.papermc.generator.Main;
|
||||
import io.papermc.generator.registry.RegistryEntries;
|
||||
import io.papermc.generator.registry.RegistryEntry;
|
||||
import io.papermc.generator.registry.RegistryIdentifiable;
|
||||
import io.papermc.generator.rewriter.types.Types;
|
||||
import io.papermc.generator.rewriter.utils.Annotations;
|
||||
import io.papermc.generator.utils.Formatting;
|
||||
import io.papermc.generator.utils.experimental.SingleFlagHolder;
|
||||
import io.papermc.typewriter.ClassNamed;
|
||||
import io.papermc.typewriter.replace.SearchMetadata;
|
||||
import io.papermc.typewriter.replace.SearchReplaceRewriter;
|
||||
import java.util.Iterator;
|
||||
@ -25,7 +25,6 @@ import static javax.lang.model.element.Modifier.STATIC;
|
||||
public class RegistryTagRewriter<T> extends SearchReplaceRewriter implements RegistryIdentifiable<T> {
|
||||
|
||||
private final ResourceKey<? extends Registry<T>> registryKey;
|
||||
private final String fetchMethod = "getTag";
|
||||
|
||||
public RegistryTagRewriter(ResourceKey<? extends Registry<T>> registryKey) {
|
||||
this.registryKey = registryKey;
|
||||
@ -38,9 +37,8 @@ public class RegistryTagRewriter<T> extends SearchReplaceRewriter implements Reg
|
||||
|
||||
@Override
|
||||
protected void insert(SearchMetadata metadata, StringBuilder builder) {
|
||||
Registry<T> registry = Main.REGISTRY_ACCESS.lookupOrThrow(this.registryKey);
|
||||
ClassNamed apiClass = RegistryEntries.byRegistryKey(this.registryKey).data().api().klass();
|
||||
Iterator<? extends TagKey<T>> keyIterator = registry.listTagIds().sorted(Formatting.alphabeticKeyOrder(reference -> reference.location().getPath())).iterator();
|
||||
RegistryEntry<T> entry = RegistryEntries.byRegistryKey(this.registryKey);
|
||||
Iterator<? extends TagKey<T>> keyIterator = entry.registry().listTagIds().sorted(Formatting.alphabeticKeyOrder(reference -> reference.location().getPath())).iterator();
|
||||
|
||||
while (keyIterator.hasNext()) {
|
||||
TagKey<T> tagKey = keyIterator.next();
|
||||
@ -53,7 +51,7 @@ public class RegistryTagRewriter<T> extends SearchReplaceRewriter implements Reg
|
||||
builder.append(metadata.indent());
|
||||
builder.append("%s %s %s ".formatted(PUBLIC, STATIC, FINAL));
|
||||
|
||||
builder.append("%s<%s>".formatted(Types.TAG.simpleName(), apiClass.simpleName())).append(' ').append(this.rewriteFieldName(tagKey));
|
||||
builder.append("%s<%s>".formatted(Types.TAG.simpleName(), entry.data().api().klass().simpleName())).append(' ').append(this.rewriteFieldName(tagKey));
|
||||
builder.append(" = ");
|
||||
builder.append(this.rewriteFieldValue(tagKey));
|
||||
builder.append(';');
|
||||
@ -70,6 +68,6 @@ public class RegistryTagRewriter<T> extends SearchReplaceRewriter implements Reg
|
||||
}
|
||||
|
||||
protected String rewriteFieldValue(TagKey<T> tagKey) {
|
||||
return "%s(%s)".formatted(this.fetchMethod, quoted(tagKey.location().getPath()));
|
||||
return "%s(%s)".formatted(TagRewriter.FETCH_METHOD, quoted(tagKey.location().getPath()));
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package io.papermc.generator.rewriter.types.registry;
|
||||
|
||||
import com.mojang.logging.LogUtils;
|
||||
import io.papermc.generator.Main;
|
||||
import io.papermc.generator.registry.RegistryEntries;
|
||||
import io.papermc.generator.rewriter.types.Types;
|
||||
@ -7,22 +8,35 @@ import io.papermc.generator.rewriter.utils.Annotations;
|
||||
import io.papermc.generator.utils.Formatting;
|
||||
import io.papermc.generator.utils.experimental.SingleFlagHolder;
|
||||
import io.papermc.typewriter.ClassNamed;
|
||||
import io.papermc.typewriter.parser.Lexer;
|
||||
import io.papermc.typewriter.parser.sequence.SequenceTokens;
|
||||
import io.papermc.typewriter.parser.sequence.TokenTaskBuilder;
|
||||
import io.papermc.typewriter.parser.token.CharSequenceToken;
|
||||
import io.papermc.typewriter.parser.token.TokenType;
|
||||
import io.papermc.typewriter.replace.SearchMetadata;
|
||||
import io.papermc.typewriter.replace.SearchReplaceRewriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.tags.TagKey;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import static io.papermc.generator.utils.Formatting.quoted;
|
||||
|
||||
@ApiStatus.Obsolete
|
||||
public class TagRewriter extends SearchReplaceRewriter {
|
||||
|
||||
public record TagRegistry(String legacyFolderName, ClassNamed apiType, ResourceKey<? extends Registry<?>> registryKey) {
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
static final String FETCH_METHOD = "getTag";
|
||||
|
||||
private record TagRegistry(String legacyFolderName, ClassNamed apiType, ResourceKey<? extends Registry<?>> registryKey) {
|
||||
public TagRegistry(String legacyFolderName, ResourceKey<? extends Registry<?>> registryKey) {
|
||||
this(legacyFolderName, RegistryEntries.BY_REGISTRY_KEY.get(registryKey).data().api().klass(), registryKey);
|
||||
}
|
||||
@ -37,8 +51,39 @@ public class TagRewriter extends SearchReplaceRewriter {
|
||||
// new TagRegistry("damage_types", Registries.DAMAGE_TYPE) - separate in DamageTypeTags
|
||||
};
|
||||
|
||||
private static final Set<TokenType> FORMAT_TOKENS = EnumSet.of(
|
||||
TokenType.COMMENT,
|
||||
TokenType.SINGLE_COMMENT,
|
||||
TokenType.JAVADOC,
|
||||
TokenType.MARKDOWN_JAVADOC
|
||||
);
|
||||
|
||||
private List<String> parseExistingFields(String content) {
|
||||
List<String> fields = new ArrayList<>();
|
||||
|
||||
Lexer lex = new Lexer(content.toCharArray());
|
||||
lex.checkMarkdownDocComments = !this.sourcesMetadata.canSkipMarkdownDocComments();
|
||||
// todo skipUntilNextLine + cleanup lexer flags
|
||||
SequenceTokens.wrap(lex, FORMAT_TOKENS)
|
||||
.group(action -> {
|
||||
action
|
||||
.skip(TokenType.IDENTIFIER) // Tag
|
||||
.skipClosure(TokenType.LT, TokenType.GT, true) // <*>
|
||||
.map(TokenType.IDENTIFIER, token -> {
|
||||
fields.add(((CharSequenceToken) token).value());
|
||||
})
|
||||
.skipQualifiedName() // Bukkit.getTag
|
||||
.skipClosure(TokenType.LPAREN, TokenType.RPAREN, true) // (*)
|
||||
.skip(TokenType.SECO); // ;
|
||||
}, TokenTaskBuilder::asRepeatable)
|
||||
.executeOrThrow();
|
||||
return fields;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void insert(SearchMetadata metadata, StringBuilder builder) {
|
||||
List<String> replacedFields = !Main.IS_UPDATING ? new ArrayList<>() : this.parseExistingFields(metadata.replacedContent());
|
||||
|
||||
for (int i = 0, len = SUPPORTED_REGISTRIES.length; i < len; i++) {
|
||||
final TagRegistry tagRegistry = SUPPORTED_REGISTRIES[i];
|
||||
|
||||
@ -53,11 +98,11 @@ public class TagRewriter extends SearchReplaceRewriter {
|
||||
}
|
||||
|
||||
// registry name field
|
||||
builder.append(metadata.indent());
|
||||
builder.append("%s %s = %s;".formatted(String.class.getSimpleName(), registryFieldName, quoted(tagRegistry.legacyFolderName())));
|
||||
//builder.append(metadata.indent());
|
||||
//builder.append("%s %s = %s;".formatted(String.class.getSimpleName(), registryFieldName, quoted(tagRegistry.legacyFolderName())));
|
||||
|
||||
builder.append('\n');
|
||||
builder.append('\n');
|
||||
//builder.append('\n');
|
||||
//builder.append('\n');
|
||||
|
||||
Iterator<? extends TagKey<?>> keyIterator = registry.listTagIds().sorted(Formatting.alphabeticKeyOrder(tagKey -> tagKey.location().getPath())).iterator();
|
||||
|
||||
@ -65,6 +110,7 @@ public class TagRewriter extends SearchReplaceRewriter {
|
||||
TagKey<?> tagKey = keyIterator.next();
|
||||
final String keyPath = tagKey.location().getPath();
|
||||
final String fieldName = fieldPrefix + Formatting.formatKeyAsField(keyPath);
|
||||
replacedFields.remove(fieldName);
|
||||
|
||||
// tag field
|
||||
String featureFlagName = Main.EXPERIMENTAL_TAGS.get(tagKey);
|
||||
@ -75,7 +121,7 @@ public class TagRewriter extends SearchReplaceRewriter {
|
||||
builder.append(metadata.indent());
|
||||
builder.append("%s<%s>".formatted(this.source.mainClass().simpleName(), this.importCollector.getShortName(tagRegistry.apiType()))).append(' ').append(fieldName);
|
||||
builder.append(" = ");
|
||||
builder.append("%s.getTag(%s, %s.minecraft(%s), %s.class)".formatted(Types.BUKKIT.simpleName(), registryFieldName, Types.NAMESPACED_KEY.simpleName(), quoted(keyPath), tagRegistry.apiType().simpleName())); // assume type is imported properly
|
||||
builder.append("%s.%s(%s, %s.minecraft(%s), %s.class)".formatted(Types.BUKKIT_CLASS.simpleName(), FETCH_METHOD, registryFieldName, Types.NAMESPACED_KEY.simpleName(), quoted(keyPath), tagRegistry.apiType().simpleName())); // assume type is imported properly
|
||||
builder.append(';');
|
||||
|
||||
builder.append('\n');
|
||||
@ -84,5 +130,10 @@ public class TagRewriter extends SearchReplaceRewriter {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!replacedFields.isEmpty()) {
|
||||
LOGGER.warn("Removed {} tag field(s) from {} because they are no longer present in the game:", replacedFields.size(), Types.TAG.canonicalName());
|
||||
replacedFields.forEach(fieldName -> LOGGER.warn("- {}", fieldName));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
package io.papermc.generator.rewriter.types.simple;
|
||||
|
||||
import io.papermc.generator.rewriter.types.Types;
|
||||
import io.papermc.generator.utils.BasePackage;
|
||||
import io.papermc.generator.utils.BlockStateMapping;
|
||||
import io.papermc.typewriter.replace.SearchMetadata;
|
||||
import io.papermc.typewriter.replace.SearchReplaceRewriter;
|
||||
@ -12,7 +12,7 @@ public class CraftBlockDataMapping extends SearchReplaceRewriter {
|
||||
protected void insert(SearchMetadata metadata, StringBuilder builder) {
|
||||
BlockStateMapping.MAPPING.entrySet().stream().sorted(Comparator.comparing(entry -> entry.getKey().getCanonicalName())).forEach(entry -> {
|
||||
builder.append(metadata.indent());
|
||||
builder.append("register(%s.class, %s.block.impl.%s::new);".formatted(entry.getKey().getCanonicalName(), Types.IMPL_PACKAGE, entry.getValue().implName()));
|
||||
builder.append("register(%s.class, %s::new);".formatted(entry.getKey().getCanonicalName(), BasePackage.BUKKIT.impl().concat(".block.impl.").concat(entry.getValue().implName())));
|
||||
builder.append('\n');
|
||||
});
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package io.papermc.generator.rewriter.types.simple;
|
||||
|
||||
import com.mojang.logging.LogUtils;
|
||||
import io.papermc.generator.Main;
|
||||
import io.papermc.typewriter.replace.SearchMetadata;
|
||||
import io.papermc.typewriter.replace.SearchReplaceRewriter;
|
||||
import java.awt.Color;
|
||||
@ -11,7 +12,6 @@ import org.slf4j.Logger;
|
||||
public class MapPaletteRewriter extends SearchReplaceRewriter {
|
||||
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
private static final boolean UPDATING = Boolean.getBoolean("paper.updatingMinecraft");
|
||||
|
||||
@Override
|
||||
protected void insert(SearchMetadata metadata, StringBuilder builder) {
|
||||
@ -34,7 +34,7 @@ public class MapPaletteRewriter extends SearchReplaceRewriter {
|
||||
}
|
||||
}
|
||||
|
||||
if (UPDATING) {
|
||||
if (Main.IS_UPDATING) {
|
||||
LOGGER.warn("There are {} map colors, check CraftMapView#render for possible change and update md5 hash in CraftMapColorCache", count);
|
||||
}
|
||||
}
|
||||
|
@ -43,15 +43,15 @@ public class PoseRewriter extends EnumCloneRewriter<Pose> {
|
||||
.group(action -> {
|
||||
ProtoConstant constant = new ProtoConstant();
|
||||
action
|
||||
.map(TokenType.JAVADOC, token -> {
|
||||
.map(TokenType.JAVADOC, token -> { // /** */
|
||||
constant.javadocs(((CharSequenceBlockToken) token));
|
||||
}, TokenTaskBuilder::asOptional)
|
||||
.map(TokenType.IDENTIFIER, token -> {
|
||||
.map(TokenType.IDENTIFIER, token -> { // <name>
|
||||
constant.name(((CharSequenceToken) token).value());
|
||||
})
|
||||
.skipClosure(TokenType.LPAREN, TokenType.RPAREN, true, TokenTaskBuilder::asOptional)
|
||||
.skipClosure(TokenType.LSCOPE, TokenType.RSCOPE, true, TokenTaskBuilder::asOptional)
|
||||
.map(END_VALUE_MARKERS::contains, $ -> {
|
||||
.skipClosure(TokenType.LPAREN, TokenType.RPAREN, true, TokenTaskBuilder::asOptional) // (*)?
|
||||
.skipClosure(TokenType.LSCOPE, TokenType.RSCOPE, true, TokenTaskBuilder::asOptional) // {*}?
|
||||
.map(END_VALUE_MARKERS::contains, $ -> { // ;|,
|
||||
// this part will fail for the last entry for enum without end (,;)
|
||||
if (constant.isComplete()) {
|
||||
map.put(constant.name(), constant.javadocs());
|
||||
|
@ -12,7 +12,6 @@ import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.Predicate;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.world.entity.npc.VillagerProfession;
|
||||
@ -40,16 +39,16 @@ public class VillagerProfessionRewriter extends RegistryFieldRewriter<VillagerPr
|
||||
.group(action -> {
|
||||
ProtoConstant constant = new ProtoConstant();
|
||||
action
|
||||
.map(TokenType.JAVADOC, token -> {
|
||||
.map(TokenType.JAVADOC, token -> { // /** */
|
||||
constant.javadocs(((CharSequenceBlockToken) token));
|
||||
}, TokenTaskBuilder::asOptional)
|
||||
.skipQualifiedName(Predicate.isEqual(TokenType.JAVADOC))
|
||||
.map(TokenType.IDENTIFIER, token -> {
|
||||
.skip(TokenType.IDENTIFIER) // Profession
|
||||
.map(TokenType.IDENTIFIER, token -> { // <name>
|
||||
constant.name(((CharSequenceToken) token).value());
|
||||
})
|
||||
.skip(TokenType.IDENTIFIER)
|
||||
.skipClosure(TokenType.LPAREN, TokenType.RPAREN, true)
|
||||
.map(TokenType.SECO, $ -> {
|
||||
.skip(TokenType.IDENTIFIER) // getProfession
|
||||
.skipClosure(TokenType.LPAREN, TokenType.RPAREN, true) // (*)
|
||||
.map(TokenType.SECO, $ -> { // ;
|
||||
if (constant.isComplete()) {
|
||||
map.put(constant.name(), constant.javadocs());
|
||||
}
|
||||
|
@ -4,51 +4,51 @@ import com.squareup.javapoet.ClassName;
|
||||
import io.papermc.typewriter.ClassNamed;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
import static io.papermc.generator.utils.BasePackage.BUKKIT;
|
||||
import static io.papermc.generator.utils.BasePackage.PAPER;
|
||||
import static io.papermc.generator.utils.BasePackage.PAPER_LEGACY;
|
||||
|
||||
@NullMarked
|
||||
public final class Types {
|
||||
|
||||
public static final String API_PACKAGE = "org.bukkit";
|
||||
public static final String PAPER_PACKAGE = "io.papermc.paper";
|
||||
public static final ClassName NAMESPACED_KEY = BUKKIT.className("NamespacedKey");
|
||||
|
||||
public static final ClassName NAMESPACED_KEY = ClassName.get(API_PACKAGE, "NamespacedKey");
|
||||
public static final ClassName MINECRAFT_EXPERIMENTAL = BUKKIT.className("MinecraftExperimental");
|
||||
|
||||
public static final ClassName MINECRAFT_EXPERIMENTAL = ClassName.get(API_PACKAGE, "MinecraftExperimental");
|
||||
public static final ClassName MINECRAFT_EXPERIMENTAL_REQUIRES = BUKKIT.className("MinecraftExperimental", "Requires");
|
||||
|
||||
public static final ClassName MINECRAFT_EXPERIMENTAL_REQUIRES = ClassName.get(API_PACKAGE, "MinecraftExperimental", "Requires");
|
||||
public static final ClassName AXIS = BUKKIT.className("Axis");
|
||||
|
||||
public static final ClassName AXIS = ClassName.get(API_PACKAGE, "Axis");
|
||||
public static final ClassName BLOCK_FACE = BUKKIT.relativeClass("block", "BlockFace");
|
||||
|
||||
public static final ClassName BLOCK_FACE = ClassName.get(API_PACKAGE + ".block", "BlockFace");
|
||||
public static final ClassName VECTOR = BUKKIT.relativeClass("util", "Vector");
|
||||
|
||||
public static final ClassName VECTOR = ClassName.get(API_PACKAGE + ".util", "Vector");
|
||||
public static final ClassName NOTE = BUKKIT.className("Note");
|
||||
|
||||
public static final ClassName NOTE = ClassName.get(API_PACKAGE, "Note");
|
||||
|
||||
public static final ClassName BLOCK_DATA_RAIL_SHAPE = ClassName.get(API_PACKAGE + ".block.data", "Rail", "Shape");
|
||||
public static final ClassName BLOCK_DATA_RAIL_SHAPE = BUKKIT.relativeClass("block.data", "Rail", "Shape");
|
||||
|
||||
public static final ClassName KEY = ClassName.get("net.kyori.adventure.key", "Key");
|
||||
|
||||
public static final ClassName REGISTRY_KEY = ClassName.get(PAPER_PACKAGE + ".registry", "RegistryKey");
|
||||
public static final ClassName REGISTRY_KEY = PAPER.relativeClass("registry", "RegistryKey");
|
||||
|
||||
public static final ClassName TYPED_KEY = ClassName.get(PAPER_PACKAGE + ".registry", "TypedKey");
|
||||
public static final ClassName TYPED_KEY = PAPER.relativeClass("registry", "TypedKey");
|
||||
|
||||
public static final ClassName GOAL_KEY = ClassName.get("com.destroystokyo.paper.entity.ai", "GoalKey");
|
||||
public static final ClassName GOAL_KEY = PAPER_LEGACY.relativeClass("entity.ai", "GoalKey");
|
||||
|
||||
public static final ClassName GOAL = ClassName.get("com.destroystokyo.paper.entity.ai", "Goal");
|
||||
public static final ClassName GOAL = PAPER_LEGACY.relativeClass("entity.ai", "Goal");
|
||||
|
||||
public static final ClassName MOB = ClassName.get(API_PACKAGE + ".entity", "Mob");
|
||||
public static final ClassName MOB = BUKKIT.relativeClass("entity", "Mob");
|
||||
|
||||
public static final ClassName RANGED_ENTITY = ClassName.get("com.destroystokyo.paper.entity", "RangedEntity");
|
||||
public static final ClassName RANGED_ENTITY = PAPER_LEGACY.relativeClass("entity", "RangedEntity");
|
||||
|
||||
public static final ClassName TAG_KEY = ClassName.get(PAPER_PACKAGE + ".registry.tag", "TagKey");
|
||||
|
||||
public static final ClassName GENERATED_FROM = ClassName.get(PAPER_PACKAGE + ".generated", "GeneratedFrom");
|
||||
public static final ClassName CRAFT_BLOCK_DATA = BUKKIT.relativeImpClass("block.data", "CraftBlockData");
|
||||
|
||||
public static final String IMPL_PACKAGE = "org.bukkit.craftbukkit";
|
||||
public static final ClassName CRAFT_BLOCK = BUKKIT.relativeImpClass("block", "CraftBlock");
|
||||
|
||||
public static final ClassName CRAFT_BLOCK_DATA = ClassName.get(IMPL_PACKAGE + ".block.data", "CraftBlockData");
|
||||
public static final ClassName TAG_KEY = PAPER.relativeClass("registry.tag", "TagKey");
|
||||
|
||||
public static final ClassName CRAFT_BLOCK = ClassName.get(IMPL_PACKAGE + ".block", "CraftBlock");
|
||||
public static final ClassName GENERATED_FROM = PAPER.relativeClass("generated", "GeneratedFrom");
|
||||
|
||||
public static ClassName typed(ClassNamed name) {
|
||||
if (name.knownClass() != null) {
|
||||
|
@ -22,6 +22,7 @@ import io.papermc.generator.types.craftblockdata.property.holder.VirtualField;
|
||||
import io.papermc.generator.types.craftblockdata.property.holder.converter.DataConverter;
|
||||
import io.papermc.generator.types.craftblockdata.property.holder.converter.DataConverters;
|
||||
import io.papermc.generator.utils.Annotations;
|
||||
import io.papermc.generator.utils.BasePackage;
|
||||
import io.papermc.generator.utils.BlockStateMapping;
|
||||
import io.papermc.generator.utils.CommonVariable;
|
||||
import io.papermc.generator.utils.NamingManager;
|
||||
@ -52,7 +53,7 @@ public class CraftBlockDataGenerator extends OverriddenClassGenerator {
|
||||
private final BlockStateMapping.BlockData blockData;
|
||||
|
||||
protected CraftBlockDataGenerator(Class<? extends Block> blockClass, BlockStateMapping.BlockData blockData) {
|
||||
super(blockData.api(), blockData.implName(), Types.IMPL_PACKAGE + ".block.impl");
|
||||
super(blockData.api(), blockData.implName(), BasePackage.BUKKIT.impl().concat(".block.impl"));
|
||||
this.blockClass = blockClass;
|
||||
this.blockData = blockData;
|
||||
this.printWarningOnMissingOverride = true;
|
||||
|
@ -0,0 +1,46 @@
|
||||
package io.papermc.generator.utils;
|
||||
|
||||
import com.squareup.javapoet.ClassName;
|
||||
import io.papermc.typewriter.ClassNamed;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
@NullMarked
|
||||
public record BasePackage(String api, String impl) {
|
||||
|
||||
public static final BasePackage PAPER = new BasePackage("io.papermc.paper");
|
||||
public static final BasePackage BUKKIT = new BasePackage("org.bukkit", "org.bukkit.craftbukkit");
|
||||
@ApiStatus.Obsolete
|
||||
public static final BasePackage PAPER_LEGACY = new BasePackage("com.destroystokyo.paper");
|
||||
@Deprecated
|
||||
public static final BasePackage SPIGOT = new BasePackage("org.spigotmc");
|
||||
|
||||
BasePackage(String name) {
|
||||
this(name, name);
|
||||
}
|
||||
|
||||
public ClassName className(String simpleName, String... simpleNames) {
|
||||
return relativeClass(null, simpleName, simpleNames);
|
||||
}
|
||||
|
||||
public ClassName relativeClass(@Nullable String packageName, String simpleName, String... simpleNames) {
|
||||
return ClassName.get(packageName == null ? this.api : String.join(".", this.api, packageName), simpleName, simpleNames);
|
||||
}
|
||||
|
||||
public ClassName relativeImpClass(@Nullable String packageName, String simpleName, String... simpleNames) {
|
||||
return ClassName.get(packageName == null ? this.impl : String.join(".", this.impl, packageName), simpleName, simpleNames);
|
||||
}
|
||||
|
||||
public ClassNamed classNamed(String simpleName, String... simpleNames) {
|
||||
return relativeClassName(null, simpleName, simpleNames);
|
||||
}
|
||||
|
||||
public ClassNamed relativeClassName(@Nullable String packageName, String simpleName, String... simpleNames) {
|
||||
return ClassNamed.of(packageName == null ? this.api : String.join(".", this.api, packageName), simpleName, simpleNames);
|
||||
}
|
||||
|
||||
public ClassNamed relativeImpClassName(@Nullable String packageName, String simpleName, String... simpleNames) {
|
||||
return ClassNamed.of(packageName == null ? this.impl : String.join(".", this.impl, packageName), simpleName, simpleNames);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user