Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,13 @@ public final class DamageTypeTagKeys {
*/
public static final TagKey<DamageType> BYPASSES_ARMOR = create(key("bypasses_armor"));

/**
* {@code #minecraft:bypasses_cooldown}
*
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
*/
public static final TagKey<DamageType> BYPASSES_COOLDOWN = create(key("bypasses_cooldown"));

/**
* {@code #minecraft:bypasses_effects}
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package io.papermc.paper.datacomponent;

import io.papermc.paper.registry.RegistryElement;
import org.bukkit.Keyed;
import org.jetbrains.annotations.ApiStatus;
import org.jspecify.annotations.NullMarked;

@NullMarked
@ApiStatus.Experimental
@ApiStatus.NonExtendable
public interface DataComponentType extends Keyed {
public interface DataComponentType extends RegistryElement<DataComponentType>, Keyed {

/**
* Checks if this data component type is persistent, or
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import io.papermc.paper.registry.RegistryAccess;
import io.papermc.paper.registry.RegistryBuilderFactory;
import io.papermc.paper.registry.RegistryElement;
import io.papermc.paper.registry.RegistryKey;
import io.papermc.paper.registry.data.InlinedRegistryBuilderProvider;
import io.papermc.paper.registry.data.dialog.DialogRegistryEntry;
Expand All @@ -19,7 +20,7 @@
* Can also be created during bootstrap via {@link io.papermc.paper.registry.event.RegistryEvents#DIALOG}.
*/
@ApiStatus.NonExtendable
public interface Dialog extends Keyed, DialogLike {
public interface Dialog extends RegistryElement<Dialog>, Keyed, DialogLike {

/**
* Creates a new dialog using the provided builder.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package io.papermc.paper.registry;

import io.papermc.paper.registry.tag.TagKey;
import net.kyori.adventure.key.Key;
import org.bukkit.Keyed;
import org.jspecify.annotations.NullMarked;

/**
* An element of a registry which might or might not be registered.
* <p>
* For unregistered element, the equality methods exposed here will return {@code false}
* as there's no way to identify them with a key.
*
* @see RegistryKey
* @see org.bukkit.Registry
* @see org.bukkit.Registry#getKey(Keyed)
*/
@NullMarked
public interface RegistryElement<T> {

/**
* Checks whether this element is identified by the
* given key extracted from this keyed.
*
* @param type the keyed to extract the key from
* @return the result
*/
default boolean is(Keyed type) {
return this.is(type.key());
}

/**
* Checks whether this element is identified by the given key.
*
* @param type the key
* @return the result
*/
boolean is(Key type);

/**
* Checks whether this element is contained in the
* tag identified by the given tag key.
*
* @param type the tag key
* @return the result
*/
boolean is(TagKey<T> type);
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ static <T> RegistryValueSet<T> valueSet(final RegistryKey<T> registryKey, final
/**
* Creates a {@link RegistryKeySet} from registry-backed values.
* <p>All values provided <b>must</b> have keys in the given registry.
* <!--For anonymous values, use {@link #valueSet(RegistryKey, Iterable)}--></p>
* For anonymous values, use {@link #valueSet(RegistryKey, Iterable)}.</p>
* <p>If references to actual objects are not available yet, use {@link #keySet(RegistryKey, Iterable)} to
* create an equivalent {@link RegistryKeySet} using just {@link TypedKey TypedKeys}.</p>
*
Expand Down
3 changes: 2 additions & 1 deletion paper-api/src/main/java/org/bukkit/Art.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.google.common.base.Preconditions;
import io.papermc.paper.registry.RegistryAccess;
import io.papermc.paper.registry.RegistryElement;
import io.papermc.paper.registry.RegistryKey;
import java.util.Locale;
import net.kyori.adventure.key.Key;
Expand All @@ -18,7 +19,7 @@
* There may be additional arts present in the server, for example from a {@link io.papermc.paper.datapack.Datapack}
* which can be accessed via {@link RegistryAccess#registryAccess()} and {@link RegistryKey#PAINTING_VARIANT}.
*/
public interface Art extends OldEnum<Art>, Keyed {
public interface Art extends RegistryElement<Art>, OldEnum<Art>, Keyed {

// Start generate - Art
Art ALBAN = getArt("alban");
Expand Down
3 changes: 2 additions & 1 deletion paper-api/src/main/java/org/bukkit/Fluid.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.bukkit;

import com.google.common.base.Preconditions;
import io.papermc.paper.registry.RegistryElement;
import io.papermc.paper.registry.RegistryKey;
import java.util.Locale;
import net.kyori.adventure.key.Key;
Expand All @@ -11,7 +12,7 @@
/**
* Represents a fluid type.
*/
public interface Fluid extends OldEnum<Fluid>, Keyed {
public interface Fluid extends RegistryElement<Fluid>, OldEnum<Fluid>, Keyed {

// Start generate - Fluid
Fluid EMPTY = getFluid("empty");
Expand Down
3 changes: 2 additions & 1 deletion paper-api/src/main/java/org/bukkit/GameEvent.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.bukkit;

import io.papermc.paper.registry.RegistryElement;
import java.util.Collection;
import net.kyori.adventure.key.Key;
import net.kyori.adventure.key.KeyPattern;
Expand All @@ -9,7 +10,7 @@
/**
* Represents a generic Mojang game event.
*/
public abstract class GameEvent implements Keyed {
public abstract class GameEvent implements RegistryElement<GameEvent>, Keyed {

// Start generate - GameEvent
public static final GameEvent BLOCK_ACTIVATE = getEvent("block_activate");
Expand Down
3 changes: 2 additions & 1 deletion paper-api/src/main/java/org/bukkit/GameRule.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.google.common.base.Preconditions;
import io.papermc.paper.InternalAPIBridge;
import io.papermc.paper.registry.RegistryElement;
import io.papermc.paper.world.flag.FeatureDependant;
import java.util.function.UnaryOperator;
import org.jetbrains.annotations.ApiStatus;
Expand All @@ -19,7 +20,7 @@
* @see GameRules
*/
@ApiStatus.NonExtendable
public abstract class GameRule<T> implements net.kyori.adventure.translation.Translatable, FeatureDependant, Keyed {
public abstract class GameRule<T> implements RegistryElement<GameRule<T>>, net.kyori.adventure.translation.Translatable, FeatureDependant, Keyed {

// Boolean rules
/**
Expand Down
3 changes: 2 additions & 1 deletion paper-api/src/main/java/org/bukkit/JukeboxSong.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.bukkit;

import io.papermc.paper.registry.RegistryAccess;
import io.papermc.paper.registry.RegistryElement;
import io.papermc.paper.registry.RegistryKey;
import net.kyori.adventure.key.Key;
import net.kyori.adventure.key.KeyPattern;
Expand All @@ -11,7 +12,7 @@
* Represents a song which may play in a Jukebox.
*/
@NullMarked
public interface JukeboxSong extends Keyed, Translatable {
public interface JukeboxSong extends RegistryElement<JukeboxSong>, Keyed, Translatable {

// Start generate - JukeboxSong
JukeboxSong ELEVEN = get("11");
Expand Down
3 changes: 2 additions & 1 deletion paper-api/src/main/java/org/bukkit/MusicInstrument.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import io.papermc.paper.registry.RegistryAccess;
import io.papermc.paper.registry.RegistryBuilderFactory;
import io.papermc.paper.registry.RegistryElement;
import io.papermc.paper.registry.RegistryKey;
import io.papermc.paper.registry.data.InlinedRegistryBuilderProvider;
import io.papermc.paper.registry.data.InstrumentRegistryEntry;
Expand All @@ -15,7 +16,7 @@
import org.jspecify.annotations.Nullable;

@NullMarked
public abstract class MusicInstrument implements Keyed, net.kyori.adventure.translation.Translatable {
public abstract class MusicInstrument implements RegistryElement<MusicInstrument>, Keyed, net.kyori.adventure.translation.Translatable {

/**
* Creates an inlined music instrument.
Expand Down
3 changes: 2 additions & 1 deletion paper-api/src/main/java/org/bukkit/Sound.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.bukkit;

import com.google.common.base.Preconditions;
import io.papermc.paper.registry.RegistryElement;
import io.papermc.paper.registry.RegistryKey;
import java.util.Locale;
import net.kyori.adventure.key.Key;
Expand All @@ -21,7 +22,7 @@
* guarantee values will not be removed from this interface. As such, you should not
* depend on the ordinal values of this class.
*/
public interface Sound extends OldEnum<Sound>, Keyed, net.kyori.adventure.sound.Sound.Type { // Paper - implement Sound.Type
public interface Sound extends RegistryElement<Sound>, OldEnum<Sound>, Keyed, net.kyori.adventure.sound.Sound.Type { // Paper - implement Sound.Type

// Start generate - Sound
Sound AMBIENT_BASALT_DELTAS_ADDITIONS = getSound("ambient.basalt_deltas.additions");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.bukkit.attribute;

import com.google.common.base.Preconditions;
import io.papermc.paper.registry.RegistryElement;
import io.papermc.paper.registry.RegistryKey;
import java.util.Locale;
import net.kyori.adventure.key.Key;
Expand All @@ -16,7 +17,7 @@
/**
* Types of attributes which may be present on an {@link Attributable}.
*/
public interface Attribute extends OldEnum<Attribute>, Keyed, Translatable, net.kyori.adventure.translation.Translatable { // Paper - Adventure translations
public interface Attribute extends RegistryElement<Attribute>, OldEnum<Attribute>, Keyed, Translatable, net.kyori.adventure.translation.Translatable { // Paper - Adventure translations

/**
* Maximum health of an Entity.
Expand Down
3 changes: 2 additions & 1 deletion paper-api/src/main/java/org/bukkit/block/Biome.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.google.common.base.Preconditions;
import io.papermc.paper.InternalAPIBridge;
import io.papermc.paper.registry.RegistryAccess;
import io.papermc.paper.registry.RegistryElement;
import io.papermc.paper.registry.RegistryKey;
import java.util.Locale;
import net.kyori.adventure.key.Key;
Expand All @@ -23,7 +24,7 @@
* There may be additional biomes present in the server, for example from a {@link io.papermc.paper.datapack.Datapack}
* which can be accessed via {@link io.papermc.paper.registry.RegistryAccess#getRegistry(RegistryKey)} and {@link RegistryKey#BIOME}.
*/
public interface Biome extends OldEnum<Biome>, Keyed, net.kyori.adventure.translation.Translatable { // Paper - Adventure translations
public interface Biome extends RegistryElement<Biome>, OldEnum<Biome>, Keyed, net.kyori.adventure.translation.Translatable { // Paper - Adventure translations

// Start generate - Biome
Biome BADLANDS = getBiome("badlands");
Expand Down
3 changes: 2 additions & 1 deletion paper-api/src/main/java/org/bukkit/block/BlockType.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.bukkit.block;

import io.papermc.paper.registry.RegistryElement;
import java.util.Collection;
import java.util.function.Consumer;
import net.kyori.adventure.key.Key;
Expand Down Expand Up @@ -132,7 +133,7 @@
* Represents a block type.
*/
@NullMarked
public interface BlockType extends Keyed, Translatable, net.kyori.adventure.translation.Translatable, io.papermc.paper.world.flag.FeatureDependant { // Paper - add translatable & feature flag API
public interface BlockType extends RegistryElement<BlockType>, Keyed, Translatable, net.kyori.adventure.translation.Translatable, io.papermc.paper.world.flag.FeatureDependant { // Paper - add translatable & feature flag API

/**
* Typed represents a subtype of {@link BlockType}s that have a known block
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.google.common.base.Preconditions;
import io.papermc.paper.registry.RegistryAccess;
import io.papermc.paper.registry.RegistryElement;
import io.papermc.paper.registry.RegistryKey;
import java.util.Locale;
import net.kyori.adventure.key.Key;
Expand All @@ -14,7 +15,7 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

public interface PatternType extends OldEnum<PatternType>, Keyed {
public interface PatternType extends RegistryElement<PatternType>, OldEnum<PatternType>, Keyed {

// Start generate - PatternType
PatternType BASE = getType("base");
Expand Down
3 changes: 2 additions & 1 deletion paper-api/src/main/java/org/bukkit/damage/DamageType.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.bukkit.damage;

import io.papermc.paper.registry.RegistryAccess;
import io.papermc.paper.registry.RegistryElement;
import io.papermc.paper.registry.RegistryKey;
import net.kyori.adventure.key.Key;
import net.kyori.adventure.key.KeyPattern;
Expand All @@ -17,7 +18,7 @@
*
* @see <a href="https://minecraft.wiki/w/Damage_type">Minecraft Wiki</a>
*/
public interface DamageType extends Keyed, Translatable {
public interface DamageType extends RegistryElement<DamageType>, Keyed, Translatable {

// Start generate - DamageType
DamageType ARROW = getDamageType("arrow");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.bukkit.enchantments;

import io.papermc.paper.registry.RegistryAccess;
import io.papermc.paper.registry.RegistryElement;
import io.papermc.paper.registry.RegistryKey;
import java.util.Locale;
import net.kyori.adventure.key.Key;
Expand All @@ -17,7 +18,7 @@
/**
* The various type of enchantments that may be added to armour or weapons
*/
public abstract class Enchantment implements Keyed, Translatable, net.kyori.adventure.translation.Translatable { // Paper - Adventure translations
public abstract class Enchantment implements RegistryElement<Enchantment>, Keyed, Translatable, net.kyori.adventure.translation.Translatable { // Paper - Adventure translations
/**
* Provides protection against environmental damage
*/
Expand Down
3 changes: 2 additions & 1 deletion paper-api/src/main/java/org/bukkit/entity/Cat.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.google.common.base.Preconditions;
import io.papermc.paper.registry.RegistryAccess;
import io.papermc.paper.registry.RegistryElement;
import io.papermc.paper.registry.RegistryKey;
import java.util.Locale;
import net.kyori.adventure.key.Key;
Expand Down Expand Up @@ -53,7 +54,7 @@ public interface Cat extends Tameable, Sittable, io.papermc.paper.entity.CollarC
/**
* Represents the various different cat types there are.
*/
interface Type extends OldEnum<Type>, Keyed {
interface Type extends RegistryElement<Type>, OldEnum<Type>, Keyed {

// Start generate - CatType
Type ALL_BLACK = getType("all_black");
Expand Down
3 changes: 2 additions & 1 deletion paper-api/src/main/java/org/bukkit/entity/Chicken.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.bukkit.entity;

import io.papermc.paper.registry.RegistryAccess;
import io.papermc.paper.registry.RegistryElement;
import io.papermc.paper.registry.RegistryKey;
import net.kyori.adventure.key.Key;
import net.kyori.adventure.key.KeyPattern;
Expand Down Expand Up @@ -58,7 +59,7 @@ public interface Chicken extends Animals {
/**
* Represents the variant of a chicken.
*/
interface Variant extends Keyed {
interface Variant extends RegistryElement<Variant>, Keyed {

// Start generate - ChickenVariant
Variant COLD = getVariant("cold");
Expand Down
3 changes: 2 additions & 1 deletion paper-api/src/main/java/org/bukkit/entity/Cow.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.bukkit.entity;

import io.papermc.paper.registry.RegistryAccess;
import io.papermc.paper.registry.RegistryElement;
import io.papermc.paper.registry.RegistryKey;
import net.kyori.adventure.key.Key;
import net.kyori.adventure.key.KeyPattern;
Expand Down Expand Up @@ -30,7 +31,7 @@ public interface Cow extends AbstractCow {
/**
* Represents the variant of a cow.
*/
interface Variant extends Keyed {
interface Variant extends RegistryElement<Variant>, Keyed {

// Start generate - CowVariant
Variant COLD = getVariant("cold");
Expand Down
2 changes: 0 additions & 2 deletions paper-api/src/main/java/org/bukkit/entity/EntityType.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@
import org.bukkit.entity.minecart.RideableMinecart;
import org.bukkit.entity.minecart.SpawnerMinecart;
import org.bukkit.entity.minecart.StorageMinecart;
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffectType;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
Expand Down
Loading
Loading