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
@@ -1,12 +1,13 @@
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.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 @@ -57,6 +57,7 @@
import org.bukkit.FireworkEffect;
import org.bukkit.MusicInstrument;
import org.bukkit.Registry;
import org.bukkit.Sound;
import org.bukkit.block.banner.PatternType;
import org.bukkit.damage.DamageType;
import org.bukkit.entity.Axolotl;
Expand Down Expand Up @@ -365,7 +366,7 @@ public final class DataComponentTypes {
* Holds the unresolved loot table and seed of a container-like block.
*/
public static final DataComponentType.Valued<SeededContainerLoot> CONTAINER_LOOT = valued("container_loot");
public static final DataComponentType.Valued<Key> BREAK_SOUND = valued("break_sound");
public static final DataComponentType.Valued<Sound> BREAK_SOUND = valued("break_sound");
public static final DataComponentType.Valued<Villager.Type> VILLAGER_VARIANT = valued("villager/variant");
public static final DataComponentType.Valued<Wolf.Variant> WOLF_VARIANT = valued("wolf/variant");
public static final DataComponentType.Valued<Wolf.SoundVariant> WOLF_SOUND_VARIANT = valued("wolf/sound_variant");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import io.papermc.paper.registry.set.RegistryKeySet;
import java.util.List;
import net.kyori.adventure.key.Key;
import org.bukkit.Sound;
import org.bukkit.damage.DamageType;
import org.checkerframework.checker.index.qual.NonNegative;
import org.jetbrains.annotations.ApiStatus;
Expand Down Expand Up @@ -70,20 +71,20 @@ static Builder blocksAttacks() {
@Nullable RegistryKeySet<DamageType> bypassedBy();

/**
* Gets the key sound to play when an attack is successfully blocked.
* Gets the sound to play when an attack is successfully blocked.
*
* @return a key of the sound
* @return the sound
*/
@Contract(pure = true)
@Nullable Key blockSound();
@Nullable Sound blockSound();

/**
* Gets the key sound to play when the item goes on its disabled cooldown due to an attack.
* Gets the sound to play when the item goes on its disabled cooldown due to an attack.
*
* @return a key of the sound
* @return the sound
*/
@Contract(pure = true)
@Nullable Key disableSound();
@Nullable Sound disableSound();

/**
* Builder for {@link BlocksAttacks}.
Expand All @@ -109,10 +110,26 @@ interface Builder extends DataComponentBuilder<BlocksAttacks> {
@Contract(value = "_ -> this", mutates = "this")
Builder bypassedBy(@Nullable RegistryKeySet<DamageType> bypassedBy);

/**
* Sets the sound to play when an attack is successfully blocked.
*
* @param sound the sound, or null to play no sound
* @return the builder for chaining
* @see Sound#create(net.kyori.adventure.key.Key, Float)
* @see Sound#create(java.util.function.Consumer)
*/
@Contract(value = "_ -> this", mutates = "this")
Builder blockSound(@Nullable Key sound);

Builder blockSound(@Nullable Sound sound);

/**
* Sets the sound to play when the item goes on its disabled cooldown due to an attack.
*
* @param sound the sound, or null to play no sound
* @return the builder for chaining
* @see Sound#create(net.kyori.adventure.key.Key, Float)
* @see Sound#create(java.util.function.Consumer)
*/
@Contract(value = "_ -> this", mutates = "this")
Builder disableSound(@Nullable Key sound);
Builder disableSound(@Nullable Sound sound);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import io.papermc.paper.datacomponent.item.consumable.ItemUseAnimation;
import java.util.List;
import net.kyori.adventure.key.Key;
import org.bukkit.Sound;
import org.checkerframework.checker.index.qual.NonNegative;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Contract;
Expand All @@ -32,7 +33,7 @@ static Consumable.Builder consumable() {
ItemUseAnimation animation();

@Contract(pure = true)
Key sound();
Sound sound();

@Contract(pure = true)
boolean hasConsumeParticles();
Expand Down Expand Up @@ -67,11 +68,11 @@ interface Builder extends DataComponentBuilder<Consumable> {
/**
* Sets the sound played when consuming the item.
*
* @param sound the {@link Key} representing the sound to be used
* @param sound the sound to be used
* @return the builder for chaining
*/
@Contract(value = "_ -> this", mutates = "this")
Builder sound(Key sound);
Builder sound(Sound sound);

/**
* Sets whether consuming the item results in particle effects.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import io.papermc.paper.datacomponent.DataComponentBuilder;
import io.papermc.paper.registry.set.RegistryKeySet;
import net.kyori.adventure.key.Key;
import org.bukkit.Sound;
import org.bukkit.entity.EntityType;
import org.bukkit.inventory.EquipmentSlot;
import org.jetbrains.annotations.ApiStatus;
Expand Down Expand Up @@ -39,12 +40,12 @@ static Equippable.Builder equippable(final EquipmentSlot slot) {
EquipmentSlot slot();

/**
* Gets the equip sound key.
* Gets the equip sound.
*
* @return the equip sound key
* @return the equip sound
*/
@Contract(pure = true)
Key equipSound();
Sound equipSound();

/**
* Gets the asset id if present.
Expand Down Expand Up @@ -117,7 +118,7 @@ static Equippable.Builder equippable(final EquipmentSlot slot) {
* @return shear sound
*/
@Contract(pure = true)
Key shearSound();
Sound shearSound();

/**
* Builder for {@link Equippable}.
Expand All @@ -126,13 +127,13 @@ static Equippable.Builder equippable(final EquipmentSlot slot) {
interface Builder extends DataComponentBuilder<Equippable> {

/**
* Sets the equip sound key for this item.
* Sets the equip sound for this item.
*
* @param sound the equip sound key
* @param sound the equip sound
* @return the builder for chaining
*/
@Contract(value = "_ -> this", mutates = "this")
Builder equipSound(Key sound);
Builder equipSound(Sound sound);

/**
* Sets the asset id for this item.
Expand Down Expand Up @@ -209,10 +210,10 @@ interface Builder extends DataComponentBuilder<Equippable> {
/**
* Sets the sound that is played when shearing this equipment off an entity.
*
* @param shearSound the shear sound key
* @param shearSound the shear sound
* @return the builder for chaining
*/
@Contract(value = "_ -> this", mutates = "this")
Builder shearSound(Key shearSound);
Builder shearSound(Sound shearSound);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import io.papermc.paper.datacomponent.DataComponentBuilder;
import net.kyori.adventure.key.Key;
import org.bukkit.Sound;
import org.checkerframework.checker.index.qual.NonNegative;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Contract;
Expand Down Expand Up @@ -51,10 +52,10 @@ static Condition condition(final @NonNegative int maxDurationTicks, final float
float damageMultiplier();

@Contract(pure = true)
@Nullable Key sound();
@Nullable Sound sound();

@Contract(pure = true)
@Nullable Key hitSound();
@Nullable Sound hitSound();

interface Condition {

Expand Down Expand Up @@ -95,10 +96,26 @@ interface Builder extends DataComponentBuilder<KineticWeapon> {
@Contract(value = "_ -> this", mutates = "this")
Builder damageMultiplier(float damageMultiplier);

/**
* Sets the sound to play while this weapon is active.
*
* @param sound the sound, or null to play no sound
* @return the builder for chaining
* @see Sound#create(net.kyori.adventure.key.Key, Float)
* @see Sound#create(java.util.function.Consumer)
*/
@Contract(value = "_ -> this", mutates = "this")
Builder sound(@Nullable Key sound);

Builder sound(@Nullable Sound sound);

/**
* Sets the sound to play when this weapon hits an entity.
*
* @param sound the sound, or null to play no sound
* @return the builder for chaining
* @see Sound#create(net.kyori.adventure.key.Key, Float)
* @see Sound#create(java.util.function.Consumer)
*/
@Contract(value = "_ -> this", mutates = "this")
Builder hitSound(@Nullable Key sound);
Builder hitSound(@Nullable Sound sound);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import io.papermc.paper.datacomponent.DataComponentBuilder;
import net.kyori.adventure.key.Key;
import org.bukkit.Sound;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.Range;
Expand All @@ -25,9 +26,9 @@ static Builder piercingWeapon() {

boolean dismounts();

@Nullable Key sound();
@Nullable Sound sound();

@Nullable Key hitSound();
@Nullable Sound hitSound();

/**
* Builder for {@link PiercingWeapon}.
Expand All @@ -41,10 +42,26 @@ interface Builder extends DataComponentBuilder<PiercingWeapon> {
@Contract(value = "_ -> this", mutates = "this")
Builder dismounts(boolean dismounts);

/**
* Sets the sound to play while this weapon is active.
*
* @param sound the sound, or null to play no sound
* @return the builder for chaining
* @see Sound#create(net.kyori.adventure.key.Key, Float)
* @see Sound#create(java.util.function.Consumer)
*/
@Contract(value = "_ -> this", mutates = "this")
Builder sound(@Nullable Key sound);
Builder sound(@Nullable Sound sound);

/**
* Sets the sound to play when this weapon hits an entity.
*
* @param sound the sound, or null to play no sound
* @return the builder for chaining
* @see Sound#create(net.kyori.adventure.key.Key, Float)
* @see Sound#create(java.util.function.Consumer)
*/
@Contract(value = "_ -> this", mutates = "this")
Builder hitSound(@Nullable Key sound);
Builder hitSound(@Nullable Sound sound);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.util.Optional;
import java.util.ServiceLoader;
import net.kyori.adventure.key.Key;
import org.bukkit.Sound;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.jetbrains.annotations.ApiStatus;
Expand All @@ -26,7 +27,7 @@ static ConsumableTypesBridge bridge() {

ConsumeEffect.ClearAllStatusEffects clearAllStatusEffects();

ConsumeEffect.PlaySound playSoundEffect(Key sound);
ConsumeEffect.PlaySound playSoundEffect(Sound sound);

ConsumeEffect.TeleportRandomly teleportRandomlyEffect(float diameter);
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import io.papermc.paper.registry.set.RegistryKeySet;
import java.util.List;
import net.kyori.adventure.key.Key;
import org.bukkit.Sound;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.jetbrains.annotations.ApiStatus;
Expand Down Expand Up @@ -41,12 +42,12 @@ static RemoveStatusEffects removeEffects(final RegistryKeySet<PotionEffectType>
/**
* Creates a consume effect that plays a sound on consumption.
*
* @param key the key sound effect to play
* @param sound the sound effect to play
* @return the effect instance
*/
@Contract(value = "_ -> new", pure = true)
static PlaySound playSoundConsumeEffect(final Key key) {
return ConsumableTypesBridge.bridge().playSoundEffect(key);
static PlaySound playSoundConsumeEffect(final Sound sound) {
return ConsumableTypesBridge.bridge().playSoundEffect(sound);
}

/**
Expand Down Expand Up @@ -110,7 +111,7 @@ interface PlaySound extends ConsumeEffect {
*
* @return sound effect
*/
Key sound();
Sound sound();
}

/**
Expand Down
7 changes: 4 additions & 3 deletions paper-api/src/main/java/io/papermc/paper/dialog/Dialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

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.RegistryBuilderProvider;
import io.papermc.paper.registry.data.dialog.DialogRegistryEntry;
import java.util.function.Consumer;
import net.kyori.adventure.dialog.DialogLike;
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.Inlineable<Dialog, DialogRegistryEntry, DialogRegistryEntry.Builder>, Keyed, DialogLike {

/**
* Creates a new dialog using the provided builder.
Expand All @@ -28,7 +29,7 @@ public interface Dialog extends Keyed, DialogLike {
* @return a new dialog instance
*/
static Dialog create(final Consumer<RegistryBuilderFactory<Dialog, ? extends DialogRegistryEntry.Builder>> value) {
return InlinedRegistryBuilderProvider.instance().createDialog(value);
return RegistryBuilderProvider.instance().create(RegistryKey.DIALOG, value);
}

// Start generate - Dialog
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.papermc.paper.entity.poi;

import io.papermc.paper.InternalAPIBridge;
import io.papermc.paper.registry.RegistryElement;
import org.bukkit.Keyed;
import org.bukkit.block.data.BlockData;
import org.jspecify.annotations.NullMarked;
Expand All @@ -15,7 +16,7 @@
* @see PoiTypes
*/
@NullMarked
public interface PoiType extends Keyed {
public interface PoiType extends RegistryElement<PoiType>, Keyed {

/**
* Determines whether the provided BlockState is relevant to this
Expand Down
Loading
Loading