mirror of
https://github.com/YouHaveTrouble/Enchantio.git
synced 2026-05-12 06:06:55 +00:00
playing around with enchants
This commit is contained in:
@@ -0,0 +1,96 @@
|
||||
package me.youhavetrouble.enchantio.enchants;
|
||||
|
||||
import io.papermc.paper.registry.data.EnchantmentRegistryEntry;
|
||||
import io.papermc.paper.registry.tag.TagKey;
|
||||
import net.kyori.adventure.key.Key;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.inventory.EquipmentSlotGroup;
|
||||
import org.bukkit.inventory.ItemType;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public abstract class EnchantioEnchant {
|
||||
|
||||
private static final Map<String, EnchantioEnchant> enchantioEnchants = new HashMap();
|
||||
|
||||
private final Key key;
|
||||
private final int anvilCost;
|
||||
private final int maxLevel;
|
||||
private final int weight;
|
||||
private final Component description;
|
||||
private final EnchantmentRegistryEntry.EnchantmentCost minimumCost;
|
||||
private final EnchantmentRegistryEntry.EnchantmentCost maximumCost;
|
||||
private final Set<TagKey<ItemType>> supportedItems;
|
||||
private final Set<EquipmentSlotGroup> activeSlots;
|
||||
|
||||
public EnchantioEnchant(
|
||||
Key key,
|
||||
Component description,
|
||||
int anvilCost,
|
||||
int maxLevel,
|
||||
int weight,
|
||||
EnchantmentRegistryEntry.EnchantmentCost minimumCost,
|
||||
EnchantmentRegistryEntry.EnchantmentCost maximumCost,
|
||||
Set<TagKey<ItemType>> supportedItems,
|
||||
Set<EquipmentSlotGroup> activeSlots
|
||||
) {
|
||||
this.key = key;
|
||||
this.description = description;
|
||||
this.anvilCost = anvilCost;
|
||||
this.maxLevel = maxLevel;
|
||||
this.weight = weight;
|
||||
this.minimumCost = minimumCost;
|
||||
this.maximumCost = maximumCost;
|
||||
this.supportedItems = supportedItems;
|
||||
this.activeSlots = activeSlots;
|
||||
}
|
||||
|
||||
public Key getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public Component getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public int getAnvilCost() {
|
||||
return anvilCost;
|
||||
}
|
||||
|
||||
public int getMaxLevel() {
|
||||
return maxLevel;
|
||||
}
|
||||
|
||||
public int getWeight() {
|
||||
return weight;
|
||||
}
|
||||
|
||||
public EnchantmentRegistryEntry.EnchantmentCost getMinimumCost() {
|
||||
return minimumCost;
|
||||
}
|
||||
|
||||
public EnchantmentRegistryEntry.EnchantmentCost getMaximumCost() {
|
||||
return maximumCost;
|
||||
}
|
||||
|
||||
public Set<TagKey<ItemType>> getSupportedItems() {
|
||||
return supportedItems;
|
||||
}
|
||||
|
||||
public Iterable<EquipmentSlotGroup> getActiveSlots() {
|
||||
return activeSlots;
|
||||
}
|
||||
|
||||
protected static void registerEnchant(EnchantioEnchant enchant) {
|
||||
enchantioEnchants.put(enchant.getKey().asString(), enchant);
|
||||
}
|
||||
|
||||
public static Map<String, EnchantioEnchant> getEnchants() {
|
||||
return Collections.unmodifiableMap(enchantioEnchants);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package me.youhavetrouble.enchantio.enchants;
|
||||
|
||||
import io.papermc.paper.registry.data.EnchantmentRegistryEntry;
|
||||
import io.papermc.paper.registry.keys.tags.ItemTypeTagKeys;
|
||||
import net.kyori.adventure.key.Key;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.inventory.EquipmentSlotGroup;
|
||||
import java.util.Set;
|
||||
|
||||
public class SoulboundEnchant extends EnchantioEnchant {
|
||||
public SoulboundEnchant() {
|
||||
super(
|
||||
Key.key("enchantio:soulbound"),
|
||||
Component.translatable("enchantio.enchant.soulbound","Soulbound"),
|
||||
1,
|
||||
1,
|
||||
10,
|
||||
EnchantmentRegistryEntry.EnchantmentCost.of(1, 1),
|
||||
EnchantmentRegistryEntry.EnchantmentCost.of(3, 1),
|
||||
Set.of(
|
||||
ItemTypeTagKeys.AXES,
|
||||
ItemTypeTagKeys.PICKAXES,
|
||||
ItemTypeTagKeys.SWORDS,
|
||||
ItemTypeTagKeys.HOES,
|
||||
ItemTypeTagKeys.SHOVELS,
|
||||
ItemTypeTagKeys.ENCHANTABLE_BOW,
|
||||
ItemTypeTagKeys.ENCHANTABLE_CROSSBOW,
|
||||
ItemTypeTagKeys.ENCHANTABLE_MACE,
|
||||
ItemTypeTagKeys.ENCHANTABLE_WEAPON,
|
||||
ItemTypeTagKeys.ENCHANTABLE_ARMOR
|
||||
),
|
||||
Set.of(EquipmentSlotGroup.ANY)
|
||||
);
|
||||
registerEnchant(this);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user