Co-authored-by: Bjarne Koll <git@lynxplay.dev>
Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com>
Co-authored-by: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com>
Co-authored-by: MiniDigger | Martin <admin@minidigger.dev>
Co-authored-by: Nassim Jahnke <nassim@njahnke.dev>
Co-authored-by: Noah van der Aa <ndvdaa@gmail.com>
Co-authored-by: Owen1212055 <23108066+Owen1212055@users.noreply.github.com>
Co-authored-by: Shane Freeder <theboyetronic@gmail.com>
Co-authored-by: Spottedleaf <Spottedleaf@users.noreply.github.com>
Co-authored-by: Tamion <70228790+notTamion@users.noreply.github.com>
Co-authored-by: Warrior <50800980+Warriorrrr@users.noreply.github.com>
This commit is contained in:
Nassim Jahnke
2025-04-12 17:26:44 +02:00
parent 0767902699
commit f00727c57e
2092 changed files with 50551 additions and 48729 deletions

View File

@@ -1,6 +1,7 @@
package io.papermc.paper;
import net.kyori.adventure.util.Services;
import org.bukkit.block.Biome;
import org.bukkit.damage.DamageEffect;
import org.jetbrains.annotations.ApiStatus;
import org.jspecify.annotations.NullMarked;
@@ -35,5 +36,14 @@ public interface InternalAPIBridge {
* @return the damage effect.
*/
DamageEffect getDamageEffect(String key);
/**
* Constructs the legacy custom biome instance for the biome enum.
*
* @return the created biome.
*/
@Deprecated(forRemoval = true, since = "1.21.5")
@ApiStatus.ScheduledForRemoval(inVersion = "1.22")
Biome constructLegacyCustomBiome();
}

View File

@@ -5,7 +5,7 @@ import org.bukkit.block.Lockable;
import org.bukkit.block.TileState;
/**
* Interface for tile entities that are lockable.
* Interface for block entities that are lockable.
*/
public interface LockableTileState extends TileState, Lockable, Nameable {
}

View File

@@ -9,6 +9,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
/**
* Helper methods to bridge the gaps between Brigadier and Paper-MojangAPI.
*
* @deprecated for removal. See {@link MessageComponentSerializer} for a direct replacement of functionality found in
* this class.
* As a general entrypoint to brigadier on paper, see {@link io.papermc.paper.command.brigadier.Commands}.

View File

@@ -0,0 +1,48 @@
package io.papermc.paper.datacomponent;
import org.bukkit.Utility;
import org.bukkit.persistence.PersistentDataContainer;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
import org.jspecify.annotations.NullMarked;
/**
* This represents an object capable of holding and mutating data components.
*
* @see PersistentDataContainer
*/
@NullMarked
@ApiStatus.NonExtendable
public interface DataComponentHolder extends DataComponentView {
/**
* Sets the value of the data component type for this holder.
*
* @param type the data component type
* @param valueBuilder value builder
* @param <T> value type
*/
@Utility
@org.jetbrains.annotations.ApiStatus.Experimental
public <T> void setData(final io.papermc.paper.datacomponent.DataComponentType.@NotNull Valued<T> type, final @NotNull io.papermc.paper.datacomponent.DataComponentBuilder<T> valueBuilder);
/**
* Sets the value of the data component type for this holder.
*
* @param type the data component type
* @param value value to set
* @param <T> value type
*/
@org.jetbrains.annotations.ApiStatus.Experimental
public <T> void setData(final io.papermc.paper.datacomponent.DataComponentType.@NotNull Valued<T> type, final @NotNull T value);
/**
* Marks this non-valued data component type as present in this itemstack.
*
* @param type the data component type
*/
@org.jetbrains.annotations.ApiStatus.Experimental
public void setData(final io.papermc.paper.datacomponent.DataComponentType.@NotNull NonValued type);
// TODO: Do we even want to have the concept of overriding here? Not sure what is going on with entity components
}

View File

@@ -2,6 +2,7 @@ package io.papermc.paper.datacomponent;
import io.papermc.paper.datacomponent.item.BannerPatternLayers;
import io.papermc.paper.datacomponent.item.BlockItemDataProperties;
import io.papermc.paper.datacomponent.item.BlocksAttacks;
import io.papermc.paper.datacomponent.item.BundleContents;
import io.papermc.paper.datacomponent.item.ChargedProjectiles;
import io.papermc.paper.datacomponent.item.Consumable;
@@ -32,21 +33,42 @@ import io.papermc.paper.datacomponent.item.ResolvableProfile;
import io.papermc.paper.datacomponent.item.SeededContainerLoot;
import io.papermc.paper.datacomponent.item.SuspiciousStewEffects;
import io.papermc.paper.datacomponent.item.Tool;
import io.papermc.paper.datacomponent.item.Unbreakable;
import io.papermc.paper.datacomponent.item.TooltipDisplay;
import io.papermc.paper.datacomponent.item.UseCooldown;
import io.papermc.paper.datacomponent.item.UseRemainder;
import io.papermc.paper.datacomponent.item.Weapon;
import io.papermc.paper.datacomponent.item.WritableBookContent;
import io.papermc.paper.datacomponent.item.WrittenBookContent;
import io.papermc.paper.item.MapPostProcessing;
import java.util.List;
import io.papermc.paper.registry.tag.TagKey;
import net.kyori.adventure.key.Key;
import net.kyori.adventure.text.Component;
import org.bukkit.Art;
import org.bukkit.DyeColor;
import org.bukkit.FireworkEffect;
import org.bukkit.MusicInstrument;
import org.bukkit.NamespacedKey;
import org.bukkit.Registry;
import org.bukkit.block.banner.PatternType;
import org.bukkit.entity.Axolotl;
import org.bukkit.entity.Cat;
import org.bukkit.entity.Chicken;
import org.bukkit.entity.Cow;
import org.bukkit.entity.Fox;
import org.bukkit.entity.Frog;
import org.bukkit.entity.Horse;
import org.bukkit.entity.Llama;
import org.bukkit.entity.MushroomCow;
import org.bukkit.entity.Parrot;
import org.bukkit.entity.Pig;
import org.bukkit.entity.Rabbit;
import org.bukkit.entity.Salmon;
import org.bukkit.entity.TropicalFish;
import org.bukkit.entity.Villager;
import org.bukkit.entity.Wolf;
import org.bukkit.inventory.ItemRarity;
import org.bukkit.inventory.meta.trim.TrimMaterial;
import org.checkerframework.checker.index.qual.NonNegative;
import org.checkerframework.checker.index.qual.Positive;
import org.checkerframework.common.value.qual.IntRange;
@@ -88,7 +110,7 @@ public final class DataComponentTypes {
/**
* If set, the item will not lose any durability when used.
*/
public static final DataComponentType.Valued<Unbreakable> UNBREAKABLE = valued("unbreakable");
public static final DataComponentType.NonValued UNBREAKABLE = unvalued("unbreakable");
/**
* Custom name override for an item (as set by renaming with an Anvil).
*
@@ -144,15 +166,7 @@ public final class DataComponentTypes {
* Controls the minecraft:custom_model_data property in the item model.
*/
public static final DataComponentType.Valued<CustomModelData> CUSTOM_MODEL_DATA = valued("custom_model_data");
/**
* If set, disables 'additional' tooltip part which comes from the item type
* (e.g. content of a shulker).
*/
public static final DataComponentType.NonValued HIDE_ADDITIONAL_TOOLTIP = unvalued("hide_additional_tooltip");
/**
* If set, it will completely hide whole item tooltip (that includes item name).
*/
public static final DataComponentType.NonValued HIDE_TOOLTIP = unvalued("hide_tooltip");
public static final DataComponentType.Valued<TooltipDisplay> TOOLTIP_DISPLAY = valued("tooltip_display");
/**
* The additional experience cost required to modify an item in an Anvil.
* If not present, has an implicit default value of: {@code 0}.
@@ -188,12 +202,14 @@ public final class DataComponentTypes {
* Controls the behavior of the item as a tool.
*/
public static final DataComponentType.Valued<Tool> TOOL = valued("tool");
public static final DataComponentType.Valued<Weapon> WEAPON = valued("weapon");
public static final DataComponentType.Valued<Enchantable> ENCHANTABLE = valued("enchantable");
public static final DataComponentType.Valued<Equippable> EQUIPPABLE = valued("equippable");
public static final DataComponentType.Valued<Repairable> REPAIRABLE = valued("repairable");
public static final DataComponentType.NonValued GLIDER = unvalued("glider");
public static final DataComponentType.Valued<Key> TOOLTIP_STYLE = valued("tooltip_style");
public static final DataComponentType.Valued<DeathProtection> DEATH_PROTECTION = valued("death_protection");
public static final DataComponentType.Valued<BlocksAttacks> BLOCKS_ATTACKS = valued("blocks_attacks");
/**
* Stores list of enchantments and their levels for an Enchanted Book.
* Unlike {@link #ENCHANTMENTS}, the effects provided by enchantments
@@ -243,6 +259,7 @@ public final class DataComponentTypes {
* or potion applied to a Tipped Arrow.
*/
public static final DataComponentType.Valued<PotionContents> POTION_CONTENTS = valued("potion_contents");
public static final DataComponentType.Valued<Float> POTION_DURATION_SCALE = valued("potion_duration_scale");
/**
* Holds the effects that will be applied when consuming Suspicious Stew.
*/
@@ -267,11 +284,14 @@ public final class DataComponentTypes {
* Holds the instrument type used by a Goat Horn.
*/
public static final DataComponentType.Valued<MusicInstrument> INSTRUMENT = valued("instrument");
// this is a either holder, but due to legacy item loading
public static final DataComponentType.Valued<TrimMaterial> PROVIDES_TRIM_MATERIAL = valued("provides_trim_material");
/**
* Controls the amplifier amount for an Ominous Bottle's Bad Omen effect.
*/
public static final DataComponentType.Valued<OminousBottleAmplifier> OMINOUS_BOTTLE_AMPLIFIER = valued("ominous_bottle_amplifier");
public static final DataComponentType.Valued<JukeboxPlayable> JUKEBOX_PLAYABLE = valued("jukebox_playable");
public static final DataComponentType.Valued<TagKey<PatternType>> PROVIDES_BANNER_PATTERNS = valued("provides_banner_patterns");
/**
* List of recipes that should be unlocked when using the Knowledge Book item.
*/
@@ -329,14 +349,50 @@ 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<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");
public static final DataComponentType.Valued<DyeColor> WOLF_COLLAR = valued("wolf/collar");
public static final DataComponentType.Valued<Fox.Type> FOX_VARIANT = valued("fox/variant");
public static final DataComponentType.Valued<Salmon.Variant> SALMON_SIZE = valued("salmon/size");
public static final DataComponentType.Valued<Parrot.Variant> PARROT_VARIANT = valued("parrot/variant");
public static final DataComponentType.Valued<TropicalFish.Pattern> TROPICAL_FISH_PATTERN = valued("tropical_fish/pattern");
public static final DataComponentType.Valued<DyeColor> TROPICAL_FISH_BASE_COLOR = valued("tropical_fish/base_color");
public static final DataComponentType.Valued<DyeColor> TROPICAL_FISH_PATTERN_COLOR = valued("tropical_fish/pattern_color");
public static final DataComponentType.Valued<MushroomCow.Variant> MOOSHROOM_VARIANT = valued("mooshroom/variant");
public static final DataComponentType.Valued<Rabbit.Type> RABBIT_VARIANT = valued("rabbit/variant");
public static final DataComponentType.Valued<Pig.Variant> PIG_VARIANT = valued("pig/variant");
public static final DataComponentType.Valued<Cow.Variant> COW_VARIANT = valued("cow/variant");
// TODO: This is a eitherholder? Why specifically the chicken?? Oh wait this is prolly for chicken egg cause legacy item loading
public static final DataComponentType.Valued<Chicken.Variant> CHICKEN_VARIANT = valued("chicken/variant");
public static final DataComponentType.Valued<Frog.Variant> FROG_VARIANT = valued("frog/variant");
public static final DataComponentType.Valued<Horse.Style> HORSE_VARIANT = valued("horse/variant");
public static final DataComponentType.Valued<Art> PAINTING_VARIANT = valued("painting/variant");
public static final DataComponentType.Valued<Llama.Color> LLAMA_VARIANT = valued("llama/variant");
public static final DataComponentType.Valued<Axolotl.Variant> AXOLOTL_VARIANT = valued("axolotl/variant");
public static final DataComponentType.Valued<Cat.Type> CAT_VARIANT = valued("cat/variant");
public static final DataComponentType.Valued<DyeColor> CAT_COLLAR = valued("cat/collar");
public static final DataComponentType.Valued<DyeColor> SHEEP_COLOR = valued("sheep/color");
public static final DataComponentType.Valued<DyeColor> SHULKER_COLOR = valued("shulker/color");
private static DataComponentType.NonValued unvalued(final String name) {
return (DataComponentType.NonValued) requireNonNull(Registry.DATA_COMPONENT_TYPE.get(NamespacedKey.minecraft(name)), name + " unvalued data component type couldn't be found, this is a bug.");
final DataComponentType dataComponentType = requireNonNull(Registry.DATA_COMPONENT_TYPE.get(NamespacedKey.minecraft(name)), name + " unvalued data component type couldn't be found, this is a bug.");
if (dataComponentType instanceof DataComponentType.NonValued) {
return (DataComponentType.NonValued) dataComponentType;
}
throw new IllegalStateException(name + " is not a valid unvalued type, it is a " + dataComponentType.getClass().getTypeName());
}
@SuppressWarnings("unchecked")
private static <T> DataComponentType.Valued<T> valued(final String name) {
return (DataComponentType.Valued<T>) requireNonNull(Registry.DATA_COMPONENT_TYPE.get(NamespacedKey.minecraft(name)), name + " valued data component type couldn't be found, this is a bug.");
DataComponentType dataComponentType = requireNonNull(Registry.DATA_COMPONENT_TYPE.get(NamespacedKey.minecraft(name)), name + " valued data component type couldn't be found, this is a bug.");
if (dataComponentType instanceof DataComponentType.Valued) {
return (DataComponentType.Valued<T>) dataComponentType;
}
throw new IllegalStateException(name + " is not a valid valued type, it is a " + dataComponentType.getClass().getTypeName());
}
private DataComponentTypes() {

View File

@@ -0,0 +1,65 @@
package io.papermc.paper.datacomponent;
import org.bukkit.Utility;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.NullMarked;
/**
* This represents a view of a data component holder. No
* methods on this interface mutate the holder.
*
* @see DataComponentHolder
*/
@NullMarked
@ApiStatus.NonExtendable
public interface DataComponentView {
// Paper start - data component API
/**
* Gets the value for the data component type on this stack.
*
* @param type the data component type
* @param <T> the value type
* @return the value for the data component type, or {@code null} if not set or marked as removed
* @see #hasData(io.papermc.paper.datacomponent.DataComponentType) for DataComponentType.NonValued
*/
@Contract(pure = true)
@ApiStatus.Experimental
public <T> @Nullable T getData(final DataComponentType.@NotNull Valued<T> type);
/**
* Gets the value for the data component type on this holder with
* a fallback value.
*
* @param type the data component type
* @param fallback the fallback value if the value isn't present
* @param <T> the value type
* @return the value for the data component type or the fallback value
*/
@Utility
@Contract(value = "_, !null -> !null", pure = true)
@ApiStatus.Experimental
public <T> @Nullable T getDataOrDefault(final DataComponentType.@NotNull Valued<? extends T> type, final @Nullable T fallback);
/**
* Checks if the data component type is set on this holder.
*
* @param type the data component type
* @return {@code true} if set, {@code false} otherwise
*/
@Contract(pure = true)
@ApiStatus.Experimental
boolean hasData(final io.papermc.paper.datacomponent.@NotNull DataComponentType type);
// Not applicable to entities
// /**
// * Gets all the data component types set on this holder.
// *
// * @return an immutable set of data component types
// */
// @Contract("-> new")
// @ApiStatus.Experimental
// java.util.@Unmodifiable Set<io.papermc.paper.datacomponent.@NotNull DataComponentType> getDataTypes();
}

View File

@@ -0,0 +1,68 @@
package io.papermc.paper.datacomponent.item;
import io.papermc.paper.datacomponent.DataComponentBuilder;
import io.papermc.paper.registry.tag.TagKey;
import net.kyori.adventure.key.Key;
import org.bukkit.damage.DamageType;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Contract;
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;
// TODO
@NullMarked
@ApiStatus.Experimental
@ApiStatus.NonExtendable
public interface BlocksAttacks {
@Contract(value = "-> new", pure = true)
static Builder blocksAttacks() {
return ItemComponentTypesBridge.bridge().blocksAttacks();
}
float blockDelaySeconds();
float disableCooldownScale();
//List<DamageReduction> damageReductions();
//ItemDamageFunction itemDamage();
@Nullable TagKey<DamageType> bypassedBy();
@Nullable Key blockSound();
@Nullable Key disableSound();
/**
* Builder for {@link BlocksAttacks}.
*/
@ApiStatus.Experimental
@ApiStatus.NonExtendable
interface Builder extends DataComponentBuilder<BlocksAttacks> {
@Contract(value = "_ -> this", mutates = "this")
Builder blockDelaySeconds(float delay);
@Contract(value = "_ -> this", mutates = "this")
Builder disableCooldownScale(float scale);
//@Contract(value = "_ -> this", mutates = "this")
//Builder addDamageReduction(DamageReduction reduction);
//@Contract(value = "_ -> this", mutates = "this")
//Builder damageReductions(List<DamageReduction> reductions);
//@Contract(value = "_ -> this", mutates = "this")
//Builder itemDamage(ItemDamageFunction function);
@Contract(value = "_ -> this", mutates = "this")
Builder bypassedBy(@Nullable TagKey<DamageType> bypassedBy);
@Contract(value = "_ -> this", mutates = "this")
Builder blockSound(@Nullable Key sound);
@Contract(value = "_ -> this", mutates = "this")
Builder disableSound(@Nullable Key sound);
}
}

View File

@@ -13,11 +13,11 @@ import org.jspecify.annotations.NullMarked;
@NullMarked
@ApiStatus.Experimental
@ApiStatus.NonExtendable
public interface DyedItemColor extends ShownInTooltip<DyedItemColor> {
public interface DyedItemColor {
@Contract(value = "_, _ -> new", pure = true)
static DyedItemColor dyedItemColor(final Color color, final boolean showInTooltip) {
return dyedItemColor().color(color).showInTooltip(showInTooltip).build();
static DyedItemColor dyedItemColor(final Color color) {
return dyedItemColor().color(color).build();
}
@Contract(value = "-> new", pure = true)
@@ -38,7 +38,7 @@ public interface DyedItemColor extends ShownInTooltip<DyedItemColor> {
*/
@ApiStatus.Experimental
@ApiStatus.NonExtendable
interface Builder extends ShownInTooltip.Builder<Builder>, DataComponentBuilder<DyedItemColor> {
interface Builder extends DataComponentBuilder<DyedItemColor> {
/**
* Sets the color of this builder.

View File

@@ -96,6 +96,14 @@ public interface Equippable extends BuildableDataComponent<Equippable, Equippabl
@Contract(pure = true)
boolean damageOnHurt();
/**
* Checks if the item should be equipped when interacting with an entity.
*
* @return true if it equips on interact, false otherwise
*/
@Contract(pure = true)
boolean equipOnInteract();
/**
* Builder for {@link Equippable}.
*/
@@ -165,5 +173,14 @@ public interface Equippable extends BuildableDataComponent<Equippable, Equippabl
*/
@Contract(value = "_ -> this", mutates = "this")
Builder damageOnHurt(boolean damageOnHurt);
/**
* Sets whether the item should be equipped when interacting with an entity.
*
* @param equipOnInteract true if it equips on interact
* @return the builder for chaining
*/
@Contract(value = "_ -> this", mutates = "this")
Builder equipOnInteract(boolean equipOnInteract);
}
}

View File

@@ -1,6 +1,7 @@
package io.papermc.paper.datacomponent.item;
import io.papermc.paper.block.BlockPredicate;
import io.papermc.paper.datacomponent.BuildableDataComponent;
import io.papermc.paper.datacomponent.DataComponentBuilder;
import java.util.List;
import org.jetbrains.annotations.ApiStatus;
@@ -16,7 +17,7 @@ import org.jspecify.annotations.NullMarked;
@NullMarked
@ApiStatus.Experimental
@ApiStatus.NonExtendable
public interface ItemAdventurePredicate extends ShownInTooltip<ItemAdventurePredicate> {
public interface ItemAdventurePredicate {
@Contract(value = "_ -> new", pure = true)
static ItemAdventurePredicate itemAdventurePredicate(final List<BlockPredicate> predicates) {
@@ -41,7 +42,7 @@ public interface ItemAdventurePredicate extends ShownInTooltip<ItemAdventurePred
*/
@ApiStatus.Experimental
@ApiStatus.NonExtendable
interface Builder extends ShownInTooltip.Builder<Builder>, DataComponentBuilder<ItemAdventurePredicate> {
interface Builder extends DataComponentBuilder<ItemAdventurePredicate> {
/**
* Adds a block predicate to this builder.
*

View File

@@ -13,12 +13,7 @@ import org.jspecify.annotations.NullMarked;
@NullMarked
@ApiStatus.Experimental
@ApiStatus.NonExtendable
public interface ItemArmorTrim extends ShownInTooltip<ItemArmorTrim> {
@Contract(value = "_, _ -> new", pure = true)
static ItemArmorTrim itemArmorTrim(final ArmorTrim armorTrim, final boolean showInTooltip) {
return itemArmorTrim(armorTrim).showInTooltip(showInTooltip).build();
}
public interface ItemArmorTrim {
@Contract(value = "_ -> new", pure = true)
static ItemArmorTrim.Builder itemArmorTrim(final ArmorTrim armorTrim) {
@@ -38,7 +33,7 @@ public interface ItemArmorTrim extends ShownInTooltip<ItemArmorTrim> {
*/
@ApiStatus.Experimental
@ApiStatus.NonExtendable
interface Builder extends ShownInTooltip.Builder<Builder>, DataComponentBuilder<ItemArmorTrim> {
interface Builder extends DataComponentBuilder<ItemArmorTrim> {
/**
* Sets the armor trim for this builder.

View File

@@ -17,7 +17,7 @@ import org.jspecify.annotations.NullMarked;
@NullMarked
@ApiStatus.Experimental
@ApiStatus.NonExtendable
public interface ItemAttributeModifiers extends ShownInTooltip<ItemAttributeModifiers> {
public interface ItemAttributeModifiers {
@Contract(value = "-> new", pure = true)
static ItemAttributeModifiers.Builder itemAttributes() {
@@ -69,7 +69,7 @@ public interface ItemAttributeModifiers extends ShownInTooltip<ItemAttributeModi
*/
@ApiStatus.Experimental
@ApiStatus.NonExtendable
interface Builder extends ShownInTooltip.Builder<Builder>, DataComponentBuilder<ItemAttributeModifiers> {
interface Builder extends DataComponentBuilder<ItemAttributeModifiers> {
/**
* Adds a modifier to this builder.

View File

@@ -34,8 +34,6 @@ interface ItemComponentTypesBridge {
PotDecorations.Builder potDecorations();
Unbreakable.Builder unbreakable();
ItemLore.Builder lore();
ItemEnchantments.Builder enchantments();
@@ -109,4 +107,10 @@ interface ItemComponentTypesBridge {
DeathProtection.Builder deathProtection();
OminousBottleAmplifier ominousBottleAmplifier(int amplifier);
BlocksAttacks.Builder blocksAttacks();
TooltipDisplay.Builder tooltipDisplay();
Weapon.Builder weapon();
}

View File

@@ -17,11 +17,11 @@ import org.jspecify.annotations.NullMarked;
@NullMarked
@ApiStatus.Experimental
@ApiStatus.NonExtendable
public interface ItemEnchantments extends ShownInTooltip<ItemEnchantments> {
public interface ItemEnchantments {
@Contract(value = "_, _ -> new", pure = true)
static ItemEnchantments itemEnchantments(final Map<Enchantment, @IntRange(from = 1, to = 255) Integer> enchantments, final boolean showInTooltip) {
return itemEnchantments().addAll(enchantments).showInTooltip(showInTooltip).build();
static ItemEnchantments itemEnchantments(final Map<Enchantment, @IntRange(from = 1, to = 255) Integer> enchantments) {
return itemEnchantments().addAll(enchantments).build();
}
@Contract(value = "-> new", pure = true)
@@ -42,7 +42,7 @@ public interface ItemEnchantments extends ShownInTooltip<ItemEnchantments> {
*/
@ApiStatus.Experimental
@ApiStatus.NonExtendable
interface Builder extends ShownInTooltip.Builder<Builder>, DataComponentBuilder<ItemEnchantments> {
interface Builder extends DataComponentBuilder<ItemEnchantments> {
/**
* Adds an enchantment with the given level to this component.

View File

@@ -13,7 +13,7 @@ import org.jspecify.annotations.NullMarked;
@NullMarked
@ApiStatus.Experimental
@ApiStatus.NonExtendable
public interface JukeboxPlayable extends ShownInTooltip<JukeboxPlayable> {
public interface JukeboxPlayable {
@Contract(value = "_ -> new", pure = true)
static JukeboxPlayable.Builder jukeboxPlayable(final JukeboxSong song) {
@@ -28,7 +28,7 @@ public interface JukeboxPlayable extends ShownInTooltip<JukeboxPlayable> {
*/
@ApiStatus.Experimental
@ApiStatus.NonExtendable
interface Builder extends ShownInTooltip.Builder<JukeboxPlayable.Builder>, DataComponentBuilder<JukeboxPlayable> {
interface Builder extends DataComponentBuilder<JukeboxPlayable> {
/**
* Sets the jukebox song.

View File

@@ -1,55 +0,0 @@
package io.papermc.paper.datacomponent.item;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Contract;
import org.jspecify.annotations.NullMarked;
/**
* Holds the state of whether a data component should be shown
* in an item's tooltip.
*
* @param <T> the data component type
*/
@NullMarked
@ApiStatus.Experimental
@ApiStatus.NonExtendable
public interface ShownInTooltip<T> {
/**
* Gets if the data component should be shown in the item's tooltip.
*
* @return {@code true} to show in the tooltip
*/
@Contract(pure = true)
boolean showInTooltip();
/**
* Returns a copy of this data component with the specified
* show-in-tooltip state.
*
* @param showInTooltip {@code true} to show in the tooltip
* @return the new data component
*/
@Contract(value = "_ -> new", pure = true)
T showInTooltip(boolean showInTooltip);
/**
* A builder for creating a {@link ShownInTooltip} data component.
*
* @param <B> builder type
*/
@ApiStatus.Experimental
@ApiStatus.NonExtendable
interface Builder<B> {
/**
* Sets if the data component should be shown in the item's tooltip.
*
* @param showInTooltip {@code true} to show in the tooltip
* @return the builder for chaining
* @see #showInTooltip()
*/
@Contract(value = "_ -> this", mutates = "this")
B showInTooltip(boolean showInTooltip);
}
}

View File

@@ -71,6 +71,14 @@ public interface Tool {
@Contract(pure = true)
@Unmodifiable List<Tool.Rule> rules();
/**
* Whether this tool can destroy blocks in creative mode.
*
* @return whether this tool can destroy blocks in creative mode
*/
@Contract(pure = true)
boolean canDestroyBlocksInCreative();
@ApiStatus.Experimental
@ApiStatus.NonExtendable
interface Rule {
@@ -136,6 +144,16 @@ public interface Tool {
@Contract(value = "_ -> this", mutates = "this")
Builder addRule(Rule rule);
/**
* Controls whether this tool can destroy blocks in creative mode.
*
* @param canDestroyBlocksInCreative whether this tool can destroy blocks in creative mode
* @return the builder for chaining
* @see #canDestroyBlocksInCreative()
*/
@Contract(value = "_ -> this", mutates = "this")
Builder canDestroyBlocksInCreative(boolean canDestroyBlocksInCreative);
/**
* Adds rules to the tool that control the breaking speed / damage per block if matched.
*

View File

@@ -0,0 +1,46 @@
package io.papermc.paper.datacomponent.item;
import io.papermc.paper.datacomponent.DataComponentBuilder;
import io.papermc.paper.datacomponent.DataComponentType;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Contract;
import org.jspecify.annotations.NullMarked;
import java.util.Set;
@NullMarked
@ApiStatus.Experimental
@ApiStatus.NonExtendable
public interface TooltipDisplay {
/**
* Returns a new builder for creating a TooltipDisplay.
*
* @return a builder
*/
@Contract(value = "-> new", pure = true)
static Builder tooltipDisplay() {
return ItemComponentTypesBridge.bridge().tooltipDisplay();
}
boolean hideTooltip();
Set<DataComponentType> hiddenComponents();
/**
* Builder for {@link TooltipDisplay}.
*/
@ApiStatus.Experimental
@ApiStatus.NonExtendable
interface Builder extends DataComponentBuilder<TooltipDisplay> {
@Contract(value = "_ -> this", mutates = "this")
Builder hideTooltip(boolean hide);
@Contract(value = "_ -> this", mutates = "this")
Builder addHiddenComponents(DataComponentType... components);
@Contract(value = "_ -> this", mutates = "this")
Builder hiddenComponents(Set<DataComponentType> components);
}
}

View File

@@ -1,34 +0,0 @@
package io.papermc.paper.datacomponent.item;
import io.papermc.paper.datacomponent.DataComponentBuilder;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Contract;
import org.jspecify.annotations.NullMarked;
/**
* If set, the item will not lose any durability when used.
* @see io.papermc.paper.datacomponent.DataComponentTypes#UNBREAKABLE
*/
@NullMarked
@ApiStatus.Experimental
@ApiStatus.NonExtendable
public interface Unbreakable extends ShownInTooltip<Unbreakable> {
@Contract(value = "_ -> new", pure = true)
static Unbreakable unbreakable(final boolean showInTooltip) {
return unbreakable().showInTooltip(showInTooltip).build();
}
@Contract(value = "-> new", pure = true)
static Unbreakable.Builder unbreakable() {
return ItemComponentTypesBridge.bridge().unbreakable();
}
/**
* Builder for {@link Unbreakable}.
*/
@ApiStatus.Experimental
@ApiStatus.NonExtendable
interface Builder extends ShownInTooltip.Builder<Builder>, DataComponentBuilder<Unbreakable> {
}
}

View File

@@ -0,0 +1,54 @@
package io.papermc.paper.datacomponent.item;
import io.papermc.paper.datacomponent.DataComponentBuilder;
import org.jetbrains.annotations.ApiStatus;
import org.jspecify.annotations.NullMarked;
@NullMarked
@ApiStatus.Experimental
@ApiStatus.NonExtendable
public interface Weapon {
/**
* Returns a new builder for creating a Weapon.
*
* @return a builder instance.
*/
static Builder weapon() {
return ItemComponentTypesBridge.bridge().weapon();
}
/**
* The damage that the weapon deals per attack.
*/
int itemDamagePerAttack();
/**
* The number of seconds that blocking is disabled.
*/
float disableBlockingForSeconds();
/**
* Builder for {@link Weapon}.
*/
@ApiStatus.Experimental
@ApiStatus.NonExtendable
interface Builder extends DataComponentBuilder<Weapon> {
/**
* Sets the damage per attack.
*
* @param damage the damage value.
* @return the builder for chaining.
*/
Builder itemDamagePerAttack(int damage);
/**
* Sets the disable blocking duration (in seconds).
*
* @param seconds the duration in seconds.
* @return the builder for chaining.
*/
Builder disableBlockingForSeconds(float seconds);
}
}

View File

@@ -4,6 +4,8 @@ package io.papermc.paper.datacomponent.item.consumable;
* Represents the hand animation that is used when a player is consuming this item.
*/
public enum ItemUseAnimation {
// Start generate - ItemUseAnimation
// @GeneratedFrom 1.21.5
NONE,
EAT,
DRINK,
@@ -14,5 +16,6 @@ public enum ItemUseAnimation {
SPYGLASS,
TOOT_HORN,
BRUSH,
BUNDLE
BUNDLE;
// End generate - ItemUseAnimation
}

View File

@@ -17,8 +17,8 @@ public class BeaconActivatedEvent extends BlockEvent {
private static final HandlerList HANDLER_LIST = new HandlerList();
@ApiStatus.Internal
public BeaconActivatedEvent(final Block block) {
super(block);
public BeaconActivatedEvent(final Block beacon) {
super(beacon);
}
/**

View File

@@ -18,8 +18,8 @@ public class BeaconDeactivatedEvent extends BlockEvent {
private static final HandlerList HANDLER_LIST = new HandlerList();
@ApiStatus.Internal
public BeaconDeactivatedEvent(final Block block) {
super(block);
public BeaconDeactivatedEvent(final Block beacon) {
super(beacon);
}
/**

View File

@@ -22,8 +22,8 @@ public class BellRevealRaiderEvent extends BlockEvent implements Cancellable {
private boolean cancelled;
@ApiStatus.Internal
public BellRevealRaiderEvent(@NotNull Block theBlock, @NotNull Raider raider) {
super(theBlock);
public BellRevealRaiderEvent(@NotNull Block bell, @NotNull Raider raider) {
super(bell);
this.raider = raider;
}

View File

@@ -17,8 +17,8 @@ public class BlockFailedDispenseEvent extends BlockEvent {
private boolean shouldPlayEffect = true;
@ApiStatus.Internal
public BlockFailedDispenseEvent(final Block theBlock) {
super(theBlock);
public BlockFailedDispenseEvent(final Block block) {
super(block);
}
/**

View File

@@ -31,7 +31,6 @@ public class EntityFertilizeEggEvent extends EntityEvent implements Cancellable
private static final HandlerList HANDLER_LIST = new HandlerList();
private final LivingEntity mother;
private final LivingEntity father;
private final @Nullable Player breeder;
private final @Nullable ItemStack bredWith;
@@ -42,7 +41,6 @@ public class EntityFertilizeEggEvent extends EntityEvent implements Cancellable
@ApiStatus.Internal
public EntityFertilizeEggEvent(final LivingEntity mother, final LivingEntity father, final @Nullable Player breeder, final @Nullable ItemStack bredWith, final int experience) {
super(mother);
this.mother = mother;
this.father = father;
this.breeder = breeder;
this.bredWith = bredWith;
@@ -61,7 +59,7 @@ public class EntityFertilizeEggEvent extends EntityEvent implements Cancellable
* @return The "mother" entity.
*/
public LivingEntity getMother() {
return this.mother;
return this.getEntity();
}
/**

View File

@@ -39,9 +39,9 @@ public abstract class AbstractChatEvent extends PlayerEvent implements Cancellab
/**
* Gets a set of {@link Audience audiences} that this chat message will be displayed to.
*
* <p>The set returned may auto-populate on access. Any listener accessing the returned set should be aware that
* it may reduce performance for a lazy set implementation.</p>
* <p>
* The set returned may auto-populate on access. Any listener accessing the returned set should be aware that
* it may reduce performance for a lazy set implementation.
*
* @return a mutable set of {@link Audience audiences} who will receive the chat message
*/

View File

@@ -42,7 +42,7 @@ public class AsyncChatDecorateEvent extends ServerEvent implements Cancellable {
* Gets the player (if available) associated with this event.
* <p>
* Certain commands request decorations without a player context
* which is why this is possibly null.
* which is why this is possibly {@code null}.
*
* @return the player or {@code null}
*/

View File

@@ -20,8 +20,8 @@ public class PlayerClientLoadedWorldEvent extends PlayerEvent {
private final boolean timeout;
@ApiStatus.Internal
public PlayerClientLoadedWorldEvent(final Player who, final boolean timeout) {
super(who);
public PlayerClientLoadedWorldEvent(final Player player, final boolean timeout) {
super(player);
this.timeout = timeout;
}

View File

@@ -19,8 +19,11 @@ 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.Chicken;
import org.bukkit.entity.Cow;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Frog;
import org.bukkit.entity.Pig;
import org.bukkit.entity.Villager;
import org.bukkit.entity.Wolf;
import org.bukkit.entity.memory.MemoryKey;
@@ -79,20 +82,11 @@ public sealed interface RegistryKey<T> extends Keyed permits RegistryKeyImpl {
RegistryKey<BlockType> BLOCK = create("block");
/**
* @apiNote use preferably only in the context of registry entries.
* @see io.papermc.paper.registry.data
* @see io.papermc.paper.registry.keys.ItemTypeKeys
*/
@ApiStatus.Experimental // Paper - already required for registry builders
RegistryKey<ItemType> ITEM = create("item");
/**
* Built-in registry for cat variants.
* @see io.papermc.paper.registry.keys.CatVariantKeys
*/
RegistryKey<Cat.Type> CAT_VARIANT = create("cat_variant");
/**
* Built-in registry for frog variants.
* @see io.papermc.paper.registry.keys.FrogVariantKeys
*/
RegistryKey<Frog.Variant> FROG_VARIANT = create("frog_variant");
/**
* Built-in registry for villager professions.
* @see io.papermc.paper.registry.keys.VillagerProfessionKeys
@@ -130,7 +124,7 @@ public sealed interface RegistryKey<T> extends Keyed permits RegistryKeyImpl {
RegistryKey<Sound> SOUND_EVENT = create("sound_event");
/**
* Built-in registry for data component types.
* <!-- @see io.papermc.paper.registry.keys.DataComponentTypeKeys -->
* @see io.papermc.paper.registry.keys.DataComponentTypeKeys
*/
RegistryKey<DataComponentType> DATA_COMPONENT_TYPE = create("data_component_type");
@@ -169,6 +163,11 @@ public sealed interface RegistryKey<T> extends Keyed permits RegistryKeyImpl {
* @see io.papermc.paper.registry.keys.WolfVariantKeys
*/
RegistryKey<Wolf.Variant> WOLF_VARIANT = create("wolf_variant");
/**
* Data-driven registry for wolf sound variants.
* @see io.papermc.paper.registry.keys.WolfSoundVariantKeys
*/
RegistryKey<Wolf.SoundVariant> WOLF_SOUND_VARIANT = create("wolf_sound_variant");
/**
* Data-driven registry for enchantments.
* @see io.papermc.paper.registry.keys.EnchantmentKeys
@@ -194,6 +193,32 @@ public sealed interface RegistryKey<T> extends Keyed permits RegistryKeyImpl {
* @see io.papermc.paper.registry.keys.InstrumentKeys
*/
RegistryKey<MusicInstrument> INSTRUMENT = create("instrument");
/**
* Data-driven registry for cat variants.
* @see io.papermc.paper.registry.keys.CatVariantKeys
*/
RegistryKey<Cat.Type> CAT_VARIANT = create("cat_variant");
/**
* Data-driven registry for frog variants.
* @see io.papermc.paper.registry.keys.FrogVariantKeys
*/
RegistryKey<Frog.Variant> FROG_VARIANT = create("frog_variant");
/**
* Data-driven registry for chicken variants.
* @see io.papermc.paper.registry.keys.ChickenVariantKeys
*/
RegistryKey<Chicken.Variant> CHICKEN_VARIANT = create("chicken_variant");
/**
* Data-driven registry for cow variants.
* @see io.papermc.paper.registry.keys.CowVariantKeys
*/
RegistryKey<Cow.Variant> COW_VARIANT = create("cow_variant");
/**
* Data-driven registry for pig variants.
* @see io.papermc.paper.registry.keys.PigVariantKeys
*/
RegistryKey<Pig.Variant> PIG_VARIANT = create("pig_variant");
/* ******************* *

View File

@@ -24,11 +24,14 @@ import static io.papermc.paper.registry.event.RegistryEventProviderImpl.create;
@NullMarked
public final class RegistryEvents {
// Start generate - RegistryEvents
// @GeneratedFrom 1.21.5
public static final RegistryEventProvider<GameEvent, GameEventRegistryEntry.Builder> GAME_EVENT = create(RegistryKey.GAME_EVENT);
public static final RegistryEventProvider<Enchantment, EnchantmentRegistryEntry.Builder> ENCHANTMENT = create(RegistryKey.ENCHANTMENT);
public static final RegistryEventProvider<Art, PaintingVariantRegistryEntry.Builder> PAINTING_VARIANT = create(RegistryKey.PAINTING_VARIANT);
public static final RegistryEventProvider<PatternType, BannerPatternRegistryEntry.Builder> BANNER_PATTERN = create(RegistryKey.BANNER_PATTERN);
public static final RegistryEventProvider<DamageType, DamageTypeRegistryEntry.Builder> DAMAGE_TYPE = create(RegistryKey.DAMAGE_TYPE);
public static final RegistryEventProvider<Enchantment, EnchantmentRegistryEntry.Builder> ENCHANTMENT = create(RegistryKey.ENCHANTMENT);
public static final RegistryEventProvider<PatternType, BannerPatternRegistryEntry.Builder> BANNER_PATTERN = create(RegistryKey.BANNER_PATTERN);
public static final RegistryEventProvider<Art, PaintingVariantRegistryEntry.Builder> PAINTING_VARIANT = create(RegistryKey.PAINTING_VARIANT);
// End generate - RegistryEvents
private RegistryEvents() {
}