mirror of https://github.com/PaperMC/Paper.git
reorder fields alphabetically
This commit is contained in:
parent
1cfc0f7240
commit
337ba65ab1
|
@ -292,6 +292,48 @@ public final class GameEventKeys {
|
|||
*/
|
||||
public static final TypedKey<GameEvent> RESONATE_1 = create(key("resonate_1"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:resonate_10}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TypedKey<GameEvent> RESONATE_10 = create(key("resonate_10"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:resonate_11}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TypedKey<GameEvent> RESONATE_11 = create(key("resonate_11"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:resonate_12}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TypedKey<GameEvent> RESONATE_12 = create(key("resonate_12"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:resonate_13}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TypedKey<GameEvent> RESONATE_13 = create(key("resonate_13"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:resonate_14}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TypedKey<GameEvent> RESONATE_14 = create(key("resonate_14"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:resonate_15}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TypedKey<GameEvent> RESONATE_15 = create(key("resonate_15"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:resonate_2}
|
||||
*
|
||||
|
@ -349,46 +391,60 @@ public final class GameEventKeys {
|
|||
public static final TypedKey<GameEvent> RESONATE_9 = create(key("resonate_9"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:resonate_10}
|
||||
* {@code minecraft:sculk_sensor_tendrils_clicking}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TypedKey<GameEvent> RESONATE_10 = create(key("resonate_10"));
|
||||
public static final TypedKey<GameEvent> SCULK_SENSOR_TENDRILS_CLICKING = create(key("sculk_sensor_tendrils_clicking"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:resonate_11}
|
||||
* {@code minecraft:shear}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TypedKey<GameEvent> RESONATE_11 = create(key("resonate_11"));
|
||||
public static final TypedKey<GameEvent> SHEAR = create(key("shear"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:resonate_12}
|
||||
* {@code minecraft:shriek}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TypedKey<GameEvent> RESONATE_12 = create(key("resonate_12"));
|
||||
public static final TypedKey<GameEvent> SHRIEK = create(key("shriek"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:resonate_13}
|
||||
* {@code minecraft:splash}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TypedKey<GameEvent> RESONATE_13 = create(key("resonate_13"));
|
||||
public static final TypedKey<GameEvent> SPLASH = create(key("splash"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:resonate_14}
|
||||
* {@code minecraft:step}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TypedKey<GameEvent> RESONATE_14 = create(key("resonate_14"));
|
||||
public static final TypedKey<GameEvent> STEP = create(key("step"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:resonate_15}
|
||||
* {@code minecraft:swim}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TypedKey<GameEvent> RESONATE_15 = create(key("resonate_15"));
|
||||
public static final TypedKey<GameEvent> SWIM = create(key("swim"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:teleport}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TypedKey<GameEvent> TELEPORT = create(key("teleport"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:unequip}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TypedKey<GameEvent> UNEQUIP = create(key("unequip"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:sculk_sensor_tendrils_clicking}
|
||||
|
|
|
@ -5,6 +5,7 @@ import java.util.Set;
|
|||
import org.bukkit.entity.EntityType;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Represents a tag that may be defined by the server or a resource pack to
|
||||
|
@ -26,7 +27,7 @@ import org.jetbrains.annotations.NotNull;
|
|||
@GeneratedFrom("1.20.4")
|
||||
public interface Tag<T extends Keyed> extends Keyed {
|
||||
/**
|
||||
* Key for the built in block registry.
|
||||
* Key for the built-in block registry.
|
||||
*/
|
||||
String REGISTRY_BLOCKS = "blocks";
|
||||
|
||||
|
@ -1235,7 +1236,7 @@ public interface Tag<T extends Keyed> extends Keyed {
|
|||
Tag<Material> WOOL_CARPETS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("wool_carpets"), Material.class);
|
||||
|
||||
/**
|
||||
* Key for the built in item registry.
|
||||
* Key for the built-in item registry.
|
||||
*/
|
||||
String REGISTRY_ITEMS = "items";
|
||||
|
||||
|
@ -1933,7 +1934,7 @@ public interface Tag<T extends Keyed> extends Keyed {
|
|||
Tag<Material> ITEMS_WOOL_CARPETS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("wool_carpets"), Material.class);
|
||||
|
||||
/**
|
||||
* Key for the built in fluid registry.
|
||||
* Key for the built-in fluid registry.
|
||||
*/
|
||||
String REGISTRY_FLUIDS = "fluids";
|
||||
|
||||
|
@ -1952,7 +1953,7 @@ public interface Tag<T extends Keyed> extends Keyed {
|
|||
Tag<Fluid> FLUIDS_WATER = Bukkit.getTag(REGISTRY_FLUIDS, NamespacedKey.minecraft("water"), Fluid.class);
|
||||
|
||||
/**
|
||||
* Key for the built in entity_type registry.
|
||||
* Key for the built-in entity_type registry.
|
||||
*/
|
||||
String REGISTRY_ENTITY_TYPES = "entity_types";
|
||||
|
||||
|
@ -1998,6 +1999,7 @@ public interface Tag<T extends Keyed> extends Keyed {
|
|||
*/
|
||||
@ApiStatus.Experimental
|
||||
@MinecraftExperimental("update 1.21")
|
||||
@Nullable
|
||||
Tag<EntityType> ENTITY_TYPES_CAN_TURN_IN_BOATS = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("can_turn_in_boats"), EntityType.class);
|
||||
|
||||
/**
|
||||
|
@ -2007,6 +2009,7 @@ public interface Tag<T extends Keyed> extends Keyed {
|
|||
*/
|
||||
@ApiStatus.Experimental
|
||||
@MinecraftExperimental("update 1.21")
|
||||
@Nullable
|
||||
Tag<EntityType> ENTITY_TYPES_DEFLECTS_ARROWS = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("deflects_arrows"), EntityType.class);
|
||||
|
||||
/**
|
||||
|
@ -2016,6 +2019,7 @@ public interface Tag<T extends Keyed> extends Keyed {
|
|||
*/
|
||||
@ApiStatus.Experimental
|
||||
@MinecraftExperimental("update 1.21")
|
||||
@Nullable
|
||||
Tag<EntityType> ENTITY_TYPES_DEFLECTS_TRIDENTS = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("deflects_tridents"), EntityType.class);
|
||||
|
||||
/**
|
||||
|
@ -2103,7 +2107,7 @@ public interface Tag<T extends Keyed> extends Keyed {
|
|||
Tag<EntityType> ENTITY_TYPES_ZOMBIES = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("zombies"), EntityType.class);
|
||||
|
||||
/**
|
||||
* Key for the built in game_event registry.
|
||||
* Key for the built-in game_event registry.
|
||||
*/
|
||||
String REGISTRY_GAME_EVENTS = "game_events";
|
||||
|
||||
|
@ -2143,7 +2147,7 @@ public interface Tag<T extends Keyed> extends Keyed {
|
|||
Tag<GameEvent> GAME_EVENT_WARDEN_CAN_LISTEN = Bukkit.getTag(REGISTRY_GAME_EVENTS, NamespacedKey.minecraft("warden_can_listen"), GameEvent.class);
|
||||
|
||||
/**
|
||||
* @deprecated in favour of {@link #WOOL_CARPETS}.
|
||||
* @deprecated in favour of {@link #WOOL_CARPETS}
|
||||
*/
|
||||
@Deprecated
|
||||
Tag<Material> CARPETS = WOOL_CARPETS;
|
||||
|
|
|
@ -46,8 +46,8 @@ public interface Generators {
|
|||
new AttributeGenerator("Attribute", "org.bukkit.attribute"),
|
||||
new StructureTypeGenerator("StructureType", "org.bukkit.generator.structure"),
|
||||
new StructureGenerator("Structure", "org.bukkit.generator.structure"),
|
||||
new LegacyKeyedRegistryGenerator<>("TrimPattern", TrimPattern.class, "org.bukkit.inventory.meta.trim", Registries.TRIM_PATTERN, RegistryKey.TRIM_PATTERN),
|
||||
new LegacyKeyedRegistryGenerator<>("TrimMaterial", TrimMaterial.class, "org.bukkit.inventory.meta.trim", Registries.TRIM_MATERIAL, RegistryKey.TRIM_MATERIAL),
|
||||
new LegacyKeyedRegistryGenerator<>("TrimPattern", "org.bukkit.inventory.meta.trim", Registries.TRIM_PATTERN, RegistryKey.TRIM_PATTERN),
|
||||
new LegacyKeyedRegistryGenerator<>("TrimMaterial", "org.bukkit.inventory.meta.trim", Registries.TRIM_MATERIAL, RegistryKey.TRIM_MATERIAL),
|
||||
new TagGenerator("Tag", "org.bukkit")
|
||||
};
|
||||
|
||||
|
|
|
@ -18,11 +18,12 @@ public abstract class SimpleGenerator implements SourceGenerator {
|
|||
|
||||
protected abstract TypeSpec getTypeSpec();
|
||||
|
||||
protected abstract JavaFile.Builder file(JavaFile.Builder builder);
|
||||
protected JavaFile.Builder file(JavaFile.Builder builder) {
|
||||
return builder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToFile(Path parent) throws IOException {
|
||||
|
||||
JavaFile.Builder builder = JavaFile.builder(this.packageName, this.getTypeSpec());
|
||||
this.file(builder)
|
||||
.indent(" ")
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package io.papermc.generator.types.enumgen;
|
||||
|
||||
import com.squareup.javapoet.JavaFile;
|
||||
import com.squareup.javapoet.TypeSpec;
|
||||
import io.papermc.generator.types.SimpleGenerator;
|
||||
import io.papermc.generator.utils.Annotations;
|
||||
|
@ -30,10 +29,4 @@ public class EnumGenerator<T extends Enum<T>> extends SimpleGenerator {
|
|||
|
||||
return typeBuilder.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JavaFile.Builder file(JavaFile.Builder builder) {
|
||||
return builder
|
||||
.skipJavaLangImports(true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@ import com.destroystokyo.paper.entity.RangedEntity;
|
|||
import com.destroystokyo.paper.entity.ai.GoalKey;
|
||||
import com.squareup.javapoet.ClassName;
|
||||
import com.squareup.javapoet.FieldSpec;
|
||||
import com.squareup.javapoet.JavaFile;
|
||||
import com.squareup.javapoet.MethodSpec;
|
||||
import com.squareup.javapoet.ParameterSpec;
|
||||
import com.squareup.javapoet.ParameterizedTypeName;
|
||||
|
@ -19,7 +18,6 @@ import io.papermc.generator.utils.Formatting;
|
|||
import io.papermc.generator.utils.Javadocs;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import javax.lang.model.element.Modifier;
|
||||
import net.minecraft.world.entity.ai.goal.Goal;
|
||||
import net.minecraft.world.entity.ai.goal.WrappedGoal;
|
||||
import org.bukkit.NamespacedKey;
|
||||
|
@ -218,9 +216,8 @@ public class MobGoalGenerator extends SimpleGenerator {
|
|||
|
||||
for (final DeprecatedEntry value : DEPRECATED_ENTRIES) {
|
||||
TypeName typedKey = ParameterizedTypeName.get(GoalKey.class, value.entity);
|
||||
NamespacedKey key = NamespacedKey.minecraft(value.entryName);
|
||||
String keyPath = value.entryName;
|
||||
|
||||
String keyPath = key.getKey();
|
||||
String fieldName = Formatting.formatKeyAsField(keyPath);
|
||||
FieldSpec.Builder fieldBuilder = FieldSpec.builder(typedKey, fieldName, PUBLIC, STATIC, FINAL)
|
||||
.addAnnotation(Annotations.deprecatedVersioned(value.removedVersion, value.removalVersion != null))
|
||||
|
@ -239,12 +236,6 @@ public class MobGoalGenerator extends SimpleGenerator {
|
|||
return typeBuilder.addMethod(createMethod.build()).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JavaFile.Builder file(JavaFile.Builder builder) {
|
||||
return builder
|
||||
.skipJavaLangImports(true);
|
||||
}
|
||||
|
||||
record DeprecatedEntry(Class<?> entity, String entryName, @Nullable String removalVersion,
|
||||
@Nullable String removedVersion) {
|
||||
|
||||
|
|
|
@ -239,7 +239,7 @@ public class MobGoalNames {
|
|||
}
|
||||
|
||||
private static final BiMap<String, String> deobfuscationMap = HashBiMap.create();
|
||||
static final Set<String> ignored = new HashSet<>();
|
||||
private static final Set<String> ignored = new HashSet<>();
|
||||
|
||||
static {
|
||||
deobfuscationMap.put("abstract_skeleton_1", "abstract_skeleton_melee");
|
||||
|
@ -253,14 +253,14 @@ public class MobGoalNames {
|
|||
|
||||
public static String getUsableName(String name) {
|
||||
final String original = name;
|
||||
name = name.substring(name.lastIndexOf(".") + 1);
|
||||
name = name.substring(name.lastIndexOf('.') + 1);
|
||||
boolean flag = false;
|
||||
// inner classes
|
||||
if (name.contains("$")) {
|
||||
String cut = name.substring(name.indexOf("$") + 1);
|
||||
String cut = name.substring(name.indexOf('$') + 1);
|
||||
if (cut.length() <= 2) {
|
||||
name = name.replace("Entity", "");
|
||||
name = name.replace("$", "_");
|
||||
name = name.replace('$', '_');
|
||||
flag = true;
|
||||
} else {
|
||||
// mapped, wooo
|
||||
|
@ -273,7 +273,7 @@ public class MobGoalNames {
|
|||
StringBuilder sb = new StringBuilder();
|
||||
for (char c : name.toCharArray()) {
|
||||
if (c >= 'A' && c <= 'Z') {
|
||||
sb.append("_");
|
||||
sb.append('_');
|
||||
sb.append(Character.toLowerCase(c));
|
||||
} else {
|
||||
sb.append(c);
|
||||
|
|
|
@ -2,7 +2,6 @@ package io.papermc.generator.types.registry;
|
|||
|
||||
import com.google.common.base.Suppliers;
|
||||
import com.squareup.javapoet.FieldSpec;
|
||||
import com.squareup.javapoet.JavaFile;
|
||||
import com.squareup.javapoet.MethodSpec;
|
||||
import com.squareup.javapoet.ParameterSpec;
|
||||
import com.squareup.javapoet.TypeSpec;
|
||||
|
@ -10,16 +9,14 @@ import io.papermc.generator.Main;
|
|||
import io.papermc.generator.types.SimpleGenerator;
|
||||
import io.papermc.generator.utils.Annotations;
|
||||
import io.papermc.generator.utils.Formatting;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.Supplier;
|
||||
import javax.lang.model.element.Modifier;
|
||||
import io.papermc.generator.utils.RegistryUtils;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.world.flag.FeatureElement;
|
||||
import net.minecraft.world.flag.FeatureFlags;
|
||||
import org.bukkit.Keyed;
|
||||
import org.bukkit.MinecraftExperimental;
|
||||
|
@ -34,13 +31,15 @@ import static javax.lang.model.element.Modifier.PRIVATE;
|
|||
@DefaultQualifier(NonNull.class)
|
||||
public abstract class EnumRegistryGenerator<T> extends SimpleGenerator {
|
||||
|
||||
protected final ResourceKey<Registry<T>> registryKey;
|
||||
private final Registry<T> registry;
|
||||
private final Supplier<Set<ResourceKey<T>>> experimentalKeys;
|
||||
private final boolean isFilteredRegistry;
|
||||
|
||||
public EnumRegistryGenerator(final String className, final String pkg, ResourceKey<Registry<T>> registryKey) {
|
||||
public EnumRegistryGenerator(final String className, final String pkg, final ResourceKey<? extends Registry<T>> registryKey) {
|
||||
super(className, pkg);
|
||||
this.registryKey = registryKey;
|
||||
this.experimentalKeys = Suppliers.memoize(() -> RegistryUtils.collectExperimentalDataDrivenKeys(Main.REGISTRY_ACCESS.registryOrThrow(this.registryKey)));
|
||||
this.registry = Main.REGISTRY_ACCESS.registryOrThrow(registryKey);
|
||||
this.experimentalKeys = Suppliers.memoize(() -> RegistryUtils.collectExperimentalDataDrivenKeys(this.registry));
|
||||
this.isFilteredRegistry = FeatureElement.FILTERED_REGISTRIES.contains(registryKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -50,16 +49,12 @@ public abstract class EnumRegistryGenerator<T> extends SimpleGenerator {
|
|||
.addModifiers(Modifier.PUBLIC)
|
||||
.addAnnotations(Annotations.CLASS_HEADER);
|
||||
|
||||
Registry<T> registry = Main.REGISTRY_ACCESS.registryOrThrow(this.registryKey);
|
||||
List<Map.Entry<ResourceKey<T>, T>> paths = new ArrayList<>(registry.entrySet());
|
||||
paths.sort(Comparator.comparing(o -> o.getKey().location().getPath()));
|
||||
|
||||
paths.forEach(entry -> {
|
||||
ResourceKey<T> resourceKey = entry.getKey();
|
||||
this.registry.holders().sorted(Formatting.alphabeticKeyOrder(reference -> reference.key().location().getPath())).forEach(reference -> {
|
||||
ResourceKey<T> resourceKey = reference.key();
|
||||
String pathKey = resourceKey.location().getPath();
|
||||
|
||||
String fieldName = Formatting.formatKeyAsField(pathKey);
|
||||
@Nullable String experimentalValue = this.getExperimentalValue(entry);
|
||||
@Nullable String experimentalValue = this.getExperimentalValue(reference);
|
||||
TypeSpec.Builder builder = TypeSpec.anonymousClassBuilder("$S", pathKey);
|
||||
if (experimentalValue != null) {
|
||||
builder.addAnnotations(Annotations.experimentalAnnotations(experimentalValue));
|
||||
|
@ -89,14 +84,12 @@ public abstract class EnumRegistryGenerator<T> extends SimpleGenerator {
|
|||
|
||||
public abstract void addExtras(TypeSpec.Builder builder, FieldSpec keyField);
|
||||
|
||||
@Override
|
||||
protected JavaFile.Builder file(JavaFile.Builder builder) {
|
||||
return builder.skipJavaLangImports(true);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getExperimentalValue(Map.Entry<ResourceKey<T>, T> entry) {
|
||||
if (this.experimentalKeys.get().contains(entry.getKey())) {
|
||||
public String getExperimentalValue(Holder.Reference<T> reference) {
|
||||
if (this.isFilteredRegistry && reference.value() instanceof FeatureElement element && FeatureFlags.isExperimental(element.requiredFeatures())) {
|
||||
return Formatting.formatFeatureFlagSet(element.requiredFeatures());
|
||||
}
|
||||
if (this.experimentalKeys.get().contains(reference.key())) {
|
||||
return Formatting.formatFeatureFlag(FeatureFlags.UPDATE_1_21);
|
||||
}
|
||||
return null;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package io.papermc.generator.types.registry;
|
||||
|
||||
import com.google.common.base.Suppliers;
|
||||
import com.squareup.javapoet.FieldSpec;
|
||||
import com.squareup.javapoet.JavaFile;
|
||||
import com.squareup.javapoet.MethodSpec;
|
||||
|
@ -16,13 +17,15 @@ import io.papermc.generator.utils.RegistryUtils;
|
|||
import io.papermc.paper.registry.RegistryKey;
|
||||
import io.papermc.paper.registry.TypedKey;
|
||||
import java.util.Set;
|
||||
import java.util.function.Supplier;
|
||||
import net.kyori.adventure.key.Key;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.world.flag.FeatureFlags;
|
||||
import org.bukkit.MinecraftExperimental;
|
||||
import net.minecraft.world.flag.FeatureElement;
|
||||
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;
|
||||
|
@ -46,16 +49,20 @@ public class GeneratedKeyType<T, A> extends SimpleGenerator {
|
|||
""";
|
||||
|
||||
private final Class<A> apiType;
|
||||
private final ResourceKey<? extends Registry<T>> registryKey;
|
||||
private final Registry<T> registry;
|
||||
private final RegistryKey<A> apiRegistryKey;
|
||||
private final boolean publicCreateKeyMethod;
|
||||
private final Supplier<Set<ResourceKey<T>>> experimentalKeys;
|
||||
private final boolean isFilteredRegistry;
|
||||
|
||||
public GeneratedKeyType(final String className, final Class<A> apiType, final String pkg, final ResourceKey<? extends Registry<T>> registryKey, final RegistryKey<A> apiRegistryKey, final boolean publicCreateKeyMethod) {
|
||||
super(className, pkg);
|
||||
this.apiType = apiType;
|
||||
this.registryKey = registryKey;
|
||||
this.registry = Main.REGISTRY_ACCESS.registryOrThrow(registryKey);
|
||||
this.apiRegistryKey = apiRegistryKey;
|
||||
this.publicCreateKeyMethod = publicCreateKeyMethod;
|
||||
this.experimentalKeys = Suppliers.memoize(() -> RegistryUtils.collectExperimentalDataDrivenKeys(this.registry));
|
||||
this.isFilteredRegistry = FeatureElement.FILTERED_REGISTRIES.contains(registryKey);
|
||||
}
|
||||
|
||||
private MethodSpec.Builder createMethod(final TypeName returnType) {
|
||||
|
@ -92,24 +99,24 @@ public class GeneratedKeyType<T, A> extends SimpleGenerator {
|
|||
final TypeSpec.Builder typeBuilder = this.keyHolderType();
|
||||
final MethodSpec.Builder createMethod = this.createMethod(typedKey);
|
||||
|
||||
final Registry<T> registry = Main.REGISTRY_ACCESS.registryOrThrow(this.registryKey);
|
||||
final Set<ResourceKey<T>> experimental = RegistryUtils.collectExperimentalDataDrivenKeys(registry);
|
||||
|
||||
boolean allExperimental = true;
|
||||
for (final Holder.Reference<T> reference : registry.holders().sorted(Formatting.alphabeticKeyOrder(reference -> reference.key().location().getPath())).toList()) {
|
||||
for (final Holder.Reference<T> reference : this.registry.holders().sorted(Formatting.alphabeticKeyOrder(reference -> reference.key().location().getPath())).toList()) {
|
||||
final ResourceKey<T> key = reference.key();
|
||||
final String keyPath = key.location().getPath();
|
||||
final String fieldName = Formatting.formatKeyAsField(keyPath);
|
||||
final FieldSpec.Builder fieldBuilder = FieldSpec.builder(typedKey, fieldName, PUBLIC, STATIC, FINAL)
|
||||
.initializer("$N(key($S))", createMethod.build(), keyPath)
|
||||
.addJavadoc(Javadocs.getVersionDependentField("{@code $L}"), key.location().toString());
|
||||
if (experimental.contains(key)) {
|
||||
fieldBuilder.addAnnotations(experimentalAnnotations(FeatureFlags.UPDATE_1_21));
|
||||
|
||||
final @Nullable String experimentalValue = this.getExperimentalValue(reference);
|
||||
if (experimentalValue != null) {
|
||||
fieldBuilder.addAnnotations(experimentalAnnotations(experimentalValue));
|
||||
} else {
|
||||
allExperimental = false;
|
||||
}
|
||||
typeBuilder.addField(fieldBuilder.build());
|
||||
}
|
||||
|
||||
if (allExperimental) {
|
||||
typeBuilder.addAnnotations(experimentalAnnotations(FeatureFlags.UPDATE_1_21));
|
||||
createMethod.addAnnotations(experimentalAnnotations(FeatureFlags.UPDATE_1_21));
|
||||
|
@ -120,10 +127,18 @@ public class GeneratedKeyType<T, A> extends SimpleGenerator {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected JavaFile.Builder file(final JavaFile.Builder builder) {
|
||||
return builder
|
||||
.skipJavaLangImports(true)
|
||||
.addStaticImport(Key.class, "key")
|
||||
.indent(" ");
|
||||
protected JavaFile.Builder file(JavaFile.Builder builder) {
|
||||
return builder.addStaticImport(Key.class, "key");
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getExperimentalValue(final Holder.Reference<T> reference) {
|
||||
if (this.isFilteredRegistry && reference.value() instanceof FeatureElement element && FeatureFlags.isExperimental(element.requiredFeatures())) {
|
||||
return Formatting.formatFeatureFlagSet(element.requiredFeatures());
|
||||
}
|
||||
if (this.experimentalKeys.get().contains(reference.key())) {
|
||||
return Formatting.formatFeatureFlag(FeatureFlags.UPDATE_1_21);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@ package io.papermc.generator.types.registry;
|
|||
|
||||
import com.squareup.javapoet.MethodSpec;
|
||||
import com.squareup.javapoet.TypeSpec;
|
||||
import io.papermc.generator.Main;
|
||||
import io.papermc.generator.utils.Annotations;
|
||||
import io.papermc.generator.utils.Javadocs;
|
||||
import io.papermc.generator.utils.RegistryUtils;
|
||||
|
@ -28,11 +27,8 @@ public class LegacyKeyedRegistryGenerator<T, A> extends RegistryGenerator<T, A>
|
|||
can exist without a key.
|
||||
""";
|
||||
|
||||
private final ResourceKey<? extends Registry<T>> registryKey;
|
||||
|
||||
public LegacyKeyedRegistryGenerator(final String className, final Class<A> apiType, final String pkg, final ResourceKey<? extends Registry<T>> registryKey, final RegistryKey<A> apiRegistryKey) {
|
||||
super(className, apiType, pkg, apiRegistryKey, true);
|
||||
this.registryKey = registryKey;
|
||||
public LegacyKeyedRegistryGenerator(final String className, final String pkg, final ResourceKey<? extends Registry<T>> registryKey, final RegistryKey<A> apiRegistryKey) {
|
||||
super(className, pkg, registryKey, apiRegistryKey, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -48,9 +44,4 @@ public class LegacyKeyedRegistryGenerator<T, A> extends RegistryGenerator<T, A>
|
|||
.addAnnotation(NOT_NULL).build());
|
||||
}
|
||||
|
||||
@Override
|
||||
public net.minecraft.core.Registry<T> getRegistry() {
|
||||
return Main.REGISTRY_ACCESS.registryOrThrow(this.registryKey);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,26 +1,26 @@
|
|||
package io.papermc.generator.types.registry;
|
||||
|
||||
import com.google.common.base.Suppliers;
|
||||
import com.squareup.javapoet.ClassName;
|
||||
import com.squareup.javapoet.FieldSpec;
|
||||
import com.squareup.javapoet.JavaFile;
|
||||
import com.squareup.javapoet.MethodSpec;
|
||||
import com.squareup.javapoet.ParameterSpec;
|
||||
import com.squareup.javapoet.TypeName;
|
||||
import com.squareup.javapoet.TypeSpec;
|
||||
import io.papermc.generator.Main;
|
||||
import io.papermc.generator.types.SimpleGenerator;
|
||||
import io.papermc.generator.utils.Annotations;
|
||||
import io.papermc.generator.utils.Formatting;
|
||||
import io.papermc.generator.utils.Javadocs;
|
||||
import io.papermc.generator.utils.RegistryUtils;
|
||||
import io.papermc.paper.registry.RegistryKey;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.Supplier;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.flag.FeatureElement;
|
||||
import net.minecraft.world.flag.FeatureFlags;
|
||||
import org.bukkit.Keyed;
|
||||
import org.bukkit.MinecraftExperimental;
|
||||
|
@ -42,19 +42,21 @@ import static javax.lang.model.element.Modifier.STATIC;
|
|||
@DefaultQualifier(NonNull.class)
|
||||
public abstract class RegistryGenerator<T, A> extends SimpleGenerator {
|
||||
|
||||
private final Class<A> apiType;
|
||||
private final ClassName apiType;
|
||||
private final Registry<T> registry;
|
||||
protected final RegistryKey<A> apiRegistryKey;
|
||||
private final Supplier<Registry<T>> registry;
|
||||
private final boolean isInterface;
|
||||
private final Supplier<Set<ResourceKey<T>>> experimentalKeys;
|
||||
private final boolean isFilteredRegistry;
|
||||
|
||||
protected RegistryGenerator(final String className, final Class<A> apiType, final String pkg, final RegistryKey<A> apiRegistryKey, final boolean isInterface) {
|
||||
protected RegistryGenerator(final String className, final String pkg, final ResourceKey<? extends Registry<T>> registryKey, final RegistryKey<A> apiRegistryKey, final boolean isInterface) {
|
||||
super(className, pkg);
|
||||
this.apiType = apiType;
|
||||
this.registry = Suppliers.memoize(this::getRegistry);
|
||||
this.apiType = ClassName.get(pkg, className);
|
||||
this.registry = Main.REGISTRY_ACCESS.registryOrThrow(registryKey);
|
||||
this.apiRegistryKey = apiRegistryKey;
|
||||
this.isInterface = isInterface;
|
||||
this.experimentalKeys = Suppliers.memoize(() -> RegistryUtils.collectExperimentalDataDrivenKeys(this.registry.get())); // need to cleanup a bit here
|
||||
this.experimentalKeys = Suppliers.memoize(() -> RegistryUtils.collectExperimentalDataDrivenKeys(this.registry));
|
||||
this.isFilteredRegistry = FeatureElement.FILTERED_REGISTRIES.contains(registryKey);
|
||||
}
|
||||
|
||||
private MethodSpec.@Nullable Builder fetchMethod(TypeName returnType) {
|
||||
|
@ -91,28 +93,25 @@ public abstract class RegistryGenerator<T, A> extends SimpleGenerator {
|
|||
protected TypeSpec getTypeSpec() {
|
||||
TypeSpec.Builder typeBuilder = this.valueHolderType();
|
||||
|
||||
MethodSpec.@Nullable Builder fetchMethod = this.fetchMethod(TypeName.get(this.apiType)); // todo check runtime order issue when the classes are removed with the key generator
|
||||
|
||||
List<Map.Entry<ResourceKey<T>, T>> paths = new ArrayList<>(this.registry.get().entrySet());
|
||||
paths.sort(Comparator.comparing(o -> o.getKey().location().getPath()));
|
||||
MethodSpec.@Nullable Builder fetchMethod = this.fetchMethod(this.apiType); // todo runtime order issue when the classes are removed with the key generator + paper-api can't compile without some api
|
||||
|
||||
String registryField = requireNonNull(RegistryUtils.REGISTRY_KEY_FIELD_NAMES.get(this.apiRegistryKey)); // those will use the new RegistryAccess that use the registry key
|
||||
|
||||
paths.forEach(entry -> {
|
||||
ResourceKey<T> resourceKey = entry.getKey();
|
||||
String pathKey = resourceKey.location().getPath();
|
||||
this.registry.holders().sorted(Formatting.alphabeticKeyOrder(reference -> reference.key().location().getPath())).forEach(reference -> {
|
||||
ResourceLocation key = reference.key().location();
|
||||
String pathKey = key.getPath();
|
||||
String fieldName = Formatting.formatKeyAsField(pathKey);
|
||||
boolean isExperimental = this.isExperimental(entry);
|
||||
|
||||
FieldSpec.Builder fieldBuilder = FieldSpec.builder(this.apiType, fieldName, PUBLIC, STATIC, FINAL)
|
||||
.addJavadoc(Javadocs.getVersionDependentField("{@code $L}"), resourceKey.location().toString());
|
||||
.addJavadoc(Javadocs.getVersionDependentField("{@code $L}"), key.toString());
|
||||
if (this.isInterface) {
|
||||
fieldBuilder.initializer("$T.$L.get($T.minecraft($S))", org.bukkit.Registry.class, registryField, NamespacedKey.class, pathKey);
|
||||
} else {
|
||||
fieldBuilder.initializer("$N($S)", fetchMethod.build(), pathKey);
|
||||
}
|
||||
if (isExperimental) {
|
||||
fieldBuilder.addAnnotations(Annotations.experimentalAnnotations(FeatureFlags.UPDATE_1_21));
|
||||
@Nullable String experimentalValue = this.getExperimentalValue(reference);
|
||||
if (experimentalValue != null) {
|
||||
fieldBuilder.addAnnotations(Annotations.experimentalAnnotations(experimentalValue));
|
||||
}
|
||||
|
||||
typeBuilder.addField(fieldBuilder.build());
|
||||
|
@ -129,15 +128,15 @@ public abstract class RegistryGenerator<T, A> extends SimpleGenerator {
|
|||
|
||||
public abstract void addExtras(TypeSpec.Builder builder);
|
||||
|
||||
@Override
|
||||
protected JavaFile.Builder file(JavaFile.Builder builder) {
|
||||
return builder.skipJavaLangImports(true);
|
||||
}
|
||||
|
||||
public abstract Registry<T> getRegistry();
|
||||
|
||||
public boolean isExperimental(Map.Entry<ResourceKey<T>, T> entry) {
|
||||
return this.experimentalKeys.get().contains(entry.getKey());
|
||||
@Nullable
|
||||
public String getExperimentalValue(Holder.Reference<T> reference) {
|
||||
if (this.isFilteredRegistry && reference.value() instanceof FeatureElement element && FeatureFlags.isExperimental(element.requiredFeatures())) {
|
||||
return Formatting.formatFeatureFlagSet(element.requiredFeatures());
|
||||
}
|
||||
if (this.experimentalKeys.get().contains(reference.key())) {
|
||||
return Formatting.formatFeatureFlag(FeatureFlags.UPDATE_1_21);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,9 +13,9 @@ import java.util.Set;
|
|||
import java.util.function.Supplier;
|
||||
import java.util.stream.Collectors;
|
||||
import net.kyori.adventure.sound.Sound;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.world.flag.FeatureElement;
|
||||
|
@ -48,18 +48,18 @@ public class SoundGenerator extends EnumRegistryGenerator<SoundEvent> {
|
|||
|
||||
@Override
|
||||
public void addExtras(final TypeSpec.Builder builder, final FieldSpec keyField) {
|
||||
builder.addSuperinterface(Sound.Type.class)
|
||||
.addJavadoc(CLASS_HEADER);
|
||||
builder.addSuperinterface(Sound.Type.class);
|
||||
builder.addJavadoc(CLASS_HEADER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable String getExperimentalValue(final Map.Entry<ResourceKey<SoundEvent>, SoundEvent> entry) {
|
||||
@Nullable String result = super.getExperimentalValue(entry);
|
||||
public @Nullable String getExperimentalValue(final Holder.Reference<SoundEvent> reference) {
|
||||
@Nullable String result = super.getExperimentalValue(reference);
|
||||
if (result != null) {
|
||||
return result;
|
||||
}
|
||||
|
||||
String path = entry.getKey().location().getPath();
|
||||
String path = reference.key().location().getPath();
|
||||
// the below way is not perfect, but it tries its best
|
||||
if (EXPERIMENTAL_EXCEPTIONS.contains(path)) {
|
||||
return Formatting.formatFeatureFlag(FeatureFlags.UPDATE_1_21);
|
||||
|
|
|
@ -2,7 +2,6 @@ package io.papermc.generator.types.registry;
|
|||
|
||||
import com.squareup.javapoet.MethodSpec;
|
||||
import com.squareup.javapoet.TypeSpec;
|
||||
import io.papermc.generator.Main;
|
||||
import io.papermc.generator.utils.Javadocs;
|
||||
import io.papermc.paper.registry.RegistryKey;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
|
@ -27,7 +26,7 @@ public class StructureGenerator extends RegistryGenerator<net.minecraft.world.le
|
|||
""";
|
||||
|
||||
public StructureGenerator(final String className, final String pkg) {
|
||||
super(className, Structure.class, pkg, RegistryKey.STRUCTURE, false);
|
||||
super(className, pkg, Registries.STRUCTURE, RegistryKey.STRUCTURE, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -41,9 +40,4 @@ public class StructureGenerator extends RegistryGenerator<net.minecraft.world.le
|
|||
.addAnnotation(NOT_NULL).build());
|
||||
}
|
||||
|
||||
@Override
|
||||
public net.minecraft.core.Registry<net.minecraft.world.level.levelgen.structure.Structure> getRegistry() {
|
||||
return Main.REGISTRY_ACCESS.registryOrThrow(Registries.STRUCTURE);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ package io.papermc.generator.types.registry;
|
|||
import com.squareup.javapoet.TypeSpec;
|
||||
import io.papermc.generator.utils.Javadocs;
|
||||
import io.papermc.paper.registry.RegistryKey;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import org.bukkit.generator.structure.StructureType;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.framework.qual.DefaultQualifier;
|
||||
|
@ -14,7 +14,7 @@ public class StructureTypeGenerator extends RegistryGenerator<net.minecraft.worl
|
|||
private static final String CLASS_HEADER = Javadocs.getVersionDependentClassHeader("StructureTypes");
|
||||
|
||||
public StructureTypeGenerator(final String className, final String pkg) {
|
||||
super(className, StructureType.class, pkg, RegistryKey.STRUCTURE_TYPE, false);
|
||||
super(className, pkg, Registries.STRUCTURE_TYPE, RegistryKey.STRUCTURE_TYPE, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -22,9 +22,4 @@ public class StructureTypeGenerator extends RegistryGenerator<net.minecraft.worl
|
|||
builder.addJavadoc(CLASS_HEADER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public net.minecraft.core.Registry<net.minecraft.world.level.levelgen.structure.StructureType<?>> getRegistry() {
|
||||
return BuiltInRegistries.STRUCTURE_TYPE;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@ package io.papermc.generator.types.registry;
|
|||
import com.destroystokyo.paper.MaterialTags;
|
||||
import com.squareup.javapoet.ClassName;
|
||||
import com.squareup.javapoet.FieldSpec;
|
||||
import com.squareup.javapoet.JavaFile;
|
||||
import com.squareup.javapoet.MethodSpec;
|
||||
import com.squareup.javapoet.ParameterSpec;
|
||||
import com.squareup.javapoet.ParameterizedTypeName;
|
||||
|
@ -24,7 +23,6 @@ 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.bukkit.Bukkit;
|
||||
import org.bukkit.Fluid;
|
||||
import org.bukkit.GameEvent;
|
||||
|
@ -38,6 +36,7 @@ import org.checkerframework.framework.qual.DefaultQualifier;
|
|||
|
||||
import static com.squareup.javapoet.TypeSpec.interfaceBuilder;
|
||||
import static io.papermc.generator.utils.Annotations.NOT_NULL;
|
||||
import static io.papermc.generator.utils.Annotations.NULLABLE;
|
||||
import static io.papermc.generator.utils.Annotations.experimentalAnnotations;
|
||||
import static javax.lang.model.element.Modifier.ABSTRACT;
|
||||
import static javax.lang.model.element.Modifier.FINAL;
|
||||
|
@ -74,7 +73,7 @@ public class TagGenerator extends SimpleGenerator {
|
|||
@return set of tagged items
|
||||
""";
|
||||
|
||||
private static final String REGISTRY_FIELD_JAVADOC = "Key for the built in $L registry.";
|
||||
private static final String REGISTRY_FIELD_JAVADOC = "Key for the built-in $L registry.";
|
||||
|
||||
public record TagRegistry(String name, Class<?> apiType, ResourceKey<? extends Registry<?>> registryKey) {}
|
||||
|
||||
|
@ -90,15 +89,12 @@ public class TagGenerator extends SimpleGenerator {
|
|||
registry("game_events", GameEvent.class, Registries.GAME_EVENT)
|
||||
);
|
||||
|
||||
private final TypeVariableName typeVariable = TypeVariableName.get("T", Keyed.class);
|
||||
|
||||
public TagGenerator(final String className, final String pkg) {
|
||||
super(className, pkg);
|
||||
}
|
||||
|
||||
private TypeSpec.Builder tagHolderType() {
|
||||
return interfaceBuilder(this.className)
|
||||
.addTypeVariable(this.typeVariable)
|
||||
.addModifiers(PUBLIC)
|
||||
.addSuperinterface(Keyed.class)
|
||||
.addJavadoc(CLASS_HEADER_JAVADOC, MaterialTags.class, EntityTags.class)
|
||||
|
@ -107,13 +103,17 @@ public class TagGenerator extends SimpleGenerator {
|
|||
|
||||
@Override
|
||||
protected TypeSpec getTypeSpec() {
|
||||
final TypeVariableName typeVariable = TypeVariableName.get("T", Keyed.class);
|
||||
final TypeSpec.Builder typeBuilder = this.tagHolderType();
|
||||
typeBuilder.addTypeVariable(typeVariable);
|
||||
|
||||
for (final TagRegistry tagRegistry : TAG_REGISTRIES) {
|
||||
final TypeName fieldType = ParameterizedTypeName.get(Tag.class, tagRegistry.apiType());
|
||||
|
||||
final ResourceKey<? extends Registry<?>> registryKey = tagRegistry.registryKey();
|
||||
final Registry<?> registry = Main.REGISTRY_ACCESS.registryOrThrow(registryKey);
|
||||
final Collection<String> experimentalTags = Main.EXPERIMENTAL_TAGS.perRegistry().get(registryKey);
|
||||
|
||||
final String registryFieldName = "REGISTRY_" + tagRegistry.name().toUpperCase(Locale.ENGLISH);
|
||||
final FieldSpec.Builder registryFieldBuilder = FieldSpec.builder(String.class, registryFieldName)
|
||||
.addModifiers(PUBLIC, STATIC, FINAL)
|
||||
|
@ -123,9 +123,8 @@ public class TagGenerator extends SimpleGenerator {
|
|||
typeBuilder.addField(registryFieldBuilder.build());
|
||||
|
||||
final String fieldPrefix = Formatting.formatTagFieldPrefix(tagRegistry.name(), registryKey);
|
||||
final Collection<String> experimentalTags = Main.EXPERIMENTAL_TAGS.perRegistry().get(tagRegistry.registryKey());
|
||||
|
||||
for (final TagKey<?> tagKey : registry.getTagNames().sorted(Comparator.comparing(tagKey -> tagKey.location().getPath())).toList()) {
|
||||
registry.getTagNames().sorted(Comparator.comparing(tagKey -> tagKey.location().getPath())).forEach(tagKey -> {
|
||||
final String keyPath = tagKey.location().getPath();
|
||||
|
||||
final String fieldName = fieldPrefix + Formatting.formatKeyAsField(keyPath);
|
||||
|
@ -134,10 +133,11 @@ public class TagGenerator extends SimpleGenerator {
|
|||
.initializer("$T.getTag($L, $T.minecraft($S), $T.class)", Bukkit.class, registryFieldName, NamespacedKey.class, keyPath, tagRegistry.apiType())
|
||||
.addJavadoc(Javadocs.getVersionDependentField("{@code $L}"), tagKey.location().toString());
|
||||
if (experimentalTags.contains(keyPath)) {
|
||||
fieldBuilder.addAnnotations(experimentalAnnotations(Formatting.formatFeatureFlagName(Main.EXPERIMENTAL_TAGS.perFeatureFlag().get(tagKey))));
|
||||
fieldBuilder.addAnnotations(experimentalAnnotations(Formatting.formatFeatureFlagName(Main.EXPERIMENTAL_TAGS.perFeatureFlag().get(tagKey))))
|
||||
.addAnnotation(NULLABLE);
|
||||
}
|
||||
typeBuilder.addField(fieldBuilder.build());
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
@ -153,24 +153,17 @@ public class TagGenerator extends SimpleGenerator {
|
|||
// methods
|
||||
typeBuilder.addMethod(MethodSpec.methodBuilder("isTagged")
|
||||
.addModifiers(PUBLIC, ABSTRACT)
|
||||
.returns(boolean.class).addParameter(ParameterSpec.builder(this.typeVariable, "item")
|
||||
.returns(boolean.class).addParameter(ParameterSpec.builder(typeVariable, "item")
|
||||
.addAnnotation(NOT_NULL).build())
|
||||
.addJavadoc(IS_TAGGED_JAVADOC)
|
||||
.build());
|
||||
|
||||
typeBuilder.addMethod(MethodSpec.methodBuilder("getValues")
|
||||
.addModifiers(PUBLIC, ABSTRACT)
|
||||
.returns(ParameterizedTypeName.get(ClassName.get(Set.class), this.typeVariable))
|
||||
.returns(ParameterizedTypeName.get(ClassName.get(Set.class), typeVariable))
|
||||
.addJavadoc(GET_VALUES_JAVADOC)
|
||||
.addAnnotation(NOT_NULL).build());
|
||||
|
||||
return typeBuilder.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JavaFile.Builder file(JavaFile.Builder builder) {
|
||||
return builder
|
||||
.skipJavaLangImports(true)
|
||||
.indent(" ");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,6 +49,7 @@ public final class Annotations {
|
|||
@ApiStatus.Experimental
|
||||
public static final AnnotationSpec EXPERIMENTAL_API_ANNOTATION = AnnotationSpec.builder(ApiStatus.Experimental.class).build();
|
||||
public static final AnnotationSpec NOT_NULL = AnnotationSpec.builder(NotNull.class).build();
|
||||
public static final AnnotationSpec NULLABLE = AnnotationSpec.builder(Nullable.class).build();
|
||||
public static final AnnotationSpec OVERRIDE = AnnotationSpec.builder(Override.class).build();
|
||||
private static final AnnotationSpec SUPPRESS_WARNINGS = AnnotationSpec.builder(SuppressWarnings.class)
|
||||
.addMember("value", "$S", "unused")
|
||||
|
|
Loading…
Reference in New Issue