DREAMFIRE Docs ← Back to site
Loading...
Searching...
No Matches
DreamEnchantWrapper.java
Go to the documentation of this file.
1/*
2 * MIT License
3 *
4 * Copyright (c) 2025 Dreamfire Studio
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in all
14 * copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 */
24package com.dreamfirestudios.dreamcore.DreamEnchantment;
25
26import io.papermc.paper.enchantments.EnchantmentRarity;
27import io.papermc.paper.registry.set.RegistryKeySet;
28import net.kyori.adventure.text.Component;
29import org.bukkit.NamespacedKey;
30import org.bukkit.enchantments.Enchantment;
31import org.bukkit.enchantments.EnchantmentTarget; // NOTE: Bukkit's, not NMS
32import org.bukkit.entity.EntityCategory;
33import org.bukkit.entity.EntityType;
34import org.bukkit.inventory.EquipmentSlotGroup;
35import org.bukkit.inventory.ItemStack;
36import org.bukkit.inventory.ItemType;
37import org.jetbrains.annotations.NotNull;
38import org.jetbrains.annotations.Nullable;
39
40import java.util.Set;
41
50
51public final class DreamEnchantWrapper extends Enchantment {
52
53 private final IDreamEnchantment delegate;
54
60
61 public DreamEnchantWrapper(@NotNull IDreamEnchantment delegate) {
62 super(); // key comes from getKey()
63 this.delegate = delegate;
64 }
65
66 // ---- Core Paper/Bukkit surface ----
67
69 @Override public @NotNull NamespacedKey getKey() { return delegate.getKey(); }
71 @Override public int getMaxLevel() { return delegate.getMaxLevel(); }
73 @Override public int getStartLevel() { return delegate.getStartLevel(); }
75 @Override public boolean isTreasure() { return delegate.isTreasure(); }
77 @Override public boolean isCursed() { return delegate.isCursed(); }
79 @Override public boolean conflictsWith(@NotNull Enchantment other) { return delegate.conflictsWith(other); }
81 @Override public boolean canEnchantItem(@NotNull ItemStack itemStack) { return delegate.canEnchantItem(itemStack); }
83 @Override public @NotNull Component displayName(int level) { return delegate.displayName(level); }
85 @Override public boolean isTradeable() { return delegate.isTradeable(); }
87 @Override public boolean isDiscoverable() { return delegate.isDiscoverable(); }
89 @Override public int getMinModifiedCost(int level) { return delegate.getMinModifiedCost(level); }
91 @Override public int getMaxModifiedCost(int level) { return delegate.getMaxModifiedCost(level); }
93 @Override public int getAnvilCost() { return delegate.getAnvilCost(); }
95 @Override public @NotNull Set<EquipmentSlotGroup> getActiveSlotGroups() { return delegate.getActiveSlotGroups(); }
97 @Override public @NotNull Component description() { return delegate.description(); }
99 @Override public @NotNull RegistryKeySet<ItemType> getSupportedItems() { return delegate.getSupportedItems(); }
102
103 @Override public @Nullable RegistryKeySet<ItemType> getPrimaryItems() { return delegate.getPrimaryItems(); }
105 @Override public int getWeight() { return delegate.getWeight(); }
107 @Override public @NotNull RegistryKeySet<Enchantment> getExclusiveWith() { return delegate.getExclusiveWith(); }
109 @Override public @NotNull String translationKey() { return delegate.translationKey(); }
110
111 // ---- Legacy / deprecated hooks (still exposed on Paper) ----
112
114 @Deprecated @Override @SuppressWarnings({"deprecation","removal"})
115 public @NotNull String getName() { return delegate.getName(); }
116
118 @Deprecated @Override @SuppressWarnings({"deprecation","removal"})
119 public @NotNull EnchantmentTarget getItemTarget() { return delegate.getItemTarget(); }
120
122 @Deprecated @Override @SuppressWarnings({"deprecation","removal"})
123 public @NotNull EnchantmentRarity getRarity() { return delegate.getRarity(); }
124
126 @Deprecated @Override @SuppressWarnings({"deprecation","removal"})
127 public float getDamageIncrease(int level, @NotNull EntityCategory category) {
128 return delegate.getDamageIncrease(level, category);
129 }
130
132 @Deprecated @Override @SuppressWarnings({"deprecation","removal"})
133 public float getDamageIncrease(int level, @NotNull EntityType type) {
134 return delegate.getDamageIncrease(level, type);
135 }
136
138 @Deprecated @Override @SuppressWarnings({"deprecation","removal"})
139 public @NotNull String getTranslationKey() { return delegate.getTranslationKey(); }
140}
float getDamageIncrease(int level, @NotNull EntityCategory category)
float getDamageIncrease(int level, @NotNull EntityCategory category)
/
boolean isCursed()
Whether the enchantment is cursed.
boolean isTreasure()
Whether the enchantment is a treasure-only enchant.
int getMinModifiedCost(int level)
Minimum modified enchanting cost for a given level.
int getStartLevel()
Starting level when applied via typical means (e.g., table/loot).
int getAnvilCost()
Additional anvil cost when combining.
boolean isTradeable()
Whether this enchantment can be obtained via villager trading.
int getMaxModifiedCost(int level)
Maximum modified enchanting cost for a given level.
boolean isDiscoverable()
Whether this enchantment can appear via standard discovery (loot tables, enchanting table).
int getMaxLevel()
Maximum level allowed by this enchantment.