Banner pattern registry modification (#11803)

This commit is contained in:
kokiriglade
2024-12-26 23:57:34 +00:00
committed by GitHub
parent aac246ae29
commit 953f6f929e
4 changed files with 135 additions and 1 deletions

View File

@ -0,0 +1,65 @@
package io.papermc.paper.registry.data;
import io.papermc.paper.registry.RegistryBuilder;
import net.kyori.adventure.key.Key;
import org.bukkit.block.banner.PatternType;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Contract;
/**
* A data-centric version-specific registry entry for the {@link PatternType} type.
*/
@ApiStatus.Experimental
@ApiStatus.NonExtendable
public interface BannerPatternRegistryEntry {
/**
* Provides the asset id of the pattern type, which is the location of the sprite to use.
*
* @return the asset id.
*/
Key assetId();
/**
* Provides the translation key for displaying the pattern inside the banner's tooltip.
*
* @return the translation key.
*/
String translationKey();
/**
* A mutable builder for the {@link BannerPatternRegistryEntry} plugins may change in applicable registry events.
* <p>
* The following values are required for each builder:
* <ul>
* <li>{@link #assetId(Key)}</li>
* <li>{@link #translationKey(String)}</li>
* </ul>
*/
@ApiStatus.Experimental
@ApiStatus.NonExtendable
interface Builder extends BannerPatternRegistryEntry, RegistryBuilder<PatternType> {
/**
* Sets the asset id of the pattern type, which is the location of the sprite to use.
*
* @param assetId the asset id.
* @return this builder instance.
* @see BannerPatternRegistryEntry#assetId()
*/
@Contract(value = "_ -> this", mutates = "this")
Builder assetId(Key assetId);
/**
* Sets the translation key for displaying the pattern inside the banner's tooltip.
*
* @param translationKey the translation key.
* @return this builder instance.
* @see BannerPatternRegistryEntry#translationKey()
*/
@Contract(value = "_ -> this", mutates = "this")
Builder translationKey(String translationKey);
}
}

View File

@ -1,11 +1,13 @@
package io.papermc.paper.registry.event;
import io.papermc.paper.registry.RegistryKey;
import io.papermc.paper.registry.data.BannerPatternRegistryEntry;
import io.papermc.paper.registry.data.EnchantmentRegistryEntry;
import io.papermc.paper.registry.data.GameEventRegistryEntry;
import io.papermc.paper.registry.data.PaintingVariantRegistryEntry;
import org.bukkit.Art;
import org.bukkit.GameEvent;
import org.bukkit.block.banner.PatternType;
import org.bukkit.enchantments.Enchantment;
import org.jetbrains.annotations.ApiStatus;
import org.jspecify.annotations.NullMarked;
@ -23,6 +25,7 @@ public final class RegistryEvents {
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);
private RegistryEvents() {
}