mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-22 14:35:11 +01:00
add RegistryAccess for managing registries (#10154)
* add RegistryAccess for managing registries * add missing types to key data generator * fix some stuff * Add RegistryKeys for all other non-server-backed registries * fix tests * remove Experimental annotations
This commit is contained in:
parent
156675c773
commit
5632210f10
23 changed files with 2842 additions and 207 deletions
|
@ -0,0 +1,367 @@
|
||||||
|
package io.papermc.paper.registry.keys;
|
||||||
|
|
||||||
|
import static net.kyori.adventure.key.Key.key;
|
||||||
|
|
||||||
|
import io.papermc.paper.generated.GeneratedFrom;
|
||||||
|
import io.papermc.paper.registry.RegistryKey;
|
||||||
|
import io.papermc.paper.registry.TypedKey;
|
||||||
|
import net.kyori.adventure.key.Key;
|
||||||
|
import org.bukkit.MinecraftExperimental;
|
||||||
|
import org.bukkit.damage.DamageType;
|
||||||
|
import org.jetbrains.annotations.ApiStatus;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Vanilla keys for {@link RegistryKey#DAMAGE_TYPE}.
|
||||||
|
*
|
||||||
|
* @apiNote The fields provided here are a direct representation of
|
||||||
|
* what is available from the vanilla game source. They may be
|
||||||
|
* changed (including removals) on any Minecraft version
|
||||||
|
* bump, so cross-version compatibility is not provided on the
|
||||||
|
* same level as it is on most of the other API.
|
||||||
|
*/
|
||||||
|
@SuppressWarnings({
|
||||||
|
"unused",
|
||||||
|
"SpellCheckingInspection"
|
||||||
|
})
|
||||||
|
@GeneratedFrom("1.20.6")
|
||||||
|
@ApiStatus.Experimental
|
||||||
|
public final class DamageTypeKeys {
|
||||||
|
/**
|
||||||
|
* {@code minecraft:arrow}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<DamageType> ARROW = create(key("arrow"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:bad_respawn_point}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<DamageType> BAD_RESPAWN_POINT = create(key("bad_respawn_point"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:cactus}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<DamageType> CACTUS = create(key("cactus"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:cramming}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<DamageType> CRAMMING = create(key("cramming"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:dragon_breath}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<DamageType> DRAGON_BREATH = create(key("dragon_breath"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:drown}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<DamageType> DROWN = create(key("drown"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:dry_out}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<DamageType> DRY_OUT = create(key("dry_out"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:explosion}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<DamageType> EXPLOSION = create(key("explosion"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:fall}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<DamageType> FALL = create(key("fall"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:falling_anvil}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<DamageType> FALLING_ANVIL = create(key("falling_anvil"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:falling_block}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<DamageType> FALLING_BLOCK = create(key("falling_block"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:falling_stalactite}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<DamageType> FALLING_STALACTITE = create(key("falling_stalactite"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:fireball}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<DamageType> FIREBALL = create(key("fireball"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:fireworks}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<DamageType> FIREWORKS = create(key("fireworks"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:fly_into_wall}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<DamageType> FLY_INTO_WALL = create(key("fly_into_wall"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:freeze}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<DamageType> FREEZE = create(key("freeze"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:generic}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<DamageType> GENERIC = create(key("generic"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:generic_kill}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<DamageType> GENERIC_KILL = create(key("generic_kill"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:hot_floor}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<DamageType> HOT_FLOOR = create(key("hot_floor"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:in_fire}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<DamageType> IN_FIRE = create(key("in_fire"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:in_wall}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<DamageType> IN_WALL = create(key("in_wall"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:indirect_magic}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<DamageType> INDIRECT_MAGIC = create(key("indirect_magic"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:lava}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<DamageType> LAVA = create(key("lava"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:lightning_bolt}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<DamageType> LIGHTNING_BOLT = create(key("lightning_bolt"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:magic}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<DamageType> MAGIC = create(key("magic"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:mob_attack}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<DamageType> MOB_ATTACK = create(key("mob_attack"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:mob_attack_no_aggro}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<DamageType> MOB_ATTACK_NO_AGGRO = create(key("mob_attack_no_aggro"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:mob_projectile}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<DamageType> MOB_PROJECTILE = create(key("mob_projectile"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:on_fire}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<DamageType> ON_FIRE = create(key("on_fire"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:out_of_world}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<DamageType> OUT_OF_WORLD = create(key("out_of_world"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:outside_border}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<DamageType> OUTSIDE_BORDER = create(key("outside_border"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:player_attack}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<DamageType> PLAYER_ATTACK = create(key("player_attack"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:player_explosion}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<DamageType> PLAYER_EXPLOSION = create(key("player_explosion"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:sonic_boom}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<DamageType> SONIC_BOOM = create(key("sonic_boom"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:spit}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<DamageType> SPIT = create(key("spit"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:stalagmite}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<DamageType> STALAGMITE = create(key("stalagmite"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:starve}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<DamageType> STARVE = create(key("starve"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:sting}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<DamageType> STING = create(key("sting"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:sweet_berry_bush}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<DamageType> SWEET_BERRY_BUSH = create(key("sweet_berry_bush"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:thorns}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<DamageType> THORNS = create(key("thorns"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:thrown}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<DamageType> THROWN = create(key("thrown"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:trident}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<DamageType> TRIDENT = create(key("trident"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:unattributed_fireball}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<DamageType> UNATTRIBUTED_FIREBALL = create(key("unattributed_fireball"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:wind_charge}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
@ApiStatus.Experimental
|
||||||
|
@MinecraftExperimental(MinecraftExperimental.Requires.UPDATE_1_21)
|
||||||
|
public static final TypedKey<DamageType> WIND_CHARGE = create(key("wind_charge"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:wither}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<DamageType> WITHER = create(key("wither"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:wither_skull}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<DamageType> WITHER_SKULL = create(key("wither_skull"));
|
||||||
|
|
||||||
|
private DamageTypeKeys() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a key for {@link DamageType} in a registry.
|
||||||
|
*
|
||||||
|
* @param key the value's key in the registry
|
||||||
|
* @return a new typed key
|
||||||
|
*/
|
||||||
|
@ApiStatus.Experimental
|
||||||
|
public static @NotNull TypedKey<DamageType> create(final @NotNull Key key) {
|
||||||
|
return TypedKey.create(RegistryKey.DAMAGE_TYPE, key);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,336 @@
|
||||||
|
package io.papermc.paper.registry.keys;
|
||||||
|
|
||||||
|
import static net.kyori.adventure.key.Key.key;
|
||||||
|
|
||||||
|
import io.papermc.paper.generated.GeneratedFrom;
|
||||||
|
import io.papermc.paper.registry.RegistryKey;
|
||||||
|
import io.papermc.paper.registry.TypedKey;
|
||||||
|
import net.kyori.adventure.key.Key;
|
||||||
|
import org.bukkit.MinecraftExperimental;
|
||||||
|
import org.bukkit.enchantments.Enchantment;
|
||||||
|
import org.jetbrains.annotations.ApiStatus;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Vanilla keys for {@link RegistryKey#ENCHANTMENT}.
|
||||||
|
*
|
||||||
|
* @apiNote The fields provided here are a direct representation of
|
||||||
|
* what is available from the vanilla game source. They may be
|
||||||
|
* changed (including removals) on any Minecraft version
|
||||||
|
* bump, so cross-version compatibility is not provided on the
|
||||||
|
* same level as it is on most of the other API.
|
||||||
|
*/
|
||||||
|
@SuppressWarnings({
|
||||||
|
"unused",
|
||||||
|
"SpellCheckingInspection"
|
||||||
|
})
|
||||||
|
@GeneratedFrom("1.20.6")
|
||||||
|
@ApiStatus.Experimental
|
||||||
|
public final class EnchantmentKeys {
|
||||||
|
/**
|
||||||
|
* {@code minecraft:aqua_affinity}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Enchantment> AQUA_AFFINITY = create(key("aqua_affinity"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:bane_of_arthropods}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Enchantment> BANE_OF_ARTHROPODS = create(key("bane_of_arthropods"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:binding_curse}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Enchantment> BINDING_CURSE = create(key("binding_curse"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:blast_protection}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Enchantment> BLAST_PROTECTION = create(key("blast_protection"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:breach}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
@ApiStatus.Experimental
|
||||||
|
@MinecraftExperimental(MinecraftExperimental.Requires.UPDATE_1_21)
|
||||||
|
public static final TypedKey<Enchantment> BREACH = create(key("breach"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:channeling}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Enchantment> CHANNELING = create(key("channeling"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:density}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
@ApiStatus.Experimental
|
||||||
|
@MinecraftExperimental(MinecraftExperimental.Requires.UPDATE_1_21)
|
||||||
|
public static final TypedKey<Enchantment> DENSITY = create(key("density"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:depth_strider}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Enchantment> DEPTH_STRIDER = create(key("depth_strider"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:efficiency}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Enchantment> EFFICIENCY = create(key("efficiency"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:feather_falling}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Enchantment> FEATHER_FALLING = create(key("feather_falling"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:fire_aspect}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Enchantment> FIRE_ASPECT = create(key("fire_aspect"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:fire_protection}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Enchantment> FIRE_PROTECTION = create(key("fire_protection"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:flame}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Enchantment> FLAME = create(key("flame"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:fortune}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Enchantment> FORTUNE = create(key("fortune"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:frost_walker}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Enchantment> FROST_WALKER = create(key("frost_walker"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:impaling}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Enchantment> IMPALING = create(key("impaling"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:infinity}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Enchantment> INFINITY = create(key("infinity"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:knockback}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Enchantment> KNOCKBACK = create(key("knockback"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:looting}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Enchantment> LOOTING = create(key("looting"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:loyalty}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Enchantment> LOYALTY = create(key("loyalty"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:luck_of_the_sea}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Enchantment> LUCK_OF_THE_SEA = create(key("luck_of_the_sea"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:lure}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Enchantment> LURE = create(key("lure"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:mending}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Enchantment> MENDING = create(key("mending"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:multishot}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Enchantment> MULTISHOT = create(key("multishot"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:piercing}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Enchantment> PIERCING = create(key("piercing"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:power}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Enchantment> POWER = create(key("power"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:projectile_protection}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Enchantment> PROJECTILE_PROTECTION = create(key("projectile_protection"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:protection}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Enchantment> PROTECTION = create(key("protection"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:punch}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Enchantment> PUNCH = create(key("punch"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:quick_charge}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Enchantment> QUICK_CHARGE = create(key("quick_charge"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:respiration}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Enchantment> RESPIRATION = create(key("respiration"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:riptide}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Enchantment> RIPTIDE = create(key("riptide"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:sharpness}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Enchantment> SHARPNESS = create(key("sharpness"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:silk_touch}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Enchantment> SILK_TOUCH = create(key("silk_touch"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:smite}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Enchantment> SMITE = create(key("smite"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:soul_speed}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Enchantment> SOUL_SPEED = create(key("soul_speed"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:sweeping_edge}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Enchantment> SWEEPING_EDGE = create(key("sweeping_edge"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:swift_sneak}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Enchantment> SWIFT_SNEAK = create(key("swift_sneak"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:thorns}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Enchantment> THORNS = create(key("thorns"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:unbreaking}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Enchantment> UNBREAKING = create(key("unbreaking"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:vanishing_curse}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Enchantment> VANISHING_CURSE = create(key("vanishing_curse"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:wind_burst}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
@ApiStatus.Experimental
|
||||||
|
@MinecraftExperimental(MinecraftExperimental.Requires.UPDATE_1_21)
|
||||||
|
public static final TypedKey<Enchantment> WIND_BURST = create(key("wind_burst"));
|
||||||
|
|
||||||
|
private EnchantmentKeys() {
|
||||||
|
}
|
||||||
|
|
||||||
|
private static @NotNull TypedKey<Enchantment> create(final @NotNull Key key) {
|
||||||
|
return TypedKey.create(RegistryKey.ENCHANTMENT, key);
|
||||||
|
}
|
||||||
|
}
|
|
@ -449,14 +449,7 @@ public final class GameEventKeys {
|
||||||
private GameEventKeys() {
|
private GameEventKeys() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private static @NotNull TypedKey<GameEvent> create(final @NotNull Key key) {
|
||||||
* Creates a key for {@link GameEvent} in a registry.
|
|
||||||
*
|
|
||||||
* @param key the value's key in the registry
|
|
||||||
* @return a new typed key
|
|
||||||
*/
|
|
||||||
@ApiStatus.Experimental
|
|
||||||
public static @NotNull TypedKey<GameEvent> create(final @NotNull Key key) {
|
|
||||||
return TypedKey.create(RegistryKey.GAME_EVENT, key);
|
return TypedKey.create(RegistryKey.GAME_EVENT, key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,91 @@
|
||||||
|
package io.papermc.paper.registry.keys;
|
||||||
|
|
||||||
|
import static net.kyori.adventure.key.Key.key;
|
||||||
|
|
||||||
|
import io.papermc.paper.generated.GeneratedFrom;
|
||||||
|
import io.papermc.paper.registry.RegistryKey;
|
||||||
|
import io.papermc.paper.registry.TypedKey;
|
||||||
|
import net.kyori.adventure.key.Key;
|
||||||
|
import org.bukkit.MusicInstrument;
|
||||||
|
import org.jetbrains.annotations.ApiStatus;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Vanilla keys for {@link RegistryKey#INSTRUMENT}.
|
||||||
|
*
|
||||||
|
* @apiNote The fields provided here are a direct representation of
|
||||||
|
* what is available from the vanilla game source. They may be
|
||||||
|
* changed (including removals) on any Minecraft version
|
||||||
|
* bump, so cross-version compatibility is not provided on the
|
||||||
|
* same level as it is on most of the other API.
|
||||||
|
*/
|
||||||
|
@SuppressWarnings({
|
||||||
|
"unused",
|
||||||
|
"SpellCheckingInspection"
|
||||||
|
})
|
||||||
|
@GeneratedFrom("1.20.6")
|
||||||
|
@ApiStatus.Experimental
|
||||||
|
public final class InstrumentKeys {
|
||||||
|
/**
|
||||||
|
* {@code minecraft:admire_goat_horn}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<MusicInstrument> ADMIRE_GOAT_HORN = create(key("admire_goat_horn"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:call_goat_horn}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<MusicInstrument> CALL_GOAT_HORN = create(key("call_goat_horn"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:dream_goat_horn}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<MusicInstrument> DREAM_GOAT_HORN = create(key("dream_goat_horn"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:feel_goat_horn}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<MusicInstrument> FEEL_GOAT_HORN = create(key("feel_goat_horn"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:ponder_goat_horn}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<MusicInstrument> PONDER_GOAT_HORN = create(key("ponder_goat_horn"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:seek_goat_horn}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<MusicInstrument> SEEK_GOAT_HORN = create(key("seek_goat_horn"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:sing_goat_horn}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<MusicInstrument> SING_GOAT_HORN = create(key("sing_goat_horn"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:yearn_goat_horn}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<MusicInstrument> YEARN_GOAT_HORN = create(key("yearn_goat_horn"));
|
||||||
|
|
||||||
|
private InstrumentKeys() {
|
||||||
|
}
|
||||||
|
|
||||||
|
private static @NotNull TypedKey<MusicInstrument> create(final @NotNull Key key) {
|
||||||
|
return TypedKey.create(RegistryKey.INSTRUMENT, key);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,321 @@
|
||||||
|
package io.papermc.paper.registry.keys;
|
||||||
|
|
||||||
|
import static net.kyori.adventure.key.Key.key;
|
||||||
|
|
||||||
|
import io.papermc.paper.generated.GeneratedFrom;
|
||||||
|
import io.papermc.paper.registry.RegistryKey;
|
||||||
|
import io.papermc.paper.registry.TypedKey;
|
||||||
|
import net.kyori.adventure.key.Key;
|
||||||
|
import org.bukkit.MinecraftExperimental;
|
||||||
|
import org.bukkit.potion.PotionEffectType;
|
||||||
|
import org.jetbrains.annotations.ApiStatus;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Vanilla keys for {@link RegistryKey#MOB_EFFECT}.
|
||||||
|
*
|
||||||
|
* @apiNote The fields provided here are a direct representation of
|
||||||
|
* what is available from the vanilla game source. They may be
|
||||||
|
* changed (including removals) on any Minecraft version
|
||||||
|
* bump, so cross-version compatibility is not provided on the
|
||||||
|
* same level as it is on most of the other API.
|
||||||
|
*/
|
||||||
|
@SuppressWarnings({
|
||||||
|
"unused",
|
||||||
|
"SpellCheckingInspection"
|
||||||
|
})
|
||||||
|
@GeneratedFrom("1.20.6")
|
||||||
|
@ApiStatus.Experimental
|
||||||
|
public final class MobEffectKeys {
|
||||||
|
/**
|
||||||
|
* {@code minecraft:absorption}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<PotionEffectType> ABSORPTION = create(key("absorption"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:bad_omen}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<PotionEffectType> BAD_OMEN = create(key("bad_omen"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:blindness}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<PotionEffectType> BLINDNESS = create(key("blindness"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:conduit_power}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<PotionEffectType> CONDUIT_POWER = create(key("conduit_power"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:darkness}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<PotionEffectType> DARKNESS = create(key("darkness"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:dolphins_grace}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<PotionEffectType> DOLPHINS_GRACE = create(key("dolphins_grace"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:fire_resistance}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<PotionEffectType> FIRE_RESISTANCE = create(key("fire_resistance"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:glowing}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<PotionEffectType> GLOWING = create(key("glowing"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:haste}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<PotionEffectType> HASTE = create(key("haste"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:health_boost}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<PotionEffectType> HEALTH_BOOST = create(key("health_boost"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:hero_of_the_village}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<PotionEffectType> HERO_OF_THE_VILLAGE = create(key("hero_of_the_village"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:hunger}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<PotionEffectType> HUNGER = create(key("hunger"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:infested}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
@ApiStatus.Experimental
|
||||||
|
@MinecraftExperimental(MinecraftExperimental.Requires.UPDATE_1_21)
|
||||||
|
public static final TypedKey<PotionEffectType> INFESTED = create(key("infested"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:instant_damage}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<PotionEffectType> INSTANT_DAMAGE = create(key("instant_damage"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:instant_health}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<PotionEffectType> INSTANT_HEALTH = create(key("instant_health"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:invisibility}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<PotionEffectType> INVISIBILITY = create(key("invisibility"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:jump_boost}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<PotionEffectType> JUMP_BOOST = create(key("jump_boost"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:levitation}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<PotionEffectType> LEVITATION = create(key("levitation"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:luck}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<PotionEffectType> LUCK = create(key("luck"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:mining_fatigue}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<PotionEffectType> MINING_FATIGUE = create(key("mining_fatigue"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:nausea}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<PotionEffectType> NAUSEA = create(key("nausea"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:night_vision}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<PotionEffectType> NIGHT_VISION = create(key("night_vision"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:oozing}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
@ApiStatus.Experimental
|
||||||
|
@MinecraftExperimental(MinecraftExperimental.Requires.UPDATE_1_21)
|
||||||
|
public static final TypedKey<PotionEffectType> OOZING = create(key("oozing"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:poison}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<PotionEffectType> POISON = create(key("poison"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:raid_omen}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
@ApiStatus.Experimental
|
||||||
|
@MinecraftExperimental(MinecraftExperimental.Requires.UPDATE_1_21)
|
||||||
|
public static final TypedKey<PotionEffectType> RAID_OMEN = create(key("raid_omen"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:regeneration}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<PotionEffectType> REGENERATION = create(key("regeneration"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:resistance}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<PotionEffectType> RESISTANCE = create(key("resistance"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:saturation}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<PotionEffectType> SATURATION = create(key("saturation"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:slow_falling}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<PotionEffectType> SLOW_FALLING = create(key("slow_falling"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:slowness}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<PotionEffectType> SLOWNESS = create(key("slowness"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:speed}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<PotionEffectType> SPEED = create(key("speed"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:strength}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<PotionEffectType> STRENGTH = create(key("strength"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:trial_omen}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
@ApiStatus.Experimental
|
||||||
|
@MinecraftExperimental(MinecraftExperimental.Requires.UPDATE_1_21)
|
||||||
|
public static final TypedKey<PotionEffectType> TRIAL_OMEN = create(key("trial_omen"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:unluck}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<PotionEffectType> UNLUCK = create(key("unluck"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:water_breathing}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<PotionEffectType> WATER_BREATHING = create(key("water_breathing"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:weakness}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<PotionEffectType> WEAKNESS = create(key("weakness"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:weaving}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
@ApiStatus.Experimental
|
||||||
|
@MinecraftExperimental(MinecraftExperimental.Requires.UPDATE_1_21)
|
||||||
|
public static final TypedKey<PotionEffectType> WEAVING = create(key("weaving"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:wind_charged}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
@ApiStatus.Experimental
|
||||||
|
@MinecraftExperimental(MinecraftExperimental.Requires.UPDATE_1_21)
|
||||||
|
public static final TypedKey<PotionEffectType> WIND_CHARGED = create(key("wind_charged"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:wither}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<PotionEffectType> WITHER = create(key("wither"));
|
||||||
|
|
||||||
|
private MobEffectKeys() {
|
||||||
|
}
|
||||||
|
|
||||||
|
private static @NotNull TypedKey<PotionEffectType> create(final @NotNull Key key) {
|
||||||
|
return TypedKey.create(RegistryKey.MOB_EFFECT, key);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,105 @@
|
||||||
|
package io.papermc.paper.registry.keys;
|
||||||
|
|
||||||
|
import static net.kyori.adventure.key.Key.key;
|
||||||
|
|
||||||
|
import io.papermc.paper.generated.GeneratedFrom;
|
||||||
|
import io.papermc.paper.registry.RegistryKey;
|
||||||
|
import io.papermc.paper.registry.TypedKey;
|
||||||
|
import net.kyori.adventure.key.Key;
|
||||||
|
import org.bukkit.entity.Wolf;
|
||||||
|
import org.jetbrains.annotations.ApiStatus;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Vanilla keys for {@link RegistryKey#WOLF_VARIANT}.
|
||||||
|
*
|
||||||
|
* @apiNote The fields provided here are a direct representation of
|
||||||
|
* what is available from the vanilla game source. They may be
|
||||||
|
* changed (including removals) on any Minecraft version
|
||||||
|
* bump, so cross-version compatibility is not provided on the
|
||||||
|
* same level as it is on most of the other API.
|
||||||
|
*/
|
||||||
|
@SuppressWarnings({
|
||||||
|
"unused",
|
||||||
|
"SpellCheckingInspection"
|
||||||
|
})
|
||||||
|
@GeneratedFrom("1.20.6")
|
||||||
|
@ApiStatus.Experimental
|
||||||
|
public final class WolfVariantKeys {
|
||||||
|
/**
|
||||||
|
* {@code minecraft:ashen}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Wolf.Variant> ASHEN = create(key("ashen"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:black}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Wolf.Variant> BLACK = create(key("black"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:chestnut}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Wolf.Variant> CHESTNUT = create(key("chestnut"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:pale}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Wolf.Variant> PALE = create(key("pale"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:rusty}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Wolf.Variant> RUSTY = create(key("rusty"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:snowy}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Wolf.Variant> SNOWY = create(key("snowy"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:spotted}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Wolf.Variant> SPOTTED = create(key("spotted"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:striped}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Wolf.Variant> STRIPED = create(key("striped"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:woods}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Wolf.Variant> WOODS = create(key("woods"));
|
||||||
|
|
||||||
|
private WolfVariantKeys() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a key for {@link Wolf.Variant} in a registry.
|
||||||
|
*
|
||||||
|
* @param key the value's key in the registry
|
||||||
|
* @return a new typed key
|
||||||
|
*/
|
||||||
|
@ApiStatus.Experimental
|
||||||
|
public static @NotNull TypedKey<Wolf.Variant> create(final @NotNull Key key) {
|
||||||
|
return TypedKey.create(RegistryKey.WOLF_VARIANT, key);
|
||||||
|
}
|
||||||
|
}
|
|
@ -8,21 +8,31 @@ import net.minecraft.core.Registry;
|
||||||
import net.minecraft.core.registries.Registries;
|
import net.minecraft.core.registries.Registries;
|
||||||
import net.minecraft.resources.ResourceKey;
|
import net.minecraft.resources.ResourceKey;
|
||||||
import org.bukkit.GameEvent;
|
import org.bukkit.GameEvent;
|
||||||
|
import org.bukkit.MusicInstrument;
|
||||||
import org.bukkit.block.Biome;
|
import org.bukkit.block.Biome;
|
||||||
|
import org.bukkit.damage.DamageType;
|
||||||
|
import org.bukkit.enchantments.Enchantment;
|
||||||
|
import org.bukkit.entity.Wolf;
|
||||||
import org.bukkit.generator.structure.Structure;
|
import org.bukkit.generator.structure.Structure;
|
||||||
import org.bukkit.generator.structure.StructureType;
|
import org.bukkit.generator.structure.StructureType;
|
||||||
import org.bukkit.inventory.meta.trim.TrimMaterial;
|
import org.bukkit.inventory.meta.trim.TrimMaterial;
|
||||||
import org.bukkit.inventory.meta.trim.TrimPattern;
|
import org.bukkit.inventory.meta.trim.TrimPattern;
|
||||||
|
import org.bukkit.potion.PotionEffectType;
|
||||||
|
|
||||||
public interface Generators {
|
public interface Generators {
|
||||||
|
|
||||||
SourceGenerator[] API = {
|
SourceGenerator[] API = {
|
||||||
simpleKey("GameEventKeys", GameEvent.class, Registries.GAME_EVENT, RegistryKey.GAME_EVENT, true),
|
simpleKey("GameEventKeys", GameEvent.class, Registries.GAME_EVENT, RegistryKey.GAME_EVENT, false),
|
||||||
simpleKey("BiomeKeys", Biome.class, Registries.BIOME, RegistryKey.BIOME, true),
|
simpleKey("BiomeKeys", Biome.class, Registries.BIOME, RegistryKey.BIOME, true),
|
||||||
simpleKey("TrimMaterialKeys", TrimMaterial.class, Registries.TRIM_MATERIAL, RegistryKey.TRIM_MATERIAL, true),
|
simpleKey("TrimMaterialKeys", TrimMaterial.class, Registries.TRIM_MATERIAL, RegistryKey.TRIM_MATERIAL, true),
|
||||||
simpleKey("TrimPatternKeys", TrimPattern.class, Registries.TRIM_PATTERN, RegistryKey.TRIM_PATTERN, true),
|
simpleKey("TrimPatternKeys", TrimPattern.class, Registries.TRIM_PATTERN, RegistryKey.TRIM_PATTERN, true),
|
||||||
simpleKey("StructureKeys", Structure.class, Registries.STRUCTURE, RegistryKey.STRUCTURE, true),
|
simpleKey("StructureKeys", Structure.class, Registries.STRUCTURE, RegistryKey.STRUCTURE, true),
|
||||||
simpleKey("StructureTypeKeys", StructureType.class, Registries.STRUCTURE_TYPE, RegistryKey.STRUCTURE_TYPE, false),
|
simpleKey("StructureTypeKeys", StructureType.class, Registries.STRUCTURE_TYPE, RegistryKey.STRUCTURE_TYPE, false),
|
||||||
|
simpleKey("InstrumentKeys", MusicInstrument.class, Registries.INSTRUMENT, RegistryKey.INSTRUMENT, false),
|
||||||
|
simpleKey("EnchantmentKeys", Enchantment.class, Registries.ENCHANTMENT, RegistryKey.ENCHANTMENT, false),
|
||||||
|
simpleKey("MobEffectKeys", PotionEffectType.class, Registries.MOB_EFFECT, RegistryKey.MOB_EFFECT, false),
|
||||||
|
simpleKey("DamageTypeKeys", DamageType.class, Registries.DAMAGE_TYPE, RegistryKey.DAMAGE_TYPE, true),
|
||||||
|
simpleKey("WolfVariantKeys", Wolf.Variant.class, Registries.WOLF_VARIANT, RegistryKey.WOLF_VARIANT, true),
|
||||||
new MobGoalGenerator("VanillaGoal", "com.destroystokyo.paper.entity.ai")
|
new MobGoalGenerator("VanillaGoal", "com.destroystokyo.paper.entity.ai")
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -25,11 +25,14 @@ import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import net.kyori.adventure.key.Key;
|
import net.kyori.adventure.key.Key;
|
||||||
import net.minecraft.core.Holder;
|
import net.minecraft.core.Holder;
|
||||||
|
import net.minecraft.core.HolderLookup;
|
||||||
import net.minecraft.core.Registry;
|
import net.minecraft.core.Registry;
|
||||||
import net.minecraft.core.RegistrySetBuilder;
|
import net.minecraft.core.RegistrySetBuilder;
|
||||||
import net.minecraft.data.registries.UpdateOneTwentyOneRegistries;
|
import net.minecraft.data.registries.UpdateOneTwentyOneRegistries;
|
||||||
import net.minecraft.data.registries.VanillaRegistries;
|
import net.minecraft.data.registries.VanillaRegistries;
|
||||||
import net.minecraft.resources.ResourceKey;
|
import net.minecraft.resources.ResourceKey;
|
||||||
|
import net.minecraft.world.flag.FeatureElement;
|
||||||
|
import net.minecraft.world.flag.FeatureFlags;
|
||||||
import org.bukkit.MinecraftExperimental;
|
import org.bukkit.MinecraftExperimental;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
@ -151,8 +154,23 @@ public class GeneratedKeyType<T, A> extends SimpleGenerator {
|
||||||
return typeBuilder.addMethod(createMethod.build()).build();
|
return typeBuilder.addMethod(createMethod.build()).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
private Set<ResourceKey<T>> collectExperimentalKeys(final Registry<T> registry) {
|
private Set<ResourceKey<T>> collectExperimentalKeys(final Registry<T> registry) {
|
||||||
|
if (FeatureElement.FILTERED_REGISTRIES.contains(registry.key())) {
|
||||||
|
return this.collectExperimentalKeysBuiltIn(registry);
|
||||||
|
} else {
|
||||||
|
return this.collectExperimentalKeysDataDriven(registry);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Set<ResourceKey<T>> collectExperimentalKeysBuiltIn(final Registry<T> registry) {
|
||||||
|
final HolderLookup.RegistryLookup<T> filteredLookup = registry.asLookup().filterElements(v -> {
|
||||||
|
return ((FeatureElement) v).requiredFeatures().contains(FeatureFlags.UPDATE_1_21);
|
||||||
|
});
|
||||||
|
return filteredLookup.listElementIds().collect(Collectors.toUnmodifiableSet());
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
private Set<ResourceKey<T>> collectExperimentalKeysDataDriven(final Registry<T> registry) {
|
||||||
final RegistrySetBuilder.@Nullable RegistryBootstrap<T> experimentalBootstrap = (RegistrySetBuilder.RegistryBootstrap<T>) EXPERIMENTAL_REGISTRY_ENTRIES.get(this.registryKey);
|
final RegistrySetBuilder.@Nullable RegistryBootstrap<T> experimentalBootstrap = (RegistrySetBuilder.RegistryBootstrap<T>) EXPERIMENTAL_REGISTRY_ENTRIES.get(this.registryKey);
|
||||||
if (experimentalBootstrap == null) {
|
if (experimentalBootstrap == null) {
|
||||||
return Collections.emptySet();
|
return Collections.emptySet();
|
||||||
|
|
|
@ -85,20 +85,37 @@ index 0000000000000000000000000000000000000000..2512dba27edfdccbc4430815b6cba048
|
||||||
+}
|
+}
|
||||||
diff --git a/src/main/java/io/papermc/paper/registry/RegistryKey.java b/src/main/java/io/papermc/paper/registry/RegistryKey.java
|
diff --git a/src/main/java/io/papermc/paper/registry/RegistryKey.java b/src/main/java/io/papermc/paper/registry/RegistryKey.java
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000000000000000000000000000000000000..c4b30b16ce4db754b958c493ad86d0863592c263
|
index 0000000000000000000000000000000000000000..a505064565f7f029be8727b1951d9ef67c3acf2c
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/src/main/java/io/papermc/paper/registry/RegistryKey.java
|
+++ b/src/main/java/io/papermc/paper/registry/RegistryKey.java
|
||||||
@@ -0,0 +1,67 @@
|
@@ -0,0 +1,128 @@
|
||||||
+package io.papermc.paper.registry;
|
+package io.papermc.paper.registry;
|
||||||
+
|
+
|
||||||
+import net.kyori.adventure.key.Keyed;
|
+import net.kyori.adventure.key.Keyed;
|
||||||
|
+import org.bukkit.Art;
|
||||||
|
+import org.bukkit.Fluid;
|
||||||
+import org.bukkit.GameEvent;
|
+import org.bukkit.GameEvent;
|
||||||
|
+import org.bukkit.MusicInstrument;
|
||||||
|
+import org.bukkit.Particle;
|
||||||
|
+import org.bukkit.Sound;
|
||||||
|
+import org.bukkit.attribute.Attribute;
|
||||||
+import org.bukkit.block.Biome;
|
+import org.bukkit.block.Biome;
|
||||||
|
+import org.bukkit.block.banner.PatternType;
|
||||||
|
+import org.bukkit.damage.DamageType;
|
||||||
|
+import org.bukkit.enchantments.Enchantment;
|
||||||
|
+import org.bukkit.entity.Cat;
|
||||||
|
+import org.bukkit.entity.EntityType;
|
||||||
|
+import org.bukkit.entity.Frog;
|
||||||
|
+import org.bukkit.entity.Villager;
|
||||||
|
+import org.bukkit.entity.Wolf;
|
||||||
|
+import org.bukkit.entity.memory.MemoryKey;
|
||||||
+import org.bukkit.generator.structure.Structure;
|
+import org.bukkit.generator.structure.Structure;
|
||||||
+import org.bukkit.generator.structure.StructureType;
|
+import org.bukkit.generator.structure.StructureType;
|
||||||
+import org.bukkit.inventory.meta.trim.TrimMaterial;
|
+import org.bukkit.inventory.meta.trim.TrimMaterial;
|
||||||
+import org.bukkit.inventory.meta.trim.TrimPattern;
|
+import org.bukkit.inventory.meta.trim.TrimPattern;
|
||||||
+import org.jetbrains.annotations.ApiStatus;
|
+import org.bukkit.map.MapCursor;
|
||||||
|
+import org.bukkit.potion.PotionEffectType;
|
||||||
|
+import org.bukkit.potion.PotionType;
|
||||||
+
|
+
|
||||||
+import static io.papermc.paper.registry.RegistryKeyImpl.create;
|
+import static io.papermc.paper.registry.RegistryKeyImpl.create;
|
||||||
+
|
+
|
||||||
|
@ -115,7 +132,6 @@ index 0000000000000000000000000000000000000000..c4b30b16ce4db754b958c493ad86d086
|
||||||
+ * @param <T> the value type
|
+ * @param <T> the value type
|
||||||
+ */
|
+ */
|
||||||
+@SuppressWarnings("unused")
|
+@SuppressWarnings("unused")
|
||||||
+@ApiStatus.Experimental
|
|
||||||
+public sealed interface RegistryKey<T> extends Keyed permits RegistryKeyImpl {
|
+public sealed interface RegistryKey<T> extends Keyed permits RegistryKeyImpl {
|
||||||
+
|
+
|
||||||
+ /* ******************* *
|
+ /* ******************* *
|
||||||
|
@ -131,6 +147,22 @@ index 0000000000000000000000000000000000000000..c4b30b16ce4db754b958c493ad86d086
|
||||||
+ * @see io.papermc.paper.registry.keys.StructureTypeKeys
|
+ * @see io.papermc.paper.registry.keys.StructureTypeKeys
|
||||||
+ */
|
+ */
|
||||||
+ RegistryKey<StructureType> STRUCTURE_TYPE = create("worldgen/structure_type");
|
+ RegistryKey<StructureType> STRUCTURE_TYPE = create("worldgen/structure_type");
|
||||||
|
+ /**
|
||||||
|
+ * Built-in registry for instruments.
|
||||||
|
+ * @see io.papermc.paper.registry.keys.InstrumentKeys
|
||||||
|
+ */
|
||||||
|
+ RegistryKey<MusicInstrument> INSTRUMENT = create("instrument");
|
||||||
|
+ /**
|
||||||
|
+ * Built-in registry for enchantments.
|
||||||
|
+ * @see io.papermc.paper.registry.keys.EnchantmentKeys
|
||||||
|
+ */
|
||||||
|
+ RegistryKey<Enchantment> ENCHANTMENT = create("enchantment");
|
||||||
|
+ /**
|
||||||
|
+ * Built-in registry for potion effect types (mob effects).
|
||||||
|
+ * @see io.papermc.paper.registry.keys.MobEffectKeys
|
||||||
|
+ */
|
||||||
|
+ RegistryKey<PotionEffectType> MOB_EFFECT = create("mob_effect");
|
||||||
|
+
|
||||||
+
|
+
|
||||||
+ /* ********************** *
|
+ /* ********************** *
|
||||||
+ * Data-driven Registries *
|
+ * Data-driven Registries *
|
||||||
|
@ -155,13 +187,42 @@ index 0000000000000000000000000000000000000000..c4b30b16ce4db754b958c493ad86d086
|
||||||
+ * @see io.papermc.paper.registry.keys.TrimPatternKeys
|
+ * @see io.papermc.paper.registry.keys.TrimPatternKeys
|
||||||
+ */
|
+ */
|
||||||
+ RegistryKey<TrimPattern> TRIM_PATTERN = create("trim_pattern");
|
+ RegistryKey<TrimPattern> TRIM_PATTERN = create("trim_pattern");
|
||||||
|
+ /**
|
||||||
|
+ * Data-driven registry for damage types.
|
||||||
|
+ * @see io.papermc.paper.registry.keys.DamageTypeKeys
|
||||||
|
+ */
|
||||||
|
+ RegistryKey<DamageType> DAMAGE_TYPE = create("damage_type");
|
||||||
|
+ /**
|
||||||
|
+ * Data-driven registry for wolf variants
|
||||||
|
+ * @see io.papermc.paper.registry.keys.WolfVariantKeys
|
||||||
|
+ */
|
||||||
|
+ RegistryKey<Wolf.Variant> WOLF_VARIANT = create("wolf_variant");
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+ /* ******************* *
|
||||||
|
+ * API-only Registries *
|
||||||
|
+ * ******************* */
|
||||||
|
+ RegistryKey<Art> PAINTING_VARIANT = create("painting_variant");
|
||||||
|
+ RegistryKey<Attribute> ATTRIBUTE = create("attribute");
|
||||||
|
+ RegistryKey<PatternType> BANNER_PATTERN = create("banner_pattern");
|
||||||
|
+ RegistryKey<Cat.Type> CAT_VARIANT = create("cat_variant");
|
||||||
|
+ RegistryKey<EntityType> ENTITY_TYPE = create("entity_type");
|
||||||
|
+ RegistryKey<Particle> PARTICLE_TYPE = create("particle_type");
|
||||||
|
+ RegistryKey<PotionType> POTION = create("potion");
|
||||||
|
+ RegistryKey<Sound> SOUND_EVENT = create("sound_event");
|
||||||
|
+ RegistryKey<Villager.Profession> VILLAGER_PROFESSION = create("villager_profession");
|
||||||
|
+ RegistryKey<Villager.Type> VILLAGER_TYPE = create("villager_type");
|
||||||
|
+ RegistryKey<MemoryKey<?>> MEMORY_MODULE_TYPE = create("memory_module_type");
|
||||||
|
+ RegistryKey<Fluid> FLUID = create("fluid");
|
||||||
|
+ RegistryKey<Frog.Variant> FROG_VARIANT = create("frog_variant");
|
||||||
|
+ RegistryKey<MapCursor.Type> MAP_DECORATION_TYPE = create("map_decoration_type");
|
||||||
+}
|
+}
|
||||||
diff --git a/src/main/java/io/papermc/paper/registry/RegistryKeyImpl.java b/src/main/java/io/papermc/paper/registry/RegistryKeyImpl.java
|
diff --git a/src/main/java/io/papermc/paper/registry/RegistryKeyImpl.java b/src/main/java/io/papermc/paper/registry/RegistryKeyImpl.java
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000000000000000000000000000000000000..9ad300fa1668cb59bbd85ff8091591db69b8c9dc
|
index 0000000000000000000000000000000000000000..791813220b2504214b1adecc69093cd600fb0f8c
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/src/main/java/io/papermc/paper/registry/RegistryKeyImpl.java
|
+++ b/src/main/java/io/papermc/paper/registry/RegistryKeyImpl.java
|
||||||
@@ -0,0 +1,19 @@
|
@@ -0,0 +1,24 @@
|
||||||
+package io.papermc.paper.registry;
|
+package io.papermc.paper.registry;
|
||||||
+
|
+
|
||||||
+import com.google.common.collect.Sets;
|
+import com.google.common.collect.Sets;
|
||||||
|
@ -175,15 +236,20 @@ index 0000000000000000000000000000000000000000..9ad300fa1668cb59bbd85ff8091591db
|
||||||
+ static final Set<RegistryKey<?>> REGISTRY_KEYS = Sets.newIdentityHashSet();
|
+ static final Set<RegistryKey<?>> REGISTRY_KEYS = Sets.newIdentityHashSet();
|
||||||
+
|
+
|
||||||
+ static <T> RegistryKey<T> create(@Subst("some_key") final String key) {
|
+ static <T> RegistryKey<T> create(@Subst("some_key") final String key) {
|
||||||
+ final RegistryKey<T> registryKey = new RegistryKeyImpl<>(Key.key(Key.MINECRAFT_NAMESPACE, key));
|
+ final RegistryKey<T> registryKey = createInternal(key);
|
||||||
+ REGISTRY_KEYS.add(registryKey);
|
+ REGISTRY_KEYS.add(registryKey);
|
||||||
+ return registryKey;
|
+ return registryKey;
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
|
+ // creates the key without adding to the internal set of keys
|
||||||
|
+ static <T> RegistryKey<T> createInternal(@Subst("some_key") final String key) {
|
||||||
|
+ return new RegistryKeyImpl<>(Key.key(Key.MINECRAFT_NAMESPACE, key));
|
||||||
|
+ }
|
||||||
|
+
|
||||||
+}
|
+}
|
||||||
diff --git a/src/main/java/io/papermc/paper/registry/TypedKey.java b/src/main/java/io/papermc/paper/registry/TypedKey.java
|
diff --git a/src/main/java/io/papermc/paper/registry/TypedKey.java b/src/main/java/io/papermc/paper/registry/TypedKey.java
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000000000000000000000000000000000000..271454cd1b92ada4301025b57348ea77da9116a1
|
index 0000000000000000000000000000000000000000..6f5a062ba7ee7173468ecea3c1855a233bf3855e
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/src/main/java/io/papermc/paper/registry/TypedKey.java
|
+++ b/src/main/java/io/papermc/paper/registry/TypedKey.java
|
||||||
@@ -0,0 +1,44 @@
|
@@ -0,0 +1,44 @@
|
||||||
|
@ -227,13 +293,13 @@ index 0000000000000000000000000000000000000000..271454cd1b92ada4301025b57348ea77
|
||||||
+ * @return a new key for the value key and registry key
|
+ * @return a new key for the value key and registry key
|
||||||
+ */
|
+ */
|
||||||
+ @ApiStatus.Experimental
|
+ @ApiStatus.Experimental
|
||||||
+ static <T extends Keyed> @NotNull TypedKey<T> create(final @NotNull RegistryKey<T> registryKey, final @NotNull Key key) {
|
+ static <T> @NotNull TypedKey<T> create(final @NotNull RegistryKey<T> registryKey, final @NotNull Key key) {
|
||||||
+ return new TypedKeyImpl<>(key, registryKey);
|
+ return new TypedKeyImpl<>(key, registryKey);
|
||||||
+ }
|
+ }
|
||||||
+}
|
+}
|
||||||
diff --git a/src/main/java/io/papermc/paper/registry/TypedKeyImpl.java b/src/main/java/io/papermc/paper/registry/TypedKeyImpl.java
|
diff --git a/src/main/java/io/papermc/paper/registry/TypedKeyImpl.java b/src/main/java/io/papermc/paper/registry/TypedKeyImpl.java
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000000000000000000000000000000000000..3c3fd73f7742bb8602e2f9164dd4c1208a412255
|
index 0000000000000000000000000000000000000000..1a97b3359c4ece5c29131da7c3f208aaa8fab66e
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/src/main/java/io/papermc/paper/registry/TypedKeyImpl.java
|
+++ b/src/main/java/io/papermc/paper/registry/TypedKeyImpl.java
|
||||||
@@ -0,0 +1,8 @@
|
@@ -0,0 +1,8 @@
|
||||||
|
@ -243,7 +309,7 @@ index 0000000000000000000000000000000000000000..3c3fd73f7742bb8602e2f9164dd4c120
|
||||||
+import net.kyori.adventure.key.Keyed;
|
+import net.kyori.adventure.key.Keyed;
|
||||||
+import org.jetbrains.annotations.NotNull;
|
+import org.jetbrains.annotations.NotNull;
|
||||||
+
|
+
|
||||||
+record TypedKeyImpl<T extends Keyed>(@NotNull Key key, @NotNull RegistryKey<T> registryKey) implements TypedKey<T> {
|
+record TypedKeyImpl<T>(@NotNull Key key, @NotNull RegistryKey<T> registryKey) implements TypedKey<T> {
|
||||||
+}
|
+}
|
||||||
diff --git a/src/main/java/org/bukkit/MinecraftExperimental.java b/src/main/java/org/bukkit/MinecraftExperimental.java
|
diff --git a/src/main/java/org/bukkit/MinecraftExperimental.java b/src/main/java/org/bukkit/MinecraftExperimental.java
|
||||||
index b6f4810e387c22c4a70609ea1d605130245689a5..03824ae54e1bdb8b14f79b3c5e0294ae725e43f8 100644
|
index b6f4810e387c22c4a70609ea1d605130245689a5..03824ae54e1bdb8b14f79b3c5e0294ae725e43f8 100644
|
||||||
|
|
|
@ -1,92 +0,0 @@
|
||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
|
||||||
Date: Wed, 2 Mar 2022 13:36:21 -0800
|
|
||||||
Subject: [PATCH] Add PaperRegistry
|
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/io/papermc/paper/registry/Reference.java b/src/main/java/io/papermc/paper/registry/Reference.java
|
|
||||||
new file mode 100644
|
|
||||||
index 0000000000000000000000000000000000000000..d880810cbf05bc45051fe29515054211572e33b4
|
|
||||||
--- /dev/null
|
|
||||||
+++ b/src/main/java/io/papermc/paper/registry/Reference.java
|
|
||||||
@@ -0,0 +1,43 @@
|
|
||||||
+package io.papermc.paper.registry;
|
|
||||||
+
|
|
||||||
+import org.bukkit.Keyed;
|
|
||||||
+import org.bukkit.NamespacedKey;
|
|
||||||
+import org.bukkit.Registry;
|
|
||||||
+import org.jetbrains.annotations.NotNull;
|
|
||||||
+import org.jetbrains.annotations.Nullable;
|
|
||||||
+
|
|
||||||
+/**
|
|
||||||
+ * Represents a reference to a server-backed registry value that may
|
|
||||||
+ * change.
|
|
||||||
+ *
|
|
||||||
+ * @param <T> type of the value
|
|
||||||
+ */
|
|
||||||
+public interface Reference<T extends Keyed> extends Keyed {
|
|
||||||
+
|
|
||||||
+ /**
|
|
||||||
+ * Gets the value from the registry with the key.
|
|
||||||
+ *
|
|
||||||
+ * @return the value
|
|
||||||
+ * @throws java.util.NoSuchElementException if there is no value with this key
|
|
||||||
+ */
|
|
||||||
+ @NotNull T value();
|
|
||||||
+
|
|
||||||
+ /**
|
|
||||||
+ * Gets the value from the registry with the key.
|
|
||||||
+ *
|
|
||||||
+ * @return the value or null if it doesn't exist
|
|
||||||
+ */
|
|
||||||
+ @Nullable T valueOrNull();
|
|
||||||
+
|
|
||||||
+ /**
|
|
||||||
+ * Creates a reference to a registered value.
|
|
||||||
+ *
|
|
||||||
+ * @param registry the registry the value is located in
|
|
||||||
+ * @param key the key to the value
|
|
||||||
+ * @param <T> the type of the value
|
|
||||||
+ * @return a reference
|
|
||||||
+ */
|
|
||||||
+ static <T extends Keyed> @NotNull Reference<T> create(@NotNull Registry<T> registry, @NotNull NamespacedKey key) {
|
|
||||||
+ return new ReferenceImpl<>(registry, key);
|
|
||||||
+ }
|
|
||||||
+}
|
|
||||||
diff --git a/src/main/java/io/papermc/paper/registry/ReferenceImpl.java b/src/main/java/io/papermc/paper/registry/ReferenceImpl.java
|
|
||||||
new file mode 100644
|
|
||||||
index 0000000000000000000000000000000000000000..f29e76a6b66ddfec12ddf8db6dcb2df6083b5982
|
|
||||||
--- /dev/null
|
|
||||||
+++ b/src/main/java/io/papermc/paper/registry/ReferenceImpl.java
|
|
||||||
@@ -0,0 +1,31 @@
|
|
||||||
+package io.papermc.paper.registry;
|
|
||||||
+
|
|
||||||
+import org.bukkit.Keyed;
|
|
||||||
+import org.bukkit.NamespacedKey;
|
|
||||||
+import org.bukkit.Registry;
|
|
||||||
+import org.jetbrains.annotations.NotNull;
|
|
||||||
+import org.jetbrains.annotations.Nullable;
|
|
||||||
+
|
|
||||||
+import java.util.NoSuchElementException;
|
|
||||||
+
|
|
||||||
+record ReferenceImpl<T extends Keyed>(@NotNull Registry<T> registry, @NotNull NamespacedKey key) implements Reference<T> {
|
|
||||||
+
|
|
||||||
+ @Override
|
|
||||||
+ public @NotNull T value() {
|
|
||||||
+ final T value = this.registry.get(this.key);
|
|
||||||
+ if (value == null) {
|
|
||||||
+ throw new NoSuchElementException("No such value with key " + this.key);
|
|
||||||
+ }
|
|
||||||
+ return value;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ @Override
|
|
||||||
+ public @Nullable T valueOrNull() {
|
|
||||||
+ return this.registry.get(this.key);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ @Override
|
|
||||||
+ public @NotNull NamespacedKey getKey() {
|
|
||||||
+ return this.key;
|
|
||||||
+ }
|
|
||||||
+}
|
|
|
@ -0,0 +1,394 @@
|
||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||||
|
Date: Wed, 2 Mar 2022 13:36:21 -0800
|
||||||
|
Subject: [PATCH] Add RegistryAccess for managing registries
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/io/papermc/paper/registry/Reference.java b/src/main/java/io/papermc/paper/registry/Reference.java
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000000000000000000000000000..d8656772e0c983df7c40ddc367a73ce473348339
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/main/java/io/papermc/paper/registry/Reference.java
|
||||||
|
@@ -0,0 +1,47 @@
|
||||||
|
+package io.papermc.paper.registry;
|
||||||
|
+
|
||||||
|
+import org.bukkit.Keyed;
|
||||||
|
+import org.bukkit.NamespacedKey;
|
||||||
|
+import org.bukkit.Registry;
|
||||||
|
+import org.jetbrains.annotations.NotNull;
|
||||||
|
+import org.jetbrains.annotations.Nullable;
|
||||||
|
+
|
||||||
|
+/**
|
||||||
|
+ * Represents a reference to a server-backed registry value that may
|
||||||
|
+ * change.
|
||||||
|
+ *
|
||||||
|
+ * @param <T> type of the value
|
||||||
|
+ */
|
||||||
|
+@Deprecated(forRemoval = true, since = "1.20.6")
|
||||||
|
+public interface Reference<T extends Keyed> extends Keyed {
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Gets the value from the registry with the key.
|
||||||
|
+ *
|
||||||
|
+ * @return the value
|
||||||
|
+ * @throws java.util.NoSuchElementException if there is no value with this key
|
||||||
|
+ */
|
||||||
|
+ @Deprecated(forRemoval = true, since = "1.20.6")
|
||||||
|
+ @NotNull T value();
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Gets the value from the registry with the key.
|
||||||
|
+ *
|
||||||
|
+ * @return the value or null if it doesn't exist
|
||||||
|
+ */
|
||||||
|
+ @Deprecated(forRemoval = true, since = "1.20.6")
|
||||||
|
+ @Nullable T valueOrNull();
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Creates a reference to a registered value.
|
||||||
|
+ *
|
||||||
|
+ * @param registry the registry the value is located in
|
||||||
|
+ * @param key the key to the value
|
||||||
|
+ * @param <T> the type of the value
|
||||||
|
+ * @return a reference
|
||||||
|
+ */
|
||||||
|
+ @Deprecated(forRemoval = true, since = "1.20.6")
|
||||||
|
+ static <T extends Keyed> @NotNull Reference<T> create(@NotNull Registry<T> registry, @NotNull NamespacedKey key) {
|
||||||
|
+ return new ReferenceImpl<>(registry, key);
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
diff --git a/src/main/java/io/papermc/paper/registry/ReferenceImpl.java b/src/main/java/io/papermc/paper/registry/ReferenceImpl.java
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000000000000000000000000000..f29e76a6b66ddfec12ddf8db6dcb2df6083b5982
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/main/java/io/papermc/paper/registry/ReferenceImpl.java
|
||||||
|
@@ -0,0 +1,31 @@
|
||||||
|
+package io.papermc.paper.registry;
|
||||||
|
+
|
||||||
|
+import org.bukkit.Keyed;
|
||||||
|
+import org.bukkit.NamespacedKey;
|
||||||
|
+import org.bukkit.Registry;
|
||||||
|
+import org.jetbrains.annotations.NotNull;
|
||||||
|
+import org.jetbrains.annotations.Nullable;
|
||||||
|
+
|
||||||
|
+import java.util.NoSuchElementException;
|
||||||
|
+
|
||||||
|
+record ReferenceImpl<T extends Keyed>(@NotNull Registry<T> registry, @NotNull NamespacedKey key) implements Reference<T> {
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public @NotNull T value() {
|
||||||
|
+ final T value = this.registry.get(this.key);
|
||||||
|
+ if (value == null) {
|
||||||
|
+ throw new NoSuchElementException("No such value with key " + this.key);
|
||||||
|
+ }
|
||||||
|
+ return value;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public @Nullable T valueOrNull() {
|
||||||
|
+ return this.registry.get(this.key);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public @NotNull NamespacedKey getKey() {
|
||||||
|
+ return this.key;
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
diff --git a/src/main/java/io/papermc/paper/registry/RegistryAccess.java b/src/main/java/io/papermc/paper/registry/RegistryAccess.java
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000000000000000000000000000..86ab67ff5023bf6adea80b02648b6f67476e30e5
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/main/java/io/papermc/paper/registry/RegistryAccess.java
|
||||||
|
@@ -0,0 +1,49 @@
|
||||||
|
+package io.papermc.paper.registry;
|
||||||
|
+
|
||||||
|
+import org.bukkit.Keyed;
|
||||||
|
+import org.bukkit.Registry;
|
||||||
|
+import org.jetbrains.annotations.ApiStatus;
|
||||||
|
+import org.jetbrains.annotations.NotNull;
|
||||||
|
+import org.jetbrains.annotations.Nullable;
|
||||||
|
+
|
||||||
|
+/**
|
||||||
|
+ * Used for accessing different {@link Registry} instances
|
||||||
|
+ * by a {@link RegistryKey}. Get the main instance of {@link RegistryAccess}
|
||||||
|
+ * with {@link RegistryAccess#registryAccess()}.
|
||||||
|
+ */
|
||||||
|
+@ApiStatus.NonExtendable
|
||||||
|
+public interface RegistryAccess {
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Get the {@link RegistryAccess} instance for the server.
|
||||||
|
+ *
|
||||||
|
+ * @return the RegistryAccess instance
|
||||||
|
+ */
|
||||||
|
+ static @NotNull RegistryAccess registryAccess() {
|
||||||
|
+ return RegistryAccessHolder.INSTANCE.orElseThrow(() -> new IllegalStateException("No RegistryAccess implementation found"));
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Gets the registry based on the type.
|
||||||
|
+ *
|
||||||
|
+ * @param type the type
|
||||||
|
+ * @return the registry or null if none found
|
||||||
|
+ * @param <T> the type
|
||||||
|
+ * @deprecated use {@link #getRegistry(RegistryKey)} with keys from {@link RegistryKey}
|
||||||
|
+ */
|
||||||
|
+ @Deprecated(since = "1.20.6", forRemoval = true)
|
||||||
|
+ <T extends Keyed> @Nullable Registry<T> getRegistry(@NotNull Class<T> type);
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Gets the registry with the specified key.
|
||||||
|
+ *
|
||||||
|
+ * @param registryKey the key
|
||||||
|
+ * @return the registry
|
||||||
|
+ * @param <T> the type
|
||||||
|
+ * @throws java.util.NoSuchElementException if no registry with the key is found
|
||||||
|
+ * @throws IllegalArgumentException if the registry is not available yet
|
||||||
|
+ */
|
||||||
|
+ // Future note: We should have no trouble removing this generic qualifier when
|
||||||
|
+ // registry types no longer have to be "keyed" as it shouldn't break ABI or API.
|
||||||
|
+ <T extends Keyed> @NotNull Registry<T> getRegistry(@NotNull RegistryKey<T> registryKey);
|
||||||
|
+}
|
||||||
|
diff --git a/src/main/java/io/papermc/paper/registry/RegistryAccessHolder.java b/src/main/java/io/papermc/paper/registry/RegistryAccessHolder.java
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000000000000000000000000000..b89e19c070f97c9662f1e16309446494b30aa7c9
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/main/java/io/papermc/paper/registry/RegistryAccessHolder.java
|
||||||
|
@@ -0,0 +1,12 @@
|
||||||
|
+package io.papermc.paper.registry;
|
||||||
|
+
|
||||||
|
+import java.util.Optional;
|
||||||
|
+import java.util.ServiceLoader;
|
||||||
|
+
|
||||||
|
+final class RegistryAccessHolder {
|
||||||
|
+
|
||||||
|
+ static final Optional<RegistryAccess> INSTANCE = ServiceLoader.load(RegistryAccess.class).findFirst();
|
||||||
|
+
|
||||||
|
+ private RegistryAccessHolder() {
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
diff --git a/src/main/java/io/papermc/paper/registry/RegistryKeyImpl.java b/src/main/java/io/papermc/paper/registry/RegistryKeyImpl.java
|
||||||
|
index 791813220b2504214b1adecc69093cd600fb0f8c..47fe5b0d5d031110c27210a0a256c260b35d9ba1 100644
|
||||||
|
--- a/src/main/java/io/papermc/paper/registry/RegistryKeyImpl.java
|
||||||
|
+++ b/src/main/java/io/papermc/paper/registry/RegistryKeyImpl.java
|
||||||
|
@@ -10,6 +10,17 @@ record RegistryKeyImpl<T>(@NotNull Key key) implements RegistryKey<T> {
|
||||||
|
|
||||||
|
static final Set<RegistryKey<?>> REGISTRY_KEYS = Sets.newIdentityHashSet();
|
||||||
|
|
||||||
|
+ // override equals and hashCode to this can be used to simulate an "identity" hashmap
|
||||||
|
+ @Override
|
||||||
|
+ public boolean equals(final Object obj) {
|
||||||
|
+ return obj == this;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public int hashCode() {
|
||||||
|
+ return System.identityHashCode(this);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
static <T> RegistryKey<T> create(@Subst("some_key") final String key) {
|
||||||
|
final RegistryKey<T> registryKey = createInternal(key);
|
||||||
|
REGISTRY_KEYS.add(registryKey);
|
||||||
|
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
|
||||||
|
index 732ed3724e784ad659cb4411dbd73b42a8330a2c..7be6710d28dea19bd0f9054c1c2e32dacd355c45 100644
|
||||||
|
--- a/src/main/java/org/bukkit/Bukkit.java
|
||||||
|
+++ b/src/main/java/org/bukkit/Bukkit.java
|
||||||
|
@@ -2398,8 +2398,11 @@ public final class Bukkit {
|
||||||
|
* @param tClass of the registry to get
|
||||||
|
* @param <T> type of the registry
|
||||||
|
* @return the corresponding registry or null if not present
|
||||||
|
+ * @deprecated use {@link io.papermc.paper.registry.RegistryAccess#getRegistry(io.papermc.paper.registry.RegistryKey)}
|
||||||
|
+ * with keys from {@link io.papermc.paper.registry.RegistryKey}
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
+ @Deprecated(since = "1.20.6")
|
||||||
|
public static <T extends Keyed> Registry<T> getRegistry(@NotNull Class<T> tClass) {
|
||||||
|
return server.getRegistry(tClass);
|
||||||
|
}
|
||||||
|
diff --git a/src/main/java/org/bukkit/Registry.java b/src/main/java/org/bukkit/Registry.java
|
||||||
|
index a04d279561676e825905f5512c399d14a3d8f828..91117cad12eee0bdaac8e0398a0f7f288ba27a40 100644
|
||||||
|
--- a/src/main/java/org/bukkit/Registry.java
|
||||||
|
+++ b/src/main/java/org/bukkit/Registry.java
|
||||||
|
@@ -129,7 +129,7 @@ public interface Registry<T extends Keyed> extends Iterable<T> {
|
||||||
|
*
|
||||||
|
* @see Enchantment
|
||||||
|
*/
|
||||||
|
- Registry<Enchantment> ENCHANTMENT = Objects.requireNonNull(Bukkit.getRegistry(Enchantment.class), "No registry present for Enchantment. This is a bug.");
|
||||||
|
+ Registry<Enchantment> ENCHANTMENT = io.papermc.paper.registry.RegistryAccess.registryAccess().getRegistry(io.papermc.paper.registry.RegistryKey.ENCHANTMENT); // Paper
|
||||||
|
/**
|
||||||
|
* Server entity types.
|
||||||
|
*
|
||||||
|
@@ -141,7 +141,7 @@ public interface Registry<T extends Keyed> extends Iterable<T> {
|
||||||
|
*
|
||||||
|
* @see MusicInstrument
|
||||||
|
*/
|
||||||
|
- Registry<MusicInstrument> INSTRUMENT = Objects.requireNonNull(Bukkit.getRegistry(MusicInstrument.class), "No registry present for MusicInstrument. This is a bug.");
|
||||||
|
+ Registry<MusicInstrument> INSTRUMENT = io.papermc.paper.registry.RegistryAccess.registryAccess().getRegistry(io.papermc.paper.registry.RegistryKey.INSTRUMENT); // Paper
|
||||||
|
/**
|
||||||
|
* Default server loot tables.
|
||||||
|
*
|
||||||
|
@@ -159,7 +159,7 @@ public interface Registry<T extends Keyed> extends Iterable<T> {
|
||||||
|
*
|
||||||
|
* @see PotionEffectType
|
||||||
|
*/
|
||||||
|
- Registry<PotionEffectType> EFFECT = Objects.requireNonNull(Bukkit.getRegistry(PotionEffectType.class), "No registry present for PotionEffectType. This is a bug.");
|
||||||
|
+ Registry<PotionEffectType> EFFECT = io.papermc.paper.registry.RegistryAccess.registryAccess().getRegistry(io.papermc.paper.registry.RegistryKey.MOB_EFFECT); // Paper
|
||||||
|
/**
|
||||||
|
* Server particles.
|
||||||
|
*
|
||||||
|
@@ -182,14 +182,16 @@ public interface Registry<T extends Keyed> extends Iterable<T> {
|
||||||
|
* Server structures.
|
||||||
|
*
|
||||||
|
* @see Structure
|
||||||
|
+ * @deprecated use {@link io.papermc.paper.registry.RegistryAccess#getRegistry(io.papermc.paper.registry.RegistryKey)} with {@link io.papermc.paper.registry.RegistryKey#STRUCTURE}
|
||||||
|
*/
|
||||||
|
- Registry<Structure> STRUCTURE = Bukkit.getRegistry(Structure.class);
|
||||||
|
+ @Deprecated(since = "1.20.6") // Paper
|
||||||
|
+ Registry<Structure> STRUCTURE = Objects.requireNonNull(io.papermc.paper.registry.RegistryAccess.registryAccess().getRegistry(Structure.class), "No registry present for Structure. This is a bug."); // Paper
|
||||||
|
/**
|
||||||
|
* Server structure types.
|
||||||
|
*
|
||||||
|
* @see StructureType
|
||||||
|
*/
|
||||||
|
- Registry<StructureType> STRUCTURE_TYPE = Bukkit.getRegistry(StructureType.class);
|
||||||
|
+ Registry<StructureType> STRUCTURE_TYPE = io.papermc.paper.registry.RegistryAccess.registryAccess().getRegistry(io.papermc.paper.registry.RegistryKey.STRUCTURE_TYPE); // Paper
|
||||||
|
/**
|
||||||
|
* Sound keys.
|
||||||
|
*
|
||||||
|
@@ -200,21 +202,26 @@ public interface Registry<T extends Keyed> extends Iterable<T> {
|
||||||
|
* Trim materials.
|
||||||
|
*
|
||||||
|
* @see TrimMaterial
|
||||||
|
+ * @deprecated use {@link io.papermc.paper.registry.RegistryAccess#getRegistry(io.papermc.paper.registry.RegistryKey)} with {@link io.papermc.paper.registry.RegistryKey#TRIM_MATERIAL}
|
||||||
|
*/
|
||||||
|
- Registry<TrimMaterial> TRIM_MATERIAL = Bukkit.getRegistry(TrimMaterial.class);
|
||||||
|
+ @Deprecated(since = "1.20.6") // Paper
|
||||||
|
+ Registry<TrimMaterial> TRIM_MATERIAL = Objects.requireNonNull(io.papermc.paper.registry.RegistryAccess.registryAccess().getRegistry(TrimMaterial.class), "No registry present for TrimMaterial. This is a bug."); // Paper
|
||||||
|
/**
|
||||||
|
* Trim patterns.
|
||||||
|
*
|
||||||
|
* @see TrimPattern
|
||||||
|
+ * @deprecated use {@link io.papermc.paper.registry.RegistryAccess#getRegistry(io.papermc.paper.registry.RegistryKey)} with {@link io.papermc.paper.registry.RegistryKey#TRIM_PATTERN}
|
||||||
|
*/
|
||||||
|
- Registry<TrimPattern> TRIM_PATTERN = Bukkit.getRegistry(TrimPattern.class);
|
||||||
|
+ @Deprecated(since = "1.20.6")
|
||||||
|
+ Registry<TrimPattern> TRIM_PATTERN = Objects.requireNonNull(io.papermc.paper.registry.RegistryAccess.registryAccess().getRegistry(TrimPattern.class), "No registry present for TrimPattern. This is a bug."); // Paper
|
||||||
|
/**
|
||||||
|
* Damage types.
|
||||||
|
*
|
||||||
|
* @see DamageType
|
||||||
|
+ * @deprecated use {@link io.papermc.paper.registry.RegistryAccess#getRegistry(io.papermc.paper.registry.RegistryKey)} with {@link io.papermc.paper.registry.RegistryKey#DAMAGE_TYPE}
|
||||||
|
*/
|
||||||
|
- @ApiStatus.Experimental
|
||||||
|
- Registry<DamageType> DAMAGE_TYPE = Objects.requireNonNull(Bukkit.getRegistry(DamageType.class), "No registry present for DamageType. This is a bug.");
|
||||||
|
+ @Deprecated(since = "1.20.6")
|
||||||
|
+ Registry<DamageType> DAMAGE_TYPE = Objects.requireNonNull(io.papermc.paper.registry.RegistryAccess.registryAccess().getRegistry(DamageType.class), "No registry present for DamageType. This is a bug."); // Paper
|
||||||
|
/**
|
||||||
|
* Villager profession.
|
||||||
|
*
|
||||||
|
@@ -268,8 +275,10 @@ public interface Registry<T extends Keyed> extends Iterable<T> {
|
||||||
|
* Wolf variants.
|
||||||
|
*
|
||||||
|
* @see Wolf.Variant
|
||||||
|
+ * @deprecated use {@link io.papermc.paper.registry.RegistryAccess#getRegistry(io.papermc.paper.registry.RegistryKey)} with {@link io.papermc.paper.registry.RegistryKey#WOLF_VARIANT}
|
||||||
|
*/
|
||||||
|
- Registry<Wolf.Variant> WOLF_VARIANT = Objects.requireNonNull(Bukkit.getRegistry(Wolf.Variant.class), "No registry present for Wolf Variant. This is a bug.");
|
||||||
|
+ @Deprecated(since = "1.20.6")
|
||||||
|
+ Registry<Wolf.Variant> WOLF_VARIANT = Objects.requireNonNull(io.papermc.paper.registry.RegistryAccess.registryAccess().getRegistry(Wolf.Variant.class), "No registry present for Wolf$Variant. This is a bug."); // Paper
|
||||||
|
/**
|
||||||
|
* Map cursor types.
|
||||||
|
*
|
||||||
|
@@ -282,7 +291,7 @@ public interface Registry<T extends Keyed> extends Iterable<T> {
|
||||||
|
*
|
||||||
|
* @see GameEvent
|
||||||
|
*/
|
||||||
|
- Registry<GameEvent> GAME_EVENT = Objects.requireNonNull(Bukkit.getRegistry(GameEvent.class), "No registry present for GameEvent. This is a bug.");
|
||||||
|
+ Registry<GameEvent> GAME_EVENT = io.papermc.paper.registry.RegistryAccess.registryAccess().getRegistry(io.papermc.paper.registry.RegistryKey.GAME_EVENT); // Paper
|
||||||
|
/**
|
||||||
|
* Get the object by its key.
|
||||||
|
*
|
||||||
|
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
|
||||||
|
index 395f7910f535bfd33a5676b011ab62a53e30e140..5644af8154373923791e3ed5f8b01c3f5d357b9c 100644
|
||||||
|
--- a/src/main/java/org/bukkit/Server.java
|
||||||
|
+++ b/src/main/java/org/bukkit/Server.java
|
||||||
|
@@ -2046,8 +2046,11 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
|
||||||
|
* @param tClass of the registry to get
|
||||||
|
* @param <T> type of the registry
|
||||||
|
* @return the corresponding registry or null if not present
|
||||||
|
+ * @deprecated use {@link io.papermc.paper.registry.RegistryAccess#getRegistry(io.papermc.paper.registry.RegistryKey)}
|
||||||
|
+ * with keys from {@link io.papermc.paper.registry.RegistryKey}
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
+ @Deprecated(since = "1.20.6") // Paper
|
||||||
|
<T extends Keyed> Registry<T> getRegistry(@NotNull Class<T> tClass);
|
||||||
|
|
||||||
|
/**
|
||||||
|
diff --git a/src/test/java/io/papermc/paper/registry/TestRegistryAccess.java b/src/test/java/io/papermc/paper/registry/TestRegistryAccess.java
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000000000000000000000000000..f5ece852f97017f71bc129e194cb212979b2537b
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/test/java/io/papermc/paper/registry/TestRegistryAccess.java
|
||||||
|
@@ -0,0 +1,20 @@
|
||||||
|
+package io.papermc.paper.registry;
|
||||||
|
+
|
||||||
|
+import org.bukkit.Keyed;
|
||||||
|
+import org.bukkit.Registry;
|
||||||
|
+import org.jetbrains.annotations.NotNull;
|
||||||
|
+import org.jetbrains.annotations.Nullable;
|
||||||
|
+
|
||||||
|
+public class TestRegistryAccess implements RegistryAccess {
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ @Deprecated(since = "1.20.6", forRemoval = true)
|
||||||
|
+ public @Nullable <T extends Keyed> Registry<T> getRegistry(final @NotNull Class<T> type) {
|
||||||
|
+ throw new UnsupportedOperationException("Not supported");
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public @NotNull <T extends Keyed> Registry<T> getRegistry(final @NotNull RegistryKey<T> registryKey) {
|
||||||
|
+ throw new UnsupportedOperationException("Not supported");
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
diff --git a/src/test/java/org/bukkit/support/TestServer.java b/src/test/java/org/bukkit/support/TestServer.java
|
||||||
|
index b208150297a23c0b4acb79135416809718f5650e..f11c639f1dc3c5034678d80bde3127a2e81a4a93 100644
|
||||||
|
--- a/src/test/java/org/bukkit/support/TestServer.java
|
||||||
|
+++ b/src/test/java/org/bukkit/support/TestServer.java
|
||||||
|
@@ -36,26 +36,11 @@ public final class TestServer {
|
||||||
|
|
||||||
|
when(instance.getBukkitVersion()).thenReturn("BukkitVersion_" + TestServer.class.getPackage().getImplementationVersion());
|
||||||
|
|
||||||
|
- Map<Class<? extends Keyed>, Registry<?>> registers = new HashMap<>();
|
||||||
|
- when(instance.getRegistry(any())).then(invocationOnMock -> registers.computeIfAbsent(invocationOnMock.getArgument(0), aClass -> new Registry<Keyed>() {
|
||||||
|
- private final Map<NamespacedKey, Keyed> cache = new HashMap<>();
|
||||||
|
-
|
||||||
|
- @Override
|
||||||
|
- public Keyed get(NamespacedKey key) {
|
||||||
|
- return cache.computeIfAbsent(key, key2 -> mock(aClass, withSettings().stubOnly()));
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- @NotNull
|
||||||
|
- @Override
|
||||||
|
- public Stream<Keyed> stream() {
|
||||||
|
- throw new UnsupportedOperationException("Not supported");
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- @Override
|
||||||
|
- public Iterator<Keyed> iterator() {
|
||||||
|
- throw new UnsupportedOperationException("Not supported");
|
||||||
|
- }
|
||||||
|
- }));
|
||||||
|
+ // Paper start - RegistryAccess
|
||||||
|
+ when(instance.getRegistry(any())).then(invocationOnMock -> {
|
||||||
|
+ return io.papermc.paper.registry.RegistryAccess.registryAccess().getRegistry(((Class<Keyed>)invocationOnMock.getArgument(0)));
|
||||||
|
+ });
|
||||||
|
+ // Paper end - RegistryAccess
|
||||||
|
|
||||||
|
UnsafeValues unsafeValues = mock(withSettings().stubOnly());
|
||||||
|
when(instance.getUnsafe()).thenReturn(unsafeValues);
|
||||||
|
diff --git a/src/test/resources/META-INF/services/io.papermc.paper.registry.RegistryAccess b/src/test/resources/META-INF/services/io.papermc.paper.registry.RegistryAccess
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000000000000000000000000000..f0a5e6d6b99aeef349fe465080ef2ff7b58617a6
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/test/resources/META-INF/services/io.papermc.paper.registry.RegistryAccess
|
||||||
|
@@ -0,0 +1 @@
|
||||||
|
+io.papermc.paper.registry.TestRegistryAccess
|
|
@ -513,24 +513,22 @@ index 0000000000000000000000000000000000000000..1e7b53f9bc13dcd5a0a4a40004591e4f
|
||||||
+ }
|
+ }
|
||||||
+}
|
+}
|
||||||
diff --git a/src/main/java/org/bukkit/Registry.java b/src/main/java/org/bukkit/Registry.java
|
diff --git a/src/main/java/org/bukkit/Registry.java b/src/main/java/org/bukkit/Registry.java
|
||||||
index a04d279561676e825905f5512c399d14a3d8f828..ac8fe849dfd407bb2beeca16aeda3ebbe5c7a874 100644
|
index 91117cad12eee0bdaac8e0398a0f7f288ba27a40..43f410326d6d68242113e2fefe31af256889ed9c 100644
|
||||||
--- a/src/main/java/org/bukkit/Registry.java
|
--- a/src/main/java/org/bukkit/Registry.java
|
||||||
+++ b/src/main/java/org/bukkit/Registry.java
|
+++ b/src/main/java/org/bukkit/Registry.java
|
||||||
@@ -283,6 +283,17 @@ public interface Registry<T extends Keyed> extends Iterable<T> {
|
@@ -292,6 +292,15 @@ public interface Registry<T extends Keyed> extends Iterable<T> {
|
||||||
* @see GameEvent
|
* @see GameEvent
|
||||||
*/
|
*/
|
||||||
Registry<GameEvent> GAME_EVENT = Objects.requireNonNull(Bukkit.getRegistry(GameEvent.class), "No registry present for GameEvent. This is a bug.");
|
Registry<GameEvent> GAME_EVENT = io.papermc.paper.registry.RegistryAccess.registryAccess().getRegistry(io.papermc.paper.registry.RegistryKey.GAME_EVENT); // Paper
|
||||||
+
|
|
||||||
+ // Paper start
|
+ // Paper start
|
||||||
+ /**
|
+ /**
|
||||||
+ * Configured structures.
|
+ * Configured structures.
|
||||||
+ * @see io.papermc.paper.world.structure.ConfiguredStructure
|
+ * @see io.papermc.paper.world.structure.ConfiguredStructure
|
||||||
+ * @deprecated use {@link #STRUCTURE}
|
+ * @deprecated use {@link io.papermc.paper.registry.RegistryAccess#getRegistry(io.papermc.paper.registry.RegistryKey)} with {@link io.papermc.paper.registry.RegistryKey#STRUCTURE}
|
||||||
+ */
|
+ */
|
||||||
+ @Deprecated(forRemoval = true)
|
+ @Deprecated(forRemoval = true)
|
||||||
+ Registry<io.papermc.paper.world.structure.ConfiguredStructure> CONFIGURED_STRUCTURE = Bukkit.getRegistry(io.papermc.paper.world.structure.ConfiguredStructure.class);
|
+ Registry<io.papermc.paper.world.structure.ConfiguredStructure> CONFIGURED_STRUCTURE = Objects.requireNonNull(io.papermc.paper.registry.RegistryAccess.registryAccess().getRegistry(io.papermc.paper.world.structure.ConfiguredStructure.class), "No registry present for ConfiguredStructure. This is a bug.");
|
||||||
+ // Paper end
|
+ // Paper end
|
||||||
+
|
|
||||||
/**
|
/**
|
||||||
* Get the object by its key.
|
* Get the object by its key.
|
||||||
*
|
*
|
||||||
|
|
|
@ -70,7 +70,7 @@ index 0000000000000000000000000000000000000000..58f78d5e91beacaf710f62461cf869f7
|
||||||
+
|
+
|
||||||
+}
|
+}
|
||||||
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
|
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
|
||||||
index d078ea797cf4c6ab291aec3ad7fbd4740017286c..c3d3c7d05a03658157d49c6ff1ea1d7d085a6fd4 100644
|
index 652932fa3ae5360802335803b4108b65019b6922..237bdd97203dbc80c010ae57735bc45e36c78fc5 100644
|
||||||
--- a/src/main/java/org/bukkit/Bukkit.java
|
--- a/src/main/java/org/bukkit/Bukkit.java
|
||||||
+++ b/src/main/java/org/bukkit/Bukkit.java
|
+++ b/src/main/java/org/bukkit/Bukkit.java
|
||||||
@@ -330,9 +330,11 @@ public final class Bukkit {
|
@@ -330,9 +330,11 @@ public final class Bukkit {
|
||||||
|
@ -85,7 +85,7 @@ index d078ea797cf4c6ab291aec3ad7fbd4740017286c..c3d3c7d05a03658157d49c6ff1ea1d7d
|
||||||
public static DataPackManager getDataPackManager() {
|
public static DataPackManager getDataPackManager() {
|
||||||
return server.getDataPackManager();
|
return server.getDataPackManager();
|
||||||
}
|
}
|
||||||
@@ -2585,6 +2587,14 @@ public final class Bukkit {
|
@@ -2588,6 +2590,14 @@ public final class Bukkit {
|
||||||
public static com.destroystokyo.paper.entity.ai.MobGoals getMobGoals() {
|
public static com.destroystokyo.paper.entity.ai.MobGoals getMobGoals() {
|
||||||
return server.getMobGoals();
|
return server.getMobGoals();
|
||||||
}
|
}
|
||||||
|
@ -101,7 +101,7 @@ index d078ea797cf4c6ab291aec3ad7fbd4740017286c..c3d3c7d05a03658157d49c6ff1ea1d7d
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
|
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
|
||||||
index e6598c36cfc98282f30a57105986a295f1c94676..61ee087ec4a75ee8b10e204b4cdd1bab5f066819 100644
|
index d28b3ad2e9979127051e8062122572bc3d2cb0b5..d3631288ec03c5ca04221c20ecee745f7e9fa71a 100644
|
||||||
--- a/src/main/java/org/bukkit/Server.java
|
--- a/src/main/java/org/bukkit/Server.java
|
||||||
+++ b/src/main/java/org/bukkit/Server.java
|
+++ b/src/main/java/org/bukkit/Server.java
|
||||||
@@ -266,9 +266,11 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
|
@@ -266,9 +266,11 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
|
||||||
|
@ -116,7 +116,7 @@ index e6598c36cfc98282f30a57105986a295f1c94676..61ee087ec4a75ee8b10e204b4cdd1bab
|
||||||
public DataPackManager getDataPackManager();
|
public DataPackManager getDataPackManager();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -2251,5 +2253,11 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
|
@@ -2254,5 +2256,11 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
|
||||||
*/
|
*/
|
||||||
@NotNull
|
@NotNull
|
||||||
com.destroystokyo.paper.entity.ai.MobGoals getMobGoals();
|
com.destroystokyo.paper.entity.ai.MobGoals getMobGoals();
|
||||||
|
|
|
@ -5,13 +5,13 @@ Subject: [PATCH] More PotionEffectType API
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/org/bukkit/Registry.java b/src/main/java/org/bukkit/Registry.java
|
diff --git a/src/main/java/org/bukkit/Registry.java b/src/main/java/org/bukkit/Registry.java
|
||||||
index ac8fe849dfd407bb2beeca16aeda3ebbe5c7a874..76b1d08d9ae2c2cf5c6d88934929695d438b3284 100644
|
index 43f410326d6d68242113e2fefe31af256889ed9c..90ab3bef4c5b6b6e215e9c759c886ed6d0f3302b 100644
|
||||||
--- a/src/main/java/org/bukkit/Registry.java
|
--- a/src/main/java/org/bukkit/Registry.java
|
||||||
+++ b/src/main/java/org/bukkit/Registry.java
|
+++ b/src/main/java/org/bukkit/Registry.java
|
||||||
@@ -292,6 +292,31 @@ public interface Registry<T extends Keyed> extends Iterable<T> {
|
@@ -300,6 +300,31 @@ public interface Registry<T extends Keyed> extends Iterable<T> {
|
||||||
*/
|
*/
|
||||||
@Deprecated(forRemoval = true)
|
@Deprecated(forRemoval = true)
|
||||||
Registry<io.papermc.paper.world.structure.ConfiguredStructure> CONFIGURED_STRUCTURE = Bukkit.getRegistry(io.papermc.paper.world.structure.ConfiguredStructure.class);
|
Registry<io.papermc.paper.world.structure.ConfiguredStructure> CONFIGURED_STRUCTURE = Objects.requireNonNull(io.papermc.paper.registry.RegistryAccess.registryAccess().getRegistry(io.papermc.paper.world.structure.ConfiguredStructure.class), "No registry present for ConfiguredStructure. This is a bug.");
|
||||||
+
|
+
|
||||||
+ /**
|
+ /**
|
||||||
+ * Potion effect types.
|
+ * Potion effect types.
|
||||||
|
@ -38,8 +38,8 @@ index ac8fe849dfd407bb2beeca16aeda3ebbe5c7a874..76b1d08d9ae2c2cf5c6d88934929695d
|
||||||
+ }
|
+ }
|
||||||
+ };
|
+ };
|
||||||
// Paper end
|
// Paper end
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Get the object by its key.
|
||||||
diff --git a/src/main/java/org/bukkit/potion/PotionEffectType.java b/src/main/java/org/bukkit/potion/PotionEffectType.java
|
diff --git a/src/main/java/org/bukkit/potion/PotionEffectType.java b/src/main/java/org/bukkit/potion/PotionEffectType.java
|
||||||
index e045e6a74821f291938cc6af86e313c1f1c4626c..e77cf365cefafbeba09123187e70fd5274f10d53 100644
|
index e045e6a74821f291938cc6af86e313c1f1c4626c..e77cf365cefafbeba09123187e70fd5274f10d53 100644
|
||||||
--- a/src/main/java/org/bukkit/potion/PotionEffectType.java
|
--- a/src/main/java/org/bukkit/potion/PotionEffectType.java
|
||||||
|
|
|
@ -155,10 +155,10 @@ index 0000000000000000000000000000000000000000..3ede1e8f7bf0436fdc5bf395c0f9eaf1
|
||||||
+ }
|
+ }
|
||||||
+}
|
+}
|
||||||
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
|
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
|
||||||
index fb6a3b71cf3c304c5d0177747bc098e134b22d58..eb6d59bad1e4f0b394290d683f5dfed6ba6dd75b 100644
|
index 1bbf2306fd6fdb3ead79fc770434541c2e054875..88223f062665c2c738e73a725d292b868e5372af 100644
|
||||||
--- a/src/main/java/org/bukkit/Bukkit.java
|
--- a/src/main/java/org/bukkit/Bukkit.java
|
||||||
+++ b/src/main/java/org/bukkit/Bukkit.java
|
+++ b/src/main/java/org/bukkit/Bukkit.java
|
||||||
@@ -2627,6 +2627,15 @@ public final class Bukkit {
|
@@ -2630,6 +2630,15 @@ public final class Bukkit {
|
||||||
public static io.papermc.paper.datapack.DatapackManager getDatapackManager() {
|
public static io.papermc.paper.datapack.DatapackManager getDatapackManager() {
|
||||||
return server.getDatapackManager();
|
return server.getDatapackManager();
|
||||||
}
|
}
|
||||||
|
@ -175,10 +175,10 @@ index fb6a3b71cf3c304c5d0177747bc098e134b22d58..eb6d59bad1e4f0b394290d683f5dfed6
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
|
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
|
||||||
index 43b049b68a8af548cd05c67dafc23dabd07bab27..6da6c20b684eba64b85d67db2482b4a968749070 100644
|
index 5b13d84b39a006f84c74008d3141b1a2ac954b7d..0c2906de839fe8211ed431df2e5e94740f04b94a 100644
|
||||||
--- a/src/main/java/org/bukkit/Server.java
|
--- a/src/main/java/org/bukkit/Server.java
|
||||||
+++ b/src/main/java/org/bukkit/Server.java
|
+++ b/src/main/java/org/bukkit/Server.java
|
||||||
@@ -2287,5 +2287,12 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
|
@@ -2290,5 +2290,12 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
|
||||||
*/
|
*/
|
||||||
@NotNull
|
@NotNull
|
||||||
io.papermc.paper.datapack.DatapackManager getDatapackManager();
|
io.papermc.paper.datapack.DatapackManager getDatapackManager();
|
||||||
|
|
|
@ -499,10 +499,10 @@ index 0000000000000000000000000000000000000000..a6b50c9d8af589cc4747e14d343d2045
|
||||||
+ }
|
+ }
|
||||||
+}
|
+}
|
||||||
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
|
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
|
||||||
index a2e5e917a7a0f6763f2ac13583dc28d9ea35ca64..e4f3f621c4c6d2653770c149db71587fc04e0991 100644
|
index 00b855a22b5b838db46126ff5bd6797ffff97da2..6545c5879706f4e527e4f742cc553c6e852cd6f8 100644
|
||||||
--- a/src/main/java/org/bukkit/Bukkit.java
|
--- a/src/main/java/org/bukkit/Bukkit.java
|
||||||
+++ b/src/main/java/org/bukkit/Bukkit.java
|
+++ b/src/main/java/org/bukkit/Bukkit.java
|
||||||
@@ -2658,6 +2658,141 @@ public final class Bukkit {
|
@@ -2661,6 +2661,141 @@ public final class Bukkit {
|
||||||
}
|
}
|
||||||
// Paper end
|
// Paper end
|
||||||
|
|
||||||
|
@ -645,10 +645,10 @@ index a2e5e917a7a0f6763f2ac13583dc28d9ea35ca64..e4f3f621c4c6d2653770c149db71587f
|
||||||
public static Server.Spigot spigot() {
|
public static Server.Spigot spigot() {
|
||||||
return server.spigot();
|
return server.spigot();
|
||||||
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
|
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
|
||||||
index 708ea9556510b2e9de2f7f1c381572e3bde540d1..63cbc38217865be8f79890a0d8d6143461d344f3 100644
|
index b3b82405440c236f035e49d0edf6fda12e2db4bb..fb31f2a668b2d6a1115123e34adea67ed4dbfd22 100644
|
||||||
--- a/src/main/java/org/bukkit/Server.java
|
--- a/src/main/java/org/bukkit/Server.java
|
||||||
+++ b/src/main/java/org/bukkit/Server.java
|
+++ b/src/main/java/org/bukkit/Server.java
|
||||||
@@ -2316,4 +2316,119 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
|
@@ -2319,4 +2319,119 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
|
||||||
*/
|
*/
|
||||||
@NotNull org.bukkit.potion.PotionBrewer getPotionBrewer();
|
@NotNull org.bukkit.potion.PotionBrewer getPotionBrewer();
|
||||||
// Paper end
|
// Paper end
|
||||||
|
|
|
@ -31,10 +31,10 @@ index 62d2b3f950860dee0898d77b0a29635c3f9a7e23..704dba92f9246ef398ed8d162ebee3cf
|
||||||
@Override
|
@Override
|
||||||
public @NotNull String translationKey() {
|
public @NotNull String translationKey() {
|
||||||
diff --git a/src/main/java/org/bukkit/Registry.java b/src/main/java/org/bukkit/Registry.java
|
diff --git a/src/main/java/org/bukkit/Registry.java b/src/main/java/org/bukkit/Registry.java
|
||||||
index 76b1d08d9ae2c2cf5c6d88934929695d438b3284..542c0516e19b6177ff8007ca6f8955dc9082da95 100644
|
index 9a8be5c730802e5750de1fc31e65f254f5894e63..0f7f23738c57ebe37846714159bb49e5b61e9f3d 100644
|
||||||
--- a/src/main/java/org/bukkit/Registry.java
|
--- a/src/main/java/org/bukkit/Registry.java
|
||||||
+++ b/src/main/java/org/bukkit/Registry.java
|
+++ b/src/main/java/org/bukkit/Registry.java
|
||||||
@@ -328,6 +328,49 @@ public interface Registry<T extends Keyed> extends Iterable<T> {
|
@@ -335,6 +335,49 @@ public interface Registry<T extends Keyed> extends Iterable<T> {
|
||||||
@Nullable
|
@Nullable
|
||||||
T get(@NotNull NamespacedKey key);
|
T get(@NotNull NamespacedKey key);
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ index 76b1d08d9ae2c2cf5c6d88934929695d438b3284..542c0516e19b6177ff8007ca6f8955dc
|
||||||
/**
|
/**
|
||||||
* Returns a new stream, which contains all registry items, which are registered to the registry.
|
* Returns a new stream, which contains all registry items, which are registered to the registry.
|
||||||
*
|
*
|
||||||
@@ -394,5 +437,12 @@ public interface Registry<T extends Keyed> extends Iterable<T> {
|
@@ -401,5 +444,12 @@ public interface Registry<T extends Keyed> extends Iterable<T> {
|
||||||
public Iterator<T> iterator() {
|
public Iterator<T> iterator() {
|
||||||
return map.values().iterator();
|
return map.values().iterator();
|
||||||
}
|
}
|
||||||
|
|
|
@ -7208,17 +7208,24 @@ index bc91370654f5da33cbfe7d42431568915c1159d6..b43af53960978ac04bccde08544a5628
|
||||||
validate(REGISTRY);
|
validate(REGISTRY);
|
||||||
}
|
}
|
||||||
diff --git a/src/main/java/net/minecraft/server/Bootstrap.java b/src/main/java/net/minecraft/server/Bootstrap.java
|
diff --git a/src/main/java/net/minecraft/server/Bootstrap.java b/src/main/java/net/minecraft/server/Bootstrap.java
|
||||||
index 15ee2f2a83bfef2f6891d9bfb2d3a8c14b24ffb1..d0d95d729853fc296c4931a2f73a3fc5f94302c9 100644
|
index 15ee2f2a83bfef2f6891d9bfb2d3a8c14b24ffb1..26892378d27dadce25c178333188ba093dc1617b 100644
|
||||||
--- a/src/main/java/net/minecraft/server/Bootstrap.java
|
--- a/src/main/java/net/minecraft/server/Bootstrap.java
|
||||||
+++ b/src/main/java/net/minecraft/server/Bootstrap.java
|
+++ b/src/main/java/net/minecraft/server/Bootstrap.java
|
||||||
@@ -74,7 +74,11 @@ public class Bootstrap {
|
@@ -63,6 +63,7 @@ public class Bootstrap {
|
||||||
|
Bootstrap.isBootstrapped = true;
|
||||||
|
Instant instant = Instant.now();
|
||||||
|
|
||||||
|
+ io.papermc.paper.plugin.entrypoint.LaunchEntryPointHandler.enterBootstrappers(); // Paper - Entrypoint for bootstrapping
|
||||||
|
if (BuiltInRegistries.REGISTRY.keySet().isEmpty()) {
|
||||||
|
throw new IllegalStateException("Unable to load registries");
|
||||||
|
} else {
|
||||||
|
@@ -74,7 +75,10 @@ public class Bootstrap {
|
||||||
EntitySelectorOptions.bootStrap();
|
EntitySelectorOptions.bootStrap();
|
||||||
DispenseItemBehavior.bootStrap();
|
DispenseItemBehavior.bootStrap();
|
||||||
CauldronInteraction.bootStrap();
|
CauldronInteraction.bootStrap();
|
||||||
- BuiltInRegistries.bootStrap();
|
- BuiltInRegistries.bootStrap();
|
||||||
+ // Paper start
|
+ // Paper start
|
||||||
+ BuiltInRegistries.bootStrap(() -> {
|
+ BuiltInRegistries.bootStrap(() -> {
|
||||||
+ io.papermc.paper.plugin.entrypoint.LaunchEntryPointHandler.enterBootstrappers(); // Paper - Entrypoint for bootstrapping
|
|
||||||
+ });
|
+ });
|
||||||
+ // Paper end
|
+ // Paper end
|
||||||
CreativeModeTabs.validate();
|
CreativeModeTabs.validate();
|
||||||
|
|
1026
patches/server/0485-Add-RegistryAccess-for-managing-Registries.patch
Normal file
1026
patches/server/0485-Add-RegistryAccess-for-managing-Registries.patch
Normal file
File diff suppressed because it is too large
Load diff
|
@ -1,18 +0,0 @@
|
||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
|
||||||
Date: Mon, 27 Feb 2023 18:28:39 -0800
|
|
||||||
Subject: [PATCH] TODO Registry Modification API
|
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftRegistry.java b/src/main/java/org/bukkit/craftbukkit/CraftRegistry.java
|
|
||||||
index 4209a45af2bfe772f678b07b49070522de4195a8..480313506bf41410de090c59e047323345ea78da 100644
|
|
||||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftRegistry.java
|
|
||||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftRegistry.java
|
|
||||||
@@ -138,6 +138,7 @@ public class CraftRegistry<B extends Keyed, M> implements Registry<B> {
|
|
||||||
if (bukkitClass == Wolf.Variant.class) {
|
|
||||||
return new CraftRegistry<>(Wolf.Variant.class, registryHolder.registryOrThrow(Registries.WOLF_VARIANT), CraftWolf.CraftVariant::new);
|
|
||||||
}
|
|
||||||
+ // TODO registry modification API
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
|
@ -5,12 +5,49 @@ Subject: [PATCH] Add StructuresLocateEvent
|
||||||
|
|
||||||
Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com>
|
Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||||
|
|
||||||
|
diff --git a/src/main/java/io/papermc/paper/registry/PaperRegistries.java b/src/main/java/io/papermc/paper/registry/PaperRegistries.java
|
||||||
|
index cc7d4924098eab9663cc52917e4b30d6ef4b02c7..183e168afcc4302bc1e3274a89835f1f60e4bbd6 100644
|
||||||
|
--- a/src/main/java/io/papermc/paper/registry/PaperRegistries.java
|
||||||
|
+++ b/src/main/java/io/papermc/paper/registry/PaperRegistries.java
|
||||||
|
@@ -40,6 +40,12 @@ import static io.papermc.paper.registry.entry.RegistryEntry.entry;
|
||||||
|
@DefaultQualifier(NonNull.class)
|
||||||
|
public final class PaperRegistries {
|
||||||
|
|
||||||
|
+ @Deprecated(forRemoval = true)
|
||||||
|
+ @org.jetbrains.annotations.VisibleForTesting
|
||||||
|
+ public static final RegistryKey<io.papermc.paper.world.structure.ConfiguredStructure> CONFIGURED_STRUCTURE_REGISTRY_KEY = RegistryKeyImpl.createInternal("worldgen/structure");
|
||||||
|
+ @Deprecated(forRemoval = true)
|
||||||
|
+ static final RegistryEntry<Structure, io.papermc.paper.world.structure.ConfiguredStructure, ?> CONFIGURED_STRUCTURE_REGISTRY_ENTRY = entry(Registries.STRUCTURE, CONFIGURED_STRUCTURE_REGISTRY_KEY, io.papermc.paper.world.structure.ConfiguredStructure.class, io.papermc.paper.world.structure.PaperConfiguredStructure::minecraftToBukkit).delayed();
|
||||||
|
+
|
||||||
|
static final List<RegistryEntry<?, ?, ?>> REGISTRY_ENTRIES;
|
||||||
|
private static final Map<RegistryKey<?>, RegistryEntry<?, ?, ?>> BY_REGISTRY_KEY;
|
||||||
|
private static final Map<ResourceKey<?>, RegistryEntry<?, ?, ?>> BY_RESOURCE_KEY;
|
||||||
|
diff --git a/src/main/java/io/papermc/paper/registry/PaperRegistryAccess.java b/src/main/java/io/papermc/paper/registry/PaperRegistryAccess.java
|
||||||
|
index 9f2bcfe0d9e479466a1e46e503071d1151310e6a..7aa1a29e93b787e1167169bc7d6e9563daf6241e 100644
|
||||||
|
--- a/src/main/java/io/papermc/paper/registry/PaperRegistryAccess.java
|
||||||
|
+++ b/src/main/java/io/papermc/paper/registry/PaperRegistryAccess.java
|
||||||
|
@@ -45,8 +45,13 @@ public class PaperRegistryAccess implements RegistryAccess {
|
||||||
|
public <T extends Keyed> @Nullable Registry<T> getRegistry(final Class<T> type) {
|
||||||
|
final RegistryKey<T> registryKey;
|
||||||
|
final @Nullable RegistryEntry<?, T, ?> entry;
|
||||||
|
- registryKey = requireNonNull(byType(type), () -> type + " is not a valid registry type");
|
||||||
|
- entry = PaperRegistries.getEntry(registryKey);
|
||||||
|
+ if (type == io.papermc.paper.world.structure.ConfiguredStructure.class) { // manually handle "duplicate" registries to avoid polluting maps in PaperRegistries
|
||||||
|
+ registryKey = (RegistryKey<T>) PaperRegistries.CONFIGURED_STRUCTURE_REGISTRY_KEY;
|
||||||
|
+ entry = (RegistryEntry<?, T, ?>) PaperRegistries.CONFIGURED_STRUCTURE_REGISTRY_ENTRY;
|
||||||
|
+ } else {
|
||||||
|
+ registryKey = requireNonNull(byType(type), () -> type + " is not a valid registry type");
|
||||||
|
+ entry = PaperRegistries.getEntry(registryKey);
|
||||||
|
+ }
|
||||||
|
final @Nullable RegistryHolder<T> registry = (RegistryHolder<T>) this.registries.get(registryKey);
|
||||||
|
if (registry != null) {
|
||||||
|
// if the registry exists, return right away. Since this is the "legacy" method, we return DelayedRegistry
|
||||||
diff --git a/src/main/java/io/papermc/paper/world/structure/PaperConfiguredStructure.java b/src/main/java/io/papermc/paper/world/structure/PaperConfiguredStructure.java
|
diff --git a/src/main/java/io/papermc/paper/world/structure/PaperConfiguredStructure.java b/src/main/java/io/papermc/paper/world/structure/PaperConfiguredStructure.java
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000000000000000000000000000000000000..2667067fd13f61e0464ba88ae4e4a7078351d1a8
|
index 0000000000000000000000000000000000000000..013d614a1cf1ab2b5a6ec190c2b4ba7753268731
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/src/main/java/io/papermc/paper/world/structure/PaperConfiguredStructure.java
|
+++ b/src/main/java/io/papermc/paper/world/structure/PaperConfiguredStructure.java
|
||||||
@@ -0,0 +1,35 @@
|
@@ -0,0 +1,27 @@
|
||||||
+package io.papermc.paper.world.structure;
|
+package io.papermc.paper.world.structure;
|
||||||
+
|
+
|
||||||
+import java.util.Objects;
|
+import java.util.Objects;
|
||||||
|
@ -32,20 +69,12 @@ index 0000000000000000000000000000000000000000..2667067fd13f61e0464ba88ae4e4a707
|
||||||
+ private PaperConfiguredStructure() {
|
+ private PaperConfiguredStructure() {
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ @Deprecated(forRemoval = true)
|
+ public static @Nullable ConfiguredStructure minecraftToBukkit(NamespacedKey key, Structure nms) {
|
||||||
+ public static final class LegacyRegistry extends CraftRegistry<ConfiguredStructure, Structure> {
|
|
||||||
+
|
|
||||||
+ public LegacyRegistry(final Registry<Structure> minecraftRegistry) {
|
|
||||||
+ super(ConfiguredStructure.class, minecraftRegistry, LegacyRegistry::minecraftToBukkit);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ private static @Nullable ConfiguredStructure minecraftToBukkit(NamespacedKey key, Structure nms) {
|
|
||||||
+ final ResourceLocation structureTypeLoc = Objects.requireNonNull(BuiltInRegistries.STRUCTURE_TYPE.getKey(nms.type()), "unexpected structure type " + nms.type());
|
+ final ResourceLocation structureTypeLoc = Objects.requireNonNull(BuiltInRegistries.STRUCTURE_TYPE.getKey(nms.type()), "unexpected structure type " + nms.type());
|
||||||
+ final @Nullable StructureType structureType = StructureType.getStructureTypes().get(structureTypeLoc.getPath());
|
+ final @Nullable StructureType structureType = StructureType.getStructureTypes().get(structureTypeLoc.getPath());
|
||||||
+ return structureType == null ? null : new ConfiguredStructure(key, structureType);
|
+ return structureType == null ? null : new ConfiguredStructure(key, structureType);
|
||||||
+ }
|
+ }
|
||||||
+}
|
+}
|
||||||
+}
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/level/chunk/ChunkGenerator.java b/src/main/java/net/minecraft/world/level/chunk/ChunkGenerator.java
|
diff --git a/src/main/java/net/minecraft/world/level/chunk/ChunkGenerator.java b/src/main/java/net/minecraft/world/level/chunk/ChunkGenerator.java
|
||||||
index 7cdb59cd2f2ffe1195d21519ef97dae0e430285b..a8768f1925d5824ca985be1b53694ee233273758 100644
|
index 7cdb59cd2f2ffe1195d21519ef97dae0e430285b..a8768f1925d5824ca985be1b53694ee233273758 100644
|
||||||
--- a/src/main/java/net/minecraft/world/level/chunk/ChunkGenerator.java
|
--- a/src/main/java/net/minecraft/world/level/chunk/ChunkGenerator.java
|
||||||
|
@ -75,22 +104,6 @@ index 7cdb59cd2f2ffe1195d21519ef97dae0e430285b..a8768f1925d5824ca985be1b53694ee2
|
||||||
ChunkGeneratorStructureState chunkgeneratorstructurestate = world.getChunkSource().getGeneratorState();
|
ChunkGeneratorStructureState chunkgeneratorstructurestate = world.getChunkSource().getGeneratorState();
|
||||||
Map<StructurePlacement, Set<Holder<Structure>>> map = new Object2ObjectArrayMap();
|
Map<StructurePlacement, Set<Holder<Structure>>> map = new Object2ObjectArrayMap();
|
||||||
Iterator iterator = structures.iterator();
|
Iterator iterator = structures.iterator();
|
||||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftRegistry.java b/src/main/java/org/bukkit/craftbukkit/CraftRegistry.java
|
|
||||||
index 480313506bf41410de090c59e047323345ea78da..c7d377dbb53cdc1f823a839e3a113136efc16349 100644
|
|
||||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftRegistry.java
|
|
||||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftRegistry.java
|
|
||||||
@@ -139,6 +139,11 @@ public class CraftRegistry<B extends Keyed, M> implements Registry<B> {
|
|
||||||
return new CraftRegistry<>(Wolf.Variant.class, registryHolder.registryOrThrow(Registries.WOLF_VARIANT), CraftWolf.CraftVariant::new);
|
|
||||||
}
|
|
||||||
// TODO registry modification API
|
|
||||||
+ // Paper start - remove this after a while along with all ConfiguredStructure stuff
|
|
||||||
+ if (bukkitClass == io.papermc.paper.world.structure.ConfiguredStructure.class) {
|
|
||||||
+ return new io.papermc.paper.world.structure.PaperConfiguredStructure.LegacyRegistry(registryHolder.registryOrThrow(Registries.STRUCTURE));
|
|
||||||
+ }
|
|
||||||
+ // Paper end
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
diff --git a/src/test/java/io/papermc/paper/world/structure/ConfiguredStructureTest.java b/src/test/java/io/papermc/paper/world/structure/ConfiguredStructureTest.java
|
diff --git a/src/test/java/io/papermc/paper/world/structure/ConfiguredStructureTest.java b/src/test/java/io/papermc/paper/world/structure/ConfiguredStructureTest.java
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000000000000000000000000000000000000..9178fe0d01b998ca1442bf2511f8fc00db9388ba
|
index 0000000000000000000000000000000000000000..9178fe0d01b998ca1442bf2511f8fc00db9388ba
|
||||||
|
@ -194,26 +207,26 @@ index 0000000000000000000000000000000000000000..9178fe0d01b998ca1442bf2511f8fc00
|
||||||
+ }
|
+ }
|
||||||
+}
|
+}
|
||||||
diff --git a/src/test/java/org/bukkit/registry/PerRegistryTest.java b/src/test/java/org/bukkit/registry/PerRegistryTest.java
|
diff --git a/src/test/java/org/bukkit/registry/PerRegistryTest.java b/src/test/java/org/bukkit/registry/PerRegistryTest.java
|
||||||
index 4e4ea083063daf22f1bb785ef212958ea889c43b..1c4966520b6401e6571aa44d5934dfa280bc80e3 100644
|
index 4e4ea083063daf22f1bb785ef212958ea889c43b..523b4b208e05c6b70014440200e3196cc84f36cc 100644
|
||||||
--- a/src/test/java/org/bukkit/registry/PerRegistryTest.java
|
--- a/src/test/java/org/bukkit/registry/PerRegistryTest.java
|
||||||
+++ b/src/test/java/org/bukkit/registry/PerRegistryTest.java
|
+++ b/src/test/java/org/bukkit/registry/PerRegistryTest.java
|
||||||
@@ -36,6 +36,7 @@ public class PerRegistryTest extends AbstractTestingBase {
|
@@ -36,6 +36,7 @@ public class PerRegistryTest extends AbstractTestingBase {
|
||||||
if (!(object instanceof CraftRegistry<?, ?> registry)) {
|
if (!(object instanceof CraftRegistry<?, ?> registry)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
+ if (object instanceof io.papermc.paper.world.structure.PaperConfiguredStructure.LegacyRegistry) continue; // Paper - skip
|
+ if (object == Registry.CONFIGURED_STRUCTURE) continue; // Paper - skip
|
||||||
|
|
||||||
data.add(Arguments.of(registry));
|
data.add(Arguments.of(registry));
|
||||||
} catch (ReflectiveOperationException e) {
|
} catch (ReflectiveOperationException e) {
|
||||||
diff --git a/src/test/java/org/bukkit/registry/RegistryArgumentAddedTest.java b/src/test/java/org/bukkit/registry/RegistryArgumentAddedTest.java
|
diff --git a/src/test/java/org/bukkit/registry/RegistryArgumentAddedTest.java b/src/test/java/org/bukkit/registry/RegistryArgumentAddedTest.java
|
||||||
index 4adaafafb7140e983a4e90f0ff0deaaf0887a9a5..65cc33c45553e755371ec4313dd38bb61eb7d61c 100644
|
index 0dd775ad1bd0bf9ba7ea05255d543a9df8b5fcfd..c1e51d104c52dd3f3e48d651b0ff1f00ae9bf96d 100644
|
||||||
--- a/src/test/java/org/bukkit/registry/RegistryArgumentAddedTest.java
|
--- a/src/test/java/org/bukkit/registry/RegistryArgumentAddedTest.java
|
||||||
+++ b/src/test/java/org/bukkit/registry/RegistryArgumentAddedTest.java
|
+++ b/src/test/java/org/bukkit/registry/RegistryArgumentAddedTest.java
|
||||||
@@ -23,6 +23,7 @@ public class RegistryArgumentAddedTest extends AbstractTestingBase {
|
@@ -26,6 +26,7 @@ public class RegistryArgumentAddedTest extends AbstractTestingBase {
|
||||||
|
loadedRegistries.addAll(io.papermc.paper.registry.PaperRegistryAccess.instance().getLoadedServerBackedRegistries());
|
||||||
Set<Class<?>> loadedRegistries = new HashSet<>(DummyServer.registers.keySet());
|
// Paper end
|
||||||
Set<Class<?>> notFound = new HashSet<>();
|
Set<io.papermc.paper.registry.RegistryKey<?>> notFound = new HashSet<>(); // Paper
|
||||||
+ loadedRegistries.remove(io.papermc.paper.world.structure.ConfiguredStructure.class); // Paper - ignore
|
+ loadedRegistries.remove(io.papermc.paper.registry.PaperRegistries.CONFIGURED_STRUCTURE_REGISTRY_KEY); // Paper - ignore
|
||||||
|
|
||||||
RegistriesArgumentProvider
|
RegistriesArgumentProvider
|
||||||
.getData()
|
.getData()
|
||||||
|
|
|
@ -5,18 +5,18 @@ Subject: [PATCH] Improve Registry
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftRegistry.java b/src/main/java/org/bukkit/craftbukkit/CraftRegistry.java
|
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftRegistry.java b/src/main/java/org/bukkit/craftbukkit/CraftRegistry.java
|
||||||
index c7d377dbb53cdc1f823a839e3a113136efc16349..73472890e30180dc3cb6aa1bd9c5815087334682 100644
|
index e2fcbeb8635280fcd2aeedff9803386c9bcabb0c..a3a00778a8fdbc13f8adbf4e4fbc4f1303d22789 100644
|
||||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftRegistry.java
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftRegistry.java
|
||||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftRegistry.java
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftRegistry.java
|
||||||
@@ -150,6 +150,7 @@ public class CraftRegistry<B extends Keyed, M> implements Registry<B> {
|
@@ -104,6 +104,7 @@ public class CraftRegistry<B extends Keyed, M> implements Registry<B> {
|
||||||
|
|
||||||
private final Class<? super B> bukkitClass;
|
private final Class<?> bukkitClass; // Paper - relax preload class
|
||||||
private final Map<NamespacedKey, B> cache = new HashMap<>();
|
private final Map<NamespacedKey, B> cache = new HashMap<>();
|
||||||
+ private final Map<B, NamespacedKey> byValue = new java.util.IdentityHashMap<>(); // Paper - improve Registry
|
+ private final Map<B, NamespacedKey> byValue = new java.util.IdentityHashMap<>(); // Paper - improve Registry
|
||||||
private final net.minecraft.core.Registry<M> minecraftRegistry;
|
private final net.minecraft.core.Registry<M> minecraftRegistry;
|
||||||
private final BiFunction<NamespacedKey, M, B> minecraftToBukkit;
|
private final BiFunction<NamespacedKey, M, B> minecraftToBukkit;
|
||||||
private boolean init;
|
private boolean init;
|
||||||
@@ -194,6 +195,7 @@ public class CraftRegistry<B extends Keyed, M> implements Registry<B> {
|
@@ -148,6 +149,7 @@ public class CraftRegistry<B extends Keyed, M> implements Registry<B> {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.cache.put(namespacedKey, bukkit);
|
this.cache.put(namespacedKey, bukkit);
|
||||||
|
@ -24,7 +24,7 @@ index c7d377dbb53cdc1f823a839e3a113136efc16349..73472890e30180dc3cb6aa1bd9c58150
|
||||||
|
|
||||||
return bukkit;
|
return bukkit;
|
||||||
}
|
}
|
||||||
@@ -216,4 +218,11 @@ public class CraftRegistry<B extends Keyed, M> implements Registry<B> {
|
@@ -170,4 +172,11 @@ public class CraftRegistry<B extends Keyed, M> implements Registry<B> {
|
||||||
|
|
||||||
return this.minecraftToBukkit.apply(namespacedKey, minecraft);
|
return this.minecraftToBukkit.apply(namespacedKey, minecraft);
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,7 @@ index 364f8d7a7106259401154d91b1b79869d014a469..f336bf98574e4fdeabc3b21062983439
|
||||||
}
|
}
|
||||||
|
|
||||||
diff --git a/src/test/java/org/bukkit/registry/PerRegistryTest.java b/src/test/java/org/bukkit/registry/PerRegistryTest.java
|
diff --git a/src/test/java/org/bukkit/registry/PerRegistryTest.java b/src/test/java/org/bukkit/registry/PerRegistryTest.java
|
||||||
index 1c4966520b6401e6571aa44d5934dfa280bc80e3..010de6fbb75eb5d51639695d260f916072fdb22d 100644
|
index 523b4b208e05c6b70014440200e3196cc84f36cc..12b93a6e091de47522d060fa0cd84fe41318c46a 100644
|
||||||
--- a/src/test/java/org/bukkit/registry/PerRegistryTest.java
|
--- a/src/test/java/org/bukkit/registry/PerRegistryTest.java
|
||||||
+++ b/src/test/java/org/bukkit/registry/PerRegistryTest.java
|
+++ b/src/test/java/org/bukkit/registry/PerRegistryTest.java
|
||||||
@@ -49,19 +49,22 @@ public class PerRegistryTest extends AbstractTestingBase {
|
@@ -49,19 +49,22 @@ public class PerRegistryTest extends AbstractTestingBase {
|
||||||
|
|
|
@ -105,17 +105,17 @@ index 0000000000000000000000000000000000000000..e0d73113c937ddbcf8144f88b15a8d3d
|
||||||
+ }
|
+ }
|
||||||
+}
|
+}
|
||||||
diff --git a/src/main/java/net/minecraft/server/Bootstrap.java b/src/main/java/net/minecraft/server/Bootstrap.java
|
diff --git a/src/main/java/net/minecraft/server/Bootstrap.java b/src/main/java/net/minecraft/server/Bootstrap.java
|
||||||
index 05f4be8dfff37ab6804a2d990b1f8c430d42dc7c..2a49a6a6bccabf588ba67b565d8f16fda04ba0b0 100644
|
index a3a2097716430b30c9bac2581b9f67fe0c595bd2..6885a653bfe629c46bface19ff1eb666d74d4f1b 100644
|
||||||
--- a/src/main/java/net/minecraft/server/Bootstrap.java
|
--- a/src/main/java/net/minecraft/server/Bootstrap.java
|
||||||
+++ b/src/main/java/net/minecraft/server/Bootstrap.java
|
+++ b/src/main/java/net/minecraft/server/Bootstrap.java
|
||||||
@@ -76,6 +76,7 @@ public class Bootstrap {
|
@@ -77,6 +77,7 @@ public class Bootstrap {
|
||||||
CauldronInteraction.bootStrap();
|
CauldronInteraction.bootStrap();
|
||||||
// Paper start
|
// Paper start
|
||||||
BuiltInRegistries.bootStrap(() -> {
|
BuiltInRegistries.bootStrap(() -> {
|
||||||
+ io.papermc.paper.world.worldgen.OptionallyFlatBedrockConditionSource.bootstrap(); // Paper - Flat bedrock generator settings
|
+ io.papermc.paper.world.worldgen.OptionallyFlatBedrockConditionSource.bootstrap(); // Paper - Flat bedrock generator settings
|
||||||
io.papermc.paper.plugin.entrypoint.LaunchEntryPointHandler.enterBootstrappers(); // Paper - Entrypoint for bootstrapping
|
|
||||||
});
|
});
|
||||||
// Paper end
|
// Paper end
|
||||||
|
CreativeModeTabs.validate();
|
||||||
diff --git a/src/main/java/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java b/src/main/java/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java
|
diff --git a/src/main/java/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java b/src/main/java/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java
|
||||||
index dc765b92cc90f5f370254e68bbbdfa5add7935ce..8ce870a5341a61fbbaf42021ef7f7f615a6a3e09 100644
|
index dc765b92cc90f5f370254e68bbbdfa5add7935ce..8ce870a5341a61fbbaf42021ef7f7f615a6a3e09 100644
|
||||||
--- a/src/main/java/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java
|
--- a/src/main/java/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java
|
||||||
|
|
Loading…
Reference in a new issue