From 821c34376761302db221385259b6870cdeed2109 Mon Sep 17 00:00:00 2001 From: Tsumiki Miniwa <37684627+cpaca@users.noreply.github.com> Date: Sun, 14 Sep 2025 19:32:00 -0700 Subject: [PATCH 01/80] Update to 1.21 - WARNING: DOESN'T WORK ProtocolLib note: 5.2.0-SNAPSHOT wasn't working, so I just made it 5.4.0. I don't know what ProtocolLib is being used for, so I'm leaving it at this until we put more thought into it. Future commits will be about fixing all of the bugs (some things got removed/deprecated.) --- build.gradle.kts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index a677e415..5da7a6ef 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -11,7 +11,7 @@ description = "A plugin for HoloCons SMP that adds a ton of custom items and blo java { // Configure the java toolchain. This allows gradle to auto-provision JDK 17 on systems that only have JDK 8 installed for example. - toolchain.languageVersion.set(JavaLanguageVersion.of(17)) + toolchain.languageVersion.set(JavaLanguageVersion.of(21)) } repositories { @@ -21,8 +21,8 @@ repositories { } dependencies { - compileOnly("io.papermc.paper:paper-api:1.20.1-R0.1-SNAPSHOT") - compileOnly("com.comphenix.protocol:ProtocolLib:5.2.0-SNAPSHOT") + compileOnly("io.papermc.paper:paper-api:1.21.1-R0.1-SNAPSHOT") + compileOnly("com.comphenix.protocol:ProtocolLib:5.4.0-SNAPSHOT") compileOnly("com.sk89q.worldguard:worldguard-bukkit:7.0.9") implementation("com.github.stefvanschie.inventoryframework:IF:0.10.13") } @@ -38,7 +38,7 @@ tasks { // Set the release flag. This configures what version bytecode the compiler will emit, as well as what JDK APIs are usable. // See https://openjdk.java.net/jeps/247 for more information. - options.release.set(17) + options.release.set(21) } javadoc { options.encoding = Charsets.UTF_8.name() // We want UTF-8 for everything @@ -64,7 +64,7 @@ tasks { // Configure the Minecraft version for runServer task // https://github.com/jpenilla/run-paper runServer { - minecraftVersion("1.20.1") + minecraftVersion("1.21") } } @@ -72,7 +72,7 @@ tasks { // https://github.com/Minecrell/plugin-yml bukkit { main = "xyz.holocons.mc.holoitemsrevamp.HoloItemsRevamp" - apiVersion = "1.20" + apiVersion = "1.21" authors = listOf("TraceL", "dlee13") website = "holocons.xyz" depend = listOf("ProtocolLib") From d7effeee48b2d27d608023c43415e7e7d80a4a69 Mon Sep 17 00:00:00 2001 From: Tsumiki Miniwa <37684627+cpaca@users.noreply.github.com> Date: Sun, 14 Sep 2025 19:33:44 -0700 Subject: [PATCH 02/80] Remove EnchantmentRarity "As of 1.20.5 enchantments do not have a rarity." https://jd.papermc.io/paper/1.21.8/org/bukkit/enchantments/Enchantment.html --- .../holoitemsapi/enchantment/CustomEnchantment.java | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/main/java/com/strangeone101/holoitemsapi/enchantment/CustomEnchantment.java b/src/main/java/com/strangeone101/holoitemsapi/enchantment/CustomEnchantment.java index c7e1b019..19de5a74 100644 --- a/src/main/java/com/strangeone101/holoitemsapi/enchantment/CustomEnchantment.java +++ b/src/main/java/com/strangeone101/holoitemsapi/enchantment/CustomEnchantment.java @@ -1,6 +1,5 @@ package com.strangeone101.holoitemsapi.enchantment; -import io.papermc.paper.enchantments.EnchantmentRarity; import net.kyori.adventure.text.Component; import org.bukkit.NamespacedKey; @@ -117,11 +116,6 @@ public boolean isDiscoverable() { return false; } - @Override - public @NotNull EnchantmentRarity getRarity() { - return EnchantmentRarity.VERY_RARE; - } - @Override public float getDamageIncrease(int level, @NotNull EntityCategory entityCategory) { return 0; From 5146f011b283340a8d301eabc73142dc4b88959b Mon Sep 17 00:00:00 2001 From: Tsumiki Miniwa <37684627+cpaca@users.noreply.github.com> Date: Sun, 14 Sep 2025 19:37:16 -0700 Subject: [PATCH 03/80] getActiveSlots is deprecated. It's been replaced with getActiveSlotGroups. From what I can tell, the function isn't used anyway, but it's here. I'm getting the vibe I should delete the whole file. --- .../holoitemsapi/enchantment/CustomEnchantment.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/strangeone101/holoitemsapi/enchantment/CustomEnchantment.java b/src/main/java/com/strangeone101/holoitemsapi/enchantment/CustomEnchantment.java index 19de5a74..9b74c037 100644 --- a/src/main/java/com/strangeone101/holoitemsapi/enchantment/CustomEnchantment.java +++ b/src/main/java/com/strangeone101/holoitemsapi/enchantment/CustomEnchantment.java @@ -6,7 +6,7 @@ import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.EnchantmentTarget; import org.bukkit.entity.EntityCategory; -import org.bukkit.inventory.EquipmentSlot; +import org.bukkit.inventory.EquipmentSlotGroup; import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.Plugin; import org.jetbrains.annotations.NotNull; @@ -122,7 +122,7 @@ public float getDamageIncrease(int level, @NotNull EntityCategory entityCategory } @Override - public @NotNull Set getActiveSlots() { + public @NotNull Set getActiveSlotGroups() { return null; } } From 2c69fff414eabf476599271be322e2242359c065 Mon Sep 17 00:00:00 2001 From: Tsumiki Miniwa <37684627+cpaca@users.noreply.github.com> Date: Sun, 14 Sep 2025 19:47:07 -0700 Subject: [PATCH 04/80] Revamp EnchantmentListener --- .../holoitemsapi/enchantment/EnchantmentListener.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/strangeone101/holoitemsapi/enchantment/EnchantmentListener.java b/src/main/java/com/strangeone101/holoitemsapi/enchantment/EnchantmentListener.java index 5e662b18..630b1796 100644 --- a/src/main/java/com/strangeone101/holoitemsapi/enchantment/EnchantmentListener.java +++ b/src/main/java/com/strangeone101/holoitemsapi/enchantment/EnchantmentListener.java @@ -3,6 +3,7 @@ import java.util.function.Consumer; import org.bukkit.Material; +import org.bukkit.NamespacedKey; import org.bukkit.entity.ThrowableProjectile; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -19,9 +20,15 @@ public class EnchantmentListener implements Listener { private static void forEachEnchantment(final ItemStack itemStack, final Consumer action) { itemStack.getEnchantments().keySet().forEach(enchantment -> { - if (enchantment instanceof EnchantmentAbility ability) { - action.accept(ability); + NamespacedKey enchKey = enchantment.getKey(); + if (enchKey.getNamespace().equals("holocons")) { + String name = enchKey.getKey(); + // TODO: Need to convert from name to EnchantmentAbility somehow. + // Current guess is probably something to do with CustomEnchantment } +// if (enchantment instanceof EnchantmentAbility ability) { +// action.accept(ability); +// } }); } From b9d9a08f93c551f5ba2bd5ff1904704dabc65e04 Mon Sep 17 00:00:00 2001 From: Tsumiki Miniwa <37684627+cpaca@users.noreply.github.com> Date: Sun, 14 Sep 2025 20:08:46 -0700 Subject: [PATCH 05/80] Reset CustomEnchantment to scratch I might have removed too much, but from what I can tell, everything I removed was just added because it was required by the old class. I kept getCostMultiplier as it's used by AnvilListener, and lore as it's not @Override. --- .../enchantment/CustomEnchantment.java | 86 ++----------------- 1 file changed, 5 insertions(+), 81 deletions(-) diff --git a/src/main/java/com/strangeone101/holoitemsapi/enchantment/CustomEnchantment.java b/src/main/java/com/strangeone101/holoitemsapi/enchantment/CustomEnchantment.java index 9b74c037..46704ba2 100644 --- a/src/main/java/com/strangeone101/holoitemsapi/enchantment/CustomEnchantment.java +++ b/src/main/java/com/strangeone101/holoitemsapi/enchantment/CustomEnchantment.java @@ -3,41 +3,19 @@ import net.kyori.adventure.text.Component; import org.bukkit.NamespacedKey; -import org.bukkit.enchantments.Enchantment; -import org.bukkit.enchantments.EnchantmentTarget; -import org.bukkit.entity.EntityCategory; -import org.bukkit.inventory.EquipmentSlotGroup; -import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.Plugin; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.HashMap; -import java.util.Set; -/** - * An abstract class to implement custom enchantments. Unsurprisingly, The Bukkit API has no capabilities of adding custom - * enchantments to the enchanting table. Most of these methods here are practically useless because they were meant for - * enchantments that would appear in the enchantment table. However, that will not happen because, again, Bukkit has no capabilities - * of adding it. So, most of the Enchantment methods are set to default values. - * - * Some methods, like {@link Enchantment#displayName(int)} and {@link Enchantment#canEnchantItem(ItemStack)} aren't implemented. - * While they also do nothing, they might help in setting enchantment lores, and validating anvil crafts. - */ -public abstract class CustomEnchantment extends Enchantment { +public abstract class CustomEnchantment { private static final HashMap enchantmentsByKey = new HashMap<>(); public CustomEnchantment(Plugin plugin, String key) { - super(new NamespacedKey(plugin, key)); - } - - public static final void registerEnchantment(@NotNull CustomEnchantment enchantment) { - if (!Enchantment.isAcceptingRegistrations()) { - return; - } - Enchantment.registerEnchantment(enchantment); - enchantmentsByKey.put(enchantment.getKey(), enchantment); + // TODO: Should I just put the in there? since the namespace seems to always be anyway? + enchantmentsByKey.put(new NamespacedKey(plugin, key), this); } /** @@ -50,6 +28,8 @@ public static final CustomEnchantment getByKey(@Nullable NamespacedKey key) { return enchantmentsByKey.get(key); } + public abstract Component displayName(int level); + /** * Gets the lore that will be applied to items that have this enchantment. Lore will * not be applied if this returns null. @@ -69,60 +49,4 @@ public Component lore(int level) { */ public abstract int getCostMultiplier(); - @NotNull - @Deprecated - @Override - public final String getName() { - return name(); - } - - @NotNull - public final String name() { - return getKey().getKey(); - } - - @Override - public @NotNull String translationKey() { - return ""; - } - - @Override - public int getStartLevel() { - return 1; - } - - @Override - public @NotNull EnchantmentTarget getItemTarget() { - return null; - } - - @Override - public boolean isTreasure() { - return false; - } - - @Override - public boolean isCursed() { - return false; - } - - @Override - public boolean isTradeable() { - return false; - } - - @Override - public boolean isDiscoverable() { - return false; - } - - @Override - public float getDamageIncrease(int level, @NotNull EntityCategory entityCategory) { - return 0; - } - - @Override - public @NotNull Set getActiveSlotGroups() { - return null; - } } From ae8eaadc0ea49b01cf2b106ba54ba7cbd5719edc Mon Sep 17 00:00:00 2001 From: Tsumiki Miniwa <37684627+cpaca@users.noreply.github.com> Date: Sun, 14 Sep 2025 22:16:06 -0700 Subject: [PATCH 06/80] Nuking AnvilListener Not sure what it needs yet, but I do think it still needs to exist. --- .../enchantment/AnvilListener.java | 235 ------------------ 1 file changed, 235 deletions(-) diff --git a/src/main/java/com/strangeone101/holoitemsapi/enchantment/AnvilListener.java b/src/main/java/com/strangeone101/holoitemsapi/enchantment/AnvilListener.java index eb5cfcc8..fa5ab887 100644 --- a/src/main/java/com/strangeone101/holoitemsapi/enchantment/AnvilListener.java +++ b/src/main/java/com/strangeone101/holoitemsapi/enchantment/AnvilListener.java @@ -1,247 +1,12 @@ package com.strangeone101.holoitemsapi.enchantment; - -import com.strangeone101.holoitemsapi.item.CustomItemManager; -import net.kyori.adventure.text.Component; -import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer; -import org.bukkit.GameMode; -import org.bukkit.Material; -import org.bukkit.enchantments.Enchantment; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; -import org.bukkit.event.inventory.InventoryCloseEvent; -import org.bukkit.event.inventory.PrepareAnvilEvent; -import org.bukkit.inventory.AnvilInventory; -import org.bukkit.inventory.InventoryView; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.Repairable; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import xyz.holocons.mc.holoitemsrevamp.HoloItemsRevamp; -import xyz.holocons.mc.holoitemsrevamp.packet.PlayerAbilitiesPacket; - -import java.util.Map; -import java.util.stream.Collectors; -import java.util.stream.Stream; public class AnvilListener implements Listener { - private static final int MAX_REPAIR_COST = Short.MAX_VALUE; - private final HoloItemsRevamp plugin; public AnvilListener(HoloItemsRevamp plugin) { this.plugin = plugin; } - - /** - * Makes sure that after a player closes an anvil inventory, their instant build - * ability gets disabled. - */ - @EventHandler(priority = EventPriority.MONITOR) - public void onInventoryClose(InventoryCloseEvent event) { - if (!(event.getInventory() instanceof AnvilInventory) - || !(event.getPlayer() instanceof Player player) - || player.getGameMode() == GameMode.CREATIVE) { - return; - } - - new PlayerAbilitiesPacket(player, false).sendPacket(player); - } - - /** - * Handles anvil craftings regarding custom enchantments and custom items. - */ - @EventHandler - public void onPrepareAnvil(PrepareAnvilEvent event) { - // Make sure viewer is a player and they don't have creative bypasses - if (!(event.getView().getPlayer() instanceof Player player) || player.getGameMode() == GameMode.CREATIVE) - return; - - var inventory = event.getInventory(); - - var base = inventory.getFirstItem(); - var addition = inventory.getSecondItem(); - - if (base == null || !(base.getItemMeta() instanceof Repairable) || base.getAmount() != 1) - return; - - // Only handle events that contain custom enchantments - if (hasNoCustomEnchants(base) && hasNoCustomEnchants(addition)) - return; - - if (CustomItemManager.isCustomItem(base)) { // Disallow players to modify custom items - event.setResult(null); - plugin.getServer().getScheduler().runTask(plugin, () -> inventory.setResult(null)); - return; - } - - inventory.setMaximumRepairCost(MAX_REPAIR_COST); - - // Name handling with base item containing custom enchantments - if (addition == null) { - var renameText = inventory.getRenameText(); - var displayName = base.getItemMeta().hasDisplayName() - ? PlainTextComponentSerializer.plainText().serialize(base.getItemMeta().displayName()) - : ""; - if (renameText != null && !renameText.isBlank() && !displayName.equals(renameText)) { - var result = base.clone(); - var resultMeta = result.getItemMeta(); - - resultMeta.displayName(Component.text(renameText)); - result.setItemMeta(resultMeta); - - final int levelCost = inventory.getRepairCost(); - - plugin.getServer().getScheduler().runTask(plugin, () -> { - if (!base.equals(inventory.getFirstItem())) - return; - - inventory.setResult(result); - inventory.setRepairCost(levelCost); - player.setWindowProperty(InventoryView.Property.REPAIR_COST, levelCost); - new PlayerAbilitiesPacket(player, hasEnoughLevels(player, levelCost)).sendPacket(player); - }); - } - return; - } - - // Enchantment handling if addition item is an enchanted book - if (addition.getType() == Material.ENCHANTED_BOOK) { - var customEnchants = combineCustomEnchants(base, addition); - var result = event.getResult(); - int levelCost = inventory.getRepairCost(); - - if (customEnchants.isEmpty()) - return; - - // Enchantment handling if the enchanted book contains only custom enchantments - if (result == null) { - result = base.clone(); - levelCost = ((Repairable) base.getItemMeta()).getRepairCost(); - } - - customEnchants.forEach(result::addEnchantment); - plugin.getEnchantManager().removeCustomEnchantmentLore(result); - plugin.getEnchantManager().applyCustomEnchantmentLore(result); - - final var finalLevelCost = getCustomEnchantCost(customEnchants, levelCost); - final var finalResult = result; - - inventory.setResult(finalResult); - inventory.setRepairCost(finalLevelCost); - - plugin.getServer().getScheduler().runTask(plugin, () -> { - if (!base.equals(inventory.getFirstItem()) || !addition.equals(inventory.getSecondItem())) - return; - - inventory.setResult(finalResult); - inventory.setRepairCost(finalLevelCost); - player.setWindowProperty(InventoryView.Property.REPAIR_COST, finalLevelCost); - new PlayerAbilitiesPacket(player, hasEnoughLevels(player, finalLevelCost)).sendPacket(player); - }); - return; - } - - // Enchantment handling if the addition is not an enchanted book - if (CustomItemManager.isCustomItem(addition)) { - // It's a custom item, but not an enchanted book. Should not be used to - // enchant/repair stuff - event.setResult(null); - plugin.getServer().getScheduler().runTask(plugin, () -> inventory.setResult(null)); - return; - } - - var result = inventory.getResult(); - if (result == null) { - return; - } - - var customEnchants = combineCustomEnchants(base, addition); - var levelCost = getCustomEnchantCost(customEnchants, inventory.getRepairCost()); - - customEnchants.forEach(result::addEnchantment); - plugin.getEnchantManager().removeCustomEnchantmentLore(result); - plugin.getEnchantManager().applyCustomEnchantmentLore(result); - - event.setResult(result); - inventory.setRepairCost(levelCost); - - plugin.getServer().getScheduler().runTask(plugin, () -> { - if (!base.equals(inventory.getFirstItem()) || !addition.equals(inventory.getSecondItem())) - return; - - inventory.setResult(result); - inventory.setRepairCost(levelCost); - player.setWindowProperty(InventoryView.Property.REPAIR_COST, levelCost); - new PlayerAbilitiesPacket(player, hasEnoughLevels(player, levelCost)).sendPacket(player); - }); - } - - private static boolean hasEnoughLevels(Player player, int repairCost) { - return player.getLevel() >= repairCost; - } - - /** - * Combines custom enchantments from two items while handling conflicts and - * levels. - * - * @param base The base item - * @param addition The second item - * @return A map containing all custom enchants - */ - private static Map combineCustomEnchants( - @NotNull ItemStack base, - @NotNull ItemStack addition) { - final var baseEnchantments = EnchantManager.getEnchantments(base); - final var additionEnchantments = EnchantManager.getEnchantments(addition) - .entrySet() - .stream() - .filter(entry -> hasNoConflictEnchants(baseEnchantments, entry.getKey()) - && entry.getKey().canEnchantItem(base)) - .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); - - final var combinedEnchantments = Stream - .of(baseEnchantments, additionEnchantments).>mapMulti( - (enchantments, consumer) -> { - for (final var entry : enchantments.entrySet()) { - if (entry.getKey() instanceof CustomEnchantment enchantment) { - consumer.accept(Map.entry(enchantment, entry.getValue())); - } - } - }) - .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, - (a, b) -> a.equals(b) ? a + 1 : Integer.max(a, b))); - combinedEnchantments.replaceAll((enchantment, level) -> Integer.min(level, enchantment.getMaxLevel())); - - return combinedEnchantments; - } - - /** - * Get the total enchantment cost from the map of enchantments. - * - * @param enchantments Enchantments to calculate level cost - * @param initialCost Repair cost before custom enchantments are considered - * @return Level cost to add enchantments to an item - */ - private static int getCustomEnchantCost(Map enchantments, int initialCost) { - return enchantments.entrySet().stream() - .reduce(initialCost, AnvilListener::levelCostAccumulator, Integer::sum); - } - - private static int levelCostAccumulator(int partialCost, Map.Entry nextEnchantment) { - return partialCost + Integer.min(nextEnchantment.getKey().getCostMultiplier(), MAX_REPAIR_COST) - * nextEnchantment.getValue(); - } - - private static boolean hasNoConflictEnchants(Map enchantments, Enchantment other) { - return enchantments.keySet().stream().noneMatch(other::conflictsWith); - } - - private static boolean hasNoCustomEnchants(@Nullable ItemStack itemStack) { - return itemStack == null || !itemStack.hasItemMeta() - || EnchantManager.getEnchantments(itemStack).keySet().stream() - .noneMatch(entry -> entry instanceof CustomEnchantment); - } } From 8e2c7957ed627b8f466c99e00614d913d75dc60b Mon Sep 17 00:00:00 2001 From: Tsumiki Miniwa <37684627+cpaca@users.noreply.github.com> Date: Sun, 14 Sep 2025 22:28:04 -0700 Subject: [PATCH 07/80] Update Enchantable to use minecraft registries. --- .../holoitemsapi/enchantment/Enchantable.java | 15 ++++++++++++++- .../mc/holoitemsrevamp/item/BackdashBoots.java | 8 +++----- .../mc/holoitemsrevamp/item/MagnetBook.java | 5 +++-- .../mc/holoitemsrevamp/item/MementoItem.java | 5 +++-- .../mc/holoitemsrevamp/item/PlowBook.java | 5 +++-- .../mc/holoitemsrevamp/item/TideRiderItem.java | 5 +++-- 6 files changed, 29 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/strangeone101/holoitemsapi/enchantment/Enchantable.java b/src/main/java/com/strangeone101/holoitemsapi/enchantment/Enchantable.java index 53f0b722..f0f4c31a 100644 --- a/src/main/java/com/strangeone101/holoitemsapi/enchantment/Enchantable.java +++ b/src/main/java/com/strangeone101/holoitemsapi/enchantment/Enchantable.java @@ -1,5 +1,8 @@ package com.strangeone101.holoitemsapi.enchantment; +import io.papermc.paper.registry.RegistryAccess; +import io.papermc.paper.registry.RegistryKey; +import org.bukkit.NamespacedKey; import org.bukkit.enchantments.Enchantment; import org.bukkit.inventory.ItemStack; @@ -8,11 +11,21 @@ */ public interface Enchantable { + /** + * Returns the key used by the custom enchantment. + * @return The NamespacedKey + */ + public NamespacedKey getEnchantmentKey(); + /** * Returns the enchantment the custom item uses. * @return The enchantment. */ - public Enchantment getEnchantment(); + public default Enchantment getEnchantment() { + return RegistryAccess.registryAccess() + .getRegistry(RegistryKey.ENCHANTMENT) + .get(getEnchantmentKey()); + } /** * Applies the enchantment to the itemstack. diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/BackdashBoots.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/BackdashBoots.java index 718fc09f..9db8c9b5 100644 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/BackdashBoots.java +++ b/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/BackdashBoots.java @@ -1,6 +1,5 @@ package xyz.holocons.mc.holoitemsrevamp.item; -import com.strangeone101.holoitemsapi.enchantment.CustomEnchantment; import com.strangeone101.holoitemsapi.enchantment.EnchantManager; import com.strangeone101.holoitemsapi.item.CustomItem; import com.strangeone101.holoitemsapi.enchantment.Enchantable; @@ -8,8 +7,7 @@ import net.kyori.adventure.text.format.NamedTextColor; import org.bukkit.Bukkit; import org.bukkit.Material; -import org.bukkit.enchantments.Enchantment; -import org.bukkit.entity.Player; +import org.bukkit.NamespacedKey; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.Recipe; import org.bukkit.inventory.ShapedRecipe; @@ -49,8 +47,8 @@ protected Recipe getRecipe() { } @Override - public Enchantment getEnchantment() { - return CustomEnchantment.getByKey(getKey()); + public NamespacedKey getEnchantmentKey() { + return getKey(); } @Override diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/MagnetBook.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/MagnetBook.java index 3d6a05a8..488fd972 100644 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/MagnetBook.java +++ b/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/MagnetBook.java @@ -7,6 +7,7 @@ import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; import org.bukkit.Material; +import org.bukkit.NamespacedKey; import org.bukkit.enchantments.Enchantment; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.Recipe; @@ -52,8 +53,8 @@ protected Recipe getRecipe() { } @Override - public Enchantment getEnchantment() { - return CustomEnchantment.getByKey(getKey()); + public NamespacedKey getEnchantmentKey() { + return getKey(); } @Override diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/MementoItem.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/MementoItem.java index ab4b84ea..6a6ac855 100644 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/MementoItem.java +++ b/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/MementoItem.java @@ -1,5 +1,6 @@ package xyz.holocons.mc.holoitemsrevamp.item; +import org.bukkit.NamespacedKey; import xyz.holocons.mc.holoitemsrevamp.HoloItemsRevamp; import org.bukkit.Bukkit; @@ -50,8 +51,8 @@ protected Recipe getRecipe() { } @Override - public Enchantment getEnchantment() { - return CustomEnchantment.getByKey(getKey()); + public NamespacedKey getEnchantmentKey() { + return getKey(); } @Override diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/PlowBook.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/PlowBook.java index a1f7678d..17f8ecc7 100644 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/PlowBook.java +++ b/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/PlowBook.java @@ -7,6 +7,7 @@ import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; import org.bukkit.Material; +import org.bukkit.NamespacedKey; import org.bukkit.enchantments.Enchantment; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.Recipe; @@ -47,8 +48,8 @@ protected Recipe getRecipe() { } @Override - public Enchantment getEnchantment() { - return CustomEnchantment.getByKey(getKey()); + public NamespacedKey getEnchantmentKey() { + return getKey(); } @Override diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/TideRiderItem.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/TideRiderItem.java index 7ae4b245..2e99b634 100644 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/TideRiderItem.java +++ b/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/TideRiderItem.java @@ -8,6 +8,7 @@ import net.kyori.adventure.text.format.NamedTextColor; import org.bukkit.Bukkit; import org.bukkit.Material; +import org.bukkit.NamespacedKey; import org.bukkit.enchantments.Enchantment; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.Recipe; @@ -51,8 +52,8 @@ protected Recipe getRecipe() { } @Override - public @NotNull Enchantment getEnchantment() { - return CustomEnchantment.getByKey(getKey()); + public NamespacedKey getEnchantmentKey() { + return getKey(); } @Override From a4b2ff26390ff4d6847f7b86692a896f247e3a65 Mon Sep 17 00:00:00 2001 From: Tsumiki Miniwa <37684627+cpaca@users.noreply.github.com> Date: Sun, 14 Sep 2025 22:46:02 -0700 Subject: [PATCH 08/80] Remove EnchantManager --- .../enchantment/EnchantManager.java | 116 ------------------ .../mc/holoitemsrevamp/HoloItemsRevamp.java | 7 -- .../holoitemsrevamp/item/BackdashBoots.java | 8 +- .../mc/holoitemsrevamp/item/MagnetBook.java | 6 - .../mc/holoitemsrevamp/item/MementoItem.java | 6 - .../mc/holoitemsrevamp/item/PlowBook.java | 6 - .../holoitemsrevamp/item/TideRiderItem.java | 6 - 7 files changed, 1 insertion(+), 154 deletions(-) delete mode 100644 src/main/java/com/strangeone101/holoitemsapi/enchantment/EnchantManager.java diff --git a/src/main/java/com/strangeone101/holoitemsapi/enchantment/EnchantManager.java b/src/main/java/com/strangeone101/holoitemsapi/enchantment/EnchantManager.java deleted file mode 100644 index 5f524024..00000000 --- a/src/main/java/com/strangeone101/holoitemsapi/enchantment/EnchantManager.java +++ /dev/null @@ -1,116 +0,0 @@ -package com.strangeone101.holoitemsapi.enchantment; - -import net.kyori.adventure.text.Component; -import org.bukkit.enchantments.Enchantment; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.EnchantmentStorageMeta; -import xyz.holocons.mc.holoitemsrevamp.HoloItemsRevamp; -import xyz.holocons.mc.holoitemsrevamp.enchantment.*; -import xyz.holocons.mc.holoitemsrevamp.integration.Integrations; - -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Set; -import java.util.stream.Collectors; -import java.util.stream.IntStream; -import java.util.stream.Stream; - -public class EnchantManager { - - private final List enchantmentNames; - private final Map, Component> enchantmentLores; - - public EnchantManager(HoloItemsRevamp plugin) { - try { - final var field = Enchantment.class.getDeclaredField("acceptingNew"); - field.setAccessible(true); - field.set(null, true); - } catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) { - throw new RuntimeException(e); - } - - final var enchantments = buildCustomEnchantments(plugin); - - enchantments.forEach(CustomEnchantment::registerEnchantment); - enchantments.forEach(Integrations.WORLDGUARD::registerEnchantment); - - this.enchantmentNames = enchantments.stream().map(CustomEnchantment::name).toList(); - // Key is a pair of Enchantment and level, value is the lore - this.enchantmentLores = enchantments - .stream()., Component>>mapMulti( - (customEnchantment, consumer) -> IntStream - .rangeClosed(customEnchantment.getStartLevel(), customEnchantment.getMaxLevel()) - .forEach(level -> { - final var lore = customEnchantment.lore(level); - if (lore != null) { - consumer.accept(Map.entry(Map.entry(customEnchantment, level), lore)); - } - })) - .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); - - Enchantment.stopAcceptingRegistrations(); - } - - public List enchantmentNames() { - return enchantmentNames; - } - - /** - * If the item stack is an enchanted book, it will get the enchantments using - * {@link EnchantmentStorageMeta#getStoredEnchants()} - * - * @param itemStack An ItemStack that has enchantments - * @return A map of the enchantments - */ - public static Map getEnchantments(ItemStack itemStack) { - return itemStack.getItemMeta() instanceof EnchantmentStorageMeta enchantmentStorageMeta - ? enchantmentStorageMeta.getStoredEnchants() - : itemStack.getEnchantments(); - } - - /** - * Applies the display names of all custom enchantments present on an itemstack - * to the itemstack as lore. If any custom enchantment lore is already on the - * given itemstack, {@code EnchantManager#removeCustomEnchantmentLore} should be - * done first. - * - * @param itemStack An ItemStack that has custom enchantments - */ - public void applyCustomEnchantmentLore(ItemStack itemStack) { - final var enchantmentLore = getEnchantments(itemStack).entrySet().stream() - .map(enchantmentLores::get) - .filter(Objects::nonNull); - - final var oldLore = itemStack.lore(); - final var newLore = oldLore == null - ? enchantmentLore.toList() - : Stream.concat(enchantmentLore, oldLore.stream()).toList(); - itemStack.lore(newLore.isEmpty() ? null : newLore); - } - - /** - * Removes all custom enchantment lore from the given itemstack. - * - * @param itemStack An ItemStack without custom enchantments - */ - public void removeCustomEnchantmentLore(ItemStack itemStack) { - final var oldLore = itemStack.lore(); - if (oldLore != null) { - final var newLore = oldLore.stream() - .filter(loreComponent -> !enchantmentLores.containsValue(loreComponent)) - .toList(); - itemStack.lore(newLore.isEmpty() ? null : newLore); - } - } - - private static Set buildCustomEnchantments(HoloItemsRevamp plugin) { - return Set.of( - new Magnet(plugin), - new Memento(plugin), - new TideRider(plugin), - new Backdash(plugin), - new Plow(plugin) - ); - } -} diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/HoloItemsRevamp.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/HoloItemsRevamp.java index 4ae4d8ca..2665d236 100644 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/HoloItemsRevamp.java +++ b/src/main/java/xyz/holocons/mc/holoitemsrevamp/HoloItemsRevamp.java @@ -2,7 +2,6 @@ import com.strangeone101.holoitemsapi.Keys; import com.strangeone101.holoitemsapi.enchantment.AnvilListener; -import com.strangeone101.holoitemsapi.enchantment.EnchantManager; import com.strangeone101.holoitemsapi.enchantment.EnchantmentListener; import com.strangeone101.holoitemsapi.item.BlockListener; import com.strangeone101.holoitemsapi.item.CustomItemManager; @@ -17,14 +16,12 @@ public final class HoloItemsRevamp extends JavaPlugin { private CollectionManager collectionManager; - private EnchantManager enchantManager; private CustomBlockStorage trackingManager; @Override public void onLoad() { Keys.fillKeys(this); - this.enchantManager = new EnchantManager(this); this.collectionManager = new CollectionManager(this); this.trackingManager = new CustomBlockStorage(this); @@ -56,10 +53,6 @@ public CollectionManager getCollectionManager() { return collectionManager; } - public EnchantManager getEnchantManager() { - return enchantManager; - } - public CustomBlockStorage getTrackingManager() { return trackingManager; } diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/BackdashBoots.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/BackdashBoots.java index 9db8c9b5..0cbc2b90 100644 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/BackdashBoots.java +++ b/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/BackdashBoots.java @@ -1,6 +1,5 @@ package xyz.holocons.mc.holoitemsrevamp.item; -import com.strangeone101.holoitemsapi.enchantment.EnchantManager; import com.strangeone101.holoitemsapi.item.CustomItem; import com.strangeone101.holoitemsapi.enchantment.Enchantable; import net.kyori.adventure.text.Component; @@ -24,11 +23,8 @@ public class BackdashBoots extends CustomItem implements Enchantable { Component.text("Crouch to backdash") ); - private final EnchantManager enchantManager; - public BackdashBoots(HoloItemsRevamp plugin) { super(plugin, name, material, displayName, lore); - this.enchantManager = plugin.getEnchantManager(); this.setStackable(false); this.register(); } @@ -57,9 +53,7 @@ public ItemStack applyEnchantment(ItemStack itemStack) { var enchantedMeta = enchantedStack.hasItemMeta() ? enchantedStack.getItemMeta() : Bukkit.getItemFactory().getItemMeta(enchantedStack.getType()); if (enchantedMeta.addEnchant(getEnchantment(), 1, false)) { - enchantedStack.setItemMeta(enchantedMeta); - enchantManager.removeCustomEnchantmentLore(enchantedStack); - enchantManager.applyCustomEnchantmentLore(enchantedStack); + enchantedStack.setItemMeta(enchantedMeta) return enchantedStack; } else { return null; diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/MagnetBook.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/MagnetBook.java index 488fd972..9c2f6555 100644 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/MagnetBook.java +++ b/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/MagnetBook.java @@ -1,7 +1,6 @@ package xyz.holocons.mc.holoitemsrevamp.item; import com.strangeone101.holoitemsapi.enchantment.CustomEnchantment; -import com.strangeone101.holoitemsapi.enchantment.EnchantManager; import com.strangeone101.holoitemsapi.enchantment.Enchantable; import com.strangeone101.holoitemsapi.item.CustomItem; import net.kyori.adventure.text.Component; @@ -26,11 +25,8 @@ public class MagnetBook extends CustomItem implements Enchantable { Component.text("Automatically put mined items to your inventory!", NamedTextColor.DARK_PURPLE) ); - private final EnchantManager enchantManager; - public MagnetBook(HoloItemsRevamp plugin) { super(plugin, name, material, displayName, lore); - this.enchantManager = plugin.getEnchantManager(); this.register(); } @@ -64,8 +60,6 @@ public ItemStack applyEnchantment(ItemStack itemStack) { if (enchantedMeta.addStoredEnchant(getEnchantment(), 1, false)) { enchantedStack.setItemMeta(enchantedMeta); - enchantManager.removeCustomEnchantmentLore(enchantedStack); - enchantManager.applyCustomEnchantmentLore(enchantedStack); return enchantedStack; } else { return null; diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/MementoItem.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/MementoItem.java index 6a6ac855..a693cb38 100644 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/MementoItem.java +++ b/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/MementoItem.java @@ -11,7 +11,6 @@ import org.bukkit.inventory.ShapedRecipe; import com.strangeone101.holoitemsapi.enchantment.CustomEnchantment; -import com.strangeone101.holoitemsapi.enchantment.EnchantManager; import com.strangeone101.holoitemsapi.enchantment.Enchantable; import com.strangeone101.holoitemsapi.item.CustomItem; @@ -29,11 +28,8 @@ public class MementoItem extends CustomItem implements Enchantable { Component.text("Keep your items on death. Consumable.", NamedTextColor.DARK_PURPLE) ); - private final EnchantManager enchantManager; - public MementoItem(HoloItemsRevamp plugin) { super(plugin, name, material, displayName, lore); - this.enchantManager = plugin.getEnchantManager(); this.register(); } @@ -62,8 +58,6 @@ public ItemStack applyEnchantment(ItemStack itemStack) { if (enchantedMeta.addEnchant(getEnchantment(), 1, false)) { enchantedStack.setItemMeta(enchantedMeta); - enchantManager.removeCustomEnchantmentLore(enchantedStack); - enchantManager.applyCustomEnchantmentLore(enchantedStack); return enchantedStack; } else { return null; diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/PlowBook.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/PlowBook.java index 17f8ecc7..b540db8c 100644 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/PlowBook.java +++ b/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/PlowBook.java @@ -1,7 +1,6 @@ package xyz.holocons.mc.holoitemsrevamp.item; import com.strangeone101.holoitemsapi.enchantment.CustomEnchantment; -import com.strangeone101.holoitemsapi.enchantment.EnchantManager; import com.strangeone101.holoitemsapi.enchantment.Enchantable; import com.strangeone101.holoitemsapi.item.CustomItem; import net.kyori.adventure.text.Component; @@ -25,11 +24,8 @@ public class PlowBook extends CustomItem implements Enchantable { Component.text("Shovel snow!", NamedTextColor.DARK_PURPLE) ); - private final EnchantManager enchantManager; - public PlowBook(HoloItemsRevamp plugin){ super(plugin, name, material, displayName, lore); - this.enchantManager = plugin.getEnchantManager(); this.register(); } @@ -59,8 +55,6 @@ public ItemStack applyEnchantment(ItemStack itemStack) { if (enchantedMeta.addStoredEnchant(getEnchantment(), 1, false)) { enchantedStack.setItemMeta(enchantedMeta); - enchantManager.removeCustomEnchantmentLore(enchantedStack); - enchantManager.applyCustomEnchantmentLore(enchantedStack); return enchantedStack; } else { return null; diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/TideRiderItem.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/TideRiderItem.java index 2e99b634..b946361c 100644 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/TideRiderItem.java +++ b/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/TideRiderItem.java @@ -1,7 +1,6 @@ package xyz.holocons.mc.holoitemsrevamp.item; import com.strangeone101.holoitemsapi.enchantment.CustomEnchantment; -import com.strangeone101.holoitemsapi.enchantment.EnchantManager; import com.strangeone101.holoitemsapi.enchantment.Enchantable; import com.strangeone101.holoitemsapi.item.CustomItem; import net.kyori.adventure.text.Component; @@ -27,11 +26,8 @@ public class TideRiderItem extends CustomItem implements Enchantable { Component.text("Surf the waves") ); - private final EnchantManager enchantManager; - public TideRiderItem(HoloItemsRevamp plugin) { super(plugin, name, material, displayName, lore); - this.enchantManager = plugin.getEnchantManager(); this.register(); } @@ -63,8 +59,6 @@ public ItemStack applyEnchantment(ItemStack itemStack) { if (enchantedMeta.addEnchant(getEnchantment(), 1, false)) { enchantedStack.setItemMeta(enchantedMeta); - enchantManager.removeCustomEnchantmentLore(enchantedStack); - enchantManager.applyCustomEnchantmentLore(enchantedStack); return enchantedStack; } else { return null; From d6fa5054e856c8578948b99835b4960ca9c299df Mon Sep 17 00:00:00 2001 From: Tsumiki Miniwa <37684627+cpaca@users.noreply.github.com> Date: Sun, 14 Sep 2025 22:47:10 -0700 Subject: [PATCH 09/80] Delete EnchantCommand.java --- .../holoitemsrevamp/command/MainCommand.java | 4 +- .../command/subcommand/EnchantCommand.java | 102 ------------------ 2 files changed, 1 insertion(+), 105 deletions(-) delete mode 100644 src/main/java/xyz/holocons/mc/holoitemsrevamp/command/subcommand/EnchantCommand.java diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/command/MainCommand.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/command/MainCommand.java index 34a44f0d..b88999c8 100644 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/command/MainCommand.java +++ b/src/main/java/xyz/holocons/mc/holoitemsrevamp/command/MainCommand.java @@ -14,7 +14,6 @@ import xyz.holocons.mc.holoitemsrevamp.HoloItemsRevamp; import xyz.holocons.mc.holoitemsrevamp.command.subcommand.AcquireCommand; import xyz.holocons.mc.holoitemsrevamp.command.subcommand.CollectionsCommand; -import xyz.holocons.mc.holoitemsrevamp.command.subcommand.EnchantCommand; import xyz.holocons.mc.holoitemsrevamp.command.subcommand.StatsCommand; import java.util.Arrays; @@ -30,8 +29,7 @@ public MainCommand(HoloItemsRevamp plugin) { this.subCommands = Set.of( new AcquireCommand(plugin), new CollectionsCommand(plugin), - new StatsCommand(), - new EnchantCommand(plugin) + new StatsCommand() ); // Create text component message for help page final var helpComponentBuilder = Component.text() diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/command/subcommand/EnchantCommand.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/command/subcommand/EnchantCommand.java deleted file mode 100644 index 12c16f21..00000000 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/command/subcommand/EnchantCommand.java +++ /dev/null @@ -1,102 +0,0 @@ -package xyz.holocons.mc.holoitemsrevamp.command.subcommand; - -import org.bukkit.NamespacedKey; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import com.strangeone101.holoitemsapi.enchantment.CustomEnchantment; - -import net.kyori.adventure.text.Component; -import net.kyori.adventure.text.format.NamedTextColor; -import xyz.holocons.mc.holoitemsrevamp.HoloItemsRevamp; -import xyz.holocons.mc.holoitemsrevamp.command.SubCommand; - -import java.util.List; - -public class EnchantCommand implements SubCommand { - - private final HoloItemsRevamp plugin; - - public EnchantCommand(HoloItemsRevamp plugin) { - this.plugin = plugin; - } - - @Override - public String getName() { - return "enchant"; - } - - @Override - public String getDesc() { - return "Enchants an item in your hand"; - } - - @Override - public String getFormat() { - return " [level]"; - } - - @Override - public String getPermission() { - return "holoitems.enchant"; - } - - @Override - public List getAutoComplete(String[] args) { - return switch (args.length) { - case 1 -> plugin.getEnchantManager().enchantmentNames(); - default -> List.of(); - }; - } - - @Override - public boolean execute(CommandSender sender, String[] args) { - if (!(sender instanceof Player player)) { - sender.sendMessage("Do not use this command as console."); - return true; - } - - if (!player.hasPermission(getPermission())) { - player.sendMessage("You do not have the permission to use this command!"); - return true; - } - - if (args.length < 1) { - player.sendMessage("Not enough arguments"); - return false; - } - - var itemStack = player.getInventory().getItemInMainHand(); - var itemMeta = itemStack.getItemMeta(); - - if (itemMeta == null) { - player.sendMessage(Component.translatable("commands.enchant.failed.itemless", NamedTextColor.RED, Component.text(player.getName()))); - return true; - } - - var key = NamespacedKey.fromString(args[0], plugin); - var customEnchantment = CustomEnchantment.getByKey(key); - - if (customEnchantment == null) { - player.sendMessage(args[0] + " is not a valid enchantment!"); - return false; - } - - int level; - try { - level = Integer.parseInt(args[1]); - } catch (ArrayIndexOutOfBoundsException | NumberFormatException e) { - level = customEnchantment.getStartLevel(); - } - - if (itemMeta.addEnchant(customEnchantment, level, false)) { - itemStack.setItemMeta(itemMeta); - plugin.getEnchantManager().removeCustomEnchantmentLore(itemStack); - plugin.getEnchantManager().applyCustomEnchantmentLore(itemStack); - player.sendMessage("Enchanted!"); - } else { - player.sendMessage("Could not set enchant!"); - } - return true; - } -} From 3297d53509f0c6e75fca4b593e48a635928651c7 Mon Sep 17 00:00:00 2001 From: Tsumiki Miniwa <37684627+cpaca@users.noreply.github.com> Date: Sun, 14 Sep 2025 22:47:25 -0700 Subject: [PATCH 10/80] Fix accidentally-deleted semicolon --- .../xyz/holocons/mc/holoitemsrevamp/item/BackdashBoots.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/BackdashBoots.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/BackdashBoots.java index 0cbc2b90..729da206 100644 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/BackdashBoots.java +++ b/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/BackdashBoots.java @@ -53,7 +53,7 @@ public ItemStack applyEnchantment(ItemStack itemStack) { var enchantedMeta = enchantedStack.hasItemMeta() ? enchantedStack.getItemMeta() : Bukkit.getItemFactory().getItemMeta(enchantedStack.getType()); if (enchantedMeta.addEnchant(getEnchantment(), 1, false)) { - enchantedStack.setItemMeta(enchantedMeta) + enchantedStack.setItemMeta(enchantedMeta); return enchantedStack; } else { return null; From d3a24e63bed2a3d26bbdba5f106f6fe60c8da230 Mon Sep 17 00:00:00 2001 From: Tsumiki Miniwa <37684627+cpaca@users.noreply.github.com> Date: Sun, 14 Sep 2025 22:51:57 -0700 Subject: [PATCH 11/80] Fix CustomLootRegistry Enchantments --- .../strangeone101/holoitemsapi/loot/CustomLootRegistry.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/strangeone101/holoitemsapi/loot/CustomLootRegistry.java b/src/main/java/com/strangeone101/holoitemsapi/loot/CustomLootRegistry.java index 77d30e37..46cd47bd 100644 --- a/src/main/java/com/strangeone101/holoitemsapi/loot/CustomLootRegistry.java +++ b/src/main/java/com/strangeone101/holoitemsapi/loot/CustomLootRegistry.java @@ -67,7 +67,7 @@ public static void handleDeath(LivingEntity entity, List drops) { if (entity.getKiller() == null) return; Location location = entity.getLocation(); - int looting_mod = entity.getKiller().getInventory().getItemInMainHand().getEnchantmentLevel(Enchantment.LOOT_BONUS_MOBS); + int looting_mod = entity.getKiller().getInventory().getItemInMainHand().getEnchantmentLevel(Enchantment.LOOTING); double luck_mod = entity.getKiller().getAttribute(Attribute.GENERIC_LUCK).getValue(); LootContext.Builder builder = new LootContext.Builder(location); @@ -95,7 +95,7 @@ public static void handleDeath(LivingEntity entity, List drops) { */ public static void handleBlockBreak(BlockBreakEvent event) { if (BLOCK_TABLES.containsKey(event.getBlock().getType())) { - int fortune_mod = event.getPlayer().getInventory().getItemInMainHand().getEnchantmentLevel(Enchantment.LOOT_BONUS_BLOCKS); + int fortune_mod = event.getPlayer().getInventory().getItemInMainHand().getEnchantmentLevel(Enchantment.FORTUNE); double luck_mod = event.getPlayer().getAttribute(Attribute.GENERIC_LUCK).getValue(); boolean silk_mod = event.getPlayer().getInventory().getItemInMainHand().getEnchantmentLevel(Enchantment.SILK_TOUCH) > 0; From fc36c02be4bee2cd5b99e67ed5460a3b1a6995e7 Mon Sep 17 00:00:00 2001 From: Tsumiki Miniwa <37684627+cpaca@users.noreply.github.com> Date: Sun, 14 Sep 2025 23:00:01 -0700 Subject: [PATCH 12/80] CustomEnchantment implements EnchantmentAbility --- .../holoitemsapi/enchantment/CustomEnchantment.java | 8 +++++--- .../holocons/mc/holoitemsrevamp/enchantment/Backdash.java | 3 ++- .../holocons/mc/holoitemsrevamp/enchantment/Magnet.java | 2 +- .../holocons/mc/holoitemsrevamp/enchantment/Memento.java | 2 +- .../xyz/holocons/mc/holoitemsrevamp/enchantment/Plow.java | 2 +- .../mc/holoitemsrevamp/enchantment/TideRider.java | 2 +- 6 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/strangeone101/holoitemsapi/enchantment/CustomEnchantment.java b/src/main/java/com/strangeone101/holoitemsapi/enchantment/CustomEnchantment.java index 46704ba2..e148647c 100644 --- a/src/main/java/com/strangeone101/holoitemsapi/enchantment/CustomEnchantment.java +++ b/src/main/java/com/strangeone101/holoitemsapi/enchantment/CustomEnchantment.java @@ -9,13 +9,15 @@ import java.util.HashMap; -public abstract class CustomEnchantment { +public abstract class CustomEnchantment implements EnchantmentAbility { private static final HashMap enchantmentsByKey = new HashMap<>(); + protected final NamespacedKey key; + public CustomEnchantment(Plugin plugin, String key) { - // TODO: Should I just put the in there? since the namespace seems to always be anyway? - enchantmentsByKey.put(new NamespacedKey(plugin, key), this); + this.key = new NamespacedKey(plugin, key); + enchantmentsByKey.put(this.key, this); } /** diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/Backdash.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/Backdash.java index 9c30dd61..d84b2b31 100644 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/Backdash.java +++ b/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/Backdash.java @@ -1,5 +1,6 @@ package xyz.holocons.mc.holoitemsrevamp.enchantment; +import org.bukkit.NamespacedKey; import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.EnchantmentTarget; import org.bukkit.event.player.PlayerToggleSneakEvent; @@ -15,7 +16,7 @@ import xyz.holocons.mc.holoitemsrevamp.HoloItemsRevamp; import xyz.holocons.mc.holoitemsrevamp.integration.Integrations; -public class Backdash extends CustomEnchantment implements EnchantmentAbility { +public class Backdash extends CustomEnchantment { public Backdash(HoloItemsRevamp plugin) { super(plugin, "backdash"); diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/Magnet.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/Magnet.java index f29b0524..0afc9923 100644 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/Magnet.java +++ b/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/Magnet.java @@ -17,7 +17,7 @@ import xyz.holocons.mc.holoitemsrevamp.HoloItemsRevamp; import xyz.holocons.mc.holoitemsrevamp.integration.Integrations; -public class Magnet extends CustomEnchantment implements EnchantmentAbility { +public class Magnet extends CustomEnchantment { private final HoloItemsRevamp plugin; diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/Memento.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/Memento.java index 571c2dce..0c42198b 100644 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/Memento.java +++ b/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/Memento.java @@ -16,7 +16,7 @@ import xyz.holocons.mc.holoitemsrevamp.HoloItemsRevamp; import xyz.holocons.mc.holoitemsrevamp.integration.Integrations; -public class Memento extends CustomEnchantment implements EnchantmentAbility { +public class Memento extends CustomEnchantment { public Memento(HoloItemsRevamp plugin) { super(plugin, "memento"); diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/Plow.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/Plow.java index 3247a602..d455cbd1 100644 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/Plow.java +++ b/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/Plow.java @@ -17,7 +17,7 @@ import xyz.holocons.mc.holoitemsrevamp.util.EntityExpiringSet; import xyz.holocons.mc.holoitemsrevamp.util.ExpiringSet; -public class Plow extends CustomEnchantment implements EnchantmentAbility { +public class Plow extends CustomEnchantment { private final EntityExpiringSet plowMarker = new EntityExpiringSet( new ExpiringSet.ConstantTicksToLiveExpirationPolicy<>(20)); diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/TideRider.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/TideRider.java index 9f3c56f5..80d92a93 100644 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/TideRider.java +++ b/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/TideRider.java @@ -23,7 +23,7 @@ import xyz.holocons.mc.holoitemsrevamp.HoloItemsRevamp; import xyz.holocons.mc.holoitemsrevamp.integration.Integrations; -public class TideRider extends CustomEnchantment implements EnchantmentAbility { +public class TideRider extends CustomEnchantment { private final HoloItemsRevamp plugin; From 2a6a9280c14e2c0099862c2611f09f36e178ea55 Mon Sep 17 00:00:00 2001 From: Tsumiki Miniwa <37684627+cpaca@users.noreply.github.com> Date: Sun, 14 Sep 2025 23:00:01 -0700 Subject: [PATCH 13/80] CustomEnchantment implements EnchantmentAbility --- .../holoitemsapi/enchantment/CustomEnchantment.java | 13 ++++++++++--- .../mc/holoitemsrevamp/enchantment/Backdash.java | 3 ++- .../mc/holoitemsrevamp/enchantment/Magnet.java | 2 +- .../mc/holoitemsrevamp/enchantment/Memento.java | 2 +- .../mc/holoitemsrevamp/enchantment/Plow.java | 2 +- .../mc/holoitemsrevamp/enchantment/TideRider.java | 2 +- 6 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/strangeone101/holoitemsapi/enchantment/CustomEnchantment.java b/src/main/java/com/strangeone101/holoitemsapi/enchantment/CustomEnchantment.java index 46704ba2..ef73ff32 100644 --- a/src/main/java/com/strangeone101/holoitemsapi/enchantment/CustomEnchantment.java +++ b/src/main/java/com/strangeone101/holoitemsapi/enchantment/CustomEnchantment.java @@ -9,13 +9,20 @@ import java.util.HashMap; -public abstract class CustomEnchantment { +public abstract class CustomEnchantment implements EnchantmentAbility { private static final HashMap enchantmentsByKey = new HashMap<>(); + protected final NamespacedKey key; + public CustomEnchantment(Plugin plugin, String key) { - // TODO: Should I just put the in there? since the namespace seems to always be anyway? - enchantmentsByKey.put(new NamespacedKey(plugin, key), this); + this.key = new NamespacedKey(plugin, key); + enchantmentsByKey.put(this.key, this); + } + + @Override + public @NotNull NamespacedKey getKey() { + return this.key; } /** diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/Backdash.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/Backdash.java index 9c30dd61..d84b2b31 100644 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/Backdash.java +++ b/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/Backdash.java @@ -1,5 +1,6 @@ package xyz.holocons.mc.holoitemsrevamp.enchantment; +import org.bukkit.NamespacedKey; import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.EnchantmentTarget; import org.bukkit.event.player.PlayerToggleSneakEvent; @@ -15,7 +16,7 @@ import xyz.holocons.mc.holoitemsrevamp.HoloItemsRevamp; import xyz.holocons.mc.holoitemsrevamp.integration.Integrations; -public class Backdash extends CustomEnchantment implements EnchantmentAbility { +public class Backdash extends CustomEnchantment { public Backdash(HoloItemsRevamp plugin) { super(plugin, "backdash"); diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/Magnet.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/Magnet.java index f29b0524..0afc9923 100644 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/Magnet.java +++ b/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/Magnet.java @@ -17,7 +17,7 @@ import xyz.holocons.mc.holoitemsrevamp.HoloItemsRevamp; import xyz.holocons.mc.holoitemsrevamp.integration.Integrations; -public class Magnet extends CustomEnchantment implements EnchantmentAbility { +public class Magnet extends CustomEnchantment { private final HoloItemsRevamp plugin; diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/Memento.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/Memento.java index 571c2dce..0c42198b 100644 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/Memento.java +++ b/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/Memento.java @@ -16,7 +16,7 @@ import xyz.holocons.mc.holoitemsrevamp.HoloItemsRevamp; import xyz.holocons.mc.holoitemsrevamp.integration.Integrations; -public class Memento extends CustomEnchantment implements EnchantmentAbility { +public class Memento extends CustomEnchantment { public Memento(HoloItemsRevamp plugin) { super(plugin, "memento"); diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/Plow.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/Plow.java index 3247a602..d455cbd1 100644 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/Plow.java +++ b/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/Plow.java @@ -17,7 +17,7 @@ import xyz.holocons.mc.holoitemsrevamp.util.EntityExpiringSet; import xyz.holocons.mc.holoitemsrevamp.util.ExpiringSet; -public class Plow extends CustomEnchantment implements EnchantmentAbility { +public class Plow extends CustomEnchantment { private final EntityExpiringSet plowMarker = new EntityExpiringSet( new ExpiringSet.ConstantTicksToLiveExpirationPolicy<>(20)); diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/TideRider.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/TideRider.java index 9f3c56f5..80d92a93 100644 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/TideRider.java +++ b/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/TideRider.java @@ -23,7 +23,7 @@ import xyz.holocons.mc.holoitemsrevamp.HoloItemsRevamp; import xyz.holocons.mc.holoitemsrevamp.integration.Integrations; -public class TideRider extends CustomEnchantment implements EnchantmentAbility { +public class TideRider extends CustomEnchantment { private final HoloItemsRevamp plugin; From 90ecb0a73c835092503c20f12e13f4ea5ac4ec2a Mon Sep 17 00:00:00 2001 From: Tsumiki Miniwa <37684627+cpaca@users.noreply.github.com> Date: Sun, 14 Sep 2025 23:04:05 -0700 Subject: [PATCH 14/80] Remove now-extraneous functions These will be defined by the datapack. --- .../mc/holoitemsrevamp/enchantment/Backdash.java | 15 --------------- .../mc/holoitemsrevamp/enchantment/Magnet.java | 15 --------------- .../mc/holoitemsrevamp/enchantment/Memento.java | 15 --------------- .../mc/holoitemsrevamp/enchantment/Plow.java | 15 --------------- .../mc/holoitemsrevamp/enchantment/TideRider.java | 15 --------------- 5 files changed, 75 deletions(-) diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/Backdash.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/Backdash.java index d84b2b31..ab4818f7 100644 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/Backdash.java +++ b/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/Backdash.java @@ -22,21 +22,6 @@ public Backdash(HoloItemsRevamp plugin) { super(plugin, "backdash"); } - @Override - public int getMaxLevel() { - return 1; - } - - @Override - public boolean conflictsWith(@NotNull Enchantment other) { - return false; - } - - @Override - public boolean canEnchantItem(@NotNull ItemStack item) { - return EnchantmentTarget.ARMOR_FEET.includes(item); - } - @Override public @NotNull Component displayName(int level) { return Component.text("Backdash", NamedTextColor.GRAY) diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/Magnet.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/Magnet.java index 0afc9923..7ea4da05 100644 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/Magnet.java +++ b/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/Magnet.java @@ -26,21 +26,6 @@ public Magnet(HoloItemsRevamp plugin) { this.plugin = plugin; } - @Override - public int getMaxLevel() { - return 1; - } - - @Override - public boolean conflictsWith(@NotNull Enchantment other) { - return false; - } - - @Override - public boolean canEnchantItem(@NotNull ItemStack item) { - return EnchantmentTarget.TOOL.includes(item); - } - @Override public @NotNull Component displayName(int level) { return Component.text() diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/Memento.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/Memento.java index 0c42198b..ee426dcf 100644 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/Memento.java +++ b/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/Memento.java @@ -22,21 +22,6 @@ public Memento(HoloItemsRevamp plugin) { super(plugin, "memento"); } - @Override - public int getMaxLevel() { - return 1; - } - - @Override - public boolean conflictsWith(@NotNull Enchantment other) { - return true; - } - - @Override - public boolean canEnchantItem(@NotNull ItemStack item) { - return item.getType() == Material.ENDER_CHEST; - } - @Override public @NotNull Component displayName(int level) { return Component.text() diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/Plow.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/Plow.java index d455cbd1..ed70738b 100644 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/Plow.java +++ b/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/Plow.java @@ -26,21 +26,6 @@ public Plow(HoloItemsRevamp plugin) { super(plugin, "plow"); } - @Override - public int getMaxLevel() { - return 1; - } - - @Override - public boolean conflictsWith(@NotNull Enchantment enchantment) { - return false; - } - - @Override - public boolean canEnchantItem(@NotNull ItemStack itemStack) { - return MaterialTags.SHOVELS.isTagged(itemStack); - } - @Override public @NotNull Component displayName(int i) { return Component.text() diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/TideRider.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/TideRider.java index 80d92a93..8d21c9eb 100644 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/TideRider.java +++ b/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/TideRider.java @@ -32,21 +32,6 @@ public TideRider(HoloItemsRevamp plugin) { this.plugin = plugin; } - @Override - public int getMaxLevel() { - return 1; - } - - @Override - public boolean conflictsWith(@NotNull Enchantment other) { - return !other.equals(Enchantment.MENDING) && !other.equals(Enchantment.VANISHING_CURSE); - } - - @Override - public boolean canEnchantItem(@NotNull ItemStack item) { - return EnchantmentTarget.TRIDENT.includes(item); - } - @Override public @NotNull Component displayName(int level) { return Component.text("Tide Rider", NamedTextColor.GRAY) From 0de04b485bd52f96512e01bb8285a3f50142494b Mon Sep 17 00:00:00 2001 From: Tsumiki Miniwa <37684627+cpaca@users.noreply.github.com> Date: Sun, 14 Sep 2025 23:08:35 -0700 Subject: [PATCH 15/80] Remove Tide Rider particles --- .../xyz/holocons/mc/holoitemsrevamp/enchantment/TideRider.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/TideRider.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/TideRider.java index 8d21c9eb..aacbeec8 100644 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/TideRider.java +++ b/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/TideRider.java @@ -80,7 +80,8 @@ public void run() { final var location = player.getLocation(); if (elapsedTicks % 2 != 0) { - world.spawnParticle(Particle.WATER_WAKE, location, 80, 0.2, 0.0, 0.2); + // TODO: Figure out what particle to replace this with. +// world.spawnParticle(Particle.WATER_WAKE, location, 80, 0.2, 0.0, 0.2); } final var direction = location.getDirection().setY(0.0001).normalize(); From 1c2a79b36384d3fb95082328306a2af62896b9d5 Mon Sep 17 00:00:00 2001 From: Tsumiki Miniwa <37684627+cpaca@users.noreply.github.com> Date: Mon, 15 Sep 2025 00:08:00 -0700 Subject: [PATCH 16/80] Update John Rengelman's Shadow It's now managed by GradleUp. --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index 5da7a6ef..316691b8 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,7 +1,7 @@ plugins { `java-library` id("net.minecrell.plugin-yml.bukkit") version "0.6.0" // Generates plugin.yml - id("com.github.johnrengelman.shadow") version "8.1.1" // Shades and relocates dependencies into our plugin jar + id("com.gradleup.shadow") version "8.3.9" // Shades and relocates dependencies into our plugin jar id("xyz.jpenilla.run-paper") version "2.3.0" // Adds runServer and runMojangMappedServer tasks for testing } From 3c202fba686e524b1e1dc2a6bedf9b02013cf0c8 Mon Sep 17 00:00:00 2001 From: Tsumiki Miniwa <37684627+cpaca@users.noreply.github.com> Date: Mon, 15 Sep 2025 03:55:44 -0700 Subject: [PATCH 17/80] Fix enchantment namespace --- .../holoitemsapi/enchantment/CustomEnchantment.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/strangeone101/holoitemsapi/enchantment/CustomEnchantment.java b/src/main/java/com/strangeone101/holoitemsapi/enchantment/CustomEnchantment.java index ef73ff32..56014e17 100644 --- a/src/main/java/com/strangeone101/holoitemsapi/enchantment/CustomEnchantment.java +++ b/src/main/java/com/strangeone101/holoitemsapi/enchantment/CustomEnchantment.java @@ -12,11 +12,13 @@ public abstract class CustomEnchantment implements EnchantmentAbility { private static final HashMap enchantmentsByKey = new HashMap<>(); + // TODO: Either make plugin use this namespace, or change datapack's namespace. + private static final String ENCHANTMENT_NAMESPACE = "holocons"; protected final NamespacedKey key; public CustomEnchantment(Plugin plugin, String key) { - this.key = new NamespacedKey(plugin, key); + this.key = new NamespacedKey(ENCHANTMENT_NAMESPACE, key); enchantmentsByKey.put(this.key, this); } From 61d0dd4c7215ac70fa19a3968da473325e96e0b1 Mon Sep 17 00:00:00 2001 From: Tsumiki Miniwa <37684627+cpaca@users.noreply.github.com> Date: Mon, 15 Sep 2025 04:06:00 -0700 Subject: [PATCH 18/80] have to use holoitems namespace enchantable items are getting their key using CustomItem's getKey(), which uses the plugin. This will be resolved in a future version, as Enchantable only exists on CustomItem objects, which (now) only exist to add one recipe each. --- .../holoitemsapi/enchantment/CustomEnchantment.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/strangeone101/holoitemsapi/enchantment/CustomEnchantment.java b/src/main/java/com/strangeone101/holoitemsapi/enchantment/CustomEnchantment.java index 56014e17..c35723cf 100644 --- a/src/main/java/com/strangeone101/holoitemsapi/enchantment/CustomEnchantment.java +++ b/src/main/java/com/strangeone101/holoitemsapi/enchantment/CustomEnchantment.java @@ -13,7 +13,7 @@ public abstract class CustomEnchantment implements EnchantmentAbility { private static final HashMap enchantmentsByKey = new HashMap<>(); // TODO: Either make plugin use this namespace, or change datapack's namespace. - private static final String ENCHANTMENT_NAMESPACE = "holocons"; + private static final String ENCHANTMENT_NAMESPACE = "holoitems"; protected final NamespacedKey key; From d90fe5bb4cdd58200cda10262936243da445b25e Mon Sep 17 00:00:00 2001 From: Tsumiki Miniwa <37684627+cpaca@users.noreply.github.com> Date: Mon, 15 Sep 2025 04:30:00 -0700 Subject: [PATCH 19/80] Re-register enchantments again --- .../enchantment/CustomEnchantment.java | 22 ++++++++++++++++++- .../enchantment/EnchantmentListener.java | 7 +++--- .../mc/holoitemsrevamp/HoloItemsRevamp.java | 3 +++ 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/strangeone101/holoitemsapi/enchantment/CustomEnchantment.java b/src/main/java/com/strangeone101/holoitemsapi/enchantment/CustomEnchantment.java index c35723cf..d227c71a 100644 --- a/src/main/java/com/strangeone101/holoitemsapi/enchantment/CustomEnchantment.java +++ b/src/main/java/com/strangeone101/holoitemsapi/enchantment/CustomEnchantment.java @@ -6,8 +6,11 @@ import org.bukkit.plugin.Plugin; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import xyz.holocons.mc.holoitemsrevamp.HoloItemsRevamp; +import xyz.holocons.mc.holoitemsrevamp.enchantment.*; import java.util.HashMap; +import java.util.Set; public abstract class CustomEnchantment implements EnchantmentAbility { @@ -19,7 +22,6 @@ public abstract class CustomEnchantment implements EnchantmentAbility { public CustomEnchantment(Plugin plugin, String key) { this.key = new NamespacedKey(ENCHANTMENT_NAMESPACE, key); - enchantmentsByKey.put(this.key, this); } @Override @@ -58,4 +60,22 @@ public Component lore(int level) { */ public abstract int getCostMultiplier(); + public static final void loadCustomEnchantments(HoloItemsRevamp plugin) { + Set enchantments = Set.of( + new Magnet(plugin), + new Memento(plugin), + new TideRider(plugin), + new Backdash(plugin), + new Plow(plugin) + ); + + for(var ench : enchantments) { + if(enchantmentsByKey.containsKey(ench.key)){ + throw new RuntimeException("Duplicate CustomEnchantment defined for namespacedKey " + ench.key); + } + else { + enchantmentsByKey.put(ench.key, ench); + } + } + } } diff --git a/src/main/java/com/strangeone101/holoitemsapi/enchantment/EnchantmentListener.java b/src/main/java/com/strangeone101/holoitemsapi/enchantment/EnchantmentListener.java index 630b1796..968adf89 100644 --- a/src/main/java/com/strangeone101/holoitemsapi/enchantment/EnchantmentListener.java +++ b/src/main/java/com/strangeone101/holoitemsapi/enchantment/EnchantmentListener.java @@ -21,10 +21,9 @@ private static void forEachEnchantment(final ItemStack itemStack, final Consumer action) { itemStack.getEnchantments().keySet().forEach(enchantment -> { NamespacedKey enchKey = enchantment.getKey(); - if (enchKey.getNamespace().equals("holocons")) { - String name = enchKey.getKey(); - // TODO: Need to convert from name to EnchantmentAbility somehow. - // Current guess is probably something to do with CustomEnchantment + var ench = CustomEnchantment.getByKey(enchKey); + if(ench != null) { + action.accept(ench); } // if (enchantment instanceof EnchantmentAbility ability) { // action.accept(ability); diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/HoloItemsRevamp.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/HoloItemsRevamp.java index 2665d236..01f7d056 100644 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/HoloItemsRevamp.java +++ b/src/main/java/xyz/holocons/mc/holoitemsrevamp/HoloItemsRevamp.java @@ -2,6 +2,7 @@ import com.strangeone101.holoitemsapi.Keys; import com.strangeone101.holoitemsapi.enchantment.AnvilListener; +import com.strangeone101.holoitemsapi.enchantment.CustomEnchantment; import com.strangeone101.holoitemsapi.enchantment.EnchantmentListener; import com.strangeone101.holoitemsapi.item.BlockListener; import com.strangeone101.holoitemsapi.item.CustomItemManager; @@ -22,6 +23,8 @@ public final class HoloItemsRevamp extends JavaPlugin { public void onLoad() { Keys.fillKeys(this); + CustomEnchantment.loadCustomEnchantments(this); + this.collectionManager = new CollectionManager(this); this.trackingManager = new CustomBlockStorage(this); From 5123db821684e59300563acd4faa850f5c8b5116 Mon Sep 17 00:00:00 2001 From: Tsumiki Miniwa <37684627+cpaca@users.noreply.github.com> Date: Mon, 15 Sep 2025 04:30:00 -0700 Subject: [PATCH 20/80] Register and listen to enchantments --- .../enchantment/CustomEnchantment.java | 22 ++++++++++++++++++- .../enchantment/EnchantmentListener.java | 7 +++--- .../mc/holoitemsrevamp/HoloItemsRevamp.java | 3 +++ 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/strangeone101/holoitemsapi/enchantment/CustomEnchantment.java b/src/main/java/com/strangeone101/holoitemsapi/enchantment/CustomEnchantment.java index c35723cf..d227c71a 100644 --- a/src/main/java/com/strangeone101/holoitemsapi/enchantment/CustomEnchantment.java +++ b/src/main/java/com/strangeone101/holoitemsapi/enchantment/CustomEnchantment.java @@ -6,8 +6,11 @@ import org.bukkit.plugin.Plugin; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import xyz.holocons.mc.holoitemsrevamp.HoloItemsRevamp; +import xyz.holocons.mc.holoitemsrevamp.enchantment.*; import java.util.HashMap; +import java.util.Set; public abstract class CustomEnchantment implements EnchantmentAbility { @@ -19,7 +22,6 @@ public abstract class CustomEnchantment implements EnchantmentAbility { public CustomEnchantment(Plugin plugin, String key) { this.key = new NamespacedKey(ENCHANTMENT_NAMESPACE, key); - enchantmentsByKey.put(this.key, this); } @Override @@ -58,4 +60,22 @@ public Component lore(int level) { */ public abstract int getCostMultiplier(); + public static final void loadCustomEnchantments(HoloItemsRevamp plugin) { + Set enchantments = Set.of( + new Magnet(plugin), + new Memento(plugin), + new TideRider(plugin), + new Backdash(plugin), + new Plow(plugin) + ); + + for(var ench : enchantments) { + if(enchantmentsByKey.containsKey(ench.key)){ + throw new RuntimeException("Duplicate CustomEnchantment defined for namespacedKey " + ench.key); + } + else { + enchantmentsByKey.put(ench.key, ench); + } + } + } } diff --git a/src/main/java/com/strangeone101/holoitemsapi/enchantment/EnchantmentListener.java b/src/main/java/com/strangeone101/holoitemsapi/enchantment/EnchantmentListener.java index 630b1796..968adf89 100644 --- a/src/main/java/com/strangeone101/holoitemsapi/enchantment/EnchantmentListener.java +++ b/src/main/java/com/strangeone101/holoitemsapi/enchantment/EnchantmentListener.java @@ -21,10 +21,9 @@ private static void forEachEnchantment(final ItemStack itemStack, final Consumer action) { itemStack.getEnchantments().keySet().forEach(enchantment -> { NamespacedKey enchKey = enchantment.getKey(); - if (enchKey.getNamespace().equals("holocons")) { - String name = enchKey.getKey(); - // TODO: Need to convert from name to EnchantmentAbility somehow. - // Current guess is probably something to do with CustomEnchantment + var ench = CustomEnchantment.getByKey(enchKey); + if(ench != null) { + action.accept(ench); } // if (enchantment instanceof EnchantmentAbility ability) { // action.accept(ability); diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/HoloItemsRevamp.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/HoloItemsRevamp.java index 2665d236..01f7d056 100644 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/HoloItemsRevamp.java +++ b/src/main/java/xyz/holocons/mc/holoitemsrevamp/HoloItemsRevamp.java @@ -2,6 +2,7 @@ import com.strangeone101.holoitemsapi.Keys; import com.strangeone101.holoitemsapi.enchantment.AnvilListener; +import com.strangeone101.holoitemsapi.enchantment.CustomEnchantment; import com.strangeone101.holoitemsapi.enchantment.EnchantmentListener; import com.strangeone101.holoitemsapi.item.BlockListener; import com.strangeone101.holoitemsapi.item.CustomItemManager; @@ -22,6 +23,8 @@ public final class HoloItemsRevamp extends JavaPlugin { public void onLoad() { Keys.fillKeys(this); + CustomEnchantment.loadCustomEnchantments(this); + this.collectionManager = new CollectionManager(this); this.trackingManager = new CustomBlockStorage(this); From ff988d44a63abafb36df26f4f5e37965b8c2d31f Mon Sep 17 00:00:00 2001 From: Tsumiki Miniwa <37684627+cpaca@users.noreply.github.com> Date: Mon, 15 Sep 2025 05:07:44 -0700 Subject: [PATCH 21/80] Replace unstackable with integer stackSize --- .../com/strangeone101/holoitemsapi/Keys.java | 1 + .../holoitemsapi/item/CustomItem.java | 35 +++++++++++++------ .../command/subcommand/AcquireCommand.java | 23 +++++++----- .../holoitemsrevamp/item/BackdashBoots.java | 4 ++- .../mc/holoitemsrevamp/item/MementoItem.java | 1 + 5 files changed, 43 insertions(+), 21 deletions(-) diff --git a/src/main/java/com/strangeone101/holoitemsapi/Keys.java b/src/main/java/com/strangeone101/holoitemsapi/Keys.java index 36450272..5f3d78fd 100644 --- a/src/main/java/com/strangeone101/holoitemsapi/Keys.java +++ b/src/main/java/com/strangeone101/holoitemsapi/Keys.java @@ -10,6 +10,7 @@ public class Keys { public static Property OWNER; public static Property COOLDOWN; + // TODO: Remove? public static Property UNSTACKABLE; public static Property ITEM_ID; diff --git a/src/main/java/com/strangeone101/holoitemsapi/item/CustomItem.java b/src/main/java/com/strangeone101/holoitemsapi/item/CustomItem.java index aa9627f5..acdbf8b3 100644 --- a/src/main/java/com/strangeone101/holoitemsapi/item/CustomItem.java +++ b/src/main/java/com/strangeone101/holoitemsapi/item/CustomItem.java @@ -49,7 +49,7 @@ public class CustomItem implements Keyed { private Component displayName; private List lore; private int cooldown = 0; - private boolean stackable = true; + private Integer stackSize = null; private Set> properties = new HashSet<>(); private Set> statGoals; private int hex; @@ -119,7 +119,9 @@ public ItemStack buildStack(Player player) { Keys.ITEM_ID.set(meta.getPersistentDataContainer(), getInternalName()); // If the item shouldn't be stackable, add a random INTEGER to the NBT - Keys.UNSTACKABLE.set(meta.getPersistentDataContainer(), !isStackable()); + if(this.getStackSize() != null){ + meta.setMaxStackSize(this.getStackSize()); + } if (flags != null && flags.length > 0) meta.addItemFlags(flags); @@ -385,20 +387,31 @@ public void register() { } /** - * If the item is stackable - * @return True if stackable + * The stack size of the item, or null if using the default. + * @return the stack size, or null + */ + public Integer getStackSize() { + return stackSize; + } + + /** + * The stack size of the item, or the default stack size if it's not defined. + * @return the stack size */ - public boolean isStackable() { - return stackable && material.getMaxStackSize() != 1; + public int getStackSizeOrDefault() { + // Note: I did it this way because Registry does it this way (though with getOrThrow). + // https://jd.papermc.io/paper/1.21.8/org/bukkit/Registry.html#get(org.bukkit.NamespacedKey) + // I'm not 100% sure if this is the best way, though. + return stackSize != null ? stackSize : material.getMaxStackSize(); } /** - * Whether the item can be stacked - * @param stackable Stackable + * Sets the stack size of the item. Feeding null will reset to the default stack size. + * @param stackSize The new stack size * @return Itself */ - public CustomItem setStackable(boolean stackable) { - this.stackable = stackable; + public CustomItem setStackSize(Integer stackSize) { + this.stackSize = stackSize; return this; } @@ -427,7 +440,7 @@ public String toString() { ", textureID=" + customModelID + ", material=" + material + ", displayName='" + displayName + "\'\u00A7r'" + - ", stackable=" + stackable + + ", stackSize=" + stackSize + ", properties=" + properties + '}'; } diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/command/subcommand/AcquireCommand.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/command/subcommand/AcquireCommand.java index 9077c951..3c99ca4b 100644 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/command/subcommand/AcquireCommand.java +++ b/src/main/java/xyz/holocons/mc/holoitemsrevamp/command/subcommand/AcquireCommand.java @@ -99,15 +99,20 @@ public boolean execute(CommandSender sender, String[] args) { } var itemStack = customItem.buildStack(player); - Map leftoverItems; - if (customItem.isStackable()) { - itemStack.setAmount(amount); - leftoverItems = player.getInventory().addItem(itemStack); - } else { - var itemStacks = new ItemStack[amount]; - Arrays.fill(itemStacks, itemStack); - leftoverItems = player.getInventory().addItem(itemStacks); - } + itemStack.setAmount(customItem.getStackSize()); + + int totalItemStacks = ((amount - 1)/customItem.getStackSize()) + 1; + int lastItemStackSize = amount - ((totalItemStacks - 1) * customItem.getStackSize()); + // Failsafe incase my math was bad (it was one time lol) + lastItemStackSize = Math.clamp(0, lastItemStackSize, customItem.getStackSize()); + ItemStack lastItemStack = itemStack.clone(); + lastItemStack.setAmount(lastItemStackSize); + + var itemStacks = new ItemStack[totalItemStacks]; + Arrays.fill(itemStacks, itemStack); + itemStacks[totalItemStacks - 1] = lastItemStack; + + Map leftoverItems = player.getInventory().addItem(itemStacks); // If items could not fit in player's inventory, drop them in the world leftoverItems.values().forEach(item -> player.getWorld().dropItemNaturally(player.getLocation(), item)); diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/BackdashBoots.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/BackdashBoots.java index 729da206..66c873cd 100644 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/BackdashBoots.java +++ b/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/BackdashBoots.java @@ -25,7 +25,9 @@ public class BackdashBoots extends CustomItem implements Enchantable { public BackdashBoots(HoloItemsRevamp plugin) { super(plugin, name, material, displayName, lore); - this.setStackable(false); + // TODO: Why was setUnstackable() here? It's boots, they don't stack anyway? + // Should this be removed? + this.setStackSize(1); this.register(); } diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/MementoItem.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/MementoItem.java index a693cb38..e78b64ca 100644 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/MementoItem.java +++ b/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/MementoItem.java @@ -30,6 +30,7 @@ public class MementoItem extends CustomItem implements Enchantable { public MementoItem(HoloItemsRevamp plugin) { super(plugin, name, material, displayName, lore); + this.setStackSize(99); this.register(); } From 79ec8fefb313beb685d6e5c414ab1865e461b016 Mon Sep 17 00:00:00 2001 From: Tsumiki Miniwa <37684627+cpaca@users.noreply.github.com> Date: Mon, 15 Sep 2025 16:46:49 -0700 Subject: [PATCH 22/80] Add datapack and associated gradle task --- build.gradle.kts | 8 ++++++++ .../data/holoitems/enchantment/backdash.json | 17 +++++++++++++++++ .../data/holoitems/enchantment/magnet.json | 17 +++++++++++++++++ .../data/holoitems/enchantment/memento.json | 17 +++++++++++++++++ .../data/holoitems/enchantment/plow.json | 17 +++++++++++++++++ .../data/holoitems/enchantment/tide_rider.json | 17 +++++++++++++++++ holoitems_datapack/pack.mcmeta | 6 ++++++ 7 files changed, 99 insertions(+) create mode 100644 holoitems_datapack/data/holoitems/enchantment/backdash.json create mode 100644 holoitems_datapack/data/holoitems/enchantment/magnet.json create mode 100644 holoitems_datapack/data/holoitems/enchantment/memento.json create mode 100644 holoitems_datapack/data/holoitems/enchantment/plow.json create mode 100644 holoitems_datapack/data/holoitems/enchantment/tide_rider.json create mode 100644 holoitems_datapack/pack.mcmeta diff --git a/build.gradle.kts b/build.gradle.kts index 316691b8..a9c451ef 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -64,10 +64,18 @@ tasks { // Configure the Minecraft version for runServer task // https://github.com/jpenilla/run-paper runServer { + dependsOn("copyDatapack") minecraftVersion("1.21") } } +tasks.register("copyDatapack") { + // Not sure what group to make this + description = "Copies the datapack into the world's datapacks folder" + from("./holoitems_datapack") + into("./run/world/datapacks/holoitems_datapack") +} + // Configure plugin.yml generation // https://github.com/Minecrell/plugin-yml bukkit { diff --git a/holoitems_datapack/data/holoitems/enchantment/backdash.json b/holoitems_datapack/data/holoitems/enchantment/backdash.json new file mode 100644 index 00000000..5facfed7 --- /dev/null +++ b/holoitems_datapack/data/holoitems/enchantment/backdash.json @@ -0,0 +1,17 @@ +{ + "description": "Backdash", + "supported_items": "#minecraft:enchantable/foot_armor", + "primary_items": [], + "weight": 1, + "max_level": 1, + "min_cost": { + "base": 100, + "per_level_above_first": 100 + }, + "max_cost": { + "base": 100, + "per_level_above_first": 100 + }, + "anvil_cost": 20, + "slots": ["feet"] +} \ No newline at end of file diff --git a/holoitems_datapack/data/holoitems/enchantment/magnet.json b/holoitems_datapack/data/holoitems/enchantment/magnet.json new file mode 100644 index 00000000..42d56d8b --- /dev/null +++ b/holoitems_datapack/data/holoitems/enchantment/magnet.json @@ -0,0 +1,17 @@ +{ + "description": "Magnet", + "supported_items": "#minecraft:pickaxes", + "primary_items": [], + "weight": 1, + "max_level": 1, + "min_cost": { + "base": 100, + "per_level_above_first": 100 + }, + "max_cost": { + "base": 100, + "per_level_above_first": 100 + }, + "anvil_cost": 39, + "slots": ["mainhand"] +} \ No newline at end of file diff --git a/holoitems_datapack/data/holoitems/enchantment/memento.json b/holoitems_datapack/data/holoitems/enchantment/memento.json new file mode 100644 index 00000000..61b90c99 --- /dev/null +++ b/holoitems_datapack/data/holoitems/enchantment/memento.json @@ -0,0 +1,17 @@ +{ + "description": "Memento", + "supported_items": "minecraft:ender_chest", + "primary_items": [], + "weight": 1, + "max_level": 1, + "min_cost": { + "base": 100, + "per_level_above_first": 100 + }, + "max_cost": { + "base": 100, + "per_level_above_first": 100 + }, + "anvil_cost": 30, + "slots": ["any"] +} \ No newline at end of file diff --git a/holoitems_datapack/data/holoitems/enchantment/plow.json b/holoitems_datapack/data/holoitems/enchantment/plow.json new file mode 100644 index 00000000..30877791 --- /dev/null +++ b/holoitems_datapack/data/holoitems/enchantment/plow.json @@ -0,0 +1,17 @@ +{ + "description": "Plow", + "supported_items": "#minecraft:shovels", + "primary_items": [], + "weight": 1, + "max_level": 1, + "min_cost": { + "base": 100, + "per_level_above_first": 100 + }, + "max_cost": { + "base": 100, + "per_level_above_first": 100 + }, + "anvil_cost": 32, + "slots": ["mainhand"] +} \ No newline at end of file diff --git a/holoitems_datapack/data/holoitems/enchantment/tide_rider.json b/holoitems_datapack/data/holoitems/enchantment/tide_rider.json new file mode 100644 index 00000000..50bf85de --- /dev/null +++ b/holoitems_datapack/data/holoitems/enchantment/tide_rider.json @@ -0,0 +1,17 @@ +{ + "description": "Tide Rider", + "supported_items": "#minecraft:enchantable/trident", + "primary_items": [], + "weight": 1, + "max_level": 1, + "min_cost": { + "base": 100, + "per_level_above_first": 100 + }, + "max_cost": { + "base": 100, + "per_level_above_first": 100 + }, + "anvil_cost": 20, + "slots": ["mainhand"] +} \ No newline at end of file diff --git a/holoitems_datapack/pack.mcmeta b/holoitems_datapack/pack.mcmeta new file mode 100644 index 00000000..0c256684 --- /dev/null +++ b/holoitems_datapack/pack.mcmeta @@ -0,0 +1,6 @@ +{ + "pack": { + "pack_format": 48, + "description": "HoloItems" + } +} From 07086fa67f5f182db51ad75c789175e3ddb23c54 Mon Sep 17 00:00:00 2001 From: Tsumiki Miniwa <37684627+cpaca@users.noreply.github.com> Date: Mon, 15 Sep 2025 16:53:53 -0700 Subject: [PATCH 23/80] Make copyDatapack delete old datapack --- build.gradle.kts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index a9c451ef..18623196 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -69,11 +69,16 @@ tasks { } } -tasks.register("copyDatapack") { +tasks.register("copyDatapack") { // Not sure what group to make this description = "Copies the datapack into the world's datapacks folder" - from("./holoitems_datapack") - into("./run/world/datapacks/holoitems_datapack") + + delete("./run/world/datapacks/holoitems_datapack") + + copy { + from("./holoitems_datapack") + into("./run/world/datapacks/holoitems_datapack") + } } // Configure plugin.yml generation From 0100d06da09744d2827f0ba27cd5d7435f37fbea Mon Sep 17 00:00:00 2001 From: Tsumiki Miniwa <37684627+cpaca@users.noreply.github.com> Date: Mon, 15 Sep 2025 18:21:04 -0700 Subject: [PATCH 24/80] Fix enchantment namespace --- .../holoitemsapi/enchantment/CustomEnchantment.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/strangeone101/holoitemsapi/enchantment/CustomEnchantment.java b/src/main/java/com/strangeone101/holoitemsapi/enchantment/CustomEnchantment.java index d227c71a..12051823 100644 --- a/src/main/java/com/strangeone101/holoitemsapi/enchantment/CustomEnchantment.java +++ b/src/main/java/com/strangeone101/holoitemsapi/enchantment/CustomEnchantment.java @@ -15,13 +15,12 @@ public abstract class CustomEnchantment implements EnchantmentAbility { private static final HashMap enchantmentsByKey = new HashMap<>(); - // TODO: Either make plugin use this namespace, or change datapack's namespace. - private static final String ENCHANTMENT_NAMESPACE = "holoitems"; protected final NamespacedKey key; public CustomEnchantment(Plugin plugin, String key) { - this.key = new NamespacedKey(ENCHANTMENT_NAMESPACE, key); + // namespace is "holoitems" + this.key = new NamespacedKey(plugin, key); } @Override From edbb871488d6c75510e2ef161aab5b3b0e72a107 Mon Sep 17 00:00:00 2001 From: Tsumiki Miniwa <37684627+cpaca@users.noreply.github.com> Date: Tue, 16 Sep 2025 00:32:33 -0700 Subject: [PATCH 25/80] Move Backdash recipe to datapack Doing this one early because I need it for another commit I wanna try. --- .../data/holoitems/recipe/backdash.json | 25 +++++++++++++++++++ .../holoitemsrevamp/item/BackdashBoots.java | 13 ---------- 2 files changed, 25 insertions(+), 13 deletions(-) create mode 100644 holoitems_datapack/data/holoitems/recipe/backdash.json diff --git a/holoitems_datapack/data/holoitems/recipe/backdash.json b/holoitems_datapack/data/holoitems/recipe/backdash.json new file mode 100644 index 00000000..915e5832 --- /dev/null +++ b/holoitems_datapack/data/holoitems/recipe/backdash.json @@ -0,0 +1,25 @@ +{ + "type": "crafting_shaped", + "pattern": [ + "p p", + "m m" + ], + "key": { + "p": {"item":"minecraft:piston"}, + "m": {"item":"minecraft:phantom_membrane"} + }, + "result": { + "id": "leather_boots", + "components": { + "dyed_color": {"rgb":0}, + "enchantments": {"levels": {"holoitems:backdash": 1}}, + "lore": ["\"Crouch to backdash\""], + "custom_name": "{\"color\":\"dark_gray\",\"text\":\"Backdash\"}", + "custom_data": { + "PublicBukkitValues": { + "holoitems:item_id": "backdash" + } + } + } + } +} \ No newline at end of file diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/BackdashBoots.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/BackdashBoots.java index 66c873cd..13d3a99d 100644 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/BackdashBoots.java +++ b/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/BackdashBoots.java @@ -31,19 +31,6 @@ public BackdashBoots(HoloItemsRevamp plugin) { this.register(); } - @Override - protected Recipe getRecipe() { - final var recipe = new ShapedRecipe(getKey(), buildStack(null)); - recipe.shape( - " ", - "A A", - "B B" - ); - recipe.setIngredient('A', Material.PISTON); - recipe.setIngredient('B', Material.PHANTOM_MEMBRANE); - return recipe; - } - @Override public NamespacedKey getEnchantmentKey() { return getKey(); From 0ebc7a5d9a3c1d0f2fca9a98f83ab69dc4e7fca0 Mon Sep 17 00:00:00 2001 From: Tsumiki Miniwa <37684627+cpaca@users.noreply.github.com> Date: Tue, 16 Sep 2025 02:07:04 -0700 Subject: [PATCH 26/80] Implement book-like items Also makes backdash booklike. --- .../data/holoitems/recipe/backdash.json | 2 +- .../com/strangeone101/holoitemsapi/Keys.java | 32 +++++++++ .../enchantment/AnvilListener.java | 67 +++++++++++++++++++ .../holoitemsapi/recipe/CraftListener.java | 1 + 4 files changed, 101 insertions(+), 1 deletion(-) diff --git a/holoitems_datapack/data/holoitems/recipe/backdash.json b/holoitems_datapack/data/holoitems/recipe/backdash.json index 915e5832..b3196921 100644 --- a/holoitems_datapack/data/holoitems/recipe/backdash.json +++ b/holoitems_datapack/data/holoitems/recipe/backdash.json @@ -17,7 +17,7 @@ "custom_name": "{\"color\":\"dark_gray\",\"text\":\"Backdash\"}", "custom_data": { "PublicBukkitValues": { - "holoitems:item_id": "backdash" + "holoitems:book_like": 20 } } } diff --git a/src/main/java/com/strangeone101/holoitemsapi/Keys.java b/src/main/java/com/strangeone101/holoitemsapi/Keys.java index 5f3d78fd..703c415f 100644 --- a/src/main/java/com/strangeone101/holoitemsapi/Keys.java +++ b/src/main/java/com/strangeone101/holoitemsapi/Keys.java @@ -4,6 +4,8 @@ import org.bukkit.persistence.PersistentDataContainer; import org.bukkit.persistence.PersistentDataType; import org.bukkit.plugin.Plugin; +import org.jetbrains.annotations.NotNull; + import java.util.UUID; public class Keys { @@ -13,6 +15,12 @@ public class Keys { // TODO: Remove? public static Property UNSTACKABLE; public static Property ITEM_ID; + /** + * Used to represent an item that can also be used "like" an enchantment book. + * The first example of this is Backdash, which is both boots and applicable to other boots. + * This is an integer: The integer represents how much it costs to apply the book-like item to another item. + */ + public static Property BOOK_LIKE; public static void fillKeys(Plugin plugin) { OWNER = new Property(plugin, "owner") { @@ -110,5 +118,29 @@ public String getPropertyName() { return "Item ID"; } }; + + // Note: This is Byte instead of Integer, because minecraft keeps parsing the datapack + // value as a Byte, and making it a ByteTag. I do not know how to stop it. + BOOK_LIKE = new Property(plugin, "book_like") { + @Override + public boolean has(PersistentDataContainer data) { + return data.has(getKey(), PersistentDataType.BYTE); + } + + @Override + public Byte get(PersistentDataContainer data) { + return data.getOrDefault(getKey(), PersistentDataType.BYTE, (byte) 0); + } + + @Override + public void set(PersistentDataContainer data, Byte value) { + data.set(getKey(), PersistentDataType.BYTE, value); + } + + @Override + public String getPropertyName() { + return "Book-like"; + } + }; } } diff --git a/src/main/java/com/strangeone101/holoitemsapi/enchantment/AnvilListener.java b/src/main/java/com/strangeone101/holoitemsapi/enchantment/AnvilListener.java index fa5ab887..e2508abf 100644 --- a/src/main/java/com/strangeone101/holoitemsapi/enchantment/AnvilListener.java +++ b/src/main/java/com/strangeone101/holoitemsapi/enchantment/AnvilListener.java @@ -1,7 +1,13 @@ package com.strangeone101.holoitemsapi.enchantment; +import com.strangeone101.holoitemsapi.Keys; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; +import org.bukkit.event.inventory.PrepareAnvilEvent; import xyz.holocons.mc.holoitemsrevamp.HoloItemsRevamp; +import java.util.Map; + public class AnvilListener implements Listener { private final HoloItemsRevamp plugin; @@ -9,4 +15,65 @@ public class AnvilListener implements Listener { public AnvilListener(HoloItemsRevamp plugin) { this.plugin = plugin; } + + @EventHandler(ignoreCancelled = true) + public void onPrepareAnvil(PrepareAnvilEvent event) { + // Handle Anvil scenarios involving the BOOK_LIKE key. + var inventory = event.getInventory(); + var firstItem = inventory.getFirstItem(); + var secondItem = inventory.getSecondItem(); + if(firstItem == null || secondItem == null) { + // BOOK_LIKE doesn't care about these scenarios (only renaming possible) + return; + } + + if(Keys.BOOK_LIKE.get(secondItem.getItemMeta().getPersistentDataContainer()) > 0) { + // Second item is book-like. That means its enchantments need to be applied to the result. + var result = inventory.getResult(); + if(result == null) { + result = firstItem.clone(); + event.setResult(result); + } + + boolean addedEnch = false; + for(Map.Entry ench : secondItem.getEnchantments().entrySet()) { + // Note the >=: I do not care to implement "merging" (ie: two lv3 enchs becomes a lv4 ench) + if(result.getEnchantmentLevel(ench.getKey()) >= ench.getValue()) { + continue; + } + try { + result.addEnchantment(ench.getKey(), ench.getValue()); + } catch (IllegalArgumentException ignored) { + + } + addedEnch = true; + } + + if(!addedEnch) { + // Whatever enchantment(s) were on the 2nd item weren't allowed to be on the result. + // Therefore, block the result from being made. + event.setResult(null); + } + else { + // If it succeeded, the repair-cost also needs to be set. + // If it's non-zero, the book_like tag tells us what the repair cost should be! + // TODO: Remove this todo when your IDE is no longer marking getView and setRepairCost as unstable + // (when that happens, it might get deprecated/changed/removed, hence the todo.) + var anvilView = event.getView(); + anvilView.setRepairCost(Keys.BOOK_LIKE.get(secondItem.getItemMeta().getPersistentDataContainer())); + } + } + + if(Keys.BOOK_LIKE.has(firstItem.getItemMeta().getPersistentDataContainer())) { + // First item is book-like. + // If this is adding enchantments, don't let the result stay book-like. + // (If this is just a renaming or repairing, it's fine.) + var result = event.getResult(); + if(result != null) { + if(!firstItem.getEnchantments().equals(result.getEnchantments())) { + Keys.BOOK_LIKE.set(result.getItemMeta().getPersistentDataContainer(), (byte) 0); + } + } + } + } } diff --git a/src/main/java/com/strangeone101/holoitemsapi/recipe/CraftListener.java b/src/main/java/com/strangeone101/holoitemsapi/recipe/CraftListener.java index 516d24a1..ae643e64 100644 --- a/src/main/java/com/strangeone101/holoitemsapi/recipe/CraftListener.java +++ b/src/main/java/com/strangeone101/holoitemsapi/recipe/CraftListener.java @@ -31,6 +31,7 @@ public void onCraftItem(CraftItemEvent event) { ItemStack stack = event.getCurrentItem(); if (CustomItemManager.isCustomItem(event.getCurrentItem()) && event.getWhoClicked() instanceof Player) { //Makes the output a fresh build of the item. Means it will be owned by that player + // TODO: Don't do that? Maybe? buildStack is messing with the output of the datapacks. event.setCurrentItem(CustomItemManager.getCustomItem(stack).buildStack((Player) event.getWhoClicked())); } From 5891896bb6ff66012a64e8d2d4b7d66aa5c19b09 Mon Sep 17 00:00:00 2001 From: Tsumiki Miniwa <37684627+cpaca@users.noreply.github.com> Date: Tue, 16 Sep 2025 02:18:19 -0700 Subject: [PATCH 27/80] Remove Keys.OWNER --- .../com/strangeone101/holoitemsapi/Keys.java | 24 ------------------- .../holoitemsapi/item/CustomItem.java | 11 --------- 2 files changed, 35 deletions(-) diff --git a/src/main/java/com/strangeone101/holoitemsapi/Keys.java b/src/main/java/com/strangeone101/holoitemsapi/Keys.java index 703c415f..728c74f6 100644 --- a/src/main/java/com/strangeone101/holoitemsapi/Keys.java +++ b/src/main/java/com/strangeone101/holoitemsapi/Keys.java @@ -10,7 +10,6 @@ public class Keys { - public static Property OWNER; public static Property COOLDOWN; // TODO: Remove? public static Property UNSTACKABLE; @@ -23,29 +22,6 @@ public class Keys { public static Property BOOK_LIKE; public static void fillKeys(Plugin plugin) { - OWNER = new Property(plugin, "owner") { - - @Override - public boolean has(PersistentDataContainer data) { - return data.has(getKey(), DataType.UUID); - } - - @Override - public UUID get(PersistentDataContainer data) { - return data.get(getKey(), DataType.UUID); - } - - @Override - public void set(PersistentDataContainer data, UUID value) { - data.set(getKey(), DataType.UUID, value); - } - - @Override - public String getPropertyName() { - return "Owner"; - } - }; - COOLDOWN = new Property(plugin, "cooldown") { @Override diff --git a/src/main/java/com/strangeone101/holoitemsapi/item/CustomItem.java b/src/main/java/com/strangeone101/holoitemsapi/item/CustomItem.java index acdbf8b3..5cf0b863 100644 --- a/src/main/java/com/strangeone101/holoitemsapi/item/CustomItem.java +++ b/src/main/java/com/strangeone101/holoitemsapi/item/CustomItem.java @@ -108,10 +108,6 @@ public ItemStack buildStack(Player player) { if (customModelID != 0) meta.setCustomModelData(customModelID); //Used for resource packs - if (properties.contains(Keys.OWNER) && player != null) { - Keys.OWNER.set(meta.getPersistentDataContainer(), player.getUniqueId()); - } - if (properties.contains(Keys.COOLDOWN)) { Keys.COOLDOWN.set(meta.getPersistentDataContainer(), 0L); } @@ -146,13 +142,6 @@ public ItemStack updateStack(Player player, ItemStack itemStack) { } } - if (properties.contains(Keys.OWNER) && player != null) { - var uuid = Keys.OWNER.get(meta.getPersistentDataContainer()); - if (uuid == null) { // There should be a UUID, so we'll add the player's UUID as a failsafe - Keys.OWNER.set(meta.getPersistentDataContainer(), player.getUniqueId()); - } - } - if (properties.contains(Keys.UNSTACKABLE)) { if (!Keys.UNSTACKABLE.has(meta.getPersistentDataContainer())) { Keys.UNSTACKABLE.set(meta.getPersistentDataContainer(), true); From 7b294f2aa54906a49e21a6df868f45ab0b3879ad Mon Sep 17 00:00:00 2001 From: Tsumiki Miniwa <37684627+cpaca@users.noreply.github.com> Date: Tue, 16 Sep 2025 02:53:34 -0700 Subject: [PATCH 28/80] Grindstone now removes BookLike --- .../java/com/strangeone101/holoitemsapi/Keys.java | 6 +++++- .../holoitemsapi/enchantment/AnvilListener.java | 12 ++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/strangeone101/holoitemsapi/Keys.java b/src/main/java/com/strangeone101/holoitemsapi/Keys.java index 728c74f6..7adac9e0 100644 --- a/src/main/java/com/strangeone101/holoitemsapi/Keys.java +++ b/src/main/java/com/strangeone101/holoitemsapi/Keys.java @@ -110,7 +110,11 @@ public Byte get(PersistentDataContainer data) { @Override public void set(PersistentDataContainer data, Byte value) { - data.set(getKey(), PersistentDataType.BYTE, value); + if (value == 0) { + data.remove(getKey()); + } else { + data.set(getKey(), PersistentDataType.BYTE, value); + } } @Override diff --git a/src/main/java/com/strangeone101/holoitemsapi/enchantment/AnvilListener.java b/src/main/java/com/strangeone101/holoitemsapi/enchantment/AnvilListener.java index e2508abf..7eaa0580 100644 --- a/src/main/java/com/strangeone101/holoitemsapi/enchantment/AnvilListener.java +++ b/src/main/java/com/strangeone101/holoitemsapi/enchantment/AnvilListener.java @@ -4,6 +4,7 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.inventory.PrepareAnvilEvent; +import org.bukkit.event.inventory.PrepareGrindstoneEvent; import xyz.holocons.mc.holoitemsrevamp.HoloItemsRevamp; import java.util.Map; @@ -76,4 +77,15 @@ public void onPrepareAnvil(PrepareAnvilEvent event) { } } } + + @EventHandler(ignoreCancelled = true) + public void onPrepareGrindstone(PrepareGrindstoneEvent event) { + // Make grindstones remove book-like value. + var result = event.getResult(); + if(result != null) { + var meta = result.getItemMeta(); + Keys.BOOK_LIKE.set(meta.getPersistentDataContainer(), (byte) 0); + result.setItemMeta(meta); + } + } } From 6829a53c6622c902c30dba3460c7183a87466113 Mon Sep 17 00:00:00 2001 From: Tsumiki Miniwa <37684627+cpaca@users.noreply.github.com> Date: Tue, 16 Sep 2025 03:24:33 -0700 Subject: [PATCH 29/80] Make BookLike a boolean --- .../com/strangeone101/holoitemsapi/Keys.java | 19 ++++++++----------- .../enchantment/AnvilListener.java | 19 ++++++++++++++----- 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/strangeone101/holoitemsapi/Keys.java b/src/main/java/com/strangeone101/holoitemsapi/Keys.java index 7adac9e0..322d3cc0 100644 --- a/src/main/java/com/strangeone101/holoitemsapi/Keys.java +++ b/src/main/java/com/strangeone101/holoitemsapi/Keys.java @@ -17,9 +17,8 @@ public class Keys { /** * Used to represent an item that can also be used "like" an enchantment book. * The first example of this is Backdash, which is both boots and applicable to other boots. - * This is an integer: The integer represents how much it costs to apply the book-like item to another item. */ - public static Property BOOK_LIKE; + public static Property BOOK_LIKE; public static void fillKeys(Plugin plugin) { COOLDOWN = new Property(plugin, "cooldown") { @@ -95,25 +94,23 @@ public String getPropertyName() { } }; - // Note: This is Byte instead of Integer, because minecraft keeps parsing the datapack - // value as a Byte, and making it a ByteTag. I do not know how to stop it. - BOOK_LIKE = new Property(plugin, "book_like") { + BOOK_LIKE = new Property(plugin, "book_like") { @Override public boolean has(PersistentDataContainer data) { - return data.has(getKey(), PersistentDataType.BYTE); + return data.has(getKey(), PersistentDataType.BOOLEAN); } @Override - public Byte get(PersistentDataContainer data) { - return data.getOrDefault(getKey(), PersistentDataType.BYTE, (byte) 0); + public Boolean get(PersistentDataContainer data) { + return data.getOrDefault(getKey(), PersistentDataType.BOOLEAN, true); } @Override - public void set(PersistentDataContainer data, Byte value) { - if (value == 0) { + public void set(PersistentDataContainer data, Boolean value) { + if (value == null || !value) { data.remove(getKey()); } else { - data.set(getKey(), PersistentDataType.BYTE, value); + data.set(getKey(), PersistentDataType.BOOLEAN, true); } } diff --git a/src/main/java/com/strangeone101/holoitemsapi/enchantment/AnvilListener.java b/src/main/java/com/strangeone101/holoitemsapi/enchantment/AnvilListener.java index 7eaa0580..0f793483 100644 --- a/src/main/java/com/strangeone101/holoitemsapi/enchantment/AnvilListener.java +++ b/src/main/java/com/strangeone101/holoitemsapi/enchantment/AnvilListener.java @@ -1,10 +1,14 @@ package com.strangeone101.holoitemsapi.enchantment; import com.strangeone101.holoitemsapi.Keys; +import io.papermc.paper.registry.RegistryAccess; +import org.bukkit.NamespacedKey; import org.bukkit.enchantments.Enchantment; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.inventory.PrepareAnvilEvent; import org.bukkit.event.inventory.PrepareGrindstoneEvent; +import org.bukkit.inventory.meta.Repairable; +import org.bukkit.persistence.PersistentDataType; import xyz.holocons.mc.holoitemsrevamp.HoloItemsRevamp; import java.util.Map; @@ -28,7 +32,7 @@ public void onPrepareAnvil(PrepareAnvilEvent event) { return; } - if(Keys.BOOK_LIKE.get(secondItem.getItemMeta().getPersistentDataContainer()) > 0) { + if(Keys.BOOK_LIKE.get(secondItem.getItemMeta().getPersistentDataContainer())) { // Second item is book-like. That means its enchantments need to be applied to the result. var result = inventory.getResult(); if(result == null) { @@ -59,9 +63,14 @@ public void onPrepareAnvil(PrepareAnvilEvent event) { // If it succeeded, the repair-cost also needs to be set. // If it's non-zero, the book_like tag tells us what the repair cost should be! // TODO: Remove this todo when your IDE is no longer marking getView and setRepairCost as unstable - // (when that happens, it might get deprecated/changed/removed, hence the todo.) + // (when that happens, it might get deprecated/changed/removed.) var anvilView = event.getView(); - anvilView.setRepairCost(Keys.BOOK_LIKE.get(secondItem.getItemMeta().getPersistentDataContainer())); + if(firstItem instanceof Repairable repairable) { + anvilView.setRepairCost(repairable.getRepairCost()); + } + else { + anvilView.setRepairCost(1); + } } } @@ -72,7 +81,7 @@ public void onPrepareAnvil(PrepareAnvilEvent event) { var result = event.getResult(); if(result != null) { if(!firstItem.getEnchantments().equals(result.getEnchantments())) { - Keys.BOOK_LIKE.set(result.getItemMeta().getPersistentDataContainer(), (byte) 0); + Keys.BOOK_LIKE.set(result.getItemMeta().getPersistentDataContainer(), false); } } } @@ -84,7 +93,7 @@ public void onPrepareGrindstone(PrepareGrindstoneEvent event) { var result = event.getResult(); if(result != null) { var meta = result.getItemMeta(); - Keys.BOOK_LIKE.set(meta.getPersistentDataContainer(), (byte) 0); + Keys.BOOK_LIKE.set(meta.getPersistentDataContainer(), false); result.setItemMeta(meta); } } From c379eae4d5db89673adaa34665321e44b77581cf Mon Sep 17 00:00:00 2001 From: Tsumiki Miniwa <37684627+cpaca@users.noreply.github.com> Date: Tue, 16 Sep 2025 03:29:32 -0700 Subject: [PATCH 30/80] make non-booklike anvil uses work again --- src/main/java/com/strangeone101/holoitemsapi/Keys.java | 2 +- .../strangeone101/holoitemsapi/enchantment/AnvilListener.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/strangeone101/holoitemsapi/Keys.java b/src/main/java/com/strangeone101/holoitemsapi/Keys.java index 322d3cc0..d330d641 100644 --- a/src/main/java/com/strangeone101/holoitemsapi/Keys.java +++ b/src/main/java/com/strangeone101/holoitemsapi/Keys.java @@ -102,7 +102,7 @@ public boolean has(PersistentDataContainer data) { @Override public Boolean get(PersistentDataContainer data) { - return data.getOrDefault(getKey(), PersistentDataType.BOOLEAN, true); + return data.getOrDefault(getKey(), PersistentDataType.BOOLEAN, false); } @Override diff --git a/src/main/java/com/strangeone101/holoitemsapi/enchantment/AnvilListener.java b/src/main/java/com/strangeone101/holoitemsapi/enchantment/AnvilListener.java index 0f793483..5beeb73e 100644 --- a/src/main/java/com/strangeone101/holoitemsapi/enchantment/AnvilListener.java +++ b/src/main/java/com/strangeone101/holoitemsapi/enchantment/AnvilListener.java @@ -74,7 +74,7 @@ public void onPrepareAnvil(PrepareAnvilEvent event) { } } - if(Keys.BOOK_LIKE.has(firstItem.getItemMeta().getPersistentDataContainer())) { + if(Keys.BOOK_LIKE.get(firstItem.getItemMeta().getPersistentDataContainer())) { // First item is book-like. // If this is adding enchantments, don't let the result stay book-like. // (If this is just a renaming or repairing, it's fine.) From ebe5ab7858e8c4bc5b7d6b18a34be228461f55bb Mon Sep 17 00:00:00 2001 From: Tsumiki Miniwa <37684627+cpaca@users.noreply.github.com> Date: Tue, 16 Sep 2025 03:33:00 -0700 Subject: [PATCH 31/80] Switch to item_name instead of custom_name --- holoitems_datapack/data/holoitems/recipe/backdash.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/holoitems_datapack/data/holoitems/recipe/backdash.json b/holoitems_datapack/data/holoitems/recipe/backdash.json index b3196921..267275a5 100644 --- a/holoitems_datapack/data/holoitems/recipe/backdash.json +++ b/holoitems_datapack/data/holoitems/recipe/backdash.json @@ -14,7 +14,7 @@ "dyed_color": {"rgb":0}, "enchantments": {"levels": {"holoitems:backdash": 1}}, "lore": ["\"Crouch to backdash\""], - "custom_name": "{\"color\":\"dark_gray\",\"text\":\"Backdash\"}", + "item_name": "{\"color\":\"dark_gray\",\"text\":\"Backdash\"}", "custom_data": { "PublicBukkitValues": { "holoitems:book_like": 20 From 5e3ce175dc50fb8e64cbeae1db8636e2d0fc962d Mon Sep 17 00:00:00 2001 From: Tsumiki Miniwa <37684627+cpaca@users.noreply.github.com> Date: Tue, 16 Sep 2025 07:27:32 -0700 Subject: [PATCH 32/80] Fix acquire command --- .../command/subcommand/AcquireCommand.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/command/subcommand/AcquireCommand.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/command/subcommand/AcquireCommand.java index 3c99ca4b..6f80c8f9 100644 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/command/subcommand/AcquireCommand.java +++ b/src/main/java/xyz/holocons/mc/holoitemsrevamp/command/subcommand/AcquireCommand.java @@ -99,12 +99,12 @@ public boolean execute(CommandSender sender, String[] args) { } var itemStack = customItem.buildStack(player); - itemStack.setAmount(customItem.getStackSize()); + itemStack.setAmount(customItem.getStackSizeOrDefault()); - int totalItemStacks = ((amount - 1)/customItem.getStackSize()) + 1; - int lastItemStackSize = amount - ((totalItemStacks - 1) * customItem.getStackSize()); + int totalItemStacks = ((amount - 1)/customItem.getStackSizeOrDefault()) + 1; + int lastItemStackSize = amount - ((totalItemStacks - 1) * customItem.getStackSizeOrDefault()); // Failsafe incase my math was bad (it was one time lol) - lastItemStackSize = Math.clamp(0, lastItemStackSize, customItem.getStackSize()); + lastItemStackSize = Math.clamp(0, lastItemStackSize, customItem.getStackSizeOrDefault()); ItemStack lastItemStack = itemStack.clone(); lastItemStack.setAmount(lastItemStackSize); From 66437e862f1dac5715351d0bb928edcd4876b0da Mon Sep 17 00:00:00 2001 From: Tsumiki Miniwa <37684627+cpaca@users.noreply.github.com> Date: Tue, 16 Sep 2025 07:47:48 -0700 Subject: [PATCH 33/80] Move all recipes to datapack --- .../data/holoitems/recipe/backdash.json | 3 +- .../data/holoitems/recipe/holy_fire.json | 33 ++++++++++++ .../data/holoitems/recipe/magnet.json | 50 +++++++++++++++++++ .../data/holoitems/recipe/memento.json | 41 +++++++++++++++ .../data/holoitems/recipe/plow.json | 38 ++++++++++++++ .../data/holoitems/recipe/tide_rider.json | 38 ++++++++++++++ .../holoitemsapi/recipe/CraftListener.java | 10 ++-- .../holoitemsrevamp/item/HolyFireBlock.java | 11 ---- .../mc/holoitemsrevamp/item/MagnetBook.java | 18 ------- .../mc/holoitemsrevamp/item/MementoItem.java | 13 ----- .../mc/holoitemsrevamp/item/PlowBook.java | 14 ------ .../holoitemsrevamp/item/TideRiderItem.java | 16 ------ 12 files changed, 207 insertions(+), 78 deletions(-) create mode 100644 holoitems_datapack/data/holoitems/recipe/holy_fire.json create mode 100644 holoitems_datapack/data/holoitems/recipe/magnet.json create mode 100644 holoitems_datapack/data/holoitems/recipe/memento.json create mode 100644 holoitems_datapack/data/holoitems/recipe/plow.json create mode 100644 holoitems_datapack/data/holoitems/recipe/tide_rider.json diff --git a/holoitems_datapack/data/holoitems/recipe/backdash.json b/holoitems_datapack/data/holoitems/recipe/backdash.json index 267275a5..3a79e2c5 100644 --- a/holoitems_datapack/data/holoitems/recipe/backdash.json +++ b/holoitems_datapack/data/holoitems/recipe/backdash.json @@ -17,7 +17,8 @@ "item_name": "{\"color\":\"dark_gray\",\"text\":\"Backdash\"}", "custom_data": { "PublicBukkitValues": { - "holoitems:book_like": 20 + "holoitems:item_id": "backdash", + "holoitems:book_like": 1 } } } diff --git a/holoitems_datapack/data/holoitems/recipe/holy_fire.json b/holoitems_datapack/data/holoitems/recipe/holy_fire.json new file mode 100644 index 00000000..09c899b1 --- /dev/null +++ b/holoitems_datapack/data/holoitems/recipe/holy_fire.json @@ -0,0 +1,33 @@ +{ + "type": "minecraft:crafting_shaped", + "pattern": [ + " a ", + "aba", + "ccc" + ], + "key": { + "a": { + "item": "minecraft:end_rod" + }, + "b": { + "item": "minecraft:quartz" + }, + "c": { + "item": "minecraft:raw_gold_block" + } + }, + "result": { + "id": "minecraft:soul_campfire", + "components": { + "minecraft:custom_data": { + "PublicBukkitValues": { + "holoitems:item_id": "holy_fire" + } + }, + "minecraft:item_name": "{\"color\":\"dark_purple\",\"text\":\"Holy Fire\"}", + "minecraft:lore": [ + "{\"color\":\"aqua\",\"italic\":false,\"text\":\"Prevent natural mob spawning within 100 blocks when lit\"}" + ] + } + } +} \ No newline at end of file diff --git a/holoitems_datapack/data/holoitems/recipe/magnet.json b/holoitems_datapack/data/holoitems/recipe/magnet.json new file mode 100644 index 00000000..2ad9a105 --- /dev/null +++ b/holoitems_datapack/data/holoitems/recipe/magnet.json @@ -0,0 +1,50 @@ +{ + "type": "minecraft:crafting_shaped", + "pattern": [ + "AAB", + "CDE", + "FGD" + ], + "key": { + "A": { + "item": "minecraft:powered_rail" + }, + "B": { + "item": "minecraft:iron_pickaxe" + }, + "C": { + "item": "minecraft:hopper" + }, + "D": { + "item": "minecraft:iron_block" + }, + "E": { + "item": "minecraft:redstone" + }, + "F": { + "item": "minecraft:dropper" + }, + "G": { + "item": "minecraft:comparator" + } + }, + "result": { + "id": "minecraft:enchanted_book", + "components": { + "minecraft:custom_data": { + "PublicBukkitValues": { + "holoitems:item_id": "magnet" + } + }, + "minecraft:item_name": "{\"color\":\"red\",\"text\":\"Magnet\"}", + "minecraft:lore": [ + "{\"color\":\"dark_purple\", \"text\":\"Automatically put mined items to your inventory!\"}" + ], + "minecraft:stored_enchantments": { + "levels": { + "holoitems:magnet": 1 + } + } + } + } +} \ No newline at end of file diff --git a/holoitems_datapack/data/holoitems/recipe/memento.json b/holoitems_datapack/data/holoitems/recipe/memento.json new file mode 100644 index 00000000..5a8f4cd0 --- /dev/null +++ b/holoitems_datapack/data/holoitems/recipe/memento.json @@ -0,0 +1,41 @@ +{ + "type": "minecraft:crafting_shaped", + "pattern": [ + "AAA", + "ABA", + "AAA" + ], + "key": { + "A": [ + { + "item": "minecraft:obsidian" + }, + { + "item": "minecraft:crying_obsidian" + } + ], + "B": { + "item": "minecraft:end_crystal" + } + }, + "result": { + "id": "minecraft:ender_chest", + "components": { + "minecraft:custom_data": { + "PublicBukkitValues": { + "holoitems:item_id": "memento" + } + }, + "minecraft:item_name": "{\"color\":\"dark_purple\",\"text\":\"Memento\"}", + "minecraft:enchantments": { + "levels": { + "holoitems:memento": 1 + } + }, + "minecraft:lore": [ + "{\"color\":\"dark_purple\",\"text\":\"Keep your items on death. Consumable.\"}" + ], + "minecraft:max_stack_size": 99 + } + } +} \ No newline at end of file diff --git a/holoitems_datapack/data/holoitems/recipe/plow.json b/holoitems_datapack/data/holoitems/recipe/plow.json new file mode 100644 index 00000000..3e473fcb --- /dev/null +++ b/holoitems_datapack/data/holoitems/recipe/plow.json @@ -0,0 +1,38 @@ +{ + "type": "minecraft:crafting_shaped", + "pattern": [ + "ABA", + "ACA", + "ACA" + ], + "key": { + "A": { + "item": "minecraft:tinted_glass" + }, + "B": { + "item": "minecraft:obsidian" + }, + "C": { + "item": "minecraft:stick" + } + }, + "result": { + "id": "minecraft:enchanted_book", + "components": { + "minecraft:custom_data": { + "PublicBukkitValues": { + "holoitems:item_id": "plow" + } + }, + "minecraft:item_name": "{\"color\":\"red\",\"text\":\"Plow\"}", + "minecraft:lore": [ + "{\"color\":\"dark_purple\",\"text\":\"Shovel snow!\"}" + ], + "minecraft:stored_enchantments": { + "levels": { + "holoitems:plow": 1 + } + } + } + } +} \ No newline at end of file diff --git a/holoitems_datapack/data/holoitems/recipe/tide_rider.json b/holoitems_datapack/data/holoitems/recipe/tide_rider.json new file mode 100644 index 00000000..b3dc1406 --- /dev/null +++ b/holoitems_datapack/data/holoitems/recipe/tide_rider.json @@ -0,0 +1,38 @@ +{ + "type": "minecraft:crafting_shaped", + "pattern": [ + "ABA", + "AC ", + " A " + ], + "key": { + "A": { + "item": "minecraft:prismarine_bricks" + }, + "B": { + "item": "minecraft:trident" + }, + "C": { + "item": "minecraft:enchanted_golden_apple" + } + }, + "result": { + "id": "minecraft:trident", + "components": { + "minecraft:custom_data": { + "PublicBukkitValues": { + "holoitems:item_id": "tide_rider" + } + }, + "minecraft:item_name": "{\"color\":\"blue\",\"text\":\"Tide Rider\"}", + "minecraft:enchantments": { + "levels": { + "holoitems:tide_rider": 1 + } + }, + "minecraft:lore": [ + "{\"text\":\"Surf the waves\"}" + ] + } + } +} \ No newline at end of file diff --git a/src/main/java/com/strangeone101/holoitemsapi/recipe/CraftListener.java b/src/main/java/com/strangeone101/holoitemsapi/recipe/CraftListener.java index ae643e64..01ae252c 100644 --- a/src/main/java/com/strangeone101/holoitemsapi/recipe/CraftListener.java +++ b/src/main/java/com/strangeone101/holoitemsapi/recipe/CraftListener.java @@ -29,11 +29,11 @@ public CraftListener(HoloItemsRevamp plugin) { @EventHandler(ignoreCancelled = true) public void onCraftItem(CraftItemEvent event) { ItemStack stack = event.getCurrentItem(); - if (CustomItemManager.isCustomItem(event.getCurrentItem()) && event.getWhoClicked() instanceof Player) { - //Makes the output a fresh build of the item. Means it will be owned by that player - // TODO: Don't do that? Maybe? buildStack is messing with the output of the datapacks. - event.setCurrentItem(CustomItemManager.getCustomItem(stack).buildStack((Player) event.getWhoClicked())); - } +// if (CustomItemManager.isCustomItem(event.getCurrentItem()) && event.getWhoClicked() instanceof Player) { +// //Makes the output a fresh build of the item. Means it will be owned by that player +// // TODO: Don't do that? Maybe? buildStack is messing with the output of the datapacks. +// event.setCurrentItem(CustomItemManager.getCustomItem(stack).buildStack((Player) event.getWhoClicked())); +// } if (!RecipeManager.isManagedRecipe(event.getRecipe())) { for (ItemStack ingredient : event.getInventory().getMatrix()) { diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/HolyFireBlock.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/HolyFireBlock.java index 69d7120f..44ba22b3 100644 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/HolyFireBlock.java +++ b/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/HolyFireBlock.java @@ -46,17 +46,6 @@ public HolyFireBlock(HoloItemsRevamp plugin) { register(); } - @Override - protected Recipe getRecipe() { - final var recipe = new ShapedRecipe(getKey(), buildStack(null)); - recipe.shape(" a ", "aba", "ccc"); - recipe.setIngredient('a', Material.END_ROD); - recipe.setIngredient('b', new CustomItemRecipeChoice("saint_quartz")); - recipe.setIngredient('c', Material.RAW_GOLD_BLOCK); - recipe.setGroup(name); - return recipe; - } - @Override public void onBlockBreak(BlockBreakEvent event, BlockState blockState) { holyFireMarker.remove(blockState); diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/MagnetBook.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/MagnetBook.java index 9c2f6555..ea4b85af 100644 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/MagnetBook.java +++ b/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/MagnetBook.java @@ -30,24 +30,6 @@ public MagnetBook(HoloItemsRevamp plugin) { this.register(); } - @Override - protected Recipe getRecipe() { - final var recipe = new ShapedRecipe(getKey(), buildStack(null)); - recipe.shape( - "AAB", - "CDE", - "FGD" - ); - recipe.setIngredient('A', Material.POWERED_RAIL); - recipe.setIngredient('B', Material.IRON_PICKAXE); - recipe.setIngredient('C', Material.HOPPER); - recipe.setIngredient('D', Material.IRON_BLOCK); - recipe.setIngredient('E', Material.REDSTONE); - recipe.setIngredient('F', Material.DROPPER); - recipe.setIngredient('G', Material.COMPARATOR); - return recipe; - } - @Override public NamespacedKey getEnchantmentKey() { return getKey(); diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/MementoItem.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/MementoItem.java index e78b64ca..55b9a109 100644 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/MementoItem.java +++ b/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/MementoItem.java @@ -34,19 +34,6 @@ public MementoItem(HoloItemsRevamp plugin) { this.register(); } - @Override - protected Recipe getRecipe() { - final var recipe = new ShapedRecipe(getKey(), buildStack(null)); - recipe.shape( - "AAA", - "ABA", - "AAA" - ); - recipe.setIngredient('A', Material.ENDER_CHEST); - recipe.setIngredient('B', Material.END_CRYSTAL); - return recipe; - } - @Override public NamespacedKey getEnchantmentKey() { return getKey(); diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/PlowBook.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/PlowBook.java index b540db8c..c2ab6c60 100644 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/PlowBook.java +++ b/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/PlowBook.java @@ -29,20 +29,6 @@ public PlowBook(HoloItemsRevamp plugin){ this.register(); } - @Override - protected Recipe getRecipe() { - ShapedRecipe recipe = new ShapedRecipe(getKey(), buildStack(null)); - recipe.shape( - "ABA", - "ACA", - "ACA" - ); - recipe.setIngredient('A', Material.TINTED_GLASS); - recipe.setIngredient('B', Material.OBSIDIAN); - recipe.setIngredient('C', Material.STICK); - return recipe; - } - @Override public NamespacedKey getEnchantmentKey() { return getKey(); diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/TideRiderItem.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/TideRiderItem.java index b946361c..b016651c 100644 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/TideRiderItem.java +++ b/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/TideRiderItem.java @@ -31,22 +31,6 @@ public TideRiderItem(HoloItemsRevamp plugin) { this.register(); } - @Override - protected Recipe getRecipe() { - final var recipe = new ShapedRecipe(getKey(), buildStack(null)); - recipe.shape( - "ABC", - "DEF", - "GDI" - ); - recipe.setIngredient('A', Material.PRISMARINE_BRICKS); - recipe.setIngredient('B', Material.TRIDENT); - recipe.setIngredient('C', Material.PRISMARINE_BRICKS); - recipe.setIngredient('E', Material.ENCHANTED_GOLDEN_APPLE); - recipe.setIngredient('D', Material.PRISMARINE_BRICKS); - return recipe; - } - @Override public NamespacedKey getEnchantmentKey() { return getKey(); From 1eaf079c57639e0062e0bb10f3cefdaaad2df0a2 Mon Sep 17 00:00:00 2001 From: Tsumiki Miniwa <37684627+cpaca@users.noreply.github.com> Date: Tue, 16 Sep 2025 08:19:12 -0700 Subject: [PATCH 34/80] Simplify/reduce code. This is equivalent to the old code, since there are now no more implementations of getRecipe. This is to help justify the next commit (which is separate, because it does a lot and I might need to undo it.) --- .../java/com/strangeone101/holoitemsapi/item/CustomItem.java | 5 ----- .../strangeone101/holoitemsapi/item/CustomItemManager.java | 1 - 2 files changed, 6 deletions(-) diff --git a/src/main/java/com/strangeone101/holoitemsapi/item/CustomItem.java b/src/main/java/com/strangeone101/holoitemsapi/item/CustomItem.java index 5cf0b863..f1ce8e12 100644 --- a/src/main/java/com/strangeone101/holoitemsapi/item/CustomItem.java +++ b/src/main/java/com/strangeone101/holoitemsapi/item/CustomItem.java @@ -17,7 +17,6 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.ItemFlag; import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.Recipe; import org.bukkit.inventory.meta.Damageable; import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.LeatherArmorMeta; @@ -77,10 +76,6 @@ public final String getInternalName() { return getKey().getKey(); } - protected Recipe getRecipe() { - return null; - } - /** * Create a new ItemStack for use. NOT for updating existing ones; see updateStack * @param player The player diff --git a/src/main/java/com/strangeone101/holoitemsapi/item/CustomItemManager.java b/src/main/java/com/strangeone101/holoitemsapi/item/CustomItemManager.java index c2312c06..fe7f468b 100644 --- a/src/main/java/com/strangeone101/holoitemsapi/item/CustomItemManager.java +++ b/src/main/java/com/strangeone101/holoitemsapi/item/CustomItemManager.java @@ -33,7 +33,6 @@ public static void register(CustomItem item) { public static void lock() { if (!locked) { locked = true; - CUSTOM_ITEMS.values().forEach(item -> RecipeManager.registerRecipe(item.getRecipe())); } } From 239ae779c2ae72f64a6e1c649f04e0da8fcc81be Mon Sep 17 00:00:00 2001 From: Tsumiki Miniwa <37684627+cpaca@users.noreply.github.com> Date: Tue, 16 Sep 2025 08:23:01 -0700 Subject: [PATCH 35/80] Remove RecipeBuilder Shaped, Shapeless, Furnace Advanced is something I need to look into and decide if I want to keep it or completely rebuild it. These things make no sense to keep though, due to datapack stuff. --- .../holoitemsapi/recipe/RecipeBuilder.java | 136 ------------------ 1 file changed, 136 deletions(-) diff --git a/src/main/java/com/strangeone101/holoitemsapi/recipe/RecipeBuilder.java b/src/main/java/com/strangeone101/holoitemsapi/recipe/RecipeBuilder.java index 631f032a..4c218325 100644 --- a/src/main/java/com/strangeone101/holoitemsapi/recipe/RecipeBuilder.java +++ b/src/main/java/com/strangeone101/holoitemsapi/recipe/RecipeBuilder.java @@ -21,142 +21,6 @@ public class RecipeBuilder { - public static class Shaped { - - private ShapedRecipe recipe; - private Map ingredients = new HashMap<>(); - private Map riingredients = new HashMap<>(); - private String[] shape; - - public Shaped(NamespacedKey key, ItemStack stack) { - this.recipe = new ShapedRecipe(key, stack); - } - - public Shaped setIngredient(char character, Material material) { - ingredients.put(character, new ItemStack(material)); - return this; - } - - public Shaped setIngredient(char character, ItemStack stack) { - ingredients.put(character, stack); - return this; - } - - public Shaped setIngredient(char character, RecipeChoice recipeChoice) { - riingredients.put(character, recipeChoice); - return this; - } - - public Shaped setShape(String... shape) { - this.shape = shape; - return this; - } - - public ShapedRecipe build() { - if (shape == null) throw new NoSuchElementException("Shape was not provided!"); - - if (ingredients.size() == 0 && riingredients.size() == 0) { - throw new NoSuchElementException("No ingredients provided!"); - } - - recipe.shape(shape); - - for (Character c : ingredients.keySet()) { - recipe.setIngredient(c, new RecipeChoice.ExactChoice(ingredients.get(c))); - } - - for (Character c : riingredients.keySet()) { - recipe.setIngredient(c, riingredients.get(c)); - } - - return recipe; - } - - public ShapedRecipe buildRegister() { - ShapedRecipe recipe = build(); - RecipeManager.registerRecipe(recipe); - return recipe; - } - } - - public static class Shapeless { - - private ShapelessRecipe recipe; - private Map ingredients = new HashMap<>(); - private Map riingredients = new HashMap<>(); - private int totalSlots = 0; - - public Shapeless(NamespacedKey key, ItemStack stack) { - this.recipe = new ShapelessRecipe(key, stack); - } - - public Shapeless addIngredient(Material material) { - ingredients.put(new ItemStack(material), 1); - totalSlots++; - return this; - } - - public Shapeless addIngredient(ItemStack stack) { - ingredients.put(stack, 1); - totalSlots++; - return this; - } - - public Shapeless addIngredient(RecipeChoice recipeChoice) { - riingredients.put(recipeChoice, 1); - totalSlots++; - return this; - } - - public Shapeless addIngredient(Material material, int amount) { - ingredients.put(new ItemStack(material), amount); - totalSlots += amount; - return this; - } - - public Shapeless addIngredient(ItemStack stack, int amount) { - ingredients.put(stack, amount); - totalSlots += amount; - return this; - } - - public Shapeless setIngredient(RecipeChoice recipeChoice, int amount) { - riingredients.put(recipeChoice, amount); - totalSlots += amount; - return this; - } - - public ShapelessRecipe build() { - if (totalSlots > 9) throw new NoSuchElementException("Provided more than 9 slots!"); - - if (ingredients.size() == 0 && riingredients.size() == 0) { - throw new NoSuchElementException("No ingredients provided!"); - } - - for (ItemStack stack : ingredients.keySet()) { - for (int i = 0; i < ingredients.get(stack); i++) - recipe.addIngredient(new RecipeChoice.ExactChoice(stack)); - - } - - for (RecipeChoice c : riingredients.keySet()) { - recipe.addIngredient(c); - } - - return recipe; - } - - public ShapelessRecipe buildRegister() { - ShapelessRecipe recipe = build(); - RecipeManager.registerRecipe(recipe); - return recipe; - } - } - - public static class Furnace { - //TODO - } - public static class AdvancedShape extends AdvancedRecipe { private ShapedRecipe recipe; From 2ada2a51bbc7510aaa1bf2007d4d34c40164a3f4 Mon Sep 17 00:00:00 2001 From: cpaca <37684627+cpaca@users.noreply.github.com> Date: Tue, 16 Sep 2025 08:28:33 -0700 Subject: [PATCH 36/80] Correct runServer version Co-authored-by: Derek Lee --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index 18623196..c45411f1 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -65,7 +65,7 @@ tasks { // https://github.com/jpenilla/run-paper runServer { dependsOn("copyDatapack") - minecraftVersion("1.21") + minecraftVersion("1.21.1") } } From 7ccfb241cfffe8a1d542bd8a3f4b8d99f8740498 Mon Sep 17 00:00:00 2001 From: cpaca <37684627+cpaca@users.noreply.github.com> Date: Tue, 16 Sep 2025 08:28:48 -0700 Subject: [PATCH 37/80] Correct apiVersion version Co-authored-by: Derek Lee --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index c45411f1..ed4b20a5 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -85,7 +85,7 @@ tasks.register("copyDatapack") { // https://github.com/Minecrell/plugin-yml bukkit { main = "xyz.holocons.mc.holoitemsrevamp.HoloItemsRevamp" - apiVersion = "1.21" + apiVersion = "1.21.1" authors = listOf("TraceL", "dlee13") website = "holocons.xyz" depend = listOf("ProtocolLib") From 1056f040a9b9cd90751ce1279d772148695f4184 Mon Sep 17 00:00:00 2001 From: Tsumiki Miniwa <37684627+cpaca@users.noreply.github.com> Date: Tue, 16 Sep 2025 19:03:15 -0700 Subject: [PATCH 38/80] Switch from bukkit plugin.yml to paper-plugin.yml MainCommand is now broken, as command registration is different with paper-plugin.yml --- build.gradle.kts | 23 +++++++++++++------ .../data/holoitems/recipe/holy_fire.json | 2 +- .../holoitems/tags/item/saint_quartz.json | 7 ++++++ .../mc/holoitemsrevamp/HoloItemsRevamp.java | 10 +++++++- .../holoitemsrevamp/HoloitemsBootstrap.java | 18 +++++++++++++++ .../holoitemsrevamp/command/MainCommand.java | 23 ++++++++++++++++++- 6 files changed, 73 insertions(+), 10 deletions(-) create mode 100644 holoitems_datapack/data/holoitems/tags/item/saint_quartz.json create mode 100644 src/main/java/xyz/holocons/mc/holoitemsrevamp/HoloitemsBootstrap.java diff --git a/build.gradle.kts b/build.gradle.kts index ed4b20a5..45d2ab36 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,6 +1,7 @@ plugins { `java-library` - id("net.minecrell.plugin-yml.bukkit") version "0.6.0" // Generates plugin.yml + id("java") + id("net.minecrell.plugin-yml.paper") version "0.6.0" // Generates plugin.yml id("com.gradleup.shadow") version "8.3.9" // Shades and relocates dependencies into our plugin jar id("xyz.jpenilla.run-paper") version "2.3.0" // Adds runServer and runMojangMappedServer tasks for testing } @@ -18,6 +19,7 @@ repositories { maven("https://repo.papermc.io/repository/maven-public/") maven("https://repo.dmulloy2.net/repository/public/") maven("https://maven.enginehub.org/repo/") + maven("https://papermc.io/repo/repository/maven-public/") } dependencies { @@ -83,18 +85,25 @@ tasks.register("copyDatapack") { // Configure plugin.yml generation // https://github.com/Minecrell/plugin-yml -bukkit { +paper { main = "xyz.holocons.mc.holoitemsrevamp.HoloItemsRevamp" + bootstrapper = "xyz.holocons.mc.holoitemsrevamp.HoloitemsBootstrap" apiVersion = "1.21.1" authors = listOf("TraceL", "dlee13") website = "holocons.xyz" - depend = listOf("ProtocolLib") - softDepend = listOf("WorldGuard") prefix = "HoloItems" - commands { - register("holoitems") { - usage = "/holoitems" + serverDependencies { + register("ProtocolLib") + + register("WorldGuard") { + required = false } } + +// commands { +// register("holoitems") { +// usage = "/holoitems" +// } +// } } diff --git a/holoitems_datapack/data/holoitems/recipe/holy_fire.json b/holoitems_datapack/data/holoitems/recipe/holy_fire.json index 09c899b1..c9f18c7b 100644 --- a/holoitems_datapack/data/holoitems/recipe/holy_fire.json +++ b/holoitems_datapack/data/holoitems/recipe/holy_fire.json @@ -10,7 +10,7 @@ "item": "minecraft:end_rod" }, "b": { - "item": "minecraft:quartz" + "tag": "holoitems:saint_quartz" }, "c": { "item": "minecraft:raw_gold_block" diff --git a/holoitems_datapack/data/holoitems/tags/item/saint_quartz.json b/holoitems_datapack/data/holoitems/tags/item/saint_quartz.json new file mode 100644 index 00000000..a3193b00 --- /dev/null +++ b/holoitems_datapack/data/holoitems/tags/item/saint_quartz.json @@ -0,0 +1,7 @@ +{ + "values": [ + { + "id": "minecraft:quartz" + } + ] +} \ No newline at end of file diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/HoloItemsRevamp.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/HoloItemsRevamp.java index 01f7d056..dfe5bf19 100644 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/HoloItemsRevamp.java +++ b/src/main/java/xyz/holocons/mc/holoitemsrevamp/HoloItemsRevamp.java @@ -8,6 +8,7 @@ import com.strangeone101.holoitemsapi.item.CustomItemManager; import com.strangeone101.holoitemsapi.recipe.CraftListener; import com.strangeone101.holoitemsapi.tracking.CustomBlockStorage; +import io.papermc.paper.plugin.lifecycle.event.types.LifecycleEvents; import org.bukkit.plugin.java.JavaPlugin; import xyz.holocons.mc.holoitemsrevamp.collection.CollectionManager; @@ -43,7 +44,14 @@ public void onEnable() { getServer().getPluginManager().registerEvents(new CraftListener(this), this); getServer().getPluginManager().registerEvents(new BlockListener(this), this); - getCommand("holoitems").setExecutor(new MainCommand(this)); +// getCommand("holoitems").setExecutor(new MainCommand(this)); + var lifecycleManager = this.getLifecycleManager(); + var mainCommand = new MainCommand(this); + lifecycleManager.registerEventHandler(LifecycleEvents.COMMANDS, commands -> { + var registrar = commands.registrar(); + registrar.register("holoitems", mainCommand); + }); + getLogger().info("HoloItems-Revamped [ON]"); } diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/HoloitemsBootstrap.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/HoloitemsBootstrap.java new file mode 100644 index 00000000..a5f79b7a --- /dev/null +++ b/src/main/java/xyz/holocons/mc/holoitemsrevamp/HoloitemsBootstrap.java @@ -0,0 +1,18 @@ +package xyz.holocons.mc.holoitemsrevamp; + +import io.papermc.paper.plugin.bootstrap.BootstrapContext; +import io.papermc.paper.plugin.bootstrap.PluginBootstrap; +import io.papermc.paper.plugin.lifecycle.event.types.LifecycleEvents; +import io.papermc.paper.registry.RegistryKey; +import org.jetbrains.annotations.NotNull; +import xyz.holocons.mc.holoitemsrevamp.command.MainCommand; + +public class HoloitemsBootstrap implements PluginBootstrap { + @Override + public void bootstrap(@NotNull BootstrapContext context) { + var manager = context.getLifecycleManager(); + manager.registerEventHandler(LifecycleEvents.TAGS.preFlatten(RegistryKey.ITEM), event -> { + // TODO + }); + } +} diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/command/MainCommand.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/command/MainCommand.java index b88999c8..a5bfcb4d 100644 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/command/MainCommand.java +++ b/src/main/java/xyz/holocons/mc/holoitemsrevamp/command/MainCommand.java @@ -1,11 +1,14 @@ package xyz.holocons.mc.holoitemsrevamp.command; +import io.papermc.paper.command.brigadier.BasicCommand; +import io.papermc.paper.command.brigadier.CommandSourceStack; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.TextComponent; import net.kyori.adventure.text.event.ClickEvent; import net.kyori.adventure.text.event.HoverEvent; import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.format.TextDecoration; +import org.apache.commons.lang3.NotImplementedException; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.command.TabExecutor; @@ -17,10 +20,11 @@ import xyz.holocons.mc.holoitemsrevamp.command.subcommand.StatsCommand; import java.util.Arrays; +import java.util.Collection; import java.util.List; import java.util.Set; -public class MainCommand implements TabExecutor { +public class MainCommand implements TabExecutor, BasicCommand { private final Set subCommands; private final TextComponent helpComponent; @@ -85,4 +89,21 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command } return null; } + + @Override + public void execute(CommandSourceStack sourceStack, String[] args) { + // TODO + throw new NotImplementedException(); + } + + @Override + public Collection suggest(CommandSourceStack sourceStack, String[] args) { + // TODO + throw new NotImplementedException(); + } + + @Override + public boolean canUse(CommandSender sender) { + return true; + } } From d0a660d7377e7394aa7f0e3078c1a90ad4207c9f Mon Sep 17 00:00:00 2001 From: Tsumiki Miniwa <37684627+cpaca@users.noreply.github.com> Date: Tue, 16 Sep 2025 23:31:41 -0700 Subject: [PATCH 39/80] Fix command --- .../holoitemsrevamp/command/MainCommand.java | 88 +++++++++---------- 1 file changed, 41 insertions(+), 47 deletions(-) diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/command/MainCommand.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/command/MainCommand.java index a5bfcb4d..568595f1 100644 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/command/MainCommand.java +++ b/src/main/java/xyz/holocons/mc/holoitemsrevamp/command/MainCommand.java @@ -19,29 +19,26 @@ import xyz.holocons.mc.holoitemsrevamp.command.subcommand.CollectionsCommand; import xyz.holocons.mc.holoitemsrevamp.command.subcommand.StatsCommand; -import java.util.Arrays; -import java.util.Collection; -import java.util.List; -import java.util.Set; +import java.util.*; -public class MainCommand implements TabExecutor, BasicCommand { - - private final Set subCommands; +public class MainCommand implements BasicCommand { + + // Maps from the name of a subcommand to that subcommand + private final Map subCommands = new HashMap<>(); private final TextComponent helpComponent; public MainCommand(HoloItemsRevamp plugin) { - this.subCommands = Set.of( - new AcquireCommand(plugin), - new CollectionsCommand(plugin), - new StatsCommand() - ); + addSubCommand(new AcquireCommand(plugin)); + addSubCommand(new CollectionsCommand(plugin)); + addSubCommand(new StatsCommand()); + // Create text component message for help page final var helpComponentBuilder = Component.text() .append(Component.text("=====", NamedTextColor.DARK_AQUA)) .append(Component.text("HoloItems", NamedTextColor.GREEN)) .append(Component.text("======", NamedTextColor.DARK_AQUA)) .append(Component.newline()); - for (var subCommand : subCommands) { + for (var subCommand : subCommands.values()) { helpComponentBuilder.append( Component.text() .append(Component.text("/holoitems ", NamedTextColor.WHITE)) @@ -56,54 +53,51 @@ public MainCommand(HoloItemsRevamp plugin) { } @Override - public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) { - if (args.length != 0) { - for (var subCommand : subCommands) { - if (args[0].equalsIgnoreCase(subCommand.getName())) { - if (!subCommand.execute(sender, Arrays.copyOfRange(args, 1, args.length))) { - sender.sendMessage(Component.text("/holoitems " + subCommand.getName() + " " + subCommand.getFormat()) - .decoration(TextDecoration.BOLD, true) - .decoration(TextDecoration.UNDERLINED, true) - .color(NamedTextColor.RED)); - } - return true; - } + public void execute(CommandSourceStack sourceStack, String[] args) { + System.out.println(Arrays.toString(args)); + var sender = sourceStack.getSender(); + if(args.length == 0) { + sender.sendMessage(helpComponent); + return; + } + var subCommand = subCommands.get(args[0]); + if (subCommand != null) { + // found subcommand, attempt to execute: + if (!subCommand.execute(sender, Arrays.copyOfRange(args, 1, args.length))) { + sender.sendMessage(Component.text("/holoitems " + subCommand.getName() + " " + subCommand.getFormat()) + .decoration(TextDecoration.BOLD, true) + .decoration(TextDecoration.UNDERLINED, true) + .color(NamedTextColor.RED)); } - // If no subCommands matched... + } + else { + // no found subcommand: sender.sendMessage(Component.text("Command not found!", NamedTextColor.RED).decoration(TextDecoration.BOLD, true)); } - sender.sendMessage(helpComponent); - return true; } @Override - public @Nullable List onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, @NotNull String[] args) { + public @NotNull Collection suggest(CommandSourceStack sourceStack, String[] args) { + // TODO if (args.length <= 1) { - return subCommands.stream().map(SubCommand::getName).toList(); + return subCommands.keySet(); } else { - for (var subCommand : subCommands) { - if (args[0].equalsIgnoreCase(subCommand.getName())) { - return subCommand.getAutoComplete(Arrays.copyOfRange(args, 1, args.length)); - } + var subCommand = subCommands.get(args[0]); + if(subCommand == null) { + return List.of(); + } + else { + return subCommand.getAutoComplete(Arrays.copyOfRange(args, 1, args.length)); } } - return null; - } - - @Override - public void execute(CommandSourceStack sourceStack, String[] args) { - // TODO - throw new NotImplementedException(); - } - - @Override - public Collection suggest(CommandSourceStack sourceStack, String[] args) { - // TODO - throw new NotImplementedException(); } @Override public boolean canUse(CommandSender sender) { return true; } + + private void addSubCommand(SubCommand subCommand) { + this.subCommands.put(subCommand.getName(), subCommand); + } } From 79abbe7517190ea5a12155abb6a0285f4dbfccae Mon Sep 17 00:00:00 2001 From: Tsumiki Miniwa <37684627+cpaca@users.noreply.github.com> Date: Tue, 16 Sep 2025 23:36:22 -0700 Subject: [PATCH 40/80] Remove CraftListener, RecipeBuilder, RecipeManager. --- .../holoitemsapi/item/CustomItem.java | 1 + .../holoitemsapi/item/CustomItemManager.java | 1 - .../holoitemsapi/recipe/CraftListener.java | 220 -------------- .../holoitemsapi/recipe/RecipeBuilder.java | 270 ------------------ .../holoitemsapi/recipe/RecipeManager.java | 173 ----------- .../mc/holoitemsrevamp/HoloItemsRevamp.java | 3 +- 6 files changed, 2 insertions(+), 666 deletions(-) delete mode 100644 src/main/java/com/strangeone101/holoitemsapi/recipe/CraftListener.java delete mode 100644 src/main/java/com/strangeone101/holoitemsapi/recipe/RecipeBuilder.java delete mode 100644 src/main/java/com/strangeone101/holoitemsapi/recipe/RecipeManager.java diff --git a/src/main/java/com/strangeone101/holoitemsapi/item/CustomItem.java b/src/main/java/com/strangeone101/holoitemsapi/item/CustomItem.java index f1ce8e12..a5c43283 100644 --- a/src/main/java/com/strangeone101/holoitemsapi/item/CustomItem.java +++ b/src/main/java/com/strangeone101/holoitemsapi/item/CustomItem.java @@ -17,6 +17,7 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.ItemFlag; import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.Recipe; import org.bukkit.inventory.meta.Damageable; import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.LeatherArmorMeta; diff --git a/src/main/java/com/strangeone101/holoitemsapi/item/CustomItemManager.java b/src/main/java/com/strangeone101/holoitemsapi/item/CustomItemManager.java index fe7f468b..958148f7 100644 --- a/src/main/java/com/strangeone101/holoitemsapi/item/CustomItemManager.java +++ b/src/main/java/com/strangeone101/holoitemsapi/item/CustomItemManager.java @@ -7,7 +7,6 @@ import org.bukkit.inventory.ItemStack; import com.strangeone101.holoitemsapi.Keys; -import com.strangeone101.holoitemsapi.recipe.RecipeManager; /** * A registry for managing all custom items diff --git a/src/main/java/com/strangeone101/holoitemsapi/recipe/CraftListener.java b/src/main/java/com/strangeone101/holoitemsapi/recipe/CraftListener.java deleted file mode 100644 index 01ae252c..00000000 --- a/src/main/java/com/strangeone101/holoitemsapi/recipe/CraftListener.java +++ /dev/null @@ -1,220 +0,0 @@ -package com.strangeone101.holoitemsapi.recipe; - -import com.strangeone101.holoitemsapi.item.CustomItemManager; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.inventory.CraftItemEvent; -import org.bukkit.event.inventory.PrepareItemCraftEvent; -import org.bukkit.event.player.PlayerRecipeDiscoverEvent; -import org.bukkit.inventory.CraftingInventory; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.RecipeChoice; -import org.bukkit.inventory.ShapedRecipe; -import org.bukkit.inventory.ShapelessRecipe; -import org.bukkit.scheduler.BukkitRunnable; -import xyz.holocons.mc.holoitemsrevamp.HoloItemsRevamp; - -import java.util.HashMap; -import java.util.Map; - -public class CraftListener implements Listener { - - private final HoloItemsRevamp plugin; - - public CraftListener(HoloItemsRevamp plugin) { - this.plugin = plugin; - } - - @EventHandler(ignoreCancelled = true) - public void onCraftItem(CraftItemEvent event) { - ItemStack stack = event.getCurrentItem(); -// if (CustomItemManager.isCustomItem(event.getCurrentItem()) && event.getWhoClicked() instanceof Player) { -// //Makes the output a fresh build of the item. Means it will be owned by that player -// // TODO: Don't do that? Maybe? buildStack is messing with the output of the datapacks. -// event.setCurrentItem(CustomItemManager.getCustomItem(stack).buildStack((Player) event.getWhoClicked())); -// } - - if (!RecipeManager.isManagedRecipe(event.getRecipe())) { - for (ItemStack ingredient : event.getInventory().getMatrix()) { - if (CustomItemManager.isCustomItem(ingredient)) { - event.setCancelled(true); - } - } - } else if (RecipeManager.isHiddenRecipe(event.getRecipe())) { - RecipeBuilder.AdvancedRecipe recipe = RecipeManager.getAdvancedFromDummy(event.getRecipe()); - boolean notMatch = false; - - if (recipe instanceof RecipeBuilder.AdvancedShape) { - RecipeBuilder.AdvancedShape advancedShape = (RecipeBuilder.AdvancedShape) recipe; - CraftingInventory craftingInventory = event.getInventory(); - int size = craftingInventory.getSize() == 9 ? 3 : 2; - int offset = 0; - outter: - for (int row = 0; row < size; row++) { - for (int col = 0; col < size; col++) { - int currIndex = row * size + col; - if (craftingInventory.getMatrix()[currIndex] != null) { - offset = currIndex - advancedShape.getFirstNotEmpty(); - break outter; - } - } - } - - String[] shape = advancedShape.getShape(); - ItemStack[] matrix = craftingInventory.getMatrix(); - outter: - for (int row = 0; row < shape.length; row++) { - for (int col = 0; col < shape[row].length(); col++) { - int matrixNum = offset + (row * 3) + col; - if (shape[row].charAt(col) == ' ') { - if (matrix[matrixNum] != null) { - notMatch = true; - break outter; - } - } else { - ItemStack craftingStack = matrix[matrixNum]; - if (!advancedShape.checkStack(shape[row].charAt(col), craftingStack)) { - notMatch = true; - break outter; - } - } - } - } - } - - if (!notMatch) { - ItemStack updated = recipe.getCraftModifier().create(event.getInventory().getResult(), - recipe.getInputItems(event.getInventory()), recipe.buildContext(event.getInventory(), event.getClick())); - - event.getInventory().setResult(updated); - } else { - event.setCancelled(true); - } - } else if (RecipeManager.isAdvancedRecipe(event.getRecipe())) { - RecipeBuilder.AdvancedRecipe advRecipe = RecipeManager.getAdvancedRecipe(event.getRecipe()); - - ItemStack updated = advRecipe.getCraftModifier().create(event.getInventory().getResult(), - advRecipe.getInputItems(event.getInventory()), advRecipe.buildContext(event.getInventory(), event.getClick())); - - event.getInventory().setResult(updated); - event.setCurrentItem(updated); - } - - if (RecipeManager.hasNonConsumable(event.getRecipe())) { - Map slots = new HashMap<>(); - for (int slot = 0; slot < event.getInventory().getSize(); slot++) { - ItemStack slotItem = event.getInventory().getItem(slot); - - if (event.getRecipe() instanceof ShapedRecipe) { - for (RecipeChoice choice : ((ShapedRecipe) event.getRecipe()).getChoiceMap().values()) { - if (choice instanceof NonConsumableChoice && choice.test(slotItem)) { - slots.put(slot, slotItem.clone()); - if (event.isShiftClick()) { //If they shift click, - slotItem.setAmount(64); //Allow it to craft as many as possible - event.getInventory().setItem(slot, slotItem); - } - } - } - } else if (event.getRecipe() instanceof ShapelessRecipe) { - for (RecipeChoice choice : ((ShapelessRecipe) event.getRecipe()).getChoiceList()) { - if (choice instanceof NonConsumableChoice && choice.test(slotItem)) { - slots.put(slot, slotItem.clone()); - if (event.isShiftClick()) { //If they shift click, - slotItem.setAmount(64); //Allow it to craft as many as possible - event.getInventory().setItem(slot, slotItem); - } - } - } - } - } - - //1 tick later, restore the items that were removed - if (slots.size() > 0) { - new BukkitRunnable() { - @Override - public void run() { - for (int slot : slots.keySet()) { - event.getInventory().setItem(slot, slots.get(slot)); - } - } - }.runTaskLater(plugin, 1L); - } - } - } - - @EventHandler - public void onPrepareItemCraft(PrepareItemCraftEvent event) { - if (!RecipeManager.isManagedRecipe(event.getRecipe())) { - for (ItemStack ingredient : event.getInventory().getMatrix()) { - if (CustomItemManager.isCustomItem(ingredient)) { - event.getInventory().setResult(null); //Stops recipes using our custom items - } - } - } else if (RecipeManager.isHiddenRecipe(event.getRecipe())) { - RecipeBuilder.AdvancedRecipe recipe = RecipeManager.getAdvancedFromDummy(event.getRecipe()); - boolean notMatch = false; - - if (recipe instanceof RecipeBuilder.AdvancedShape) { - RecipeBuilder.AdvancedShape advancedShape = (RecipeBuilder.AdvancedShape) recipe; - CraftingInventory craftingInventory = event.getInventory(); - int size = craftingInventory.getSize() == 9 ? 3 : 2; - int offset = 0; - outter: - for (int row = 0; row < size; row++) { - for (int col = 0; col < size; col++) { - int currIndex = row * size + col; - if (craftingInventory.getMatrix()[currIndex] != null) { - offset = currIndex - advancedShape.getFirstNotEmpty(); - break outter; - } - } - } - - String[] shape = advancedShape.getShape(); - ItemStack[] matrix = craftingInventory.getMatrix(); - outter: - for (int row = 0; row < shape.length; row++) { - for (int col = 0; col < shape[row].length(); col++) { - int matrixNum = offset + (row * 3) + col; - if (shape[row].charAt(col) == ' ') { - if (matrix[matrixNum] != null) { - notMatch = true; - break outter; - } - } else { - ItemStack craftingStack = matrix[matrixNum]; - if (!advancedShape.checkStack(shape[row].charAt(col), craftingStack)) { - notMatch = true; - break outter; - } - } - } - } - } - - if (!notMatch) { - ItemStack updated = recipe.getPreviewModifier().create(event.getInventory().getResult(), - recipe.getInputItems(event.getInventory()), recipe.buildContext(event.getInventory(), null)); - - event.getInventory().setResult(updated); - } else { - event.getInventory().setResult(null); - } - } else if (RecipeManager.isAdvancedRecipe(event.getRecipe())) { - RecipeBuilder.AdvancedRecipe advRecipe = RecipeManager.getAdvancedRecipe(event.getRecipe()); - - ItemStack updated = advRecipe.getPreviewModifier().create(event.getInventory().getResult(), - advRecipe.getInputItems(event.getInventory()), advRecipe.buildContext(event.getInventory(), null)); - - event.getInventory().setResult(updated); - } - } - - @EventHandler - public void onPlayerRecipeDiscover(PlayerRecipeDiscoverEvent event) { - if (RecipeManager.isHiddenRecipe(event.getRecipe())) { - event.setCancelled(true); - } - } -} diff --git a/src/main/java/com/strangeone101/holoitemsapi/recipe/RecipeBuilder.java b/src/main/java/com/strangeone101/holoitemsapi/recipe/RecipeBuilder.java deleted file mode 100644 index 4c218325..00000000 --- a/src/main/java/com/strangeone101/holoitemsapi/recipe/RecipeBuilder.java +++ /dev/null @@ -1,270 +0,0 @@ -package com.strangeone101.holoitemsapi.recipe; - -import org.bukkit.Material; -import org.bukkit.NamespacedKey; -import org.bukkit.entity.Player; -import org.bukkit.event.inventory.ClickType; -import org.bukkit.inventory.CraftingInventory; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.RecipeChoice; -import org.bukkit.inventory.ShapedRecipe; -import org.bukkit.inventory.ShapelessRecipe; -import org.bukkit.inventory.meta.ItemMeta; - -import com.strangeone101.holoitemsapi.item.CustomItemManager; - -import xyz.holocons.mc.holoitemsrevamp.HoloItemsRevamp; - -import java.util.HashMap; -import java.util.Map; -import java.util.NoSuchElementException; - -public class RecipeBuilder { - - public static class AdvancedShape extends AdvancedRecipe { - - private ShapedRecipe recipe; - private Map ingredients = new HashMap<>(); - private Map riingredients = new HashMap<>(); - private Map groups = new HashMap<>(); - private Map indexedGroups = new HashMap<>(); - private String[] shape; - private int firstNotEmpty = -1; - - - public AdvancedShape(String key, ItemStack output) { - super(key, output); - } - - public AdvancedShape setGroupFilter(RecipeGroup group, CustomItemRecipeChoice choice) { - this.filters.put(group, choice); - return this; - } - - // public AdvancedShape setGroupItems(RecipeGroup group, ItemStack... itemstacks) { - // this.filters.put(group, new CustomItemRecipeChoice(itemstacks)); - // return this; - // } - - // public AdvancedShape setGroupItems(RecipeGroup group, Material... materials) { - // ItemStack[] stacks = new ItemStack[materials.length]; - // for (int i = 0; i < materials.length; i++) { - // stacks[i] = new ItemStack(materials[i]); - // } - // this.filters.put(group, new CustomItemRecipeChoice(stacks)); - // return this; - // } - - public AdvancedShape setIngredientGroup(char character, RecipeGroup group) { - this.groups.put(character, group); - return this; - } - - public AdvancedShape setIngredient(char character, Material material) { - ingredients.put(character, new ItemStack(material)); - return this; - } - - public AdvancedShape setIngredient(char character, ItemStack stack) { - ingredients.put(character, stack); - return this; - } - - public AdvancedShape setIngredient(char character, RecipeChoice recipeChoice) { - riingredients.put(character, recipeChoice); - return this; - } - - public AdvancedShape setShape(String... shape) { - this.shape = shape; - return this; - } - - public String[] getShape() { - return this.shape; - } - - public int getFirstNotEmpty() { - return firstNotEmpty; - } - - public boolean checkStack(char ingredientChar, ItemStack stack) { - if (ingredients.containsKey(ingredientChar)) { - if (CustomItemManager.isCustomItem(ingredients.get(ingredientChar)) && CustomItemManager.isCustomItem(stack)) { - return CustomItemManager.getCustomItem(ingredients.get(ingredientChar)).getCustomModelID() == CustomItemManager.getCustomItem(stack).getCustomModelID(); - } else { - return ingredients.get(ingredientChar).isSimilar(stack); - } - } else if (riingredients.containsKey(ingredientChar)) { - return riingredients.get(ingredientChar).test(stack); - } else if (groups.containsKey(ingredientChar)) { - return this.filters.get(groups.get(ingredientChar)).test(stack); - } - return false; - } - - public AdvancedShape previewModifier(RecipeModifier modifier) { - this.preview = modifier; - return this; - } - - public AdvancedShape craftModifier(RecipeModifier modifier) { - this.craft = modifier; - return this; - } - - public AdvancedShape enableRecipeBookPreviews() { - this.previewInRecipeBook = true; - return this; - } - - public ShapedRecipe[] buildRegister(HoloItemsRevamp plugin) { - if (shape == null) throw new NoSuchElementException("Shape was not provided!"); - - if (ingredients.size() == 0 && riingredients.size() == 0 && filters.size() == 0) { - throw new NoSuchElementException("No ingredients provided!"); - } - - if (previewInRecipeBook) { - //TODO Make 20 recipes with different inputs from the groups - //before grouping them together - } else { - ShapedRecipe recipe = new ShapedRecipe(new NamespacedKey(plugin, key), output); - - ItemStack dummyItem = new ItemStack(Material.KNOWLEDGE_BOOK); - ItemMeta dummyMeta = dummyItem.getItemMeta(); - dummyMeta.setDisplayName(recipe.getKey().getKey()); - dummyItem.setItemMeta(dummyMeta); - ShapedRecipe dummyRecipe = new ShapedRecipe(new NamespacedKey(plugin, "__" + key), dummyItem); - - recipe.shape(shape); - dummyRecipe.shape(shape); - - for (Character c : ingredients.keySet()) { - recipe.setIngredient(c, new RecipeChoice.ExactChoice(ingredients.get(c))); - dummyRecipe.setIngredient(c, new RecipeChoice.ExactChoice(ingredients.get(c))); - } - - for (Character c : riingredients.keySet()) { - recipe.setIngredient(c, riingredients.get(c)); - dummyRecipe.setIngredient(c, riingredients.get(c)); - } - - for (Character c : groups.keySet()) { - RecipeGroup g = groups.get(c); - recipe.setIngredient(c, filters.get(g)); //The proper item it accepts - dummyRecipe.setIngredient(c, filters.get(g).getItemStack().getType()); //The dummy item without any NBT - - outter: - for (int row = 0; row < 3 && row < shape.length; row++) { - for (int col = 0; col < 3 && col < shape[row].length(); col++) { - if (shape[row].charAt(col) == c) { - indexedGroups.put((byte) (row * shape.length + col), g); - break outter; - } - } - } - - } - - outter: - for (int row = 0; row < 3 && row < shape.length; row++) { - for (int col = 0; col < 3 && col < shape[row].length(); col++) { - if (shape[row].charAt(col) != ' ') { - firstNotEmpty = row * shape.length + col; - break outter; - } - } - } - - RecipeManager.registerAdvancedRecipe(recipe, dummyRecipe, this); - - return new ShapedRecipe[] {recipe}; - } - - - return null; - } - - @Override - public RecipeContext buildContext(CraftingInventory craftingTable, ClickType type) { - RecipeContext context = new RecipeContext(); - context.setPlayer((Player) craftingTable.getViewers().get(0)); - context.setRecipe(craftingTable.getRecipe()); - context.setLocation(craftingTable.getViewers().get(0).getLocation()); - context.setClickType(type); - context.setWorld(context.getLocation().getWorld()); - - return context; - } - - @Override - public Map getInputItems(CraftingInventory craftingInventory) { - int size = craftingInventory.getSize() == 9 ? 3 : 2; - int offset = 0; - outter: - for (int row = 0; row < size; row++) { - for (int col = 0; col < size; col++) { - int currIndex = row * size + col; - if (craftingInventory.getMatrix()[currIndex] != null) { - offset = currIndex - firstNotEmpty; - break outter; - } - } - } - - Map stacks = new HashMap<>(); - - for (byte index : indexedGroups.keySet()) { - int newIndex = offset + index; - - stacks.put(indexedGroups.get(index), craftingInventory.getMatrix()[newIndex]); - } - - return stacks; - } - - //TODO - } - - public static abstract class AdvancedRecipe { - protected boolean previewInRecipeBook; - protected String key; - protected ItemStack output; - protected RecipeModifier preview, craft = (item, map, context) -> item; - protected Map filters = new HashMap<>(); - - protected AdvancedRecipe(String key, ItemStack output) { - this.key = key; - this.output = output; - } - - public Map getFilters() { - return filters; - } - - public boolean shouldPreviewInRecipeBook() { - return previewInRecipeBook; - } - - public ItemStack getOutput() { - return output; - } - - public RecipeModifier getCraftModifier() { - return craft; - } - - public RecipeModifier getPreviewModifier() { - return preview; - } - - public RecipeContext buildContext(CraftingInventory craftingTable, ClickType click) { - - craftingTable.getMatrix(); - return null; - } - - public abstract Map getInputItems(CraftingInventory craftingInventory); - } -} diff --git a/src/main/java/com/strangeone101/holoitemsapi/recipe/RecipeManager.java b/src/main/java/com/strangeone101/holoitemsapi/recipe/RecipeManager.java deleted file mode 100644 index 618a02ac..00000000 --- a/src/main/java/com/strangeone101/holoitemsapi/recipe/RecipeManager.java +++ /dev/null @@ -1,173 +0,0 @@ -package com.strangeone101.holoitemsapi.recipe; - -import org.bukkit.Bukkit; -import org.bukkit.Keyed; -import org.bukkit.NamespacedKey; -import org.bukkit.inventory.Recipe; -import org.bukkit.inventory.RecipeChoice; -import org.bukkit.inventory.ShapedRecipe; -import org.bukkit.inventory.ShapelessRecipe; -import org.bukkit.inventory.SmithingRecipe; - -import java.io.InvalidObjectException; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -/** - * Manages all custom recipes used with custom items - */ -public class RecipeManager { - - private static Map recipes = new HashMap<>(); - private static Map advanced = new HashMap<>(); - private static Set nonConsumableRecipes = new HashSet<>(); - - private static Map dummyToAdvancedMap = new HashMap<>(); //Map of all dummy recipes to the advanced recipe - - /** - * Get a recipe - * @param key The namespace key - * @return The recipe - */ - public static Recipe getRecipe(NamespacedKey key) { - return recipes.get(key); - } - - /** - * Register a custom recipe - * @param recipe The recipe - */ - public static void registerRecipe(Recipe recipe) { - if (recipe == null) { - return; - } - if (!(recipe instanceof Keyed)) { - try { - throw new InvalidObjectException("Recipe of type " + recipe.getClass().getName() + " does not contain a NameSpace key! Use RecipeManager#registerRecipe(recipe, key) instead!"); - } catch (InvalidObjectException e) { - e.printStackTrace(); - return; - } - } - registerRecipe(recipe, ((Keyed)recipe).getKey()); - } - - /** - * Register a custom recipe - * @param recipe The recipe - * @param key The namespace key - */ - public static void registerRecipe(Recipe recipe, NamespacedKey key) { - recipes.put(key, recipe); - if (Bukkit.getRecipe(key) != null) { - Bukkit.removeRecipe(key); - } - Bukkit.addRecipe(recipe); - - if (recipe instanceof ShapedRecipe) { - for (RecipeChoice choice : ((ShapedRecipe) recipe).getChoiceMap().values()) { - if (choice instanceof NonConsumableChoice) - nonConsumableRecipes.add(recipe); - break; - } - } else if (recipe instanceof ShapelessRecipe) { - for (RecipeChoice choice : ((ShapelessRecipe) recipe).getChoiceList()) { - if (choice instanceof NonConsumableChoice) - nonConsumableRecipes.add(recipe); - break; - } - } else if (recipe instanceof SmithingRecipe) { - if (((SmithingRecipe) recipe).getAddition() instanceof NonConsumableChoice || - ((SmithingRecipe) recipe).getBase() instanceof NonConsumableChoice) - nonConsumableRecipes.add(recipe); - - - } - } - - public static void registerAdvancedRecipe(Recipe recipe, Recipe dummyRecipe, RecipeBuilder.AdvancedRecipe advancedShape) { - registerRecipe(recipe); - registerRecipe(dummyRecipe); - advanced.put(((Keyed) recipe).getKey(), advancedShape); - dummyToAdvancedMap.put(((Keyed) dummyRecipe).getKey(), ((Keyed) recipe).getKey()); - } - - public static boolean isAdvancedRecipe(Recipe recipe) { - if (recipe instanceof Keyed) - return advanced.containsKey(((Keyed) recipe).getKey()); - return false; - } - - public static boolean isHiddenRecipe(NamespacedKey key) { - return dummyToAdvancedMap.containsKey(key); - } - - public static boolean isHiddenRecipe(Recipe recipe) { - if (recipe instanceof Keyed) - return dummyToAdvancedMap.containsKey(((Keyed) recipe).getKey()); - return false; - } - - public static RecipeBuilder.AdvancedRecipe getAdvancedRecipe(Recipe recipe) { - if (recipe instanceof Keyed) - return advanced.get(((Keyed) recipe).getKey()); - return null; - } - - public static RecipeBuilder.AdvancedRecipe getAdvancedRecipe(NamespacedKey recipe) { - return advanced.get(recipe); - } - - public static RecipeBuilder.AdvancedRecipe getAdvancedFromDummy(Recipe recipe) { - return advanced.get(dummyToAdvancedMap.get(((Keyed) recipe).getKey())); - } - - /** - * Add a recipe to the registry WITHOUT registering it - * @param recipe The recipe - * @param key The namespace key - */ - public static void addRecipe(Recipe recipe, NamespacedKey key) { - recipes.put(key, recipe); - } - - /** - * Unregister all recipes registered. Internal use only. - */ - public static void unregisterAll() { - for (NamespacedKey key : recipes.keySet()) { - Bukkit.removeRecipe(key); - } - } - - /** - * Get whether the recipe is managed by the registry or not - * @param recipe The recipe - * @return True if handled - */ - public static boolean isManagedRecipe(Recipe recipe) { - if (recipe instanceof Keyed) - return recipes.containsKey(((Keyed) recipe).getKey()); - return false; - } - - /** - * Get how many recipes are managed - * @return The amount - */ - public static int getRegisteredAmount() { - return recipes.size(); - } - - /** - * Gets whether the recipe contains an ingredient that shouldn't - * be consumed on use - * @param recipe The recipe - * @return True if it does - */ - public static boolean hasNonConsumable(Recipe recipe) { - return nonConsumableRecipes.contains(recipe); - } -} diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/HoloItemsRevamp.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/HoloItemsRevamp.java index dfe5bf19..7a3e3169 100644 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/HoloItemsRevamp.java +++ b/src/main/java/xyz/holocons/mc/holoitemsrevamp/HoloItemsRevamp.java @@ -6,7 +6,6 @@ import com.strangeone101.holoitemsapi.enchantment.EnchantmentListener; import com.strangeone101.holoitemsapi.item.BlockListener; import com.strangeone101.holoitemsapi.item.CustomItemManager; -import com.strangeone101.holoitemsapi.recipe.CraftListener; import com.strangeone101.holoitemsapi.tracking.CustomBlockStorage; import io.papermc.paper.plugin.lifecycle.event.types.LifecycleEvents; import org.bukkit.plugin.java.JavaPlugin; @@ -41,7 +40,7 @@ public void onEnable() { getServer().getPluginManager().registerEvents(new EnchantmentListener(), this); getServer().getPluginManager().registerEvents(new AnvilListener(this), this); - getServer().getPluginManager().registerEvents(new CraftListener(this), this); +// getServer().getPluginManager().registerEvents(new CraftListener(this), this); getServer().getPluginManager().registerEvents(new BlockListener(this), this); // getCommand("holoitems").setExecutor(new MainCommand(this)); From 651787862495928c3fe5d839292f632b83a271bd Mon Sep 17 00:00:00 2001 From: Tsumiki Miniwa <37684627+cpaca@users.noreply.github.com> Date: Tue, 16 Sep 2025 23:38:26 -0700 Subject: [PATCH 41/80] Remove extraneous recipe classes --- .../holoitemsapi/recipe/ItemGroups.java | 12 ---- .../recipe/NonConsumableChoice.java | 13 ---- .../holoitemsapi/recipe/RecipeContext.java | 64 ------------------- .../holoitemsapi/recipe/RecipeGroup.java | 7 -- .../holoitemsapi/recipe/RecipeModifier.java | 10 --- 5 files changed, 106 deletions(-) delete mode 100644 src/main/java/com/strangeone101/holoitemsapi/recipe/ItemGroups.java delete mode 100644 src/main/java/com/strangeone101/holoitemsapi/recipe/NonConsumableChoice.java delete mode 100644 src/main/java/com/strangeone101/holoitemsapi/recipe/RecipeContext.java delete mode 100644 src/main/java/com/strangeone101/holoitemsapi/recipe/RecipeGroup.java delete mode 100644 src/main/java/com/strangeone101/holoitemsapi/recipe/RecipeModifier.java diff --git a/src/main/java/com/strangeone101/holoitemsapi/recipe/ItemGroups.java b/src/main/java/com/strangeone101/holoitemsapi/recipe/ItemGroups.java deleted file mode 100644 index 270d05ea..00000000 --- a/src/main/java/com/strangeone101/holoitemsapi/recipe/ItemGroups.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.strangeone101.holoitemsapi.recipe; - -import org.bukkit.Material; - -public class ItemGroups { - - public static final Material[] DYES = {Material.RED_DYE, Material.ORANGE_DYE, Material.YELLOW_DYE, Material.LIME_DYE, - Material.GREEN_DYE, Material.CYAN_DYE, Material.LIGHT_BLUE_DYE, Material.BLUE_DYE, Material.PURPLE_DYE, - Material.MAGENTA_DYE, Material.PINK_DYE, Material.BROWN_DYE, Material.WHITE_DYE, Material.GRAY_DYE, - Material.LIGHT_GRAY_DYE, Material.BLACK_DYE - }; -} diff --git a/src/main/java/com/strangeone101/holoitemsapi/recipe/NonConsumableChoice.java b/src/main/java/com/strangeone101/holoitemsapi/recipe/NonConsumableChoice.java deleted file mode 100644 index a371e926..00000000 --- a/src/main/java/com/strangeone101/holoitemsapi/recipe/NonConsumableChoice.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.strangeone101.holoitemsapi.recipe; - -/** - * A recipe choice item that will not be consumed in recipes. Like how - * milk buckets do not consume the bucket when used in crafting - */ -public class NonConsumableChoice extends CustomItemRecipeChoice { - - public NonConsumableChoice(String... ids) { - super(ids); - } - -} diff --git a/src/main/java/com/strangeone101/holoitemsapi/recipe/RecipeContext.java b/src/main/java/com/strangeone101/holoitemsapi/recipe/RecipeContext.java deleted file mode 100644 index bf001729..00000000 --- a/src/main/java/com/strangeone101/holoitemsapi/recipe/RecipeContext.java +++ /dev/null @@ -1,64 +0,0 @@ -package com.strangeone101.holoitemsapi.recipe; - -import org.bukkit.Location; -import org.bukkit.World; -import org.bukkit.entity.Player; -import org.bukkit.event.inventory.ClickType; -import org.bukkit.inventory.Recipe; - -public class RecipeContext { - - private Player player; - private Location location; - private World world; - private ClickType clickType; - private Recipe recipe; - - public Player getPlayer() { - return player; - } - - public void setPlayer(Player player) { - this.player = player; - } - - public Location getLocation() { - return location; - } - - public void setLocation(Location location) { - this.location = location; - } - - public World getWorld() { - return world; - } - - public void setWorld(World world) { - this.world = world; - } - - public boolean isRightClick() { - return getClickType().isRightClick(); - } - - public boolean isShiftClick() { - return getClickType().isShiftClick(); - } - - public Recipe getRecipe() { - return recipe; - } - - public void setRecipe(Recipe recipe) { - this.recipe = recipe; - } - - public ClickType getClickType() { - return clickType; - } - - public void setClickType(ClickType clickType) { - this.clickType = clickType; - } -} diff --git a/src/main/java/com/strangeone101/holoitemsapi/recipe/RecipeGroup.java b/src/main/java/com/strangeone101/holoitemsapi/recipe/RecipeGroup.java deleted file mode 100644 index 12d6fcb6..00000000 --- a/src/main/java/com/strangeone101/holoitemsapi/recipe/RecipeGroup.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.strangeone101.holoitemsapi.recipe; - -public enum RecipeGroup { - GROUP_1, GROUP_2, GROUP_3, - GROUP_4, GROUP_5, GROUP_6, - GROUP_7, GROUP_8, GROUP_9 -} diff --git a/src/main/java/com/strangeone101/holoitemsapi/recipe/RecipeModifier.java b/src/main/java/com/strangeone101/holoitemsapi/recipe/RecipeModifier.java deleted file mode 100644 index cbb3f902..00000000 --- a/src/main/java/com/strangeone101/holoitemsapi/recipe/RecipeModifier.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.strangeone101.holoitemsapi.recipe; - -import org.bukkit.inventory.ItemStack; - -import java.util.Map; - -public interface RecipeModifier { - - ItemStack create(ItemStack baseOutput, Map filters, RecipeContext context); -} From 2c2ba08cc8ce32524fbbef0eb2284fad6d24f44a Mon Sep 17 00:00:00 2001 From: Tsumiki Miniwa <37684627+cpaca@users.noreply.github.com> Date: Wed, 17 Sep 2025 00:13:21 -0700 Subject: [PATCH 42/80] Add CustomItem.editRecipe --- .../holoitemsapi/item/CustomItem.java | 10 +++++ .../holoitemsapi/recipe/RecipeManager.java | 42 +++++++++++++++++++ .../mc/holoitemsrevamp/HoloItemsRevamp.java | 4 ++ .../holoitemsrevamp/item/HolyFireBlock.java | 14 +++++++ 4 files changed, 70 insertions(+) create mode 100644 src/main/java/com/strangeone101/holoitemsapi/recipe/RecipeManager.java diff --git a/src/main/java/com/strangeone101/holoitemsapi/item/CustomItem.java b/src/main/java/com/strangeone101/holoitemsapi/item/CustomItem.java index a5c43283..e35ab5cd 100644 --- a/src/main/java/com/strangeone101/holoitemsapi/item/CustomItem.java +++ b/src/main/java/com/strangeone101/holoitemsapi/item/CustomItem.java @@ -198,6 +198,16 @@ public ItemStack buildGuiStack(OfflinePlayer player) { return itemStack; } + /** + * Called by RecipeManger for every recipe where this CustomItem is the result. + * Can be used by subclasses to edit recipes. + * @param r The recipe + * @return Whether the edited recipe should replace the old one + */ + public boolean editRecipe(Recipe r) { + return false; + } + /** * Replaces the string provided with variables * @param component The component diff --git a/src/main/java/com/strangeone101/holoitemsapi/recipe/RecipeManager.java b/src/main/java/com/strangeone101/holoitemsapi/recipe/RecipeManager.java new file mode 100644 index 00000000..c7bebfe9 --- /dev/null +++ b/src/main/java/com/strangeone101/holoitemsapi/recipe/RecipeManager.java @@ -0,0 +1,42 @@ +package com.strangeone101.holoitemsapi.recipe; + +import com.strangeone101.holoitemsapi.item.CustomItemManager; +import org.bukkit.Bukkit; +import org.bukkit.Keyed; +import org.bukkit.NamespacedKey; +import org.bukkit.inventory.ShapedRecipe; + +public class RecipeManager { + + public RecipeManager() { + // Load through all recipes: + // Probably very inefficient, so please only do this once. + Bukkit.recipeIterator().forEachRemaining(recipe -> { + // removing a recipe gets... difficult... without a key + // and they should all have one anyway, so this is safe. + NamespacedKey recipeKey; + if(recipe instanceof Keyed keyed) { + recipeKey = keyed.getKey(); + } + else { + // should be impossible + return; + } + + var result = recipe.getResult(); + var customItem = CustomItemManager.getCustomItem(result); + if(customItem != null) { + var shouldReplace = customItem.editRecipe(recipe); + if(shouldReplace) { + Bukkit.removeRecipe(recipeKey); + Bukkit.addRecipe(recipe); + if(recipe instanceof ShapedRecipe shaped) { + System.out.println("New choicemap"); + System.out.println(shaped.getChoiceMap()); + } + } + } + }); + } + +} diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/HoloItemsRevamp.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/HoloItemsRevamp.java index 7a3e3169..ef0ea578 100644 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/HoloItemsRevamp.java +++ b/src/main/java/xyz/holocons/mc/holoitemsrevamp/HoloItemsRevamp.java @@ -6,6 +6,7 @@ import com.strangeone101.holoitemsapi.enchantment.EnchantmentListener; import com.strangeone101.holoitemsapi.item.BlockListener; import com.strangeone101.holoitemsapi.item.CustomItemManager; +import com.strangeone101.holoitemsapi.recipe.RecipeManager; import com.strangeone101.holoitemsapi.tracking.CustomBlockStorage; import io.papermc.paper.plugin.lifecycle.event.types.LifecycleEvents; import org.bukkit.plugin.java.JavaPlugin; @@ -18,6 +19,7 @@ public final class HoloItemsRevamp extends JavaPlugin { private CollectionManager collectionManager; private CustomBlockStorage trackingManager; + private RecipeManager recipeManager; @Override public void onLoad() { @@ -38,6 +40,8 @@ public void onEnable() { CustomItemManager.lock(); trackingManager.loadTrackedBlocks(); + recipeManager = new RecipeManager(); + getServer().getPluginManager().registerEvents(new EnchantmentListener(), this); getServer().getPluginManager().registerEvents(new AnvilListener(this), this); // getServer().getPluginManager().registerEvents(new CraftListener(this), this); diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/HolyFireBlock.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/HolyFireBlock.java index 44ba22b3..92960b3f 100644 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/HolyFireBlock.java +++ b/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/HolyFireBlock.java @@ -1,8 +1,10 @@ package xyz.holocons.mc.holoitemsrevamp.item; import java.time.temporal.ChronoUnit; +import java.util.Arrays; import java.util.List; +import com.strangeone101.holoitemsapi.item.CustomItemManager; import org.bukkit.Material; import org.bukkit.block.Beacon; import org.bukkit.block.BlockFace; @@ -13,6 +15,7 @@ import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.entity.CreatureSpawnEvent; import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.Recipe; import org.bukkit.inventory.ShapedRecipe; import org.bukkit.util.NumberConversions; @@ -46,6 +49,17 @@ public HolyFireBlock(HoloItemsRevamp plugin) { register(); } + @Override + public boolean editRecipe(Recipe r) { + if(r instanceof ShapedRecipe recipe) { + // if it's not this, a new recipe was probably added to the datapack? + char saintQuartzKey = recipe.getShape()[1].charAt(1); + recipe.setIngredient(saintQuartzKey, new CustomItemRecipeChoice("saint_quartz")); + return true; + } + return false; + } + @Override public void onBlockBreak(BlockBreakEvent event, BlockState blockState) { holyFireMarker.remove(blockState); From 08815bd9f5b337f4b8fa8ae38c9563ca0ab60575 Mon Sep 17 00:00:00 2001 From: Tsumiki Miniwa <37684627+cpaca@users.noreply.github.com> Date: Wed, 17 Sep 2025 00:52:38 -0700 Subject: [PATCH 43/80] Update dependency (InventoryFramework) --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index 45d2ab36..1c6de828 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -26,7 +26,7 @@ dependencies { compileOnly("io.papermc.paper:paper-api:1.21.1-R0.1-SNAPSHOT") compileOnly("com.comphenix.protocol:ProtocolLib:5.4.0-SNAPSHOT") compileOnly("com.sk89q.worldguard:worldguard-bukkit:7.0.9") - implementation("com.github.stefvanschie.inventoryframework:IF:0.10.13") + implementation("com.github.stefvanschie.inventoryframework:IF:0.11.3") } tasks { From 26eb5b8beceb58db98d0a22404d9b4a15499f797 Mon Sep 17 00:00:00 2001 From: Tsumiki Miniwa <37684627+cpaca@users.noreply.github.com> Date: Wed, 17 Sep 2025 01:02:39 -0700 Subject: [PATCH 44/80] Fix bootstrap name --- .../{HoloitemsBootstrap.java => HoloItemsBootstrap.java} | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) rename src/main/java/xyz/holocons/mc/holoitemsrevamp/{HoloitemsBootstrap.java => HoloItemsBootstrap.java} (82%) diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/HoloitemsBootstrap.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/HoloItemsBootstrap.java similarity index 82% rename from src/main/java/xyz/holocons/mc/holoitemsrevamp/HoloitemsBootstrap.java rename to src/main/java/xyz/holocons/mc/holoitemsrevamp/HoloItemsBootstrap.java index a5f79b7a..f4beb1e6 100644 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/HoloitemsBootstrap.java +++ b/src/main/java/xyz/holocons/mc/holoitemsrevamp/HoloItemsBootstrap.java @@ -5,9 +5,8 @@ import io.papermc.paper.plugin.lifecycle.event.types.LifecycleEvents; import io.papermc.paper.registry.RegistryKey; import org.jetbrains.annotations.NotNull; -import xyz.holocons.mc.holoitemsrevamp.command.MainCommand; -public class HoloitemsBootstrap implements PluginBootstrap { +public class HoloItemsBootstrap implements PluginBootstrap { @Override public void bootstrap(@NotNull BootstrapContext context) { var manager = context.getLifecycleManager(); From d4d737face34e4a4cdbb1359864ce71ebe0b411d Mon Sep 17 00:00:00 2001 From: Tsumiki Miniwa <37684627+cpaca@users.noreply.github.com> Date: Wed, 17 Sep 2025 01:02:39 -0700 Subject: [PATCH 45/80] Fix bootstrap name --- build.gradle.kts | 2 +- .../{HoloitemsBootstrap.java => HoloItemsBootstrap.java} | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) rename src/main/java/xyz/holocons/mc/holoitemsrevamp/{HoloitemsBootstrap.java => HoloItemsBootstrap.java} (82%) diff --git a/build.gradle.kts b/build.gradle.kts index 1c6de828..0ed6c3b9 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -87,7 +87,7 @@ tasks.register("copyDatapack") { // https://github.com/Minecrell/plugin-yml paper { main = "xyz.holocons.mc.holoitemsrevamp.HoloItemsRevamp" - bootstrapper = "xyz.holocons.mc.holoitemsrevamp.HoloitemsBootstrap" + bootstrapper = "xyz.holocons.mc.holoitemsrevamp.HoloItemsBootstrap" apiVersion = "1.21.1" authors = listOf("TraceL", "dlee13") website = "holocons.xyz" diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/HoloitemsBootstrap.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/HoloItemsBootstrap.java similarity index 82% rename from src/main/java/xyz/holocons/mc/holoitemsrevamp/HoloitemsBootstrap.java rename to src/main/java/xyz/holocons/mc/holoitemsrevamp/HoloItemsBootstrap.java index a5f79b7a..f4beb1e6 100644 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/HoloitemsBootstrap.java +++ b/src/main/java/xyz/holocons/mc/holoitemsrevamp/HoloItemsBootstrap.java @@ -5,9 +5,8 @@ import io.papermc.paper.plugin.lifecycle.event.types.LifecycleEvents; import io.papermc.paper.registry.RegistryKey; import org.jetbrains.annotations.NotNull; -import xyz.holocons.mc.holoitemsrevamp.command.MainCommand; -public class HoloitemsBootstrap implements PluginBootstrap { +public class HoloItemsBootstrap implements PluginBootstrap { @Override public void bootstrap(@NotNull BootstrapContext context) { var manager = context.getLifecycleManager(); From 6adb0e04477ae8cc56f07715677fddbc3c2a6599 Mon Sep 17 00:00:00 2001 From: Tsumiki Miniwa <37684627+cpaca@users.noreply.github.com> Date: Wed, 17 Sep 2025 01:06:35 -0700 Subject: [PATCH 46/80] Remove unnecessary build.gradle.kts lines --- build.gradle.kts | 2 -- 1 file changed, 2 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 0ed6c3b9..0d047d92 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,6 +1,5 @@ plugins { `java-library` - id("java") id("net.minecrell.plugin-yml.paper") version "0.6.0" // Generates plugin.yml id("com.gradleup.shadow") version "8.3.9" // Shades and relocates dependencies into our plugin jar id("xyz.jpenilla.run-paper") version "2.3.0" // Adds runServer and runMojangMappedServer tasks for testing @@ -19,7 +18,6 @@ repositories { maven("https://repo.papermc.io/repository/maven-public/") maven("https://repo.dmulloy2.net/repository/public/") maven("https://maven.enginehub.org/repo/") - maven("https://papermc.io/repo/repository/maven-public/") } dependencies { From 7e56dfdeebdeab5743959335b96bc678650aaf95 Mon Sep 17 00:00:00 2001 From: Tsumiki Miniwa <37684627+cpaca@users.noreply.github.com> Date: Wed, 17 Sep 2025 01:10:27 -0700 Subject: [PATCH 47/80] Scrapping bootstrap idea. I'm leaving the file for now, though. --- .../xyz/holocons/mc/holoitemsrevamp/HoloItemsBootstrap.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/HoloItemsBootstrap.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/HoloItemsBootstrap.java index f4beb1e6..76c002d0 100644 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/HoloItemsBootstrap.java +++ b/src/main/java/xyz/holocons/mc/holoitemsrevamp/HoloItemsBootstrap.java @@ -9,9 +9,6 @@ public class HoloItemsBootstrap implements PluginBootstrap { @Override public void bootstrap(@NotNull BootstrapContext context) { - var manager = context.getLifecycleManager(); - manager.registerEventHandler(LifecycleEvents.TAGS.preFlatten(RegistryKey.ITEM), event -> { - // TODO - }); + } } From 4150b298d94edabfdf991a1ce784cb0a53fdf12e Mon Sep 17 00:00:00 2001 From: Tsumiki Miniwa <37684627+cpaca@users.noreply.github.com> Date: Wed, 17 Sep 2025 01:12:43 -0700 Subject: [PATCH 48/80] Remove Keys.UNSTACKABLE --- .../com/strangeone101/holoitemsapi/Keys.java | 29 ------------------- .../holoitemsapi/item/CustomItem.java | 10 ------- 2 files changed, 39 deletions(-) diff --git a/src/main/java/com/strangeone101/holoitemsapi/Keys.java b/src/main/java/com/strangeone101/holoitemsapi/Keys.java index d330d641..e411509d 100644 --- a/src/main/java/com/strangeone101/holoitemsapi/Keys.java +++ b/src/main/java/com/strangeone101/holoitemsapi/Keys.java @@ -11,8 +11,6 @@ public class Keys { public static Property COOLDOWN; - // TODO: Remove? - public static Property UNSTACKABLE; public static Property ITEM_ID; /** * Used to represent an item that can also be used "like" an enchantment book. @@ -44,33 +42,6 @@ public String getPropertyName() { } }; - UNSTACKABLE = new Property(plugin, "unstackable") { - - @Override - public boolean has(PersistentDataContainer data) { - return data.has(getKey(), PersistentDataType.INTEGER); - } - - @Override - public Boolean get(PersistentDataContainer data) { - return has(data); - } - - @Override - public void set(PersistentDataContainer data, Boolean value) { - if (value) { - data.set(getKey(), PersistentDataType.INTEGER, Bukkit.getCurrentTick()); - } else { - data.remove(getKey()); - } - } - - @Override - public String getPropertyName() { - return "Unstackable"; - } - }; - ITEM_ID = new Property(plugin, "item_id") { @Override diff --git a/src/main/java/com/strangeone101/holoitemsapi/item/CustomItem.java b/src/main/java/com/strangeone101/holoitemsapi/item/CustomItem.java index e35ab5cd..bf38fdc9 100644 --- a/src/main/java/com/strangeone101/holoitemsapi/item/CustomItem.java +++ b/src/main/java/com/strangeone101/holoitemsapi/item/CustomItem.java @@ -138,16 +138,6 @@ public ItemStack updateStack(Player player, ItemStack itemStack) { } } - if (properties.contains(Keys.UNSTACKABLE)) { - if (!Keys.UNSTACKABLE.has(meta.getPersistentDataContainer())) { - Keys.UNSTACKABLE.set(meta.getPersistentDataContainer(), true); - } - } else { - if (Keys.UNSTACKABLE.has(meta.getPersistentDataContainer())) { - Keys.UNSTACKABLE.set(meta.getPersistentDataContainer(), false); - } - } - var lore = new ArrayList(); for (var line : getLore()) { From d7680eac4bf34ce8589a6aaed5cb2f1a0007a582 Mon Sep 17 00:00:00 2001 From: Tsumiki Miniwa <37684627+cpaca@users.noreply.github.com> Date: Wed, 17 Sep 2025 05:43:05 -0700 Subject: [PATCH 49/80] Remove CustomItem.updateStack I think this was made so that if an ItemStack ended up "malformed" somehow this could fix it? That's about the only explanation I can think of. --- .../holoitemsapi/item/CustomItem.java | 33 ------------------- 1 file changed, 33 deletions(-) diff --git a/src/main/java/com/strangeone101/holoitemsapi/item/CustomItem.java b/src/main/java/com/strangeone101/holoitemsapi/item/CustomItem.java index bf38fdc9..3ed4a559 100644 --- a/src/main/java/com/strangeone101/holoitemsapi/item/CustomItem.java +++ b/src/main/java/com/strangeone101/holoitemsapi/item/CustomItem.java @@ -126,39 +126,6 @@ public ItemStack buildStack(Player player) { return stack; } - public ItemStack updateStack(Player player, ItemStack itemStack) { - var meta = itemStack.getItemMeta(); - - if (getMaterial() != itemStack.getType() && meta instanceof Damageable originalDamageable) { - int damage = originalDamageable.getDamage(); - itemStack = buildStack(player); - meta = itemStack.getItemMeta(); - if (meta instanceof Damageable newDamageable) { - newDamageable.setDamage(damage); - } - } - - var lore = new ArrayList(); - - for (var line : getLore()) { - lore.add(replaceVariables(line, meta.getPersistentDataContainer())); - } - - if (meta instanceof LeatherArmorMeta) { - ((LeatherArmorMeta) meta).setColor(Color.fromRGB(hex)); - } else if (meta instanceof PotionMeta) { - ((PotionMeta) meta).setColor(Color.fromRGB(hex)); - } - - itemStack.setItemMeta(meta); - - if (this instanceof Enchantable enchantable) { - itemStack = enchantable.applyEnchantment(itemStack); - } - - return itemStack; - } - /** * Builds an ItemStack that should only be used for showing an item through an inventory or any other methods * that does not allow the player to use the item. This will add missing statistics to the lore. From c848b75da8ff70605c9b48059064ca2062445872 Mon Sep 17 00:00:00 2001 From: Tsumiki Miniwa <37684627+cpaca@users.noreply.github.com> Date: Wed, 17 Sep 2025 05:57:34 -0700 Subject: [PATCH 50/80] Move HolyFire recipe fully back into code Yeah, he's right. Having two different places which BOTH need to be loaded for the recipe to load properly is really dumb. --- .../data/holoitems/recipe/holy_fire.json | 33 --------------- .../holoitemsapi/item/CustomItem.java | 12 +++--- .../holoitemsapi/item/CustomItemManager.java | 5 +++ .../holoitemsapi/recipe/RecipeManager.java | 42 ------------------- .../mc/holoitemsrevamp/HoloItemsRevamp.java | 4 -- .../holoitemsrevamp/item/HolyFireBlock.java | 23 ++++++---- 6 files changed, 26 insertions(+), 93 deletions(-) delete mode 100644 holoitems_datapack/data/holoitems/recipe/holy_fire.json delete mode 100644 src/main/java/com/strangeone101/holoitemsapi/recipe/RecipeManager.java diff --git a/holoitems_datapack/data/holoitems/recipe/holy_fire.json b/holoitems_datapack/data/holoitems/recipe/holy_fire.json deleted file mode 100644 index c9f18c7b..00000000 --- a/holoitems_datapack/data/holoitems/recipe/holy_fire.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "type": "minecraft:crafting_shaped", - "pattern": [ - " a ", - "aba", - "ccc" - ], - "key": { - "a": { - "item": "minecraft:end_rod" - }, - "b": { - "tag": "holoitems:saint_quartz" - }, - "c": { - "item": "minecraft:raw_gold_block" - } - }, - "result": { - "id": "minecraft:soul_campfire", - "components": { - "minecraft:custom_data": { - "PublicBukkitValues": { - "holoitems:item_id": "holy_fire" - } - }, - "minecraft:item_name": "{\"color\":\"dark_purple\",\"text\":\"Holy Fire\"}", - "minecraft:lore": [ - "{\"color\":\"aqua\",\"italic\":false,\"text\":\"Prevent natural mob spawning within 100 blocks when lit\"}" - ] - } - } -} \ No newline at end of file diff --git a/src/main/java/com/strangeone101/holoitemsapi/item/CustomItem.java b/src/main/java/com/strangeone101/holoitemsapi/item/CustomItem.java index 3ed4a559..2462ea6f 100644 --- a/src/main/java/com/strangeone101/holoitemsapi/item/CustomItem.java +++ b/src/main/java/com/strangeone101/holoitemsapi/item/CustomItem.java @@ -34,6 +34,7 @@ import net.kyori.adventure.text.Component; import net.kyori.adventure.text.TextReplacementConfig; import net.kyori.adventure.text.format.NamedTextColor; +import org.jetbrains.annotations.Nullable; import xyz.holocons.mc.holoitemsrevamp.Util; /** @@ -156,13 +157,12 @@ public ItemStack buildGuiStack(OfflinePlayer player) { } /** - * Called by RecipeManger for every recipe where this CustomItem is the result. - * Can be used by subclasses to edit recipes. - * @param r The recipe - * @return Whether the edited recipe should replace the old one + * Called by CustomItemManager on every CustomItem. + * If non-null, the recipe is added to the server. + * @return A recipe to add. */ - public boolean editRecipe(Recipe r) { - return false; + public @Nullable Recipe getRecipe() { + return null; } /** diff --git a/src/main/java/com/strangeone101/holoitemsapi/item/CustomItemManager.java b/src/main/java/com/strangeone101/holoitemsapi/item/CustomItemManager.java index 958148f7..bca42f6c 100644 --- a/src/main/java/com/strangeone101/holoitemsapi/item/CustomItemManager.java +++ b/src/main/java/com/strangeone101/holoitemsapi/item/CustomItemManager.java @@ -3,7 +3,9 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Objects; +import org.bukkit.Bukkit; import org.bukkit.inventory.ItemStack; import com.strangeone101.holoitemsapi.Keys; @@ -32,6 +34,9 @@ public static void register(CustomItem item) { public static void lock() { if (!locked) { locked = true; + CUSTOM_ITEMS.values().stream() + .map(CustomItem::getRecipe) + .forEach(Bukkit::addRecipe); } } diff --git a/src/main/java/com/strangeone101/holoitemsapi/recipe/RecipeManager.java b/src/main/java/com/strangeone101/holoitemsapi/recipe/RecipeManager.java deleted file mode 100644 index c7bebfe9..00000000 --- a/src/main/java/com/strangeone101/holoitemsapi/recipe/RecipeManager.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.strangeone101.holoitemsapi.recipe; - -import com.strangeone101.holoitemsapi.item.CustomItemManager; -import org.bukkit.Bukkit; -import org.bukkit.Keyed; -import org.bukkit.NamespacedKey; -import org.bukkit.inventory.ShapedRecipe; - -public class RecipeManager { - - public RecipeManager() { - // Load through all recipes: - // Probably very inefficient, so please only do this once. - Bukkit.recipeIterator().forEachRemaining(recipe -> { - // removing a recipe gets... difficult... without a key - // and they should all have one anyway, so this is safe. - NamespacedKey recipeKey; - if(recipe instanceof Keyed keyed) { - recipeKey = keyed.getKey(); - } - else { - // should be impossible - return; - } - - var result = recipe.getResult(); - var customItem = CustomItemManager.getCustomItem(result); - if(customItem != null) { - var shouldReplace = customItem.editRecipe(recipe); - if(shouldReplace) { - Bukkit.removeRecipe(recipeKey); - Bukkit.addRecipe(recipe); - if(recipe instanceof ShapedRecipe shaped) { - System.out.println("New choicemap"); - System.out.println(shaped.getChoiceMap()); - } - } - } - }); - } - -} diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/HoloItemsRevamp.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/HoloItemsRevamp.java index ef0ea578..7a3e3169 100644 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/HoloItemsRevamp.java +++ b/src/main/java/xyz/holocons/mc/holoitemsrevamp/HoloItemsRevamp.java @@ -6,7 +6,6 @@ import com.strangeone101.holoitemsapi.enchantment.EnchantmentListener; import com.strangeone101.holoitemsapi.item.BlockListener; import com.strangeone101.holoitemsapi.item.CustomItemManager; -import com.strangeone101.holoitemsapi.recipe.RecipeManager; import com.strangeone101.holoitemsapi.tracking.CustomBlockStorage; import io.papermc.paper.plugin.lifecycle.event.types.LifecycleEvents; import org.bukkit.plugin.java.JavaPlugin; @@ -19,7 +18,6 @@ public final class HoloItemsRevamp extends JavaPlugin { private CollectionManager collectionManager; private CustomBlockStorage trackingManager; - private RecipeManager recipeManager; @Override public void onLoad() { @@ -40,8 +38,6 @@ public void onEnable() { CustomItemManager.lock(); trackingManager.loadTrackedBlocks(); - recipeManager = new RecipeManager(); - getServer().getPluginManager().registerEvents(new EnchantmentListener(), this); getServer().getPluginManager().registerEvents(new AnvilListener(this), this); // getServer().getPluginManager().registerEvents(new CraftListener(this), this); diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/HolyFireBlock.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/HolyFireBlock.java index 92960b3f..bffdbc94 100644 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/HolyFireBlock.java +++ b/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/HolyFireBlock.java @@ -50,14 +50,21 @@ public HolyFireBlock(HoloItemsRevamp plugin) { } @Override - public boolean editRecipe(Recipe r) { - if(r instanceof ShapedRecipe recipe) { - // if it's not this, a new recipe was probably added to the datapack? - char saintQuartzKey = recipe.getShape()[1].charAt(1); - recipe.setIngredient(saintQuartzKey, new CustomItemRecipeChoice("saint_quartz")); - return true; - } - return false; + public Recipe getRecipe() { + final var recipeKey = getKey(); + final var outStack = buildStack(null); + final var recipe = new ShapedRecipe(recipeKey, outStack); + + recipe.shape( + " E ", + "EQE", + "GGG" + ); + recipe.setIngredient('E', Material.END_ROD); + recipe.setIngredient('G', Material.RAW_GOLD_BLOCK); + recipe.setIngredient('Q', new CustomItemRecipeChoice("saint_quartz")); + + return recipe; } @Override From 2ef28ed3b61cb6cc04b75662f5906886b917889a Mon Sep 17 00:00:00 2001 From: Tsumiki Miniwa <37684627+cpaca@users.noreply.github.com> Date: Wed, 17 Sep 2025 06:31:02 -0700 Subject: [PATCH 51/80] Add and shade lightbend (hocon) --- build.gradle.kts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/build.gradle.kts b/build.gradle.kts index 0d047d92..66ccac62 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -25,6 +25,7 @@ dependencies { compileOnly("com.comphenix.protocol:ProtocolLib:5.4.0-SNAPSHOT") compileOnly("com.sk89q.worldguard:worldguard-bukkit:7.0.9") implementation("com.github.stefvanschie.inventoryframework:IF:0.11.3") + implementation("com.typesafe:config:1.4.4") } tasks { @@ -57,6 +58,7 @@ tasks { // https://github.com/johnrengelman/shadow shadowJar { relocate("com.github.stefvanschie.inventoryframework", "shadow.inventoryframework") + relocate("com.typesafe.config", "shadow.lightbend") archiveClassifier.set("") } From 05e27eb837f995b1b359cecb423677b4fb1407ea Mon Sep 17 00:00:00 2001 From: Tsumiki Miniwa <37684627+cpaca@users.noreply.github.com> Date: Wed, 17 Sep 2025 16:30:28 -0700 Subject: [PATCH 52/80] Move recipes back to code format Since we can't have all of them in the datapack, they are going to be all in the code. --- .../data/holoitems/recipe/backdash.json | 26 ---------- .../data/holoitems/recipe/magnet.json | 50 ------------------- .../data/holoitems/recipe/memento.json | 41 --------------- .../data/holoitems/recipe/plow.json | 38 -------------- .../data/holoitems/recipe/tide_rider.json | 38 -------------- .../holoitemsrevamp/item/BackdashBoots.java | 13 +++++ .../mc/holoitemsrevamp/item/MagnetBook.java | 18 +++++++ .../mc/holoitemsrevamp/item/MementoItem.java | 13 +++++ .../mc/holoitemsrevamp/item/PlowBook.java | 14 ++++++ .../holoitemsrevamp/item/TideRiderItem.java | 14 ++++++ 10 files changed, 72 insertions(+), 193 deletions(-) delete mode 100644 holoitems_datapack/data/holoitems/recipe/backdash.json delete mode 100644 holoitems_datapack/data/holoitems/recipe/magnet.json delete mode 100644 holoitems_datapack/data/holoitems/recipe/memento.json delete mode 100644 holoitems_datapack/data/holoitems/recipe/plow.json delete mode 100644 holoitems_datapack/data/holoitems/recipe/tide_rider.json diff --git a/holoitems_datapack/data/holoitems/recipe/backdash.json b/holoitems_datapack/data/holoitems/recipe/backdash.json deleted file mode 100644 index 3a79e2c5..00000000 --- a/holoitems_datapack/data/holoitems/recipe/backdash.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "type": "crafting_shaped", - "pattern": [ - "p p", - "m m" - ], - "key": { - "p": {"item":"minecraft:piston"}, - "m": {"item":"minecraft:phantom_membrane"} - }, - "result": { - "id": "leather_boots", - "components": { - "dyed_color": {"rgb":0}, - "enchantments": {"levels": {"holoitems:backdash": 1}}, - "lore": ["\"Crouch to backdash\""], - "item_name": "{\"color\":\"dark_gray\",\"text\":\"Backdash\"}", - "custom_data": { - "PublicBukkitValues": { - "holoitems:item_id": "backdash", - "holoitems:book_like": 1 - } - } - } - } -} \ No newline at end of file diff --git a/holoitems_datapack/data/holoitems/recipe/magnet.json b/holoitems_datapack/data/holoitems/recipe/magnet.json deleted file mode 100644 index 2ad9a105..00000000 --- a/holoitems_datapack/data/holoitems/recipe/magnet.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "type": "minecraft:crafting_shaped", - "pattern": [ - "AAB", - "CDE", - "FGD" - ], - "key": { - "A": { - "item": "minecraft:powered_rail" - }, - "B": { - "item": "minecraft:iron_pickaxe" - }, - "C": { - "item": "minecraft:hopper" - }, - "D": { - "item": "minecraft:iron_block" - }, - "E": { - "item": "minecraft:redstone" - }, - "F": { - "item": "minecraft:dropper" - }, - "G": { - "item": "minecraft:comparator" - } - }, - "result": { - "id": "minecraft:enchanted_book", - "components": { - "minecraft:custom_data": { - "PublicBukkitValues": { - "holoitems:item_id": "magnet" - } - }, - "minecraft:item_name": "{\"color\":\"red\",\"text\":\"Magnet\"}", - "minecraft:lore": [ - "{\"color\":\"dark_purple\", \"text\":\"Automatically put mined items to your inventory!\"}" - ], - "minecraft:stored_enchantments": { - "levels": { - "holoitems:magnet": 1 - } - } - } - } -} \ No newline at end of file diff --git a/holoitems_datapack/data/holoitems/recipe/memento.json b/holoitems_datapack/data/holoitems/recipe/memento.json deleted file mode 100644 index 5a8f4cd0..00000000 --- a/holoitems_datapack/data/holoitems/recipe/memento.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "type": "minecraft:crafting_shaped", - "pattern": [ - "AAA", - "ABA", - "AAA" - ], - "key": { - "A": [ - { - "item": "minecraft:obsidian" - }, - { - "item": "minecraft:crying_obsidian" - } - ], - "B": { - "item": "minecraft:end_crystal" - } - }, - "result": { - "id": "minecraft:ender_chest", - "components": { - "minecraft:custom_data": { - "PublicBukkitValues": { - "holoitems:item_id": "memento" - } - }, - "minecraft:item_name": "{\"color\":\"dark_purple\",\"text\":\"Memento\"}", - "minecraft:enchantments": { - "levels": { - "holoitems:memento": 1 - } - }, - "minecraft:lore": [ - "{\"color\":\"dark_purple\",\"text\":\"Keep your items on death. Consumable.\"}" - ], - "minecraft:max_stack_size": 99 - } - } -} \ No newline at end of file diff --git a/holoitems_datapack/data/holoitems/recipe/plow.json b/holoitems_datapack/data/holoitems/recipe/plow.json deleted file mode 100644 index 3e473fcb..00000000 --- a/holoitems_datapack/data/holoitems/recipe/plow.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "type": "minecraft:crafting_shaped", - "pattern": [ - "ABA", - "ACA", - "ACA" - ], - "key": { - "A": { - "item": "minecraft:tinted_glass" - }, - "B": { - "item": "minecraft:obsidian" - }, - "C": { - "item": "minecraft:stick" - } - }, - "result": { - "id": "minecraft:enchanted_book", - "components": { - "minecraft:custom_data": { - "PublicBukkitValues": { - "holoitems:item_id": "plow" - } - }, - "minecraft:item_name": "{\"color\":\"red\",\"text\":\"Plow\"}", - "minecraft:lore": [ - "{\"color\":\"dark_purple\",\"text\":\"Shovel snow!\"}" - ], - "minecraft:stored_enchantments": { - "levels": { - "holoitems:plow": 1 - } - } - } - } -} \ No newline at end of file diff --git a/holoitems_datapack/data/holoitems/recipe/tide_rider.json b/holoitems_datapack/data/holoitems/recipe/tide_rider.json deleted file mode 100644 index b3dc1406..00000000 --- a/holoitems_datapack/data/holoitems/recipe/tide_rider.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "type": "minecraft:crafting_shaped", - "pattern": [ - "ABA", - "AC ", - " A " - ], - "key": { - "A": { - "item": "minecraft:prismarine_bricks" - }, - "B": { - "item": "minecraft:trident" - }, - "C": { - "item": "minecraft:enchanted_golden_apple" - } - }, - "result": { - "id": "minecraft:trident", - "components": { - "minecraft:custom_data": { - "PublicBukkitValues": { - "holoitems:item_id": "tide_rider" - } - }, - "minecraft:item_name": "{\"color\":\"blue\",\"text\":\"Tide Rider\"}", - "minecraft:enchantments": { - "levels": { - "holoitems:tide_rider": 1 - } - }, - "minecraft:lore": [ - "{\"text\":\"Surf the waves\"}" - ] - } - } -} \ No newline at end of file diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/BackdashBoots.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/BackdashBoots.java index 13d3a99d..d14e4cdd 100644 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/BackdashBoots.java +++ b/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/BackdashBoots.java @@ -31,6 +31,19 @@ public BackdashBoots(HoloItemsRevamp plugin) { this.register(); } + @Override + public Recipe getRecipe() { + final var recipe = new ShapedRecipe(getKey(), buildStack(null)); + recipe.shape( + " ", + "A A", + "B B" + ); + recipe.setIngredient('A', Material.PISTON); + recipe.setIngredient('B', Material.PHANTOM_MEMBRANE); + return recipe; + } + @Override public NamespacedKey getEnchantmentKey() { return getKey(); diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/MagnetBook.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/MagnetBook.java index ea4b85af..1f00c7e6 100644 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/MagnetBook.java +++ b/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/MagnetBook.java @@ -30,6 +30,24 @@ public MagnetBook(HoloItemsRevamp plugin) { this.register(); } + @Override + public Recipe getRecipe() { + final var recipe = new ShapedRecipe(getKey(), buildStack(null)); + recipe.shape( + "AAB", + "CDE", + "FGD" + ); + recipe.setIngredient('A', Material.POWERED_RAIL); + recipe.setIngredient('B', Material.IRON_PICKAXE); + recipe.setIngredient('C', Material.HOPPER); + recipe.setIngredient('D', Material.IRON_BLOCK); + recipe.setIngredient('E', Material.REDSTONE); + recipe.setIngredient('F', Material.DROPPER); + recipe.setIngredient('G', Material.COMPARATOR); + return recipe; + } + @Override public NamespacedKey getEnchantmentKey() { return getKey(); diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/MementoItem.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/MementoItem.java index 55b9a109..3f166118 100644 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/MementoItem.java +++ b/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/MementoItem.java @@ -34,6 +34,19 @@ public MementoItem(HoloItemsRevamp plugin) { this.register(); } + @Override + public Recipe getRecipe() { + final var recipe = new ShapedRecipe(getKey(), buildStack(null)); + recipe.shape( + "AAA", + "ABA", + "AAA" + ); + recipe.setIngredient('A', Material.ENDER_CHEST); + recipe.setIngredient('B', Material.END_CRYSTAL); + return recipe; + } + @Override public NamespacedKey getEnchantmentKey() { return getKey(); diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/PlowBook.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/PlowBook.java index c2ab6c60..1ec2f209 100644 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/PlowBook.java +++ b/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/PlowBook.java @@ -29,6 +29,20 @@ public PlowBook(HoloItemsRevamp plugin){ this.register(); } + @Override + public Recipe getRecipe() { + ShapedRecipe recipe = new ShapedRecipe(getKey(), buildStack(null)); + recipe.shape( + "ABA", + "ACA", + "ACA" + ); + recipe.setIngredient('A', Material.TINTED_GLASS); + recipe.setIngredient('B', Material.OBSIDIAN); + recipe.setIngredient('C', Material.STICK); + return recipe; + } + @Override public NamespacedKey getEnchantmentKey() { return getKey(); diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/TideRiderItem.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/TideRiderItem.java index b016651c..81db26f9 100644 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/TideRiderItem.java +++ b/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/TideRiderItem.java @@ -31,6 +31,20 @@ public TideRiderItem(HoloItemsRevamp plugin) { this.register(); } + @Override + public Recipe getRecipe() { + final var recipe = new ShapedRecipe(getKey(), buildStack(null)); + recipe.shape( + "ATA", + "AG ", + " D " + ); + recipe.setIngredient('A', Material.PRISMARINE_BRICKS); + recipe.setIngredient('T', Material.TRIDENT); + recipe.setIngredient('G', Material.ENCHANTED_GOLDEN_APPLE); + return recipe; + } + @Override public NamespacedKey getEnchantmentKey() { return getKey(); From 17d96d5e294796491bb9d05f61aca1a19d7111a3 Mon Sep 17 00:00:00 2001 From: Tsumiki Miniwa <37684627+cpaca@users.noreply.github.com> Date: Wed, 17 Sep 2025 16:30:41 -0700 Subject: [PATCH 53/80] remove extraneous tag --- .../data/holoitems/tags/item/saint_quartz.json | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 holoitems_datapack/data/holoitems/tags/item/saint_quartz.json diff --git a/holoitems_datapack/data/holoitems/tags/item/saint_quartz.json b/holoitems_datapack/data/holoitems/tags/item/saint_quartz.json deleted file mode 100644 index a3193b00..00000000 --- a/holoitems_datapack/data/holoitems/tags/item/saint_quartz.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "values": [ - { - "id": "minecraft:quartz" - } - ] -} \ No newline at end of file From 3e6cac2b80827065dbbc5f2f77c080a95a691a7c Mon Sep 17 00:00:00 2001 From: Tsumiki Miniwa <37684627+cpaca@users.noreply.github.com> Date: Wed, 17 Sep 2025 16:37:06 -0700 Subject: [PATCH 54/80] Make Backdash booklike again --- .../strangeone101/holoitemsapi/item/CustomItem.java | 10 ++++++++++ .../mc/holoitemsrevamp/item/BackdashBoots.java | 1 + 2 files changed, 11 insertions(+) diff --git a/src/main/java/com/strangeone101/holoitemsapi/item/CustomItem.java b/src/main/java/com/strangeone101/holoitemsapi/item/CustomItem.java index 2462ea6f..86d3fded 100644 --- a/src/main/java/com/strangeone101/holoitemsapi/item/CustomItem.java +++ b/src/main/java/com/strangeone101/holoitemsapi/item/CustomItem.java @@ -55,6 +55,7 @@ public class CustomItem implements Keyed { private Set> statGoals; private int hex; private ItemFlag[] flags; + private boolean bookLike; private Map> variables = new HashMap<>(); @@ -110,6 +111,7 @@ public ItemStack buildStack(Player player) { } Keys.ITEM_ID.set(meta.getPersistentDataContainer(), getInternalName()); + Keys.BOOK_LIKE.set(meta.getPersistentDataContainer(), this.getBookLike()); // If the item shouldn't be stackable, add a random INTEGER to the NBT if(this.getStackSize() != null){ @@ -447,4 +449,12 @@ public CustomItem setFlags(ItemFlag... flags) { this.flags = flags; return this; } + + public boolean getBookLike() { + return bookLike; + } + + public void setBookLike(boolean bookLike) { + this.bookLike = bookLike; + } } diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/BackdashBoots.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/BackdashBoots.java index d14e4cdd..4d13857b 100644 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/BackdashBoots.java +++ b/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/BackdashBoots.java @@ -28,6 +28,7 @@ public BackdashBoots(HoloItemsRevamp plugin) { // TODO: Why was setUnstackable() here? It's boots, they don't stack anyway? // Should this be removed? this.setStackSize(1); + this.setBookLike(true); this.register(); } From 181c1903093f70c1b4625b48ebb82dbdd8d27aa7 Mon Sep 17 00:00:00 2001 From: Tsumiki Miniwa <37684627+cpaca@users.noreply.github.com> Date: Wed, 17 Sep 2025 16:49:37 -0700 Subject: [PATCH 55/80] add holoitems:enchantments tag --- .../data/holoitems/tags/enchantment/enchantments | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 holoitems_datapack/data/holoitems/tags/enchantment/enchantments diff --git a/holoitems_datapack/data/holoitems/tags/enchantment/enchantments b/holoitems_datapack/data/holoitems/tags/enchantment/enchantments new file mode 100644 index 00000000..3d798f52 --- /dev/null +++ b/holoitems_datapack/data/holoitems/tags/enchantment/enchantments @@ -0,0 +1,9 @@ +{ + "values": [ + "holoitems:backdash", + "holoitems:magnet", + "holoitems:memento", + "holoitems:plow", + "holoitems:tide_rider" + ] +} \ No newline at end of file From 1c3bfef0472b981d9db8dc9056852488de9ca27b Mon Sep 17 00:00:00 2001 From: Tsumiki Miniwa <37684627+cpaca@users.noreply.github.com> Date: Thu, 18 Sep 2025 05:15:36 -0700 Subject: [PATCH 56/80] Fix TideRider recipe --- .../xyz/holocons/mc/holoitemsrevamp/item/TideRiderItem.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/TideRiderItem.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/TideRiderItem.java index 81db26f9..83edf22b 100644 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/TideRiderItem.java +++ b/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/TideRiderItem.java @@ -37,7 +37,7 @@ public Recipe getRecipe() { recipe.shape( "ATA", "AG ", - " D " + " A " ); recipe.setIngredient('A', Material.PRISMARINE_BRICKS); recipe.setIngredient('T', Material.TRIDENT); From 1151c7b33c9589ccf89ddefea0ebae36487a1809 Mon Sep 17 00:00:00 2001 From: Tsumiki Miniwa <37684627+cpaca@users.noreply.github.com> Date: Thu, 18 Sep 2025 17:12:25 -0700 Subject: [PATCH 57/80] Rename tag enchantments -> holoenchantments --- .../holoitems/tags/enchantment/{enchantments => holoenchantments} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename holoitems_datapack/data/holoitems/tags/enchantment/{enchantments => holoenchantments} (100%) diff --git a/holoitems_datapack/data/holoitems/tags/enchantment/enchantments b/holoitems_datapack/data/holoitems/tags/enchantment/holoenchantments similarity index 100% rename from holoitems_datapack/data/holoitems/tags/enchantment/enchantments rename to holoitems_datapack/data/holoitems/tags/enchantment/holoenchantments From 0e523a216cdb6e48cd0aa7833a7a0647bae249c8 Mon Sep 17 00:00:00 2001 From: Tsumiki Miniwa <37684627+cpaca@users.noreply.github.com> Date: Thu, 18 Sep 2025 17:15:06 -0700 Subject: [PATCH 58/80] Remove outdated CustomEnchantment functions --- .../enchantment/CustomEnchantment.java | 21 ------------------- .../holoitemsrevamp/enchantment/Backdash.java | 11 ---------- .../holoitemsrevamp/enchantment/Magnet.java | 14 ------------- .../holoitemsrevamp/enchantment/Memento.java | 14 ------------- .../mc/holoitemsrevamp/enchantment/Plow.java | 15 ------------- .../enchantment/TideRider.java | 11 ---------- 6 files changed, 86 deletions(-) diff --git a/src/main/java/com/strangeone101/holoitemsapi/enchantment/CustomEnchantment.java b/src/main/java/com/strangeone101/holoitemsapi/enchantment/CustomEnchantment.java index 12051823..dd83691e 100644 --- a/src/main/java/com/strangeone101/holoitemsapi/enchantment/CustomEnchantment.java +++ b/src/main/java/com/strangeone101/holoitemsapi/enchantment/CustomEnchantment.java @@ -38,27 +38,6 @@ public static final CustomEnchantment getByKey(@Nullable NamespacedKey key) { return enchantmentsByKey.get(key); } - public abstract Component displayName(int level); - - /** - * Gets the lore that will be applied to items that have this enchantment. Lore will - * not be applied if this returns null. - * @param level The level of the enchantment - * @return Lore corresponding to the given enchantment level - */ - @Nullable - public Component lore(int level) { - return displayName(level); - } - - /** - * Returns the multiplier used to add levels when combining the enchantment. This method is simillar to vanilla - * anvil mechanics - * @see Anvil Mechanics - * @return The multiplier for combining this enchantment - */ - public abstract int getCostMultiplier(); - public static final void loadCustomEnchantments(HoloItemsRevamp plugin) { Set enchantments = Set.of( new Magnet(plugin), diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/Backdash.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/Backdash.java index ab4818f7..b85fb2ab 100644 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/Backdash.java +++ b/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/Backdash.java @@ -22,12 +22,6 @@ public Backdash(HoloItemsRevamp plugin) { super(plugin, "backdash"); } - @Override - public @NotNull Component displayName(int level) { - return Component.text("Backdash", NamedTextColor.GRAY) - .decoration(TextDecoration.ITALIC, false); - } - @Override public void onPlayerToggleSneak(PlayerToggleSneakEvent event, ItemStack itemStack) { if (!event.isSneaking() @@ -37,9 +31,4 @@ public void onPlayerToggleSneak(PlayerToggleSneakEvent event, ItemStack itemStac final var player = event.getPlayer(); player.setVelocity(player.getLocation().getDirection().setY(0).normalize().multiply(-1)); } - - @Override - public int getCostMultiplier() { - return Integer.MAX_VALUE; - } } diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/Magnet.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/Magnet.java index 7ea4da05..293160a7 100644 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/Magnet.java +++ b/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/Magnet.java @@ -26,20 +26,6 @@ public Magnet(HoloItemsRevamp plugin) { this.plugin = plugin; } - @Override - public @NotNull Component displayName(int level) { - return Component.text() - .color(NamedTextColor.GRAY) - .decoration(TextDecoration.ITALIC, false) - .append(Component.text("Magnet")) - .build(); - } - - @Override - public int getCostMultiplier() { - return 12; - } - @Override public void onBlockBreak(BlockBreakEvent event, ItemStack itemStack) { final var location = event.getBlock().getLocation().toCenterLocation(); diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/Memento.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/Memento.java index ee426dcf..1fe05257 100644 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/Memento.java +++ b/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/Memento.java @@ -22,20 +22,6 @@ public Memento(HoloItemsRevamp plugin) { super(plugin, "memento"); } - @Override - public @NotNull Component displayName(int level) { - return Component.text() - .color(NamedTextColor.DARK_PURPLE) - .decoration(TextDecoration.ITALIC, false) - .append(Component.text("Memento")) - .build(); - } - - @Override - public int getCostMultiplier() { - return Integer.MAX_VALUE; - } - @Override public void onPlayerDeath(PlayerDeathEvent event, ItemStack itemStack) { final var location = event.getPlayer().getLocation(); diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/Plow.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/Plow.java index ed70738b..70047e7e 100644 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/Plow.java +++ b/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/Plow.java @@ -26,21 +26,6 @@ public Plow(HoloItemsRevamp plugin) { super(plugin, "plow"); } - @Override - public @NotNull Component displayName(int i) { - return Component.text() - .color(NamedTextColor.GRAY) - .decoration(TextDecoration.ITALIC, false) - .append(Component.text("Plow")) - .build(); - } - - @Override - public int getCostMultiplier() { - // Copied from Magnet - return 12; - } - @Override public void onBlockBreak(BlockBreakEvent event, ItemStack itemStack) { final var player = event.getPlayer(); diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/TideRider.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/TideRider.java index aacbeec8..88db2295 100644 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/TideRider.java +++ b/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/TideRider.java @@ -32,17 +32,6 @@ public TideRider(HoloItemsRevamp plugin) { this.plugin = plugin; } - @Override - public @NotNull Component displayName(int level) { - return Component.text("Tide Rider", NamedTextColor.GRAY) - .decoration(TextDecoration.ITALIC, false); - } - - @Override - public int getCostMultiplier() { - return Integer.MAX_VALUE; - } - @Override public void onPlayerInteract(PlayerInteractEvent event, ItemStack itemStack) { final var player = event.getPlayer(); From c2b38e2291556e42bd0eaf09bc4e024e2cce3fb3 Mon Sep 17 00:00:00 2001 From: Tsumiki Miniwa <37684627+cpaca@users.noreply.github.com> Date: Thu, 18 Sep 2025 17:17:54 -0700 Subject: [PATCH 59/80] Remove ProtocolLib dependency No longer being used. --- build.gradle.kts | 3 - .../packet/AbstractPacket.java | 33 ---------- .../packet/EntityDestroyPacket.java | 15 ----- .../packet/EntityMetadataPacket.java | 66 ------------------- .../packet/PlayerAbilitiesPacket.java | 20 ------ .../packet/SpawnEntityLivingPacket.java | 35 ---------- 6 files changed, 172 deletions(-) delete mode 100644 src/main/java/xyz/holocons/mc/holoitemsrevamp/packet/AbstractPacket.java delete mode 100644 src/main/java/xyz/holocons/mc/holoitemsrevamp/packet/EntityDestroyPacket.java delete mode 100644 src/main/java/xyz/holocons/mc/holoitemsrevamp/packet/EntityMetadataPacket.java delete mode 100644 src/main/java/xyz/holocons/mc/holoitemsrevamp/packet/PlayerAbilitiesPacket.java delete mode 100644 src/main/java/xyz/holocons/mc/holoitemsrevamp/packet/SpawnEntityLivingPacket.java diff --git a/build.gradle.kts b/build.gradle.kts index 66ccac62..ca0df5dd 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -22,7 +22,6 @@ repositories { dependencies { compileOnly("io.papermc.paper:paper-api:1.21.1-R0.1-SNAPSHOT") - compileOnly("com.comphenix.protocol:ProtocolLib:5.4.0-SNAPSHOT") compileOnly("com.sk89q.worldguard:worldguard-bukkit:7.0.9") implementation("com.github.stefvanschie.inventoryframework:IF:0.11.3") implementation("com.typesafe:config:1.4.4") @@ -94,8 +93,6 @@ paper { prefix = "HoloItems" serverDependencies { - register("ProtocolLib") - register("WorldGuard") { required = false } diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/packet/AbstractPacket.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/packet/AbstractPacket.java deleted file mode 100644 index 24ceb13d..00000000 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/packet/AbstractPacket.java +++ /dev/null @@ -1,33 +0,0 @@ -package xyz.holocons.mc.holoitemsrevamp.packet; - -import org.bukkit.Location; -import org.bukkit.entity.Player; - -import com.comphenix.protocol.PacketType; -import com.comphenix.protocol.ProtocolLibrary; -import com.comphenix.protocol.events.PacketContainer; - -public abstract class AbstractPacket { - - protected final PacketContainer handle; - - protected AbstractPacket(PacketType packetType) { - this.handle = new PacketContainer(packetType); - } - - public PacketContainer getHandle() { - return handle; - } - - public void sendPacket(Player player) { - ProtocolLibrary.getProtocolManager().sendServerPacket(player, getHandle()); - } - - public void broadcastNearbyPacket(Location origin, int maxObserverDistance) { - ProtocolLibrary.getProtocolManager().broadcastServerPacket(getHandle(), origin, maxObserverDistance); - } - - public void broadcastServerPacket() { - ProtocolLibrary.getProtocolManager().broadcastServerPacket(getHandle()); - } -} diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/packet/EntityDestroyPacket.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/packet/EntityDestroyPacket.java deleted file mode 100644 index 0f0e47c3..00000000 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/packet/EntityDestroyPacket.java +++ /dev/null @@ -1,15 +0,0 @@ -package xyz.holocons.mc.holoitemsrevamp.packet; - -import com.comphenix.protocol.PacketType; - -import it.unimi.dsi.fastutil.ints.IntList; - -public class EntityDestroyPacket extends AbstractPacket { - - // https://nms.screamingsandals.org/1.18.1/net/minecraft/network/protocol/game/ClientboundRemoveEntitiesPacket.html - public EntityDestroyPacket(int... entityIds) { - super(PacketType.Play.Server.ENTITY_DESTROY); - handle.getIntLists() - .write(0, IntList.of(entityIds)); // entityIds - } -} diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/packet/EntityMetadataPacket.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/packet/EntityMetadataPacket.java deleted file mode 100644 index 7369fb83..00000000 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/packet/EntityMetadataPacket.java +++ /dev/null @@ -1,66 +0,0 @@ -package xyz.holocons.mc.holoitemsrevamp.packet; - -import java.util.List; -import java.util.Optional; - -import com.comphenix.protocol.PacketType; -import com.comphenix.protocol.wrappers.WrappedChatComponent; -import com.comphenix.protocol.wrappers.WrappedDataValue; -import com.comphenix.protocol.wrappers.WrappedDataWatcher.Registry; - -import it.unimi.dsi.fastutil.ints.Int2ObjectArrayMap; -import net.kyori.adventure.text.Component; -import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer; - -public class EntityMetadataPacket extends AbstractPacket { - - public static class Metadata { - - private final Int2ObjectArrayMap dataValues; - - // https://wiki.vg/Entity_metadata#Entity_Metadata_Format - public Metadata() { - this.dataValues = new Int2ObjectArrayMap<>(); - } - - public List toList() { - return List.copyOf(dataValues.values()); - } - - private void setObject(int index, Object value, Class clazz) { - dataValues.put(index, new WrappedDataValue(index, Registry.get(clazz), value)); - } - - public void setByte(int index, byte value) { - setObject(index, value, Byte.class); - } - - public void setBoolean(int index, boolean value) { - setObject(index, value, Boolean.class); - } - - public void setVarInt(int index, int value) { - setObject(index, value, Integer.class); - } - - public void setCustomName(Component name) { - final var jsonComponent = GsonComponentSerializer.gson().serialize(name); - final var chatComponent = WrappedChatComponent.fromJson(jsonComponent); - final var optionalChatComponent = Optional.of(chatComponent.getHandle()); - dataValues.put(2, new WrappedDataValue(2, Registry.getChatComponentSerializer(true), optionalChatComponent)); - } - - public void setCustomNameVisible() { - setBoolean(3, true); - } - } - - // https://nms.screamingsandals.org/1.19.3/net/minecraft/network/protocol/game/ClientboundSetEntityDataPacket.html - public EntityMetadataPacket(int entityId, Metadata metadata) { - super(PacketType.Play.Server.ENTITY_METADATA); - handle.getIntegers() - .write(0, entityId); // id - handle.getDataValueCollectionModifier() - .write(0, metadata.toList()); // packedItems - } -} diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/packet/PlayerAbilitiesPacket.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/packet/PlayerAbilitiesPacket.java deleted file mode 100644 index 93e35461..00000000 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/packet/PlayerAbilitiesPacket.java +++ /dev/null @@ -1,20 +0,0 @@ -package xyz.holocons.mc.holoitemsrevamp.packet; - -import com.comphenix.protocol.PacketType; -import org.bukkit.entity.Player; - -public class PlayerAbilitiesPacket extends AbstractPacket { - - // https://nms.screamingsandals.org/1.18.2/net/minecraft/network/protocol/game/ClientboundPlayerAbilitiesPacket.html - public PlayerAbilitiesPacket(Player player, boolean canInstaBuild) { - super(PacketType.Play.Server.ABILITIES); - handle.getBooleans() - .write(0, player.isInvulnerable()) - .write(1, player.isFlying()) - .write(2, player.getAllowFlight()) - .write(3, canInstaBuild); - handle.getFloat() - .write(0, player.getFlySpeed() / 2) - .write(1, player.getWalkSpeed() / 2); - } -} diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/packet/SpawnEntityLivingPacket.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/packet/SpawnEntityLivingPacket.java deleted file mode 100644 index 951939b5..00000000 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/packet/SpawnEntityLivingPacket.java +++ /dev/null @@ -1,35 +0,0 @@ -package xyz.holocons.mc.holoitemsrevamp.packet; - -import java.util.UUID; - -import com.comphenix.protocol.PacketType; - -import org.bukkit.Location; -import org.bukkit.entity.EntityType; - -public class SpawnEntityLivingPacket extends AbstractPacket { - - // https://nms.screamingsandals.org/1.19.1/net/minecraft/network/protocol/game/ClientboundAddEntityPacket.html - public SpawnEntityLivingPacket(int entityId, UUID uniqueId, EntityType entityType, Location location) { - super(PacketType.Play.Server.SPAWN_ENTITY); - // https://wiki.vg/Entity_metadata#Mobs - handle.getIntegers() - .write(0, entityId) // id - .write(1, 0) // xa - .write(2, 0) // ya - .write(3, 0) // za - .write(4, 0); // data - handle.getUUIDs() - .write(0, uniqueId); // uuid - handle.getEntityTypeModifier() - .write(0, entityType); // type - handle.getDoubles() - .write(0, location.getX()) // x - .write(1, location.getY()) // y - .write(2, location.getZ()); // z - handle.getBytes() - .write(0, (byte)0) // xRot - .write(1, (byte)0) // yRot - .write(2, (byte)0); // yHeadRot - } -} From 651f4c0c3e10e160398f78fefc9f5bc399e94ba4 Mon Sep 17 00:00:00 2001 From: Tsumiki Miniwa <37684627+cpaca@users.noreply.github.com> Date: Thu, 18 Sep 2025 17:30:48 -0700 Subject: [PATCH 60/80] remove old todo --- .../xyz/holocons/mc/holoitemsrevamp/command/MainCommand.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/command/MainCommand.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/command/MainCommand.java index 568595f1..48e9ba6a 100644 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/command/MainCommand.java +++ b/src/main/java/xyz/holocons/mc/holoitemsrevamp/command/MainCommand.java @@ -78,7 +78,6 @@ public void execute(CommandSourceStack sourceStack, String[] args) { @Override public @NotNull Collection suggest(CommandSourceStack sourceStack, String[] args) { - // TODO if (args.length <= 1) { return subCommands.keySet(); } else { From 4cc91baebfa4eea88a19e079aa1d9ddae3d27f23 Mon Sep 17 00:00:00 2001 From: Tsumiki Miniwa <37684627+cpaca@users.noreply.github.com> Date: Thu, 18 Sep 2025 17:37:50 -0700 Subject: [PATCH 61/80] Fix TideRider's particle Spawning 80 seems like too much though. --- .../xyz/holocons/mc/holoitemsrevamp/enchantment/TideRider.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/TideRider.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/TideRider.java index 88db2295..cb19363b 100644 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/TideRider.java +++ b/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/TideRider.java @@ -69,8 +69,7 @@ public void run() { final var location = player.getLocation(); if (elapsedTicks % 2 != 0) { - // TODO: Figure out what particle to replace this with. -// world.spawnParticle(Particle.WATER_WAKE, location, 80, 0.2, 0.0, 0.2); + world.spawnParticle(Particle.SPLASH, location, 80, 0.2, 0.0, 0.2); } final var direction = location.getDirection().setY(0.0001).normalize(); From 72fa5bc8148aa5846aa2f2a64926e36e3261d7b6 Mon Sep 17 00:00:00 2001 From: Tsumiki Miniwa <37684627+cpaca@users.noreply.github.com> Date: Sat, 20 Sep 2025 22:28:30 -0700 Subject: [PATCH 62/80] Attempt to fix GitHub workflow --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index de57e6c2..9d023b1d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -21,7 +21,7 @@ jobs: - name: Build with Gradle run: ./gradlew build --stacktrace - name: Upload build artifact - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: ${{ github.event.repository.name }}-${{ github.sha }} path: | From f51702459a9e8323c1737b298917203f4f5ec73f Mon Sep 17 00:00:00 2001 From: Tsumiki Miniwa <37684627+cpaca@users.noreply.github.com> Date: Sun, 21 Sep 2025 01:27:26 -0700 Subject: [PATCH 63/80] Update remaining build.yml versions --- .github/workflows/build.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9d023b1d..2cd0f778 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -8,12 +8,12 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - java: [ 17 ] + java: [ 21 ] fail-fast: true steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up JDK ${{ matrix.java }} - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: java-version: ${{ matrix.java }} distribution: 'temurin' From 316326089e3ede25d31ca25034ebac0b365ba160 Mon Sep 17 00:00:00 2001 From: Tsumiki Miniwa <37684627+cpaca@users.noreply.github.com> Date: Sun, 21 Sep 2025 03:14:03 -0700 Subject: [PATCH 64/80] Fix using holoitems in non-custom recipes. --- .../holoitemsapi/recipe/CraftListener.java | 151 ++++++++++++++++++ .../holoitemsapi/recipe/RecipeManager.java | 55 +++++++ .../mc/holoitemsrevamp/HoloItemsRevamp.java | 10 +- 3 files changed, 215 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/strangeone101/holoitemsapi/recipe/CraftListener.java create mode 100644 src/main/java/com/strangeone101/holoitemsapi/recipe/RecipeManager.java diff --git a/src/main/java/com/strangeone101/holoitemsapi/recipe/CraftListener.java b/src/main/java/com/strangeone101/holoitemsapi/recipe/CraftListener.java new file mode 100644 index 00000000..331e6d77 --- /dev/null +++ b/src/main/java/com/strangeone101/holoitemsapi/recipe/CraftListener.java @@ -0,0 +1,151 @@ +package com.strangeone101.holoitemsapi.recipe; + +import com.strangeone101.holoitemsapi.item.CustomItemManager; +import org.bukkit.NamespacedKey; +import org.bukkit.block.Crafter; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.event.Cancellable; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.block.CrafterCraftEvent; +import org.bukkit.event.inventory.CraftItemEvent; +import org.bukkit.event.inventory.PrepareItemCraftEvent; +import org.bukkit.inventory.*; +import xyz.holocons.mc.holoitemsrevamp.HoloItemsRevamp; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public class CraftListener implements Listener { + + private final HoloItemsRevamp plugin; + private final RecipeManager recipeManager; + + public CraftListener(HoloItemsRevamp plugin) { + this.plugin = plugin; + this.recipeManager = this.plugin.getRecipeManager(); + } + + @EventHandler + public void onCrafterCraft(CrafterCraftEvent event) { + final var crafter = event.getBlock(); + if(crafter.getState() instanceof Crafter crafterState) { + var crafterInv = crafterState.getInventory(); + var crafterContents = crafterInv.getStorageContents(); + var recipe = event.getRecipe(); + var validCraft = checkRecipeCustomItems(crafterContents, recipe); + event.setCancelled(!validCraft); + } + else { + // ... crafter.getState() wasn't a Crafter state? + // just gonna cancel the event to be safe + event.setCancelled(true); + } + } + + @EventHandler(ignoreCancelled = true) + public void onCraft(CraftItemEvent event) { + // Shouldn't even fire if PrepareItemCraftEvent fired properly, + // but I'm checking again in here just in case. + var contents = event.getInventory().getStorageContents(); + var recipe = event.getRecipe(); + var valid = checkRecipeCustomItems(Arrays.copyOfRange(contents, 1, 10), recipe); + event.setCancelled(!valid); + } + + @EventHandler(ignoreCancelled = true) + public void onPrepareCraft(PrepareItemCraftEvent event) { + var contents = event.getInventory().getStorageContents(); + var recipe = event.getRecipe(); + var valid = checkRecipeCustomItems(Arrays.copyOfRange(contents, 1, 10), recipe); + if(!valid) { + event.getInventory().setResult(null); + } + } + + /** + * Checks the custom items in a recipe. If there are custom items where they aren't allowed, returns false. + * Otherwise, returns true. + * @return Whether the recipe is valid/okay. + */ + private boolean checkRecipeCustomItems(ItemStack[] contents, Recipe recipe) { + final List customItemIndices = new ArrayList<>(); + for (int i = 0; i < contents.length; i++) { + var stack = contents[i]; + if(stack == null) { + continue; + } + + if(CustomItemManager.isCustomItem(stack)) { + customItemIndices.add(i); + } + + // ... Depending on SandPortal's implementation, this might be relevant? + // Mostly for stopping people from making sandstone blocks with them. + boolean hasCustomEnchantments = stack + .getEnchantments().keySet().stream() + .map(Enchantment::getKey) + .map(NamespacedKey::getNamespace) + .anyMatch(s -> s.equals("holoitems")); + if(hasCustomEnchantments) { + // There might be a use for this that isn't just "Recipe is automatically invalid" + // but for now I'm leaving it like this. + return false; + } + } + + if(customItemIndices.isEmpty()) { + // no custom items in recipe so automatically valid + // at least, by this check + return true; + } + + var registeredRecipe = recipeManager.getRegisteredRecipe(recipe); + if(registeredRecipe == null) { + // recipe is not registered but there's custom items + return false; + } + + /* + The code below was made because I assumed when an event returns a Recipe, it returns the original recipe + THIS IS NOT THE CASE. The RecipeChoices I was getting were exclusively ExactChoice and MaterialChoice, even + if one of them was originally a CustomItemRecipeChoice. + + RecipeManager was made after the code below was made - but I've left it here, so that we can still use + MaterialChoice in other CustomItems. Ex: use Material.TINTED_GLASS for lunarlaser without having to explicitly + state "and NOT the Reading Glasses holoitem" + + As a result, this is tested code, but I didn't get to thoroughly test it. I've only left it here instead of + replacing it with "return true;" because I think this will be useful in the future, I just don't know when. + */ + if(registeredRecipe instanceof ShapedRecipe shapedRecipe) { + // needed so that if a 2x2 recipe is in the bottom-right + // it gets "moved" to the top-left + int minRow = customItemIndices.stream().mapToInt(i -> i/3).min().orElse(0); + int minCol = customItemIndices.stream().mapToInt(i -> i%3).min().orElse(0); + for(Integer customItemIndex : customItemIndices) { + int row = (customItemIndex/3) - minRow; + int col = (customItemIndex%3) - minCol; + Character choiceChar = shapedRecipe.getShape()[row].charAt(col); + var choice = shapedRecipe.getChoiceMap().get(choiceChar); + if(!(choice instanceof CustomItemRecipeChoice)) { + // this is a non-custom-item slot with a custom item in it + return false; + } + } + // all slots passed + return true; + } + else { + // TODO: Implement ShapelessRecipe checks. + // Recipe is not an instance of CraftingRecipe + // uh, maybe it's a furnace recipe (i know emerald leaf or whatever gnaw requires is a furnace recipe) + // either way, point is it's not implemented + plugin.getLogger().warning("CraftListener.checkRecipeCustomItems called with unknown recipe type"); + plugin.getLogger().warning("Recipe class: " + recipe.getClass().toGenericString()); + plugin.getLogger().warning("Recipe toString value: " + recipe); + return false; + } + } +} diff --git a/src/main/java/com/strangeone101/holoitemsapi/recipe/RecipeManager.java b/src/main/java/com/strangeone101/holoitemsapi/recipe/RecipeManager.java new file mode 100644 index 00000000..33e8ddf7 --- /dev/null +++ b/src/main/java/com/strangeone101/holoitemsapi/recipe/RecipeManager.java @@ -0,0 +1,55 @@ +package com.strangeone101.holoitemsapi.recipe; + +import org.bukkit.Bukkit; +import org.bukkit.Keyed; +import org.bukkit.NamespacedKey; +import org.bukkit.inventory.Recipe; +import xyz.holocons.mc.holoitemsrevamp.HoloItemsRevamp; + +import java.util.HashMap; +import java.util.Map; + +public class RecipeManager { + + private final HoloItemsRevamp plugin; + private final Map recipeMap = new HashMap<>(); + + public RecipeManager(HoloItemsRevamp plugin) { + this.plugin = plugin; + } + + /** + * Registers a recipe in this RecipeManager. Doing this also registers the recipe using Bukkit::addRecipe + */ + public void registerRecipe(Recipe recipe) { + if(recipe instanceof Keyed keyed) { + var key = keyed.getKey(); + recipeMap.put(key, recipe); + Bukkit.addRecipe(recipe); + } + else { + // This is possible for a MerchantRecipe. + throw new IllegalArgumentException("Can't register a recipe that doesn't have a NamespacedKey."); + } + } + + /** + * Gets a recipe that's been registered in this RecipeManager + */ + public Recipe getRegisteredRecipe(NamespacedKey key) { + return this.recipeMap.get(key); + } + + /** + * Gets a recipe that's been registered in this RecipeManager. This difference between the recipe returned + * by this and the parameter recipe is that the original recipe may have lost its CustomItemRecipeChoice values. + */ + public Recipe getRegisteredRecipe(Recipe recipe) { + if(recipe instanceof Keyed key) { + return getRegisteredRecipe(key.getKey()); + } + else { + return null; + } + } +} diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/HoloItemsRevamp.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/HoloItemsRevamp.java index 7a3e3169..c383684c 100644 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/HoloItemsRevamp.java +++ b/src/main/java/xyz/holocons/mc/holoitemsrevamp/HoloItemsRevamp.java @@ -6,6 +6,8 @@ import com.strangeone101.holoitemsapi.enchantment.EnchantmentListener; import com.strangeone101.holoitemsapi.item.BlockListener; import com.strangeone101.holoitemsapi.item.CustomItemManager; +import com.strangeone101.holoitemsapi.recipe.CraftListener; +import com.strangeone101.holoitemsapi.recipe.RecipeManager; import com.strangeone101.holoitemsapi.tracking.CustomBlockStorage; import io.papermc.paper.plugin.lifecycle.event.types.LifecycleEvents; import org.bukkit.plugin.java.JavaPlugin; @@ -18,6 +20,7 @@ public final class HoloItemsRevamp extends JavaPlugin { private CollectionManager collectionManager; private CustomBlockStorage trackingManager; + private RecipeManager recipeManager; @Override public void onLoad() { @@ -27,6 +30,7 @@ public void onLoad() { this.collectionManager = new CollectionManager(this); this.trackingManager = new CustomBlockStorage(this); + this.recipeManager = new RecipeManager(this); Integrations.onLoad(); } @@ -40,7 +44,7 @@ public void onEnable() { getServer().getPluginManager().registerEvents(new EnchantmentListener(), this); getServer().getPluginManager().registerEvents(new AnvilListener(this), this); -// getServer().getPluginManager().registerEvents(new CraftListener(this), this); + getServer().getPluginManager().registerEvents(new CraftListener(this), this); getServer().getPluginManager().registerEvents(new BlockListener(this), this); // getCommand("holoitems").setExecutor(new MainCommand(this)); @@ -66,4 +70,8 @@ public CollectionManager getCollectionManager() { public CustomBlockStorage getTrackingManager() { return trackingManager; } + + public RecipeManager getRecipeManager() { + return recipeManager; + } } From 27b4f501a43ea3bd38c2c9d2b132ab896b455147 Mon Sep 17 00:00:00 2001 From: Tsumiki Miniwa <37684627+cpaca@users.noreply.github.com> Date: Sun, 21 Sep 2025 03:17:46 -0700 Subject: [PATCH 65/80] Actually register recipes --- .../strangeone101/holoitemsapi/item/CustomItemManager.java | 5 +++-- .../xyz/holocons/mc/holoitemsrevamp/HoloItemsRevamp.java | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/strangeone101/holoitemsapi/item/CustomItemManager.java b/src/main/java/com/strangeone101/holoitemsapi/item/CustomItemManager.java index bca42f6c..d4d87437 100644 --- a/src/main/java/com/strangeone101/holoitemsapi/item/CustomItemManager.java +++ b/src/main/java/com/strangeone101/holoitemsapi/item/CustomItemManager.java @@ -5,6 +5,7 @@ import java.util.Map; import java.util.Objects; +import com.strangeone101.holoitemsapi.recipe.RecipeManager; import org.bukkit.Bukkit; import org.bukkit.inventory.ItemStack; @@ -31,12 +32,12 @@ public static void register(CustomItem item) { CUSTOM_ITEMS.put(item.getInternalName(), item); } - public static void lock() { + public static void lock(RecipeManager manager) { if (!locked) { locked = true; CUSTOM_ITEMS.values().stream() .map(CustomItem::getRecipe) - .forEach(Bukkit::addRecipe); + .forEach(manager::registerRecipe); } } diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/HoloItemsRevamp.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/HoloItemsRevamp.java index c383684c..cf1e14cd 100644 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/HoloItemsRevamp.java +++ b/src/main/java/xyz/holocons/mc/holoitemsrevamp/HoloItemsRevamp.java @@ -39,7 +39,7 @@ public void onLoad() { public void onEnable() { Integrations.onEnable(); - CustomItemManager.lock(); + CustomItemManager.lock(getRecipeManager()); trackingManager.loadTrackedBlocks(); getServer().getPluginManager().registerEvents(new EnchantmentListener(), this); From e47bb54fe71718fbb6ce4955bc1b19ca9f8828c8 Mon Sep 17 00:00:00 2001 From: Tsumiki Miniwa <37684627+cpaca@users.noreply.github.com> Date: Sun, 21 Sep 2025 03:18:08 -0700 Subject: [PATCH 66/80] Null-check for recipe registration --- .../strangeone101/holoitemsapi/recipe/RecipeManager.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/strangeone101/holoitemsapi/recipe/RecipeManager.java b/src/main/java/com/strangeone101/holoitemsapi/recipe/RecipeManager.java index 33e8ddf7..fceef765 100644 --- a/src/main/java/com/strangeone101/holoitemsapi/recipe/RecipeManager.java +++ b/src/main/java/com/strangeone101/holoitemsapi/recipe/RecipeManager.java @@ -22,6 +22,9 @@ public RecipeManager(HoloItemsRevamp plugin) { * Registers a recipe in this RecipeManager. Doing this also registers the recipe using Bukkit::addRecipe */ public void registerRecipe(Recipe recipe) { + if(recipe == null) { + return; + } if(recipe instanceof Keyed keyed) { var key = keyed.getKey(); recipeMap.put(key, recipe); @@ -29,7 +32,8 @@ public void registerRecipe(Recipe recipe) { } else { // This is possible for a MerchantRecipe. - throw new IllegalArgumentException("Can't register a recipe that doesn't have a NamespacedKey."); + throw new IllegalArgumentException( + "Can't register a recipe that doesn't have a NamespacedKey. Recipe:" + recipe); } } From af362353ea8a87a8a6cf0aa17651c03517cd1c43 Mon Sep 17 00:00:00 2001 From: Tsumiki Miniwa <37684627+cpaca@users.noreply.github.com> Date: Sun, 21 Sep 2025 03:26:32 -0700 Subject: [PATCH 67/80] Fix minRow/minCol calculations --- .../holoitemsapi/recipe/CraftListener.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/strangeone101/holoitemsapi/recipe/CraftListener.java b/src/main/java/com/strangeone101/holoitemsapi/recipe/CraftListener.java index 331e6d77..7a20c7be 100644 --- a/src/main/java/com/strangeone101/holoitemsapi/recipe/CraftListener.java +++ b/src/main/java/com/strangeone101/holoitemsapi/recipe/CraftListener.java @@ -122,8 +122,19 @@ private boolean checkRecipeCustomItems(ItemStack[] contents, Recipe recipe) { if(registeredRecipe instanceof ShapedRecipe shapedRecipe) { // needed so that if a 2x2 recipe is in the bottom-right // it gets "moved" to the top-left - int minRow = customItemIndices.stream().mapToInt(i -> i/3).min().orElse(0); - int minCol = customItemIndices.stream().mapToInt(i -> i%3).min().orElse(0); + int minRow = 2; + int minCol = 2; + + for (int i = 0; i < contents.length; i++) { + var stack = contents[i]; + if(stack.isEmpty()) { + int row = i/3; + int col = i%3; + minRow = Math.min(row, minRow); + minCol = Math.min(col, minCol); + } + } + for(Integer customItemIndex : customItemIndices) { int row = (customItemIndex/3) - minRow; int col = (customItemIndex%3) - minCol; From d139ea04873eb522c74ef7cf906124116e6ee4b1 Mon Sep 17 00:00:00 2001 From: Tsumiki Miniwa <37684627+cpaca@users.noreply.github.com> Date: Sun, 21 Sep 2025 20:18:36 -0700 Subject: [PATCH 68/80] Make getRecipe protected again Apparantly I changed the privacy level when I reimplemented the recipe --- .../java/com/strangeone101/holoitemsapi/item/CustomItem.java | 2 +- .../xyz/holocons/mc/holoitemsrevamp/item/BackdashBoots.java | 2 +- .../xyz/holocons/mc/holoitemsrevamp/item/HolyFireBlock.java | 2 +- .../java/xyz/holocons/mc/holoitemsrevamp/item/MagnetBook.java | 2 +- .../java/xyz/holocons/mc/holoitemsrevamp/item/MementoItem.java | 2 +- .../java/xyz/holocons/mc/holoitemsrevamp/item/PlowBook.java | 2 +- .../xyz/holocons/mc/holoitemsrevamp/item/TideRiderItem.java | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/strangeone101/holoitemsapi/item/CustomItem.java b/src/main/java/com/strangeone101/holoitemsapi/item/CustomItem.java index 86d3fded..b42968ec 100644 --- a/src/main/java/com/strangeone101/holoitemsapi/item/CustomItem.java +++ b/src/main/java/com/strangeone101/holoitemsapi/item/CustomItem.java @@ -163,7 +163,7 @@ public ItemStack buildGuiStack(OfflinePlayer player) { * If non-null, the recipe is added to the server. * @return A recipe to add. */ - public @Nullable Recipe getRecipe() { + protected @Nullable Recipe getRecipe() { return null; } diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/BackdashBoots.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/BackdashBoots.java index 4d13857b..fbf09292 100644 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/BackdashBoots.java +++ b/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/BackdashBoots.java @@ -33,7 +33,7 @@ public BackdashBoots(HoloItemsRevamp plugin) { } @Override - public Recipe getRecipe() { + protected Recipe getRecipe() { final var recipe = new ShapedRecipe(getKey(), buildStack(null)); recipe.shape( " ", diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/HolyFireBlock.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/HolyFireBlock.java index bffdbc94..d7a6dee9 100644 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/HolyFireBlock.java +++ b/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/HolyFireBlock.java @@ -50,7 +50,7 @@ public HolyFireBlock(HoloItemsRevamp plugin) { } @Override - public Recipe getRecipe() { + protected Recipe getRecipe() { final var recipeKey = getKey(); final var outStack = buildStack(null); final var recipe = new ShapedRecipe(recipeKey, outStack); diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/MagnetBook.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/MagnetBook.java index 1f00c7e6..c48a210f 100644 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/MagnetBook.java +++ b/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/MagnetBook.java @@ -31,7 +31,7 @@ public MagnetBook(HoloItemsRevamp plugin) { } @Override - public Recipe getRecipe() { + protected Recipe getRecipe() { final var recipe = new ShapedRecipe(getKey(), buildStack(null)); recipe.shape( "AAB", diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/MementoItem.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/MementoItem.java index 3f166118..d48c0325 100644 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/MementoItem.java +++ b/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/MementoItem.java @@ -35,7 +35,7 @@ public MementoItem(HoloItemsRevamp plugin) { } @Override - public Recipe getRecipe() { + protected Recipe getRecipe() { final var recipe = new ShapedRecipe(getKey(), buildStack(null)); recipe.shape( "AAA", diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/PlowBook.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/PlowBook.java index 1ec2f209..6ae67d41 100644 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/PlowBook.java +++ b/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/PlowBook.java @@ -30,7 +30,7 @@ public PlowBook(HoloItemsRevamp plugin){ } @Override - public Recipe getRecipe() { + protected Recipe getRecipe() { ShapedRecipe recipe = new ShapedRecipe(getKey(), buildStack(null)); recipe.shape( "ABA", diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/TideRiderItem.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/TideRiderItem.java index 83edf22b..2db57620 100644 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/TideRiderItem.java +++ b/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/TideRiderItem.java @@ -32,7 +32,7 @@ public TideRiderItem(HoloItemsRevamp plugin) { } @Override - public Recipe getRecipe() { + protected Recipe getRecipe() { final var recipe = new ShapedRecipe(getKey(), buildStack(null)); recipe.shape( "ATA", From e9b37b8da453c08ee99d87f3a50e386ead4e90fe Mon Sep 17 00:00:00 2001 From: Tsumiki Miniwa <37684627+cpaca@users.noreply.github.com> Date: Sun, 21 Sep 2025 21:36:13 -0700 Subject: [PATCH 69/80] Use HoloEnchantment tag instead of namespace check --- .../holoitemsapi/recipe/CraftListener.java | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/strangeone101/holoitemsapi/recipe/CraftListener.java b/src/main/java/com/strangeone101/holoitemsapi/recipe/CraftListener.java index 7a20c7be..74103520 100644 --- a/src/main/java/com/strangeone101/holoitemsapi/recipe/CraftListener.java +++ b/src/main/java/com/strangeone101/holoitemsapi/recipe/CraftListener.java @@ -1,10 +1,14 @@ package com.strangeone101.holoitemsapi.recipe; import com.strangeone101.holoitemsapi.item.CustomItemManager; +import io.papermc.paper.registry.RegistryAccess; +import io.papermc.paper.registry.RegistryKey; +import io.papermc.paper.registry.TypedKey; +import io.papermc.paper.registry.tag.TagKey; +import io.papermc.paper.registry.tag.Tag; import org.bukkit.NamespacedKey; import org.bukkit.block.Crafter; import org.bukkit.enchantments.Enchantment; -import org.bukkit.event.Cancellable; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.block.CrafterCraftEvent; @@ -17,14 +21,22 @@ import java.util.Arrays; import java.util.List; +// For the most part, the UnstableApiUsage is coming up because of Paper's Tag<>. However, in +// 1.21.8, that goes away. Therefore, after we update, this should be removed. +@SuppressWarnings("UnstableApiUsage") public class CraftListener implements Listener { private final HoloItemsRevamp plugin; private final RecipeManager recipeManager; + private final Tag<@org.jetbrains.annotations.NotNull Enchantment> HoloEnchantmentsTag; public CraftListener(HoloItemsRevamp plugin) { this.plugin = plugin; this.recipeManager = this.plugin.getRecipeManager(); + var enchantmentRegistry = RegistryAccess.registryAccess().getRegistry(RegistryKey.ENCHANTMENT); + var enchantmentTagName = new NamespacedKey(plugin, "holoenchantments"); + var enchantmentTagKey = TagKey.create(RegistryKey.ENCHANTMENT, enchantmentTagName); + this.HoloEnchantmentsTag = enchantmentRegistry.getTag(enchantmentTagKey); } @EventHandler @@ -86,8 +98,8 @@ private boolean checkRecipeCustomItems(ItemStack[] contents, Recipe recipe) { boolean hasCustomEnchantments = stack .getEnchantments().keySet().stream() .map(Enchantment::getKey) - .map(NamespacedKey::getNamespace) - .anyMatch(s -> s.equals("holoitems")); + .map(key -> TypedKey.create(RegistryKey.ENCHANTMENT, key)) + .anyMatch(HoloEnchantmentsTag::contains); if(hasCustomEnchantments) { // There might be a use for this that isn't just "Recipe is automatically invalid" // but for now I'm leaving it like this. From dad696fd928873f202896143d3953255ab6f4c6d Mon Sep 17 00:00:00 2001 From: Tsumiki Miniwa <37684627+cpaca@users.noreply.github.com> Date: Sun, 21 Sep 2025 22:30:30 -0700 Subject: [PATCH 70/80] Explain BookLike try/catch clause --- .../holoitemsapi/enchantment/AnvilListener.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/strangeone101/holoitemsapi/enchantment/AnvilListener.java b/src/main/java/com/strangeone101/holoitemsapi/enchantment/AnvilListener.java index 5beeb73e..60742a5a 100644 --- a/src/main/java/com/strangeone101/holoitemsapi/enchantment/AnvilListener.java +++ b/src/main/java/com/strangeone101/holoitemsapi/enchantment/AnvilListener.java @@ -49,7 +49,10 @@ public void onPrepareAnvil(PrepareAnvilEvent event) { try { result.addEnchantment(ench.getKey(), ench.getValue()); } catch (IllegalArgumentException ignored) { - + // either the enchantment is null (not possible) + // or the enchantment is not applicable, so they weren't applied + // in either case, an enchantment wasn't added + continue; } addedEnch = true; } From 9f35503cbfa4bb9bc55d1e2342862134a4b50100 Mon Sep 17 00:00:00 2001 From: Tsumiki Miniwa <37684627+cpaca@users.noreply.github.com> Date: Sun, 21 Sep 2025 23:42:06 -0700 Subject: [PATCH 71/80] Fix tag lookup --- .../tags/enchantment/{holoenchantments => holoenchantments.json} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename holoitems_datapack/data/holoitems/tags/enchantment/{holoenchantments => holoenchantments.json} (100%) diff --git a/holoitems_datapack/data/holoitems/tags/enchantment/holoenchantments b/holoitems_datapack/data/holoitems/tags/enchantment/holoenchantments.json similarity index 100% rename from holoitems_datapack/data/holoitems/tags/enchantment/holoenchantments rename to holoitems_datapack/data/holoitems/tags/enchantment/holoenchantments.json From 4bac8d7043bec6e534ca8513d12b7fc53fbe5393 Mon Sep 17 00:00:00 2001 From: Tsumiki Miniwa <37684627+cpaca@users.noreply.github.com> Date: Sun, 21 Sep 2025 23:48:04 -0700 Subject: [PATCH 72/80] Move enchantment tag checks to a manager Idea: What if we deleted the CustomEnchantment class? --- .../enchantment/EnchantManager.java | 33 +++++++++++++++++++ .../holoitemsapi/recipe/CraftListener.java | 16 +++------ .../mc/holoitemsrevamp/HoloItemsRevamp.java | 7 ++++ 3 files changed, 44 insertions(+), 12 deletions(-) create mode 100644 src/main/java/com/strangeone101/holoitemsapi/enchantment/EnchantManager.java diff --git a/src/main/java/com/strangeone101/holoitemsapi/enchantment/EnchantManager.java b/src/main/java/com/strangeone101/holoitemsapi/enchantment/EnchantManager.java new file mode 100644 index 00000000..cccfc524 --- /dev/null +++ b/src/main/java/com/strangeone101/holoitemsapi/enchantment/EnchantManager.java @@ -0,0 +1,33 @@ +package com.strangeone101.holoitemsapi.enchantment; + +import io.papermc.paper.registry.RegistryAccess; +import io.papermc.paper.registry.RegistryKey; +import io.papermc.paper.registry.TypedKey; +import io.papermc.paper.registry.tag.Tag; +import io.papermc.paper.registry.tag.TagKey; +import org.bukkit.NamespacedKey; +import org.bukkit.enchantments.Enchantment; +import org.jetbrains.annotations.NotNull; +import xyz.holocons.mc.holoitemsrevamp.HoloItemsRevamp; + +// For the most part, the UnstableApiUsage is coming up because of Paper's Tag<>. However, in +// 1.21.8, that goes away. Therefore, after we update, this should be removed. +@SuppressWarnings("UnstableApiUsage") +public class EnchantManager { + + private final HoloItemsRevamp plugin; + private final Tag<@NotNull Enchantment> HoloEnchantmentsTag; + + public EnchantManager(HoloItemsRevamp plugin) { + this.plugin = plugin; + var enchantmentRegistry = RegistryAccess.registryAccess().getRegistry(RegistryKey.ENCHANTMENT); + var enchantmentTagName = new NamespacedKey(plugin, "holoenchantments"); + var enchantmentTagKey = TagKey.create(RegistryKey.ENCHANTMENT, enchantmentTagName); + this.HoloEnchantmentsTag = enchantmentRegistry.getTag(enchantmentTagKey); + } + + public boolean isTaggedHoloEnchantment(Enchantment enchantment) { + var typedEnchantmentKey = TypedKey.create(RegistryKey.ENCHANTMENT, enchantment.getKey()); + return HoloEnchantmentsTag.contains(typedEnchantmentKey); + } +} diff --git a/src/main/java/com/strangeone101/holoitemsapi/recipe/CraftListener.java b/src/main/java/com/strangeone101/holoitemsapi/recipe/CraftListener.java index 74103520..ca681278 100644 --- a/src/main/java/com/strangeone101/holoitemsapi/recipe/CraftListener.java +++ b/src/main/java/com/strangeone101/holoitemsapi/recipe/CraftListener.java @@ -1,5 +1,6 @@ package com.strangeone101.holoitemsapi.recipe; +import com.strangeone101.holoitemsapi.enchantment.EnchantManager; import com.strangeone101.holoitemsapi.item.CustomItemManager; import io.papermc.paper.registry.RegistryAccess; import io.papermc.paper.registry.RegistryKey; @@ -21,22 +22,16 @@ import java.util.Arrays; import java.util.List; -// For the most part, the UnstableApiUsage is coming up because of Paper's Tag<>. However, in -// 1.21.8, that goes away. Therefore, after we update, this should be removed. -@SuppressWarnings("UnstableApiUsage") public class CraftListener implements Listener { private final HoloItemsRevamp plugin; private final RecipeManager recipeManager; - private final Tag<@org.jetbrains.annotations.NotNull Enchantment> HoloEnchantmentsTag; + private final EnchantManager enchantManager; public CraftListener(HoloItemsRevamp plugin) { this.plugin = plugin; this.recipeManager = this.plugin.getRecipeManager(); - var enchantmentRegistry = RegistryAccess.registryAccess().getRegistry(RegistryKey.ENCHANTMENT); - var enchantmentTagName = new NamespacedKey(plugin, "holoenchantments"); - var enchantmentTagKey = TagKey.create(RegistryKey.ENCHANTMENT, enchantmentTagName); - this.HoloEnchantmentsTag = enchantmentRegistry.getTag(enchantmentTagKey); + this.enchantManager = this.plugin.getEnchantManager(); } @EventHandler @@ -96,10 +91,7 @@ private boolean checkRecipeCustomItems(ItemStack[] contents, Recipe recipe) { // ... Depending on SandPortal's implementation, this might be relevant? // Mostly for stopping people from making sandstone blocks with them. boolean hasCustomEnchantments = stack - .getEnchantments().keySet().stream() - .map(Enchantment::getKey) - .map(key -> TypedKey.create(RegistryKey.ENCHANTMENT, key)) - .anyMatch(HoloEnchantmentsTag::contains); + .getEnchantments().keySet().stream().anyMatch(enchantManager::isTaggedHoloEnchantment); if(hasCustomEnchantments) { // There might be a use for this that isn't just "Recipe is automatically invalid" // but for now I'm leaving it like this. diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/HoloItemsRevamp.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/HoloItemsRevamp.java index cf1e14cd..5fd56419 100644 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/HoloItemsRevamp.java +++ b/src/main/java/xyz/holocons/mc/holoitemsrevamp/HoloItemsRevamp.java @@ -3,6 +3,7 @@ import com.strangeone101.holoitemsapi.Keys; import com.strangeone101.holoitemsapi.enchantment.AnvilListener; import com.strangeone101.holoitemsapi.enchantment.CustomEnchantment; +import com.strangeone101.holoitemsapi.enchantment.EnchantManager; import com.strangeone101.holoitemsapi.enchantment.EnchantmentListener; import com.strangeone101.holoitemsapi.item.BlockListener; import com.strangeone101.holoitemsapi.item.CustomItemManager; @@ -21,6 +22,7 @@ public final class HoloItemsRevamp extends JavaPlugin { private CollectionManager collectionManager; private CustomBlockStorage trackingManager; private RecipeManager recipeManager; + private EnchantManager enchantManager; @Override public void onLoad() { @@ -28,6 +30,7 @@ public void onLoad() { CustomEnchantment.loadCustomEnchantments(this); + this.enchantManager = new EnchantManager(this); this.collectionManager = new CollectionManager(this); this.trackingManager = new CustomBlockStorage(this); this.recipeManager = new RecipeManager(this); @@ -74,4 +77,8 @@ public CustomBlockStorage getTrackingManager() { public RecipeManager getRecipeManager() { return recipeManager; } + + public EnchantManager getEnchantManager() { + return enchantManager; + } } From d45486fc2ada5dcdc61e0d9140cf7a8ea944ad89 Mon Sep 17 00:00:00 2001 From: Tsumiki Miniwa <37684627+cpaca@users.noreply.github.com> Date: Mon, 22 Sep 2025 03:37:27 -0700 Subject: [PATCH 73/80] Remove CustomEnchantment --- .../enchantment/CustomEnchantment.java | 59 ------------------- .../enchantment/EnchantManager.java | 37 ++++++++++++ .../enchantment/EnchantmentListener.java | 13 +++- .../mc/holoitemsrevamp/HoloItemsRevamp.java | 5 +- .../holoitemsrevamp/enchantment/Backdash.java | 17 +++--- .../holoitemsrevamp/enchantment/Magnet.java | 15 +++-- .../holoitemsrevamp/enchantment/Memento.java | 18 +++--- .../mc/holoitemsrevamp/enchantment/Plow.java | 18 +++--- .../enchantment/TideRider.java | 14 ++--- .../integration/WorldGuardHook.java | 12 ++-- .../mc/holoitemsrevamp/item/MagnetBook.java | 2 - .../mc/holoitemsrevamp/item/MementoItem.java | 2 - .../mc/holoitemsrevamp/item/PlowBook.java | 2 - .../holoitemsrevamp/item/TideRiderItem.java | 3 - 14 files changed, 98 insertions(+), 119 deletions(-) delete mode 100644 src/main/java/com/strangeone101/holoitemsapi/enchantment/CustomEnchantment.java diff --git a/src/main/java/com/strangeone101/holoitemsapi/enchantment/CustomEnchantment.java b/src/main/java/com/strangeone101/holoitemsapi/enchantment/CustomEnchantment.java deleted file mode 100644 index dd83691e..00000000 --- a/src/main/java/com/strangeone101/holoitemsapi/enchantment/CustomEnchantment.java +++ /dev/null @@ -1,59 +0,0 @@ -package com.strangeone101.holoitemsapi.enchantment; - -import net.kyori.adventure.text.Component; - -import org.bukkit.NamespacedKey; -import org.bukkit.plugin.Plugin; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import xyz.holocons.mc.holoitemsrevamp.HoloItemsRevamp; -import xyz.holocons.mc.holoitemsrevamp.enchantment.*; - -import java.util.HashMap; -import java.util.Set; - -public abstract class CustomEnchantment implements EnchantmentAbility { - - private static final HashMap enchantmentsByKey = new HashMap<>(); - - protected final NamespacedKey key; - - public CustomEnchantment(Plugin plugin, String key) { - // namespace is "holoitems" - this.key = new NamespacedKey(plugin, key); - } - - @Override - public @NotNull NamespacedKey getKey() { - return this.key; - } - - /** - * Gets the CustomEnchantment at the specified key. - * @param key The NamespacedKey of the enchantment to fetch - * @return Resulting CustomEnchantment, or null if not found - */ - @Nullable - public static final CustomEnchantment getByKey(@Nullable NamespacedKey key) { - return enchantmentsByKey.get(key); - } - - public static final void loadCustomEnchantments(HoloItemsRevamp plugin) { - Set enchantments = Set.of( - new Magnet(plugin), - new Memento(plugin), - new TideRider(plugin), - new Backdash(plugin), - new Plow(plugin) - ); - - for(var ench : enchantments) { - if(enchantmentsByKey.containsKey(ench.key)){ - throw new RuntimeException("Duplicate CustomEnchantment defined for namespacedKey " + ench.key); - } - else { - enchantmentsByKey.put(ench.key, ench); - } - } - } -} diff --git a/src/main/java/com/strangeone101/holoitemsapi/enchantment/EnchantManager.java b/src/main/java/com/strangeone101/holoitemsapi/enchantment/EnchantManager.java index cccfc524..7a239e11 100644 --- a/src/main/java/com/strangeone101/holoitemsapi/enchantment/EnchantManager.java +++ b/src/main/java/com/strangeone101/holoitemsapi/enchantment/EnchantManager.java @@ -8,7 +8,12 @@ import org.bukkit.NamespacedKey; import org.bukkit.enchantments.Enchantment; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import xyz.holocons.mc.holoitemsrevamp.HoloItemsRevamp; +import xyz.holocons.mc.holoitemsrevamp.enchantment.*; + +import java.util.HashMap; +import java.util.Set; // For the most part, the UnstableApiUsage is coming up because of Paper's Tag<>. However, in // 1.21.8, that goes away. Therefore, after we update, this should be removed. @@ -17,6 +22,7 @@ public class EnchantManager { private final HoloItemsRevamp plugin; private final Tag<@NotNull Enchantment> HoloEnchantmentsTag; + private final HashMap enchantmentsByKey = new HashMap<>(); public EnchantManager(HoloItemsRevamp plugin) { this.plugin = plugin; @@ -24,10 +30,41 @@ public EnchantManager(HoloItemsRevamp plugin) { var enchantmentTagName = new NamespacedKey(plugin, "holoenchantments"); var enchantmentTagKey = TagKey.create(RegistryKey.ENCHANTMENT, enchantmentTagName); this.HoloEnchantmentsTag = enchantmentRegistry.getTag(enchantmentTagKey); + + this.loadCustomEnchantments(); } public boolean isTaggedHoloEnchantment(Enchantment enchantment) { var typedEnchantmentKey = TypedKey.create(RegistryKey.ENCHANTMENT, enchantment.getKey()); return HoloEnchantmentsTag.contains(typedEnchantmentKey); } + + /** + * Gets the CustomEnchantment at the specified key. + * @param key The NamespacedKey of the enchantment to fetch + * @return Resulting CustomEnchantment, or null if not found + */ + @Nullable + public EnchantmentAbility getByKey(@Nullable NamespacedKey key) { + return enchantmentsByKey.get(key); + } + + private void loadCustomEnchantments() { + Set enchantments = Set.of( + new Magnet(plugin), + new Memento(plugin), + new TideRider(plugin), + new Backdash(plugin), + new Plow(plugin) + ); + + for(var ench : enchantments) { + if(enchantmentsByKey.containsKey(ench.getKey())){ + throw new RuntimeException("Duplicate CustomEnchantment defined for namespacedKey " + ench.getKey()); + } + else { + enchantmentsByKey.put(ench.getKey(), ench); + } + } + } } diff --git a/src/main/java/com/strangeone101/holoitemsapi/enchantment/EnchantmentListener.java b/src/main/java/com/strangeone101/holoitemsapi/enchantment/EnchantmentListener.java index 968adf89..20bb47ad 100644 --- a/src/main/java/com/strangeone101/holoitemsapi/enchantment/EnchantmentListener.java +++ b/src/main/java/com/strangeone101/holoitemsapi/enchantment/EnchantmentListener.java @@ -14,14 +14,23 @@ import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerToggleSneakEvent; import org.bukkit.inventory.ItemStack; +import xyz.holocons.mc.holoitemsrevamp.HoloItemsRevamp; public class EnchantmentListener implements Listener { - private static void forEachEnchantment(final ItemStack itemStack, + private HoloItemsRevamp plugin; + private EnchantManager manager; + + public EnchantmentListener(HoloItemsRevamp plugin) { + this.plugin = plugin; + this.manager = this.plugin.getEnchantManager(); + } + + private void forEachEnchantment(final ItemStack itemStack, final Consumer action) { itemStack.getEnchantments().keySet().forEach(enchantment -> { NamespacedKey enchKey = enchantment.getKey(); - var ench = CustomEnchantment.getByKey(enchKey); + var ench = manager.getByKey(enchKey); if(ench != null) { action.accept(ench); } diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/HoloItemsRevamp.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/HoloItemsRevamp.java index 5fd56419..ca7e1e79 100644 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/HoloItemsRevamp.java +++ b/src/main/java/xyz/holocons/mc/holoitemsrevamp/HoloItemsRevamp.java @@ -2,7 +2,6 @@ import com.strangeone101.holoitemsapi.Keys; import com.strangeone101.holoitemsapi.enchantment.AnvilListener; -import com.strangeone101.holoitemsapi.enchantment.CustomEnchantment; import com.strangeone101.holoitemsapi.enchantment.EnchantManager; import com.strangeone101.holoitemsapi.enchantment.EnchantmentListener; import com.strangeone101.holoitemsapi.item.BlockListener; @@ -28,8 +27,6 @@ public final class HoloItemsRevamp extends JavaPlugin { public void onLoad() { Keys.fillKeys(this); - CustomEnchantment.loadCustomEnchantments(this); - this.enchantManager = new EnchantManager(this); this.collectionManager = new CollectionManager(this); this.trackingManager = new CustomBlockStorage(this); @@ -45,7 +42,7 @@ public void onEnable() { CustomItemManager.lock(getRecipeManager()); trackingManager.loadTrackedBlocks(); - getServer().getPluginManager().registerEvents(new EnchantmentListener(), this); + getServer().getPluginManager().registerEvents(new EnchantmentListener(this), this); getServer().getPluginManager().registerEvents(new AnvilListener(this), this); getServer().getPluginManager().registerEvents(new CraftListener(this), this); getServer().getPluginManager().registerEvents(new BlockListener(this), this); diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/Backdash.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/Backdash.java index b85fb2ab..a11e5661 100644 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/Backdash.java +++ b/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/Backdash.java @@ -1,25 +1,26 @@ package xyz.holocons.mc.holoitemsrevamp.enchantment; import org.bukkit.NamespacedKey; -import org.bukkit.enchantments.Enchantment; -import org.bukkit.enchantments.EnchantmentTarget; import org.bukkit.event.player.PlayerToggleSneakEvent; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; -import com.strangeone101.holoitemsapi.enchantment.CustomEnchantment; import com.strangeone101.holoitemsapi.enchantment.EnchantmentAbility; -import net.kyori.adventure.text.Component; -import net.kyori.adventure.text.format.NamedTextColor; -import net.kyori.adventure.text.format.TextDecoration; import xyz.holocons.mc.holoitemsrevamp.HoloItemsRevamp; import xyz.holocons.mc.holoitemsrevamp.integration.Integrations; -public class Backdash extends CustomEnchantment { +public class Backdash implements EnchantmentAbility { + + private final HoloItemsRevamp plugin; public Backdash(HoloItemsRevamp plugin) { - super(plugin, "backdash"); + this.plugin = plugin; + } + + @Override + public @NotNull NamespacedKey getKey() { + return new NamespacedKey(plugin, "backdash"); } @Override diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/Magnet.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/Magnet.java index 293160a7..6b0bb42d 100644 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/Magnet.java +++ b/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/Magnet.java @@ -1,31 +1,30 @@ package xyz.holocons.mc.holoitemsrevamp.enchantment; -import org.bukkit.enchantments.Enchantment; -import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.NamespacedKey; import org.bukkit.entity.Item; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.scheduler.BukkitRunnable; import org.jetbrains.annotations.NotNull; -import com.strangeone101.holoitemsapi.enchantment.CustomEnchantment; import com.strangeone101.holoitemsapi.enchantment.EnchantmentAbility; -import net.kyori.adventure.text.Component; -import net.kyori.adventure.text.format.NamedTextColor; -import net.kyori.adventure.text.format.TextDecoration; import xyz.holocons.mc.holoitemsrevamp.HoloItemsRevamp; import xyz.holocons.mc.holoitemsrevamp.integration.Integrations; -public class Magnet extends CustomEnchantment { +public class Magnet implements EnchantmentAbility { private final HoloItemsRevamp plugin; public Magnet(HoloItemsRevamp plugin) { - super(plugin, "magnet"); this.plugin = plugin; } + @Override + public @NotNull NamespacedKey getKey() { + return new NamespacedKey(plugin, "magnet"); + } + @Override public void onBlockBreak(BlockBreakEvent event, ItemStack itemStack) { final var location = event.getBlock().getLocation().toCenterLocation(); diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/Memento.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/Memento.java index 1fe05257..c19af899 100644 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/Memento.java +++ b/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/Memento.java @@ -1,25 +1,27 @@ package xyz.holocons.mc.holoitemsrevamp.enchantment; -import org.bukkit.Material; -import org.bukkit.enchantments.Enchantment; +import org.bukkit.NamespacedKey; import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; -import com.strangeone101.holoitemsapi.enchantment.CustomEnchantment; import com.strangeone101.holoitemsapi.enchantment.EnchantmentAbility; -import net.kyori.adventure.text.Component; -import net.kyori.adventure.text.format.NamedTextColor; -import net.kyori.adventure.text.format.TextDecoration; import xyz.holocons.mc.holoitemsrevamp.HoloItemsRevamp; import xyz.holocons.mc.holoitemsrevamp.integration.Integrations; -public class Memento extends CustomEnchantment { +public class Memento implements EnchantmentAbility { + + private final HoloItemsRevamp plugin; public Memento(HoloItemsRevamp plugin) { - super(plugin, "memento"); + this.plugin = plugin; + } + + @Override + public @NotNull NamespacedKey getKey() { + return new NamespacedKey(plugin, "memento"); } @Override diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/Plow.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/Plow.java index 70047e7e..50509933 100644 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/Plow.java +++ b/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/Plow.java @@ -1,29 +1,31 @@ package xyz.holocons.mc.holoitemsrevamp.enchantment; import org.bukkit.Material; -import org.bukkit.enchantments.Enchantment; +import org.bukkit.NamespacedKey; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; -import com.destroystokyo.paper.MaterialTags; -import com.strangeone101.holoitemsapi.enchantment.CustomEnchantment; import com.strangeone101.holoitemsapi.enchantment.EnchantmentAbility; -import net.kyori.adventure.text.Component; -import net.kyori.adventure.text.format.NamedTextColor; -import net.kyori.adventure.text.format.TextDecoration; import xyz.holocons.mc.holoitemsrevamp.HoloItemsRevamp; import xyz.holocons.mc.holoitemsrevamp.util.EntityExpiringSet; import xyz.holocons.mc.holoitemsrevamp.util.ExpiringSet; -public class Plow extends CustomEnchantment { +public class Plow implements EnchantmentAbility { + + private final HoloItemsRevamp plugin; private final EntityExpiringSet plowMarker = new EntityExpiringSet( new ExpiringSet.ConstantTicksToLiveExpirationPolicy<>(20)); public Plow(HoloItemsRevamp plugin) { - super(plugin, "plow"); + this.plugin = plugin; + } + + @Override + public @NotNull NamespacedKey getKey() { + return new NamespacedKey(plugin, "plow"); } @Override diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/TideRider.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/TideRider.java index cb19363b..708e7503 100644 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/TideRider.java +++ b/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/TideRider.java @@ -1,11 +1,11 @@ package xyz.holocons.mc.holoitemsrevamp.enchantment; import org.bukkit.Material; +import org.bukkit.NamespacedKey; import org.bukkit.Particle; import org.bukkit.Sound; import org.bukkit.block.BlockFace; import org.bukkit.enchantments.Enchantment; -import org.bukkit.enchantments.EnchantmentTarget; import org.bukkit.event.entity.ProjectileLaunchEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.ItemStack; @@ -14,24 +14,24 @@ import org.bukkit.scheduler.BukkitRunnable; import org.jetbrains.annotations.NotNull; -import com.strangeone101.holoitemsapi.enchantment.CustomEnchantment; import com.strangeone101.holoitemsapi.enchantment.EnchantmentAbility; -import net.kyori.adventure.text.Component; -import net.kyori.adventure.text.format.NamedTextColor; -import net.kyori.adventure.text.format.TextDecoration; import xyz.holocons.mc.holoitemsrevamp.HoloItemsRevamp; import xyz.holocons.mc.holoitemsrevamp.integration.Integrations; -public class TideRider extends CustomEnchantment { +public class TideRider implements EnchantmentAbility { private final HoloItemsRevamp plugin; public TideRider(HoloItemsRevamp plugin) { - super(plugin, "tide_rider"); this.plugin = plugin; } + @Override + public @NotNull NamespacedKey getKey() { + return new NamespacedKey(plugin, "tide_rider"); + } + @Override public void onPlayerInteract(PlayerInteractEvent event, ItemStack itemStack) { final var player = event.getPlayer(); diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/integration/WorldGuardHook.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/integration/WorldGuardHook.java index 14713f1e..55c763cc 100644 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/integration/WorldGuardHook.java +++ b/src/main/java/xyz/holocons/mc/holoitemsrevamp/integration/WorldGuardHook.java @@ -3,6 +3,7 @@ import java.util.HashMap; import java.util.Map; +import com.strangeone101.holoitemsapi.enchantment.EnchantmentAbility; import org.bukkit.Location; import com.sk89q.worldedit.bukkit.BukkitAdapter; @@ -10,14 +11,13 @@ import com.sk89q.worldguard.protection.flags.Flag; import com.sk89q.worldguard.protection.flags.StateFlag; import com.sk89q.worldguard.protection.regions.RegionContainer; -import com.strangeone101.holoitemsapi.enchantment.CustomEnchantment; public interface WorldGuardHook extends Hook { - default void registerEnchantment(CustomEnchantment enchantment) { + default void registerEnchantment(EnchantmentAbility enchantment) { } - default boolean canUseEnchantment(Location location, Class enchantmentCls) { + default boolean canUseEnchantment(Location location, Class enchantmentCls) { return true; } @@ -26,7 +26,7 @@ public class Stub implements WorldGuardHook { public class Integration implements WorldGuardHook { - public static final Map, Flag> ENCHANTMENT_FLAGS = new HashMap<>(); + public static final Map, Flag> ENCHANTMENT_FLAGS = new HashMap<>(); private boolean loaded = false; private RegionContainer regionContainer = null; @@ -46,7 +46,7 @@ public void onEnable() { } @Override - public void registerEnchantment(CustomEnchantment enchantment) { + public void registerEnchantment(EnchantmentAbility enchantment) { if (loaded) { throw new IllegalStateException("New enchantments cannot be registered at this time"); } @@ -55,7 +55,7 @@ public void registerEnchantment(CustomEnchantment enchantment) { } @Override - public boolean canUseEnchantment(Location location, Class enchantmentCls) { + public boolean canUseEnchantment(Location location, Class enchantmentCls) { final var flag = ENCHANTMENT_FLAGS.get(enchantmentCls); final var value = regionContainer.createQuery().queryValue(BukkitAdapter.adapt(location), null, flag); return value != StateFlag.State.DENY; diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/MagnetBook.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/MagnetBook.java index c48a210f..e9930254 100644 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/MagnetBook.java +++ b/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/MagnetBook.java @@ -1,13 +1,11 @@ package xyz.holocons.mc.holoitemsrevamp.item; -import com.strangeone101.holoitemsapi.enchantment.CustomEnchantment; import com.strangeone101.holoitemsapi.enchantment.Enchantable; import com.strangeone101.holoitemsapi.item.CustomItem; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; import org.bukkit.Material; import org.bukkit.NamespacedKey; -import org.bukkit.enchantments.Enchantment; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.Recipe; import org.bukkit.inventory.ShapedRecipe; diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/MementoItem.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/MementoItem.java index d48c0325..de7119ee 100644 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/MementoItem.java +++ b/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/MementoItem.java @@ -5,12 +5,10 @@ import org.bukkit.Bukkit; import org.bukkit.Material; -import org.bukkit.enchantments.Enchantment; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.Recipe; import org.bukkit.inventory.ShapedRecipe; -import com.strangeone101.holoitemsapi.enchantment.CustomEnchantment; import com.strangeone101.holoitemsapi.enchantment.Enchantable; import com.strangeone101.holoitemsapi.item.CustomItem; diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/PlowBook.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/PlowBook.java index 6ae67d41..56e52879 100644 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/PlowBook.java +++ b/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/PlowBook.java @@ -1,13 +1,11 @@ package xyz.holocons.mc.holoitemsrevamp.item; -import com.strangeone101.holoitemsapi.enchantment.CustomEnchantment; import com.strangeone101.holoitemsapi.enchantment.Enchantable; import com.strangeone101.holoitemsapi.item.CustomItem; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; import org.bukkit.Material; import org.bukkit.NamespacedKey; -import org.bukkit.enchantments.Enchantment; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.Recipe; import org.bukkit.inventory.ShapedRecipe; diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/TideRiderItem.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/TideRiderItem.java index 2db57620..c51fff70 100644 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/TideRiderItem.java +++ b/src/main/java/xyz/holocons/mc/holoitemsrevamp/item/TideRiderItem.java @@ -1,6 +1,5 @@ package xyz.holocons.mc.holoitemsrevamp.item; -import com.strangeone101.holoitemsapi.enchantment.CustomEnchantment; import com.strangeone101.holoitemsapi.enchantment.Enchantable; import com.strangeone101.holoitemsapi.item.CustomItem; import net.kyori.adventure.text.Component; @@ -8,11 +7,9 @@ import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.NamespacedKey; -import org.bukkit.enchantments.Enchantment; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.Recipe; import org.bukkit.inventory.ShapedRecipe; -import org.jetbrains.annotations.NotNull; import xyz.holocons.mc.holoitemsrevamp.HoloItemsRevamp; import java.util.List; From f27cec1ab8898b56fbef79f5b1e92a7a084e495e Mon Sep 17 00:00:00 2001 From: Tsumiki Miniwa <37684627+cpaca@users.noreply.github.com> Date: Mon, 22 Sep 2025 03:40:19 -0700 Subject: [PATCH 74/80] Suppress UnstableApiUsage for lifecycle API --- .../java/xyz/holocons/mc/holoitemsrevamp/HoloItemsRevamp.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/HoloItemsRevamp.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/HoloItemsRevamp.java index ca7e1e79..83415d12 100644 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/HoloItemsRevamp.java +++ b/src/main/java/xyz/holocons/mc/holoitemsrevamp/HoloItemsRevamp.java @@ -35,6 +35,9 @@ public void onLoad() { Integrations.onLoad(); } + // This is for the (numerous) Lifecycle functions, which are all marked Experimental in 1.21.1, but + // are no longer marked as such in later versions. + @SuppressWarnings("UnstableApiUsage") @Override public void onEnable() { Integrations.onEnable(); From 8faa0b8f7415abbbe4c74946037d15b4744e8f34 Mon Sep 17 00:00:00 2001 From: Tsumiki Miniwa <37684627+cpaca@users.noreply.github.com> Date: Mon, 22 Sep 2025 04:00:42 -0700 Subject: [PATCH 75/80] Make EnchantmentAbility not Keyed --- .../enchantment/EnchantManager.java | 32 ++++++++----------- .../enchantment/EnchantmentAbility.java | 2 +- .../holoitemsrevamp/enchantment/Backdash.java | 5 --- .../holoitemsrevamp/enchantment/Magnet.java | 5 --- .../holoitemsrevamp/enchantment/Memento.java | 5 --- .../mc/holoitemsrevamp/enchantment/Plow.java | 5 --- .../enchantment/TideRider.java | 5 --- .../integration/WorldGuardHook.java | 7 ++-- 8 files changed, 18 insertions(+), 48 deletions(-) diff --git a/src/main/java/com/strangeone101/holoitemsapi/enchantment/EnchantManager.java b/src/main/java/com/strangeone101/holoitemsapi/enchantment/EnchantManager.java index 7a239e11..5ccd52eb 100644 --- a/src/main/java/com/strangeone101/holoitemsapi/enchantment/EnchantManager.java +++ b/src/main/java/com/strangeone101/holoitemsapi/enchantment/EnchantManager.java @@ -12,8 +12,7 @@ import xyz.holocons.mc.holoitemsrevamp.HoloItemsRevamp; import xyz.holocons.mc.holoitemsrevamp.enchantment.*; -import java.util.HashMap; -import java.util.Set; +import java.util.Map; // For the most part, the UnstableApiUsage is coming up because of Paper's Tag<>. However, in // 1.21.8, that goes away. Therefore, after we update, this should be removed. @@ -22,7 +21,7 @@ public class EnchantManager { private final HoloItemsRevamp plugin; private final Tag<@NotNull Enchantment> HoloEnchantmentsTag; - private final HashMap enchantmentsByKey = new HashMap<>(); + private final Map enchantmentsByKey; public EnchantManager(HoloItemsRevamp plugin) { this.plugin = plugin; @@ -31,7 +30,7 @@ public EnchantManager(HoloItemsRevamp plugin) { var enchantmentTagKey = TagKey.create(RegistryKey.ENCHANTMENT, enchantmentTagName); this.HoloEnchantmentsTag = enchantmentRegistry.getTag(enchantmentTagKey); - this.loadCustomEnchantments(); + this.enchantmentsByKey = this.loadCustomEnchantments(); } public boolean isTaggedHoloEnchantment(Enchantment enchantment) { @@ -49,22 +48,17 @@ public EnchantmentAbility getByKey(@Nullable NamespacedKey key) { return enchantmentsByKey.get(key); } - private void loadCustomEnchantments() { - Set enchantments = Set.of( - new Magnet(plugin), - new Memento(plugin), - new TideRider(plugin), - new Backdash(plugin), - new Plow(plugin) + private Map loadCustomEnchantments() { + return Map.ofEntries( + Map.entry(createEnchKey("magnet"), new Magnet(plugin)), + Map.entry(createEnchKey("memento"), new Memento(plugin)), + Map.entry(createEnchKey("tide_rider"), new TideRider(plugin)), + Map.entry(createEnchKey("backdash"), new Backdash(plugin)), + Map.entry(createEnchKey("plow"), new Plow(plugin)) ); + } - for(var ench : enchantments) { - if(enchantmentsByKey.containsKey(ench.getKey())){ - throw new RuntimeException("Duplicate CustomEnchantment defined for namespacedKey " + ench.getKey()); - } - else { - enchantmentsByKey.put(ench.getKey(), ench); - } - } + private NamespacedKey createEnchKey(String name) { + return new NamespacedKey(plugin, name); } } diff --git a/src/main/java/com/strangeone101/holoitemsapi/enchantment/EnchantmentAbility.java b/src/main/java/com/strangeone101/holoitemsapi/enchantment/EnchantmentAbility.java index fcc8beb5..9a01c528 100644 --- a/src/main/java/com/strangeone101/holoitemsapi/enchantment/EnchantmentAbility.java +++ b/src/main/java/com/strangeone101/holoitemsapi/enchantment/EnchantmentAbility.java @@ -9,7 +9,7 @@ import org.bukkit.event.player.PlayerToggleSneakEvent; import org.bukkit.inventory.ItemStack; -public interface EnchantmentAbility extends Keyed { +public interface EnchantmentAbility { default void onBlockBreak(BlockBreakEvent event, ItemStack itemStack) { } diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/Backdash.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/Backdash.java index a11e5661..056cda7f 100644 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/Backdash.java +++ b/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/Backdash.java @@ -18,11 +18,6 @@ public Backdash(HoloItemsRevamp plugin) { this.plugin = plugin; } - @Override - public @NotNull NamespacedKey getKey() { - return new NamespacedKey(plugin, "backdash"); - } - @Override public void onPlayerToggleSneak(PlayerToggleSneakEvent event, ItemStack itemStack) { if (!event.isSneaking() diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/Magnet.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/Magnet.java index 6b0bb42d..8c76a7fc 100644 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/Magnet.java +++ b/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/Magnet.java @@ -20,11 +20,6 @@ public Magnet(HoloItemsRevamp plugin) { this.plugin = plugin; } - @Override - public @NotNull NamespacedKey getKey() { - return new NamespacedKey(plugin, "magnet"); - } - @Override public void onBlockBreak(BlockBreakEvent event, ItemStack itemStack) { final var location = event.getBlock().getLocation().toCenterLocation(); diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/Memento.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/Memento.java index c19af899..82eff90e 100644 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/Memento.java +++ b/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/Memento.java @@ -19,11 +19,6 @@ public Memento(HoloItemsRevamp plugin) { this.plugin = plugin; } - @Override - public @NotNull NamespacedKey getKey() { - return new NamespacedKey(plugin, "memento"); - } - @Override public void onPlayerDeath(PlayerDeathEvent event, ItemStack itemStack) { final var location = event.getPlayer().getLocation(); diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/Plow.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/Plow.java index 50509933..fc4b4fd9 100644 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/Plow.java +++ b/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/Plow.java @@ -23,11 +23,6 @@ public Plow(HoloItemsRevamp plugin) { this.plugin = plugin; } - @Override - public @NotNull NamespacedKey getKey() { - return new NamespacedKey(plugin, "plow"); - } - @Override public void onBlockBreak(BlockBreakEvent event, ItemStack itemStack) { final var player = event.getPlayer(); diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/TideRider.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/TideRider.java index 708e7503..2bed6037 100644 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/TideRider.java +++ b/src/main/java/xyz/holocons/mc/holoitemsrevamp/enchantment/TideRider.java @@ -27,11 +27,6 @@ public TideRider(HoloItemsRevamp plugin) { this.plugin = plugin; } - @Override - public @NotNull NamespacedKey getKey() { - return new NamespacedKey(plugin, "tide_rider"); - } - @Override public void onPlayerInteract(PlayerInteractEvent event, ItemStack itemStack) { final var player = event.getPlayer(); diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/integration/WorldGuardHook.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/integration/WorldGuardHook.java index 55c763cc..83dd62ec 100644 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/integration/WorldGuardHook.java +++ b/src/main/java/xyz/holocons/mc/holoitemsrevamp/integration/WorldGuardHook.java @@ -11,10 +11,11 @@ import com.sk89q.worldguard.protection.flags.Flag; import com.sk89q.worldguard.protection.flags.StateFlag; import com.sk89q.worldguard.protection.regions.RegionContainer; +import org.bukkit.NamespacedKey; public interface WorldGuardHook extends Hook { - default void registerEnchantment(EnchantmentAbility enchantment) { + default void registerEnchantment(NamespacedKey enchKey, EnchantmentAbility enchantment) { } default boolean canUseEnchantment(Location location, Class enchantmentCls) { @@ -46,11 +47,11 @@ public void onEnable() { } @Override - public void registerEnchantment(EnchantmentAbility enchantment) { + public void registerEnchantment(NamespacedKey enchKey, EnchantmentAbility enchantment) { if (loaded) { throw new IllegalStateException("New enchantments cannot be registered at this time"); } - final var name = "holoitems-" + enchantment.getKey().getKey().replace('_', '-'); + final var name = "holoitems-" + enchKey.getKey().replace('_', '-'); ENCHANTMENT_FLAGS.put(enchantment.getClass(), new StateFlag(name, true)); } From 9a305ad8cae295fd8ebab3674aeba7208fb45516 Mon Sep 17 00:00:00 2001 From: Tsumiki Miniwa <37684627+cpaca@users.noreply.github.com> Date: Mon, 22 Sep 2025 04:06:46 -0700 Subject: [PATCH 76/80] Register enchantments in Integrations --- .../strangeone101/holoitemsapi/enchantment/EnchantManager.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/strangeone101/holoitemsapi/enchantment/EnchantManager.java b/src/main/java/com/strangeone101/holoitemsapi/enchantment/EnchantManager.java index 5ccd52eb..848340b5 100644 --- a/src/main/java/com/strangeone101/holoitemsapi/enchantment/EnchantManager.java +++ b/src/main/java/com/strangeone101/holoitemsapi/enchantment/EnchantManager.java @@ -11,6 +11,7 @@ import org.jetbrains.annotations.Nullable; import xyz.holocons.mc.holoitemsrevamp.HoloItemsRevamp; import xyz.holocons.mc.holoitemsrevamp.enchantment.*; +import xyz.holocons.mc.holoitemsrevamp.integration.Integrations; import java.util.Map; @@ -31,6 +32,7 @@ public EnchantManager(HoloItemsRevamp plugin) { this.HoloEnchantmentsTag = enchantmentRegistry.getTag(enchantmentTagKey); this.enchantmentsByKey = this.loadCustomEnchantments(); + this.enchantmentsByKey.forEach(Integrations.WORLDGUARD::registerEnchantment); } public boolean isTaggedHoloEnchantment(Enchantment enchantment) { From 1013f10175a915be621fb550472c0a015bd14c5d Mon Sep 17 00:00:00 2001 From: Tsumiki Miniwa <37684627+cpaca@users.noreply.github.com> Date: Mon, 22 Sep 2025 04:14:27 -0700 Subject: [PATCH 77/80] Rename loadCustomEnchantments --- .../holoitemsapi/enchantment/EnchantManager.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/strangeone101/holoitemsapi/enchantment/EnchantManager.java b/src/main/java/com/strangeone101/holoitemsapi/enchantment/EnchantManager.java index 848340b5..697e8372 100644 --- a/src/main/java/com/strangeone101/holoitemsapi/enchantment/EnchantManager.java +++ b/src/main/java/com/strangeone101/holoitemsapi/enchantment/EnchantManager.java @@ -31,7 +31,7 @@ public EnchantManager(HoloItemsRevamp plugin) { var enchantmentTagKey = TagKey.create(RegistryKey.ENCHANTMENT, enchantmentTagName); this.HoloEnchantmentsTag = enchantmentRegistry.getTag(enchantmentTagKey); - this.enchantmentsByKey = this.loadCustomEnchantments(); + this.enchantmentsByKey = this.buildCustomEnchantments(); this.enchantmentsByKey.forEach(Integrations.WORLDGUARD::registerEnchantment); } @@ -50,7 +50,7 @@ public EnchantmentAbility getByKey(@Nullable NamespacedKey key) { return enchantmentsByKey.get(key); } - private Map loadCustomEnchantments() { + private Map buildCustomEnchantments() { return Map.ofEntries( Map.entry(createEnchKey("magnet"), new Magnet(plugin)), Map.entry(createEnchKey("memento"), new Memento(plugin)), From 3e2fcbb38caeb768fa018c4079ea0472a7558182 Mon Sep 17 00:00:00 2001 From: Tsumiki Miniwa <37684627+cpaca@users.noreply.github.com> Date: Mon, 22 Sep 2025 04:22:26 -0700 Subject: [PATCH 78/80] Use better entry construction in EnchantManager --- .../holoitemsapi/enchantment/EnchantManager.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/strangeone101/holoitemsapi/enchantment/EnchantManager.java b/src/main/java/com/strangeone101/holoitemsapi/enchantment/EnchantManager.java index 697e8372..19b9154c 100644 --- a/src/main/java/com/strangeone101/holoitemsapi/enchantment/EnchantManager.java +++ b/src/main/java/com/strangeone101/holoitemsapi/enchantment/EnchantManager.java @@ -52,15 +52,15 @@ public EnchantmentAbility getByKey(@Nullable NamespacedKey key) { private Map buildCustomEnchantments() { return Map.ofEntries( - Map.entry(createEnchKey("magnet"), new Magnet(plugin)), - Map.entry(createEnchKey("memento"), new Memento(plugin)), - Map.entry(createEnchKey("tide_rider"), new TideRider(plugin)), - Map.entry(createEnchKey("backdash"), new Backdash(plugin)), - Map.entry(createEnchKey("plow"), new Plow(plugin)) + createEntry("magnet", new Magnet(plugin)), + createEntry("memento", new Memento(plugin)), + createEntry("tide_rider", new TideRider(plugin)), + createEntry("backdash", new Backdash(plugin)), + createEntry("plow", new Plow(plugin)) ); } - private NamespacedKey createEnchKey(String name) { - return new NamespacedKey(plugin, name); + private Map.Entry createEntry(String name, EnchantmentAbility ability) { + return Map.entry(new NamespacedKey(plugin, name), ability); } } From 6747230a4c9b23e6934e21949a843d3c9601772c Mon Sep 17 00:00:00 2001 From: Tsumiki Miniwa <37684627+cpaca@users.noreply.github.com> Date: Tue, 23 Sep 2025 02:32:11 -0700 Subject: [PATCH 79/80] Fix javadoc error (param name was changed) --- src/main/java/xyz/holocons/mc/holoitemsrevamp/Util.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/xyz/holocons/mc/holoitemsrevamp/Util.java b/src/main/java/xyz/holocons/mc/holoitemsrevamp/Util.java index be34f24d..e1fec5fa 100644 --- a/src/main/java/xyz/holocons/mc/holoitemsrevamp/Util.java +++ b/src/main/java/xyz/holocons/mc/holoitemsrevamp/Util.java @@ -56,7 +56,8 @@ public static UUID randomUUID() { /** * Returns a player head with the base64 texture. Mostly used for GUI. * - * @param base64 A base 64 string that contains ONLY the texture + * @param url A url from textures.minecraft.net that represents the skin texture, as stored on Mojang servers. + * Read more here. * @return The ItemStack player head */ public static ItemStack getPlayerHeadFromSkinUrl(String url) { From b8b23cba1c1d016f89f9b915637be6abfabc77c3 Mon Sep 17 00:00:00 2001 From: Tsumiki Miniwa <37684627+cpaca@users.noreply.github.com> Date: Thu, 2 Oct 2025 15:09:23 -0700 Subject: [PATCH 80/80] Remove old command registration --- build.gradle.kts | 6 ------ 1 file changed, 6 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index ca0df5dd..a1dd117d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -97,10 +97,4 @@ paper { required = false } } - -// commands { -// register("holoitems") { -// usage = "/holoitems" -// } -// } }