diff --git a/.idea/dictionaries/project.xml b/.idea/dictionaries/project.xml
new file mode 100644
index 0000000..77beb54
--- /dev/null
+++ b/.idea/dictionaries/project.xml
@@ -0,0 +1,7 @@
+
+
+
+ enchantbookplus
+
+
+
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 6000659..142f066 100644
--- a/pom.xml
+++ b/pom.xml
@@ -51,10 +51,9 @@
provided
- org.jetbrains
- annotations
- 26.0.2-1
- compile
+ org.jspecify
+ jspecify
+ 1.0.0
diff --git a/src/main/java/pro/cloudnode/smp/enchantbookplus/ConfigEnchantmentEntry.java b/src/main/java/pro/cloudnode/smp/enchantbookplus/ConfigEnchantmentEntry.java
index f48a60b..a305ac3 100644
--- a/src/main/java/pro/cloudnode/smp/enchantbookplus/ConfigEnchantmentEntry.java
+++ b/src/main/java/pro/cloudnode/smp/enchantbookplus/ConfigEnchantmentEntry.java
@@ -3,21 +3,22 @@
import org.bukkit.NamespacedKey;
import org.bukkit.Registry;
import org.bukkit.enchantments.Enchantment;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
+import org.jspecify.annotations.NullMarked;
+import org.jspecify.annotations.Nullable;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
-import java.util.Optional;
+import java.util.OptionalInt;
import java.util.stream.Collectors;
+@NullMarked
public class ConfigEnchantmentEntry {
/**
* Name of the enchantment.
*/
- public final @NotNull String name;
+ public final String name;
/**
* Maximum level of the enchantment.
@@ -40,57 +41,14 @@ public class ConfigEnchantmentEntry {
protected final boolean multiplyCostByLevel;
/**
- * Maximum level of the enchantment.
- */
- public final @NotNull Optional getMaxLevel() {
- if (Optional.ofNullable(maxLevel).isEmpty())
- return Optional.empty();
-
- if (maxLevelRelative)
- return Optional.of(getEnchantment().getMaxLevel() + maxLevel);
-
- return Optional.of(maxLevel);
- }
-
- /**
- * Cost of the enchantment.
- */
- public final int getCost() {
- return cost;
- }
-
- /**
- * Multiply cost by level.
- */
- public final boolean getMultiplyCostByLevel() {
- return multiplyCostByLevel;
- }
-
- /**
- * Get enchantment
- */
- public final Enchantment getEnchantment() {
- return Registry.ENCHANTMENT.get(NamespacedKey.minecraft(name));
- }
-
- /**
- * Is enchantment
- *
- * @param enchantment The enchantment
- */
- public final boolean isEnchantment(final @NotNull Enchantment enchantment) {
- return name.equalsIgnoreCase(enchantment.getKey().getKey());
- }
-
- /**
- * @param name Name of the enchantment.
- * @param maxLevel Maximum level of the enchantment.
- * @param maxLevelRelative Max level relative
- * @param cost Cost of the enchantment.
+ * @param name Name of the enchantment.
+ * @param maxLevel Maximum level of the enchantment.
+ * @param maxLevelRelative Max level relative
+ * @param cost Cost of the enchantment.
* @param multiplyCostByLevel Multiply cost by level.
*/
public ConfigEnchantmentEntry(
- final @NotNull String name,
+ final String name,
final @Nullable Integer maxLevel,
final boolean maxLevelRelative,
final int cost,
@@ -108,42 +66,38 @@ public ConfigEnchantmentEntry(
*
* @param configValue Config object
*/
- public static @NotNull ConfigEnchantmentEntry configValue(
- final @NotNull Map<@NotNull String, @NotNull Object> configValue
+ public static ConfigEnchantmentEntry configValue(
+ final Map configValue
) throws NumberFormatException, IndexOutOfBoundsException, ClassCastException {
final String name = (String) Objects.requireNonNull(configValue.get("name"));
- final @Nullable Integer maxLevel;
+ final Integer maxLevel;
final boolean maxLevelRelative;
if (!configValue.containsKey("max-level")) {
maxLevel = null;
maxLevelRelative = false;
- }
-
- else {
+ } else {
if (!(configValue.get("max-level") instanceof final String string)) {
maxLevel = (Integer) configValue.get("max-level");
maxLevelRelative = false;
- }
-
- else {
+ } else {
if (string.startsWith("+")) {
maxLevel = Integer.parseInt(string.substring(1));
maxLevelRelative = true;
- }
- else {
+ } else {
maxLevel = Integer.parseInt(string);
maxLevelRelative = false;
}
}
}
- if (!configValue.containsKey("cost"))
+ if (!configValue.containsKey("cost")) {
return new ConfigEnchantmentEntry(name, maxLevel, maxLevelRelative, 0, false);
+ }
- if (!(configValue.get("cost") instanceof final @NotNull String costString))
+ if (!(configValue.get("cost") instanceof final String costString)) {
return new ConfigEnchantmentEntry(
name,
maxLevel,
@@ -151,8 +105,9 @@ public ConfigEnchantmentEntry(
(Integer) configValue.get("cost"),
false
);
+ }
- if (costString.startsWith("*"))
+ if (costString.startsWith("*")) {
return new ConfigEnchantmentEntry(
name,
maxLevel,
@@ -160,25 +115,18 @@ public ConfigEnchantmentEntry(
Integer.parseInt(costString.substring(1)),
true
);
+ }
- return new ConfigEnchantmentEntry(
- name,
- maxLevel,
- maxLevelRelative,
- Integer.parseInt(costString),
- false
- );
+ return new ConfigEnchantmentEntry(name, maxLevel, maxLevelRelative, Integer.parseInt(costString), false);
}
-
/**
* From config object array
*
* @param configValue Config object array
*/
- public static @NotNull List<@NotNull ConfigEnchantmentEntry> configArray(
- final @NotNull ArrayList<@NotNull Map<@NotNull String, @NotNull Object>> configValue
- ) throws NumberFormatException, IndexOutOfBoundsException, ClassCastException {
+ public static List configArray(final ArrayList