mirror of
https://github.com/YouHaveTrouble/Enchantio.git
synced 2026-05-12 06:06:55 +00:00
add ability to configure active slots for the enchant
This commit is contained in:
@@ -11,7 +11,9 @@ import net.kyori.adventure.key.Key;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.inventory.EquipmentSlotGroup;
|
||||
import org.bukkit.inventory.ItemType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -98,6 +100,13 @@ public class EnchantioConfig {
|
||||
List.of(
|
||||
"#minecraft:enchantable/mining"
|
||||
)
|
||||
)),
|
||||
getEquipmentSlotGroups(getStringList(
|
||||
telepathySection,
|
||||
"activeSlots",
|
||||
List.of(
|
||||
"MAINHAND"
|
||||
)
|
||||
))
|
||||
);
|
||||
|
||||
@@ -159,6 +168,13 @@ public class EnchantioConfig {
|
||||
"#minecraft:enchantable/weapon"
|
||||
)
|
||||
)),
|
||||
getEquipmentSlotGroups(getStringList(
|
||||
executionerSection,
|
||||
"activeSlots",
|
||||
List.of(
|
||||
"MAINHAND"
|
||||
)
|
||||
)),
|
||||
getInt(executionerSection, "maxLevel", 5),
|
||||
getDouble(executionerSection, "damageMultiplierPerLevel", 0.05),
|
||||
getDouble(executionerSection, "maxDamageHpThreshold", 0.25)
|
||||
@@ -192,6 +208,13 @@ public class EnchantioConfig {
|
||||
"#minecraft:axes"
|
||||
)
|
||||
)),
|
||||
getEquipmentSlotGroups(getStringList(
|
||||
beheadingSection,
|
||||
"activeSlots",
|
||||
List.of(
|
||||
"MAINHAND"
|
||||
)
|
||||
)),
|
||||
getInt(beheadingSection, "maxLevel", 5),
|
||||
getDouble(beheadingSection, "chanceToDropHeadPerLevel", 0.02)
|
||||
);
|
||||
@@ -254,6 +277,13 @@ public class EnchantioConfig {
|
||||
"minecraft:elytra"
|
||||
)
|
||||
)),
|
||||
getEquipmentSlotGroups(getStringList(
|
||||
airbagSection,
|
||||
"activeSlots",
|
||||
List.of(
|
||||
"CHEST"
|
||||
)
|
||||
)),
|
||||
getInt(airbagSection, "maxLevel", 4),
|
||||
getDouble(airbagSection, "damageReductionPerLevel", 0.2)
|
||||
);
|
||||
@@ -291,6 +321,13 @@ public class EnchantioConfig {
|
||||
"#minecraft:enchantable/armor"
|
||||
)
|
||||
)),
|
||||
getEquipmentSlotGroups(getStringList(
|
||||
panicSection,
|
||||
"activeSlots",
|
||||
List.of(
|
||||
"ARMOR"
|
||||
)
|
||||
)),
|
||||
getInt(panicSection, "maxLevel", 1),
|
||||
getDouble(panicSection, "panicChancePerLevel", 0.025)
|
||||
);
|
||||
@@ -338,7 +375,20 @@ public class EnchantioConfig {
|
||||
return true;
|
||||
}
|
||||
|
||||
private Set<TagEntry<ItemType>> getTagsFromList(List<String> tags) {
|
||||
private Set<EquipmentSlotGroup> getEquipmentSlotGroups(@NotNull List<String> slots) {
|
||||
Set<EquipmentSlotGroup> equipmentSlotGroups = new HashSet<>();
|
||||
for (String slot : slots) {
|
||||
try {
|
||||
EquipmentSlotGroup equipmentSlotGroup = EquipmentSlotGroup.getByName(slot.toUpperCase(Locale.ENGLISH));
|
||||
equipmentSlotGroups.add(equipmentSlotGroup);
|
||||
} catch (IllegalArgumentException e) {
|
||||
logger.warning(slot + " is not a valid equipment slot group");
|
||||
}
|
||||
}
|
||||
return equipmentSlotGroups;
|
||||
}
|
||||
|
||||
private Set<TagEntry<ItemType>> getTagsFromList(@NotNull List<String> tags) {
|
||||
Set<TagEntry<ItemType>> supportedItemTags = new HashSet<>();
|
||||
for (String itemTag : tags) {
|
||||
if (itemTag == null) continue;
|
||||
|
||||
@@ -9,6 +9,7 @@ import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.EquipmentSlotGroup;
|
||||
import org.bukkit.inventory.ItemType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
@@ -24,6 +25,7 @@ public class AirbagEnchant implements EnchantioEnchant {
|
||||
private final EnchantmentRegistryEntry.EnchantmentCost maximumCost;
|
||||
private final Set<TagEntry<ItemType>> supportedItemTags;
|
||||
private final Set<TagKey<Enchantment>> enchantTagKeys = new HashSet<>();
|
||||
private final Set<EquipmentSlotGroup> activeSlots = new HashSet<>();
|
||||
private final double damageReductionPerLevel;
|
||||
|
||||
public AirbagEnchant(
|
||||
@@ -33,6 +35,7 @@ public class AirbagEnchant implements EnchantioEnchant {
|
||||
EnchantmentRegistryEntry.EnchantmentCost maximumCost,
|
||||
boolean canGetFromEnchantingTable,
|
||||
Set<TagEntry<ItemType>> supportedItemTags,
|
||||
Set<EquipmentSlotGroup> activeSlots,
|
||||
int maxLevel,
|
||||
double damageReductionPerLevel
|
||||
) {
|
||||
@@ -43,18 +46,19 @@ public class AirbagEnchant implements EnchantioEnchant {
|
||||
this.maximumCost = maximumCost;
|
||||
this.supportedItemTags = supportedItemTags;
|
||||
this.damageReductionPerLevel = damageReductionPerLevel;
|
||||
this.activeSlots.addAll(activeSlots);
|
||||
if (canGetFromEnchantingTable) {
|
||||
enchantTagKeys.add(EnchantmentTagKeys.IN_ENCHANTING_TABLE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Key getKey() {
|
||||
public @NotNull Key getKey() {
|
||||
return KEY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getDescription() {
|
||||
public @NotNull Component getDescription() {
|
||||
return Component.translatable("enchantio.enchant.airbag", "Airbag");
|
||||
}
|
||||
|
||||
@@ -74,27 +78,27 @@ public class AirbagEnchant implements EnchantioEnchant {
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnchantmentRegistryEntry.EnchantmentCost getMinimumCost() {
|
||||
public EnchantmentRegistryEntry.@NotNull EnchantmentCost getMinimumCost() {
|
||||
return minimumCost;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnchantmentRegistryEntry.EnchantmentCost getMaximumCost() {
|
||||
public EnchantmentRegistryEntry.@NotNull EnchantmentCost getMaximumCost() {
|
||||
return maximumCost;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<EquipmentSlotGroup> getActiveSlots() {
|
||||
return Set.of(EquipmentSlotGroup.ARMOR);
|
||||
public @NotNull Iterable<EquipmentSlotGroup> getActiveSlots() {
|
||||
return activeSlots;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<TagEntry<ItemType>> getSupportedItems() {
|
||||
public @NotNull Set<TagEntry<ItemType>> getSupportedItems() {
|
||||
return supportedItemTags;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<TagKey<Enchantment>> getEnchantTagKeys() {
|
||||
public @NotNull Set<TagKey<Enchantment>> getEnchantTagKeys() {
|
||||
return Collections.unmodifiableSet(enchantTagKeys);
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.EquipmentSlotGroup;
|
||||
import org.bukkit.inventory.ItemType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
@@ -26,6 +27,7 @@ public class BeheadingEnchant implements EnchantioEnchant {
|
||||
private final Set<TagEntry<ItemType>> supportedItemTags;
|
||||
private final double chanceToDropHeadPerLevel;
|
||||
private final Set<TagKey<Enchantment>> enchantTagKeys = new HashSet<>();
|
||||
private final Set<EquipmentSlotGroup> activeSlots = new HashSet<>();
|
||||
|
||||
public BeheadingEnchant(
|
||||
int anvilCost,
|
||||
@@ -34,6 +36,7 @@ public class BeheadingEnchant implements EnchantioEnchant {
|
||||
EnchantmentRegistryEntry.EnchantmentCost maximumCost,
|
||||
boolean canGetFromEnchantingTable,
|
||||
Set<TagEntry<ItemType>> supportedItemTags,
|
||||
Set<EquipmentSlotGroup> activeSlots,
|
||||
int maxLevel,
|
||||
double chanceToDropHeadPerLevel
|
||||
) {
|
||||
@@ -44,19 +47,19 @@ public class BeheadingEnchant implements EnchantioEnchant {
|
||||
this.supportedItemTags = supportedItemTags;
|
||||
this.maxLevel = maxLevel;
|
||||
this.chanceToDropHeadPerLevel = chanceToDropHeadPerLevel;
|
||||
|
||||
this.activeSlots.addAll(activeSlots);
|
||||
if (canGetFromEnchantingTable) {
|
||||
enchantTagKeys.add(EnchantmentTagKeys.IN_ENCHANTING_TABLE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Key getKey() {
|
||||
public @NotNull Key getKey() {
|
||||
return KEY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getDescription() {
|
||||
public @NotNull Component getDescription() {
|
||||
return Component.translatable("enchantio.enchant.beheading", "Beheading");
|
||||
}
|
||||
|
||||
@@ -80,32 +83,32 @@ public class BeheadingEnchant implements EnchantioEnchant {
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnchantmentRegistryEntry.EnchantmentCost getMinimumCost() {
|
||||
public EnchantmentRegistryEntry.@NotNull EnchantmentCost getMinimumCost() {
|
||||
return minimumCost;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnchantmentRegistryEntry.EnchantmentCost getMaximumCost() {
|
||||
public EnchantmentRegistryEntry.@NotNull EnchantmentCost getMaximumCost() {
|
||||
return maximumCost;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<EquipmentSlotGroup> getActiveSlots() {
|
||||
return Set.of(EquipmentSlotGroup.ANY);
|
||||
public @NotNull Iterable<EquipmentSlotGroup> getActiveSlots() {
|
||||
return activeSlots;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TagKey<ItemType> getTagForSupportedItems() {
|
||||
public @NotNull TagKey<ItemType> getTagForSupportedItems() {
|
||||
return TagKey.create(RegistryKey.ITEM, Key.key("enchantio:beheading_enchantable"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<TagEntry<ItemType>> getSupportedItems() {
|
||||
public @NotNull Set<TagEntry<ItemType>> getSupportedItems() {
|
||||
return supportedItemTags;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<TagKey<Enchantment>> getEnchantTagKeys() {
|
||||
public @NotNull Set<TagKey<Enchantment>> getEnchantTagKeys() {
|
||||
return Collections.unmodifiableSet(enchantTagKeys);
|
||||
}
|
||||
|
||||
|
||||
@@ -10,14 +10,17 @@ import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.EquipmentSlotGroup;
|
||||
import org.bukkit.inventory.ItemType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@SuppressWarnings("UnstableApiUsage")
|
||||
public interface EnchantioEnchant {
|
||||
|
||||
@NotNull
|
||||
Key getKey();
|
||||
|
||||
@NotNull
|
||||
Component getDescription();
|
||||
|
||||
int getAnvilCost();
|
||||
@@ -26,20 +29,27 @@ public interface EnchantioEnchant {
|
||||
|
||||
int getWeight();
|
||||
|
||||
@NotNull
|
||||
EnchantmentRegistryEntry.EnchantmentCost getMinimumCost();
|
||||
|
||||
@NotNull
|
||||
EnchantmentRegistryEntry.EnchantmentCost getMaximumCost();
|
||||
|
||||
@NotNull
|
||||
Iterable<EquipmentSlotGroup> getActiveSlots();
|
||||
|
||||
@NotNull
|
||||
Set<TagEntry<ItemType>> getSupportedItems();
|
||||
|
||||
@NotNull
|
||||
Set<TagKey<Enchantment>> getEnchantTagKeys();
|
||||
|
||||
@NotNull
|
||||
default TagKey<ItemType> getTagForSupportedItems() {
|
||||
return TagKey.create(RegistryKey.ITEM, Key.key( getKey().asString() + "_enchantable"));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
default TagEntry<Enchantment> getTagEntry() {
|
||||
return TagEntry.valueEntry(TypedKey.create(RegistryKey.ENCHANTMENT, getKey()));
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package me.youhavetrouble.enchantio.enchants;
|
||||
|
||||
import io.papermc.paper.registry.RegistryKey;
|
||||
import io.papermc.paper.registry.data.EnchantmentRegistryEntry;
|
||||
import io.papermc.paper.registry.keys.tags.EnchantmentTagKeys;
|
||||
import io.papermc.paper.registry.tag.TagKey;
|
||||
@@ -10,6 +9,7 @@ import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.EquipmentSlotGroup;
|
||||
import org.bukkit.inventory.ItemType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
@@ -26,6 +26,7 @@ public class ExecutionerEnchant implements EnchantioEnchant {
|
||||
private final Set<TagEntry<ItemType>> supportedItemTags;
|
||||
private final double damageMultiplierPerLevel, maxDamageHpThreshold;
|
||||
private final Set<TagKey<Enchantment>> enchantTagKeys = new HashSet<>();
|
||||
private final Set<EquipmentSlotGroup> activeSlots = new HashSet<>();
|
||||
|
||||
|
||||
public ExecutionerEnchant(
|
||||
@@ -35,6 +36,7 @@ public class ExecutionerEnchant implements EnchantioEnchant {
|
||||
EnchantmentRegistryEntry.EnchantmentCost maximumCost,
|
||||
boolean canGetFromEnchantingTable,
|
||||
Set<TagEntry<ItemType>> supportedItemTags,
|
||||
Set<EquipmentSlotGroup> activeSlots,
|
||||
int maxLevel,
|
||||
double damageMultiplierPerLevel,
|
||||
double maxDamageHpThreshold
|
||||
@@ -45,6 +47,7 @@ public class ExecutionerEnchant implements EnchantioEnchant {
|
||||
this.maximumCost = maximumCost;
|
||||
this.supportedItemTags = supportedItemTags;
|
||||
this.maxLevel = maxLevel;
|
||||
this.activeSlots.addAll(activeSlots);
|
||||
this.damageMultiplierPerLevel = damageMultiplierPerLevel;
|
||||
this.maxDamageHpThreshold = maxDamageHpThreshold;
|
||||
if (canGetFromEnchantingTable) {
|
||||
@@ -53,12 +56,12 @@ public class ExecutionerEnchant implements EnchantioEnchant {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Key getKey() {
|
||||
public @NotNull Key getKey() {
|
||||
return KEY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getDescription() {
|
||||
public @NotNull Component getDescription() {
|
||||
return Component.translatable("enchantio.enchant.executioner","Executioner");
|
||||
}
|
||||
|
||||
@@ -86,27 +89,27 @@ public class ExecutionerEnchant implements EnchantioEnchant {
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnchantmentRegistryEntry.EnchantmentCost getMinimumCost() {
|
||||
public EnchantmentRegistryEntry.@NotNull EnchantmentCost getMinimumCost() {
|
||||
return minimumCost;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnchantmentRegistryEntry.EnchantmentCost getMaximumCost() {
|
||||
public EnchantmentRegistryEntry.@NotNull EnchantmentCost getMaximumCost() {
|
||||
return maximumCost;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<EquipmentSlotGroup> getActiveSlots() {
|
||||
return Set.of(EquipmentSlotGroup.HAND);
|
||||
public @NotNull Iterable<EquipmentSlotGroup> getActiveSlots() {
|
||||
return activeSlots;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<TagEntry<ItemType>> getSupportedItems() {
|
||||
public @NotNull Set<TagEntry<ItemType>> getSupportedItems() {
|
||||
return supportedItemTags;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<TagKey<Enchantment>> getEnchantTagKeys() {
|
||||
public @NotNull Set<TagKey<Enchantment>> getEnchantTagKeys() {
|
||||
return Collections.unmodifiableSet(enchantTagKeys);
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.EquipmentSlotGroup;
|
||||
import org.bukkit.inventory.ItemType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
@@ -25,6 +26,7 @@ public class PanicEnchant implements EnchantioEnchant {
|
||||
private final double panicChancePerLevel;
|
||||
private final Set<TagEntry<ItemType>> supportedItemTags;
|
||||
private final Set<TagKey<Enchantment>> enchantTagKeys = new HashSet<>();
|
||||
private final Set<EquipmentSlotGroup> activeSlots = new HashSet<>();
|
||||
|
||||
public PanicEnchant(
|
||||
int anvilCost,
|
||||
@@ -33,6 +35,7 @@ public class PanicEnchant implements EnchantioEnchant {
|
||||
EnchantmentRegistryEntry.EnchantmentCost maximumCost,
|
||||
boolean canGetFromEnchantingTable,
|
||||
Set<TagEntry<ItemType>> supportedItemTags,
|
||||
Set<EquipmentSlotGroup> activeSlots,
|
||||
int maxLevel,
|
||||
double panicChancePerLevel
|
||||
) {
|
||||
@@ -43,6 +46,7 @@ public class PanicEnchant implements EnchantioEnchant {
|
||||
this.maximumCost = maximumCost;
|
||||
this.supportedItemTags = supportedItemTags;
|
||||
this.panicChancePerLevel = panicChancePerLevel;
|
||||
this.activeSlots.addAll(activeSlots);
|
||||
if (canGetFromEnchantingTable) {
|
||||
enchantTagKeys.add(EnchantmentTagKeys.IN_ENCHANTING_TABLE);
|
||||
}
|
||||
@@ -50,12 +54,12 @@ public class PanicEnchant implements EnchantioEnchant {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Key getKey() {
|
||||
public @NotNull Key getKey() {
|
||||
return KEY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getDescription() {
|
||||
public @NotNull Component getDescription() {
|
||||
return Component.translatable("enchantio.enchant.panic_curse", "Curse of Panic");
|
||||
}
|
||||
|
||||
@@ -75,27 +79,27 @@ public class PanicEnchant implements EnchantioEnchant {
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnchantmentRegistryEntry.EnchantmentCost getMinimumCost() {
|
||||
public EnchantmentRegistryEntry.@NotNull EnchantmentCost getMinimumCost() {
|
||||
return minimumCost;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnchantmentRegistryEntry.EnchantmentCost getMaximumCost() {
|
||||
public EnchantmentRegistryEntry.@NotNull EnchantmentCost getMaximumCost() {
|
||||
return maximumCost;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<EquipmentSlotGroup> getActiveSlots() {
|
||||
return Set.of(EquipmentSlotGroup.ARMOR);
|
||||
public @NotNull Iterable<EquipmentSlotGroup> getActiveSlots() {
|
||||
return activeSlots;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<TagEntry<ItemType>> getSupportedItems() {
|
||||
public @NotNull Set<TagEntry<ItemType>> getSupportedItems() {
|
||||
return supportedItemTags;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<TagKey<Enchantment>> getEnchantTagKeys() {
|
||||
public @NotNull Set<TagKey<Enchantment>> getEnchantTagKeys() {
|
||||
return Collections.unmodifiableSet(enchantTagKeys);
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.EquipmentSlotGroup;
|
||||
import org.bukkit.inventory.ItemType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
@@ -44,12 +45,12 @@ public class ReplantingEnchant implements EnchantioEnchant {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Key getKey() {
|
||||
public @NotNull Key getKey() {
|
||||
return KEY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getDescription() {
|
||||
public @NotNull Component getDescription() {
|
||||
return Component.translatable("enchantio.enchant.replanting", "Replanting");
|
||||
}
|
||||
|
||||
@@ -69,27 +70,27 @@ public class ReplantingEnchant implements EnchantioEnchant {
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnchantmentRegistryEntry.EnchantmentCost getMinimumCost() {
|
||||
public EnchantmentRegistryEntry.@NotNull EnchantmentCost getMinimumCost() {
|
||||
return minimumCost;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnchantmentRegistryEntry.EnchantmentCost getMaximumCost() {
|
||||
public EnchantmentRegistryEntry.@NotNull EnchantmentCost getMaximumCost() {
|
||||
return maximumCost;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<EquipmentSlotGroup> getActiveSlots() {
|
||||
return Set.of(EquipmentSlotGroup.HAND);
|
||||
public @NotNull Iterable<EquipmentSlotGroup> getActiveSlots() {
|
||||
return Set.of(EquipmentSlotGroup.MAINHAND);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<TagEntry<ItemType>> getSupportedItems() {
|
||||
public @NotNull Set<TagEntry<ItemType>> getSupportedItems() {
|
||||
return supportedItemTags;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<TagKey<Enchantment>> getEnchantTagKeys() {
|
||||
public @NotNull Set<TagKey<Enchantment>> getEnchantTagKeys() {
|
||||
return Collections.unmodifiableSet(enchantTagKeys);
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.EquipmentSlotGroup;
|
||||
import org.bukkit.inventory.ItemType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
@@ -44,12 +45,12 @@ public class SmeltingEnchant implements EnchantioEnchant {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Key getKey() {
|
||||
public @NotNull Key getKey() {
|
||||
return KEY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getDescription() {
|
||||
public @NotNull Component getDescription() {
|
||||
return Component.translatable("enchantio.enchant.smelting", "Smelting");
|
||||
}
|
||||
|
||||
@@ -69,27 +70,27 @@ public class SmeltingEnchant implements EnchantioEnchant {
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnchantmentRegistryEntry.EnchantmentCost getMinimumCost() {
|
||||
public EnchantmentRegistryEntry.@NotNull EnchantmentCost getMinimumCost() {
|
||||
return minimumCost;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnchantmentRegistryEntry.EnchantmentCost getMaximumCost() {
|
||||
public EnchantmentRegistryEntry.@NotNull EnchantmentCost getMaximumCost() {
|
||||
return maximumCost;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<EquipmentSlotGroup> getActiveSlots() {
|
||||
return Set.of(EquipmentSlotGroup.ANY);
|
||||
public @NotNull Iterable<EquipmentSlotGroup> getActiveSlots() {
|
||||
return Set.of(EquipmentSlotGroup.MAINHAND);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<TagEntry<ItemType>> getSupportedItems() {
|
||||
public @NotNull Set<TagEntry<ItemType>> getSupportedItems() {
|
||||
return supportedItemTags;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<TagKey<Enchantment>> getEnchantTagKeys() {
|
||||
public @NotNull Set<TagKey<Enchantment>> getEnchantTagKeys() {
|
||||
return Collections.unmodifiableSet(enchantTagKeys);
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.EquipmentSlotGroup;
|
||||
import org.bukkit.inventory.ItemType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
@@ -44,12 +45,12 @@ public class SoulboundEnchant implements EnchantioEnchant {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Key getKey() {
|
||||
public @NotNull Key getKey() {
|
||||
return KEY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getDescription() {
|
||||
public @NotNull Component getDescription() {
|
||||
return Component.translatable("enchantio.enchant.soulbound", "Soulbound");
|
||||
}
|
||||
|
||||
@@ -69,27 +70,27 @@ public class SoulboundEnchant implements EnchantioEnchant {
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnchantmentRegistryEntry.EnchantmentCost getMinimumCost() {
|
||||
public EnchantmentRegistryEntry.@NotNull EnchantmentCost getMinimumCost() {
|
||||
return minimumCost;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnchantmentRegistryEntry.EnchantmentCost getMaximumCost() {
|
||||
public EnchantmentRegistryEntry.@NotNull EnchantmentCost getMaximumCost() {
|
||||
return maximumCost;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<EquipmentSlotGroup> getActiveSlots() {
|
||||
public @NotNull Iterable<EquipmentSlotGroup> getActiveSlots() {
|
||||
return Set.of(EquipmentSlotGroup.ANY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<TagEntry<ItemType>> getSupportedItems() {
|
||||
public @NotNull Set<TagEntry<ItemType>> getSupportedItems() {
|
||||
return supportedItemTags;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<TagKey<Enchantment>> getEnchantTagKeys() {
|
||||
public @NotNull Set<TagKey<Enchantment>> getEnchantTagKeys() {
|
||||
return Collections.unmodifiableSet(enchantTagKeys);
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.EquipmentSlotGroup;
|
||||
import org.bukkit.inventory.ItemType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
@@ -24,6 +25,7 @@ public class TelepathyEnchant implements EnchantioEnchant {
|
||||
private final EnchantmentRegistryEntry.EnchantmentCost maximumCost;
|
||||
private final Set<TagEntry<ItemType>> supportedItemTags;
|
||||
private final Set<TagKey<Enchantment>> enchantTagKeys = new HashSet<>();
|
||||
private final Set<EquipmentSlotGroup> activeSlots = new HashSet<>();
|
||||
|
||||
public TelepathyEnchant(
|
||||
int anvilCost,
|
||||
@@ -31,25 +33,27 @@ public class TelepathyEnchant implements EnchantioEnchant {
|
||||
EnchantmentRegistryEntry.EnchantmentCost minimumCost,
|
||||
EnchantmentRegistryEntry.EnchantmentCost maximumCost,
|
||||
boolean canGetFromEnchantingTable,
|
||||
Set<TagEntry<ItemType>> supportedItemTags
|
||||
Set<TagEntry<ItemType>> supportedItemTags,
|
||||
Set<EquipmentSlotGroup> activeSlots
|
||||
) {
|
||||
this.anvilCost = anvilCost;
|
||||
this.weight = weight;
|
||||
this.minimumCost = minimumCost;
|
||||
this.maximumCost = maximumCost;
|
||||
this.supportedItemTags = supportedItemTags;
|
||||
this.activeSlots.addAll(activeSlots);
|
||||
if (canGetFromEnchantingTable) {
|
||||
enchantTagKeys.add(EnchantmentTagKeys.IN_ENCHANTING_TABLE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Key getKey() {
|
||||
public @NotNull Key getKey() {
|
||||
return KEY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getDescription() {
|
||||
public @NotNull Component getDescription() {
|
||||
return Component.translatable("enchantio.enchant.telepathy","Telepathy");
|
||||
}
|
||||
|
||||
@@ -69,27 +73,27 @@ public class TelepathyEnchant implements EnchantioEnchant {
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnchantmentRegistryEntry.EnchantmentCost getMinimumCost() {
|
||||
public EnchantmentRegistryEntry.@NotNull EnchantmentCost getMinimumCost() {
|
||||
return minimumCost;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnchantmentRegistryEntry.EnchantmentCost getMaximumCost() {
|
||||
public EnchantmentRegistryEntry.@NotNull EnchantmentCost getMaximumCost() {
|
||||
return maximumCost;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<EquipmentSlotGroup> getActiveSlots() {
|
||||
return Set.of(EquipmentSlotGroup.HAND);
|
||||
public @NotNull Iterable<EquipmentSlotGroup> getActiveSlots() {
|
||||
return activeSlots;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<TagEntry<ItemType>> getSupportedItems() {
|
||||
public @NotNull Set<TagEntry<ItemType>> getSupportedItems() {
|
||||
return supportedItemTags;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<TagKey<Enchantment>> getEnchantTagKeys() {
|
||||
public @NotNull Set<TagKey<Enchantment>> getEnchantTagKeys() {
|
||||
return Collections.unmodifiableSet(enchantTagKeys);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user