DREAMFIRE Docs ← Back to site
Loading...
Searching...
No Matches
IDreamEnchantment.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; // legacy but still exposed
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;
38
39import java.util.Set;
40
50
51public interface IDreamEnchantment {
52
53 // ---- Identity / i18n ----
54
57
58 @NotNull NamespacedKey getKey();
59
62
63 @NotNull String translationKey();
64
68
69 @Deprecated @NotNull String getTranslationKey();
70
74
75 @Deprecated @NotNull String getName();
76
77 // ---- Applicability / items ----
78
81
82 @NotNull RegistryKeySet<ItemType> getSupportedItems();
83
87
88 @NotNull RegistryKeySet<ItemType> getPrimaryItems();
89
92
93 @NotNull Set<EquipmentSlotGroup> getActiveSlotGroups();
94
98
99 @Deprecated @NotNull EnchantmentTarget getItemTarget();
100
101 // ---- Gameplay attributes ----
102
105
108
110 boolean isTreasure();
111
113 boolean isCursed();
114
116 boolean isTradeable();
117
119 boolean isDiscoverable();
120
122 int getMinModifiedCost(int level);
123
125 int getMaxModifiedCost(int level);
126
129
132
135
136 @Deprecated @NotNull EnchantmentRarity getRarity();
137
143
144 float getDamageIncrease(int level, @NotNull EntityCategory category);
145
151
152 float getDamageIncrease(int level, @NotNull EntityType type);
153
154 // ---- Composition / conflicts ----
155
160
161 boolean conflictsWith(Enchantment other);
162
167
168 boolean canEnchantItem(@NotNull ItemStack itemStack);
169
172
173 @NotNull RegistryKeySet<Enchantment> getExclusiveWith();
174
175 // ---- UI / text ----
176
181
182 @NotNull Component displayName(int level);
183
187
188 @NotNull Component description();
189
190 // ---- Convenience helpers ----
191
201
202 default @NotNull Enchantment returnEnchantment() {
203 return new DreamEnchantWrapper(this);
204 }
205
214
215 default boolean addToItem(@NotNull ItemStack stack, int level, boolean ignoreLevelRestriction) {
216 if (stack.getItemMeta() == null) return false;
217 int clamped = Math.max(1, Math.min(level, getMaxLevel()));
218 var meta = stack.getItemMeta();
219 meta.addEnchant(returnEnchantment(), clamped, ignoreLevelRestriction);
220 stack.setItemMeta(meta);
221 return stack.getEnchantmentLevel(returnEnchantment()) > 0;
222 }
223
230
231 default boolean addToItem(@NotNull ItemStack stack) {
232 return addToItem(stack, 1, true);
233 }
234}
float getDamageIncrease(int level, @NotNull EntityCategory category)
/
default boolean addToItem(@NotNull ItemStack stack, int level, boolean ignoreLevelRestriction)
/
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.
float getDamageIncrease(int level, @NotNull EntityType type)
/
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.