split direct holder support up from ctor accepting Holder

Enchantment shouldn't support direct holders despite the ctor
accepting a Holder type. We want to limit the types
to ones that are actually used as direct holders in the game
This commit is contained in:
Jake Potrebic
2025-01-13 20:12:13 -08:00
parent 6fde26d7f8
commit fe75eaf09a
12 changed files with 70 additions and 58 deletions

View File

@@ -1,5 +1,11 @@
package io.papermc.testplugin;
import io.papermc.paper.event.player.ChatEvent;
import io.papermc.paper.registry.keys.PaintingVariantKeys;
import org.bukkit.Art;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Painting;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.plugin.java.JavaPlugin;
@@ -12,4 +18,11 @@ public final class TestPlugin extends JavaPlugin implements Listener {
// io.papermc.testplugin.brigtests.Registration.registerViaOnEnable(this);
}
@EventHandler
public void onEvent(ChatEvent event) {
final Entity targetEntity = event.getPlayer().getTargetEntity(10);
if (targetEntity instanceof Painting painting) {
painting.setArt(Art.create(f -> f.copyFrom(PaintingVariantKeys.BAROQUE).height(10)));
}
}
}