This commit is contained in:
nulli0n 2024-07-05 19:18:55 +05:00
parent 359782ff57
commit 9faac63acf
131 changed files with 2357 additions and 649 deletions

View File

@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>ExcellentEnchants</artifactId> <artifactId>ExcellentEnchants</artifactId>
<groupId>su.nightexpress.excellentenchants</groupId> <groupId>su.nightexpress.excellentenchants</groupId>
<version>4.0.5</version> <version>4.1.0</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@ -1,5 +1,6 @@
package su.nightexpress.excellentenchants.api; package su.nightexpress.excellentenchants.api;
@Deprecated
public enum DistributionMode { public enum DistributionMode {
VANILLA, VANILLA,

View File

@ -2,6 +2,7 @@ package su.nightexpress.excellentenchants.api;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@Deprecated
public enum DistributionWay { public enum DistributionWay {
ENCHANTING("Enchanting_Table"), ENCHANTING("Enchanting_Table"),

View File

@ -2,9 +2,7 @@ package su.nightexpress.excellentenchants.api.enchantment;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.Enchantment;
import org.bukkit.enchantments.EnchantmentTarget;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.ItemMeta;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -38,12 +36,24 @@ public interface EnchantmentData {
boolean checkEnchantLimit(@NotNull ItemStack item); boolean checkEnchantLimit(@NotNull ItemStack item);
boolean checkEnchantCategory(@NotNull ItemStack item); default boolean isSupportedItem(@NotNull ItemStack itemStack) {
return this.getSupportedItems().is(itemStack);
}
boolean checkItemCategory(@NotNull ItemStack item); default boolean isPrimaryItem(@NotNull ItemStack itemStack) {
return this.getPrimaryItems().is(itemStack);
}
default boolean hasItemCategory() { /**
return this.getItemCategories().length != 0; * Items on which this enchantment can be applied using an anvil or using the /enchant command.
*/
@NotNull ItemsCategory getSupportedItems();
/**
* Items for which this enchantment appears in an enchanting table.
*/
@NotNull default ItemsCategory getPrimaryItems() {
return this.getSupportedItems();
} }
@NotNull DistributionOptions getDistributionOptions(); @NotNull DistributionOptions getDistributionOptions();
@ -56,11 +66,13 @@ public interface EnchantmentData {
@NotNull String getName(); @NotNull String getName();
@Deprecated
@NotNull @NotNull
default String getNameFormatted(int level) { default String getNameFormatted(int level) {
return this.getNameFormatted(level, -1); return this.getNameFormatted(level, -1);
} }
@Deprecated
@NotNull String getNameFormatted(int level, int charges); @NotNull String getNameFormatted(int level, int charges);
@NotNull List<String> getDescription(); @NotNull List<String> getDescription();
@ -69,16 +81,12 @@ public interface EnchantmentData {
@NotNull List<String> getDescriptionReplaced(int level); @NotNull List<String> getDescriptionReplaced(int level);
@NotNull EnchantmentTarget getCategory(); @NotNull List<String> getDescriptionReplaced(int level, int charges);
@NotNull Enchantment getEnchantment(); @NotNull Enchantment getEnchantment();
void setEnchantment(@NotNull Enchantment enchantment); void setEnchantment(@NotNull Enchantment enchantment);
ItemCategory[] getItemCategories();
EquipmentSlot[] getSlots();
default boolean hasConflicts() { default boolean hasConflicts() {
return !this.getConflicts().isEmpty(); return !this.getConflicts().isEmpty();
} }

View File

@ -7,6 +7,7 @@ import su.nightexpress.nightcore.util.ItemUtil;
import java.util.function.Predicate; import java.util.function.Predicate;
@Deprecated
public enum ItemCategory { public enum ItemCategory {
HELMET(ItemUtil::isHelmet), HELMET(ItemUtil::isHelmet),

View File

@ -0,0 +1,148 @@
package su.nightexpress.excellentenchants.api.enchantment;
import org.bukkit.Material;
import org.bukkit.Tag;
import org.bukkit.enchantments.EnchantmentTarget;
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import su.nightexpress.nightcore.language.entry.LangString;
import java.util.HashSet;
import java.util.Set;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import java.util.stream.Stream;
public class ItemsCategory {
private final Supplier<Set<Material>> supplier;
private final EquipmentSlot[] slots;
private final EnchantmentTarget target;
private final String localized;
public ItemsCategory(@NotNull Supplier<Set<Material>> supplier, EquipmentSlot[] slots, @Nullable EnchantmentTarget target, @Nullable String localized) {
this.supplier = supplier;
this.slots = slots;
this.target = target;
this.localized = localized;
}
public boolean is(@NotNull ItemStack itemStack) {
return this.getMaterials().contains(itemStack.getType());
}
@NotNull
public static Builder buildDirect(@NotNull Set<Material> materials) {
return buildRef(() -> materials);
}
@NotNull
public static Builder buildDirect(Material... materials) {
return buildDirect(Stream.of(materials).collect(Collectors.toSet()));
}
@SafeVarargs
@NotNull
public static Builder buildDirect(Tag<Material>... tags) {
return buildDirect(Stream.of(tags).flatMap(tag -> tag.getValues().stream()).collect(Collectors.toSet()));
}
@NotNull
public static Builder buildRef(@NotNull Supplier<Set<Material>> supplier) {
return new Builder().supplier(supplier);
}
@NotNull
public Set<Material> getMaterials() {
return this.supplier.get();
}
public EquipmentSlot[] getSlots() {
return slots;
}
/**
* Only for compatibility reasons with versions < 1.21
*/
public EnchantmentTarget getTarget() {
return target;
}
public String getLocalized() {
return localized;
}
/*@NotNull
public static ItemsCategory create(@NotNull Set<Material> materials, EquipmentSlot... slots) {
return new ItemsCategory(() -> materials);
}
@NotNull
public static ItemsCategory create(Material... materials) {
return create(Stream.of(materials).collect(Collectors.toSet()));
}
@SafeVarargs
@NotNull
public static ItemsCategory create(Tag<Material>... tags) {
return create(Stream.of(tags).flatMap(tag -> tag.getValues().stream()).collect(Collectors.toSet()));
}*/
// @NotNull
// @Deprecated
// public static ItemsCategory fusion(ItemsCategory... categories) {
// Set<Supplier<Set<Material>>> suppliers = Stream.of(categories).map(category -> category.supplier).collect(Collectors.toSet());
// Supplier<Set<Material>> result = () -> suppliers.stream().flatMap(supplier -> supplier.get().stream()).collect(Collectors.toSet());
//
// return new ItemsCategory(result, categories[0].getSlots(), categories[0].target, categories[0].localized);
// }
public static class Builder {
private Supplier<Set<Material>> supplier;
private EquipmentSlot[] slots;
private EnchantmentTarget target;
private String localized;
public Builder() {
this.supplier = HashSet::new;
this.slots = new EquipmentSlot[0];
}
@NotNull
public ItemsCategory build() {
return new ItemsCategory(this.supplier, this.slots, this.target, this.localized);
}
@NotNull
public Builder slots(EquipmentSlot... slots) {
this.slots = slots;
return this;
}
@NotNull
public Builder supplier(@NotNull Supplier<Set<Material>> supplier) {
this.supplier = supplier;
return this;
}
@NotNull
public Builder target(EnchantmentTarget target) {
this.target = target;
return this;
}
@NotNull
public Builder localized(@NotNull LangString localized) {
return this.localized(localized.getString());
}
@NotNull
public Builder localized(@Nullable String localized) {
this.localized = localized;
return this;
}
}
}

View File

@ -6,6 +6,7 @@ import su.nightexpress.nightcore.util.random.Rnd;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@Deprecated
public enum Rarity { public enum Rarity {
COMMON(10), COMMON(10),

View File

@ -3,6 +3,7 @@ package su.nightexpress.excellentenchants.api.enchantment.distribution;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import su.nightexpress.nightcore.config.FileConfig; import su.nightexpress.nightcore.config.FileConfig;
@Deprecated
public interface DistributionOptions { public interface DistributionOptions {
void load(@NotNull FileConfig config); void load(@NotNull FileConfig config);

View File

@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>ExcellentEnchants</artifactId> <artifactId>ExcellentEnchants</artifactId>
<groupId>su.nightexpress.excellentenchants</groupId> <groupId>su.nightexpress.excellentenchants</groupId>
<version>4.0.5</version> <version>4.1.0</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
@ -67,37 +67,42 @@
<dependency> <dependency>
<groupId>su.nightexpress.excellentenchants</groupId> <groupId>su.nightexpress.excellentenchants</groupId>
<artifactId>API</artifactId> <artifactId>API</artifactId>
<version>4.0.5</version> <version>4.1.0</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>su.nightexpress.excellentenchants</groupId> <groupId>su.nightexpress.excellentenchants</groupId>
<artifactId>NMS</artifactId> <artifactId>NMS</artifactId>
<version>4.0.5</version> <version>4.1.0</version>
</dependency>
<dependency>
<groupId>su.nightexpress.excellentenchants</groupId>
<artifactId>MC_1_21</artifactId>
<version>4.1.0</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>su.nightexpress.excellentenchants</groupId> <groupId>su.nightexpress.excellentenchants</groupId>
<artifactId>MC_1_20_6</artifactId> <artifactId>MC_1_20_6</artifactId>
<version>4.0.5</version> <version>4.1.0</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>su.nightexpress.excellentenchants</groupId> <groupId>su.nightexpress.excellentenchants</groupId>
<artifactId>V1_20_R3</artifactId> <artifactId>V1_20_R3</artifactId>
<version>4.0.5</version> <version>4.1.0</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>su.nightexpress.excellentenchants</groupId> <groupId>su.nightexpress.excellentenchants</groupId>
<artifactId>V1_20_R2</artifactId> <artifactId>V1_20_R2</artifactId>
<version>4.0.5</version> <version>4.1.0</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>su.nightexpress.excellentenchants</groupId> <groupId>su.nightexpress.excellentenchants</groupId>
<artifactId>V1_20_R1</artifactId> <artifactId>V1_20_R1</artifactId>
<version>4.0.5</version> <version>4.1.0</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>su.nightexpress.excellentenchants</groupId> <groupId>su.nightexpress.excellentenchants</groupId>
<artifactId>V1_19_R3</artifactId> <artifactId>V1_19_R3</artifactId>
<version>4.0.5</version> <version>4.1.0</version>
</dependency> </dependency>
</dependencies> </dependencies>

View File

@ -1,11 +1,9 @@
package su.nightexpress.excellentenchants; package su.nightexpress.excellentenchants;
import org.bukkit.enchantments.EnchantmentTarget;
import org.bukkit.entity.Item; import org.bukkit.entity.Item;
import org.bukkit.event.block.BlockDropItemEvent; import org.bukkit.event.block.BlockDropItemEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import su.nightexpress.excellentenchants.api.enchantment.ItemCategory;
import su.nightexpress.excellentenchants.api.DistributionWay; import su.nightexpress.excellentenchants.api.DistributionWay;
import su.nightexpress.excellentenchants.api.enchantment.Rarity; import su.nightexpress.excellentenchants.api.enchantment.Rarity;
import su.nightexpress.excellentenchants.command.*; import su.nightexpress.excellentenchants.command.*;
@ -16,9 +14,10 @@ import su.nightexpress.excellentenchants.config.Perms;
import su.nightexpress.excellentenchants.enchantment.EnchantManager; import su.nightexpress.excellentenchants.enchantment.EnchantManager;
import su.nightexpress.excellentenchants.enchantment.EnchantPopulator; import su.nightexpress.excellentenchants.enchantment.EnchantPopulator;
import su.nightexpress.excellentenchants.enchantment.registry.EnchantRegistry; import su.nightexpress.excellentenchants.enchantment.registry.EnchantRegistry;
import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils;
import su.nightexpress.excellentenchants.hook.HookPlugin; import su.nightexpress.excellentenchants.hook.HookPlugin;
import su.nightexpress.excellentenchants.hook.impl.PlaceholderHook; import su.nightexpress.excellentenchants.hook.impl.PlaceholderHook;
import su.nightexpress.excellentenchants.hook.impl.ProtocolHook; import su.nightexpress.excellentenchants.hook.impl.ProtocolLibHook;
import su.nightexpress.excellentenchants.nms.EnchantNMS; import su.nightexpress.excellentenchants.nms.EnchantNMS;
import su.nightexpress.excellentenchants.nms.v1_19_R3.V1_19_R3; import su.nightexpress.excellentenchants.nms.v1_19_R3.V1_19_R3;
import su.nightexpress.excellentenchants.nms.v1_20_R1.V1_20_R1; import su.nightexpress.excellentenchants.nms.v1_20_R1.V1_20_R1;
@ -41,6 +40,7 @@ public class EnchantsPlugin extends NightPlugin {
public void onLoad() { public void onLoad() {
super.onLoad(); super.onLoad();
this.registry = new EnchantRegistry(this); this.registry = new EnchantRegistry(this);
EnchantUtils.hook(this);
} }
@Override @Override
@ -60,8 +60,8 @@ public class EnchantsPlugin extends NightPlugin {
return; return;
} }
this.getLangManager().loadEnum(ItemCategory.class); //this.getLangManager().loadEnum(ItemCategory.class);
this.getLangManager().loadEnum(EnchantmentTarget.class); //this.getLangManager().loadEnum(EnchantmentTarget.class);
this.getLangManager().loadEnum(DistributionWay.class); this.getLangManager().loadEnum(DistributionWay.class);
this.getLangManager().loadEnum(Rarity.class); this.getLangManager().loadEnum(Rarity.class);
@ -75,15 +75,22 @@ public class EnchantsPlugin extends NightPlugin {
this.enchantManager = new EnchantManager(this); this.enchantManager = new EnchantManager(this);
this.enchantManager.setup(); this.enchantManager.setup();
if (Config.ENCHANTMENTS_DISPLAY_MODE.get() == 2) { if (Plugins.isInstalled(HookPlugin.PROTOCOL_LIB)) {
ProtocolLibHook.setup(this);
}
else {
this.warn(HookPlugin.PROTOCOL_LIB + " is not installed. Enchantment descriptions won't be displayed.");
}
/*if (Config.ENCHANTMENTS_DISPLAY_MODE.get() == 2) {
if (Plugins.isInstalled(HookPlugin.PROTOCOL_LIB)) { if (Plugins.isInstalled(HookPlugin.PROTOCOL_LIB)) {
ProtocolHook.setup(this); ProtocolLibHook.setup(this);
} }
else { else {
this.warn(HookPlugin.PROTOCOL_LIB + " is not installed. Display mode is set to Plain lore."); this.warn(HookPlugin.PROTOCOL_LIB + " is not installed. Display mode is set to Plain lore.");
Config.ENCHANTMENTS_DISPLAY_MODE.set(1); Config.ENCHANTMENTS_DISPLAY_MODE.set(1);
} }
} }*/
if (Plugins.hasPlaceholderAPI()) { if (Plugins.hasPlaceholderAPI()) {
PlaceholderHook.setup(this); PlaceholderHook.setup(this);
@ -111,6 +118,7 @@ public class EnchantsPlugin extends NightPlugin {
case V1_20_R2 -> new V1_20_R2(); case V1_20_R2 -> new V1_20_R2();
case V1_20_R3 -> new V1_20_R3(); case V1_20_R3 -> new V1_20_R3();
case MC_1_20_6 -> new Internal1_20_6(); case MC_1_20_6 -> new Internal1_20_6();
case MC_1_21 -> new Internal_1_21(this);
default -> null; default -> null;
}; };
return this.enchantNMS != null; return this.enchantNMS != null;

View File

@ -69,7 +69,7 @@ public class BookCommand extends AbstractCommand<EnchantsPlugin> {
ItemStack item = new ItemStack(Material.ENCHANTED_BOOK); ItemStack item = new ItemStack(Material.ENCHANTED_BOOK);
EnchantUtils.add(item, enchantment, level, true); EnchantUtils.add(item, enchantment, level, true);
EnchantUtils.updateDisplay(item); //EnchantUtils.updateDisplay(item);
Players.addItem(player, item); Players.addItem(player, item);
Lang.COMMAND_BOOK_DONE.getMessage() Lang.COMMAND_BOOK_DONE.getMessage()

View File

@ -82,7 +82,7 @@ public class EnchantCommand extends AbstractCommand<EnchantsPlugin> {
} }
else EnchantUtils.remove(item, enchantment); else EnchantUtils.remove(item, enchantment);
EnchantUtils.updateDisplay(item); //EnchantUtils.updateDisplay(item);
player.getInventory().setItem(slot, item); player.getInventory().setItem(slot, item);
(sender == player ? Lang.COMMAND_ENCHANT_DONE_SELF : Lang.COMMAND_ENCHANT_DONE_OTHERS).getMessage() (sender == player ? Lang.COMMAND_ENCHANT_DONE_SELF : Lang.COMMAND_ENCHANT_DONE_OTHERS).getMessage()

View File

@ -80,7 +80,7 @@ public class RarityBookCommand extends AbstractCommand<EnchantsPlugin> {
ItemStack item = new ItemStack(Material.ENCHANTED_BOOK); ItemStack item = new ItemStack(Material.ENCHANTED_BOOK);
EnchantUtils.add(item, enchantmentData.getEnchantment(), level, true); EnchantUtils.add(item, enchantmentData.getEnchantment(), level, true);
EnchantUtils.updateDisplay(item); //EnchantUtils.updateDisplay(item);
Players.addItem(player, item); Players.addItem(player, item);
Lang.COMMAND_RARITY_BOOK_DONE.getMessage() Lang.COMMAND_RARITY_BOOK_DONE.getMessage()

View File

@ -141,6 +141,7 @@ public class Config {
@Deprecated
public static final ConfigValue<Integer> ENCHANTMENTS_DISPLAY_MODE = ConfigValue.create("Enchantments.Display.Mode", public static final ConfigValue<Integer> ENCHANTMENTS_DISPLAY_MODE = ConfigValue.create("Enchantments.Display.Mode",
1, 1,
"Sets how enchantment names and descriptions will be handled on items.", "Sets how enchantment names and descriptions will be handled on items.",
@ -152,6 +153,7 @@ public class Config {
"Packet mode is slower, but instantly reflect all changes. In creative mode, there is a chance for lore duplication." "Packet mode is slower, but instantly reflect all changes. In creative mode, there is a chance for lore duplication."
); );
@Deprecated
public static final ConfigValue<Boolean> ENCHANTMENTS_DISPLAY_NAME_HIDE_1ST_LEVEL = ConfigValue.create("Enchantments.Display.Name.Hide_1st_Level", public static final ConfigValue<Boolean> ENCHANTMENTS_DISPLAY_NAME_HIDE_1ST_LEVEL = ConfigValue.create("Enchantments.Display.Name.Hide_1st_Level",
true, true,
"Hides enchantment level component from name format for level 1 enchantments."); "Hides enchantment level component from name format for level 1 enchantments.");
@ -198,9 +200,8 @@ public class Config {
"Sets whether or not only enchanted books will have enchantment descriptions."); "Sets whether or not only enchanted books will have enchantment descriptions.");
public static final ConfigValue<String> ENCHANTMENTS_DISPLAY_DESCRIPTION_FORMAT = ConfigValue.create("Enchantments.Display.Description.Format", public static final ConfigValue<String> ENCHANTMENTS_DISPLAY_DESCRIPTION_FORMAT = ConfigValue.create("Enchantments.Display.Description.Format",
LIGHT_GRAY.enclose("" + GENERIC_DESCRIPTION), LIGHT_GRAY.enclose("" + ENCHANTMENT_NAME + " " + ENCHANTMENT_CHARGES + ": " + GENERIC_DESCRIPTION),
"Sets enc" + "Sets enchantment description format.");
"hantment description format.");

View File

@ -4,6 +4,7 @@ import org.jetbrains.annotations.NotNull;
import su.nightexpress.nightcore.config.FileConfig; import su.nightexpress.nightcore.config.FileConfig;
import su.nightexpress.nightcore.util.wrapper.UniInt; import su.nightexpress.nightcore.util.wrapper.UniInt;
@Deprecated
public class DistributionWaySettings { public class DistributionWaySettings {
private final boolean enabled; private final boolean enabled;

View File

@ -6,6 +6,7 @@ import su.nightexpress.excellentenchants.EnchantsPlugin;
public class Keys { public class Keys {
@Deprecated
public static NamespacedKey loreSize; public static NamespacedKey loreSize;
public static NamespacedKey itemRecharged; public static NamespacedKey itemRecharged;

View File

@ -71,4 +71,31 @@ public class Lang extends CoreLang {
public static final LangText ERROR_INVALID_RARITY = LangText.of("Error.InvalidRarity", public static final LangText ERROR_INVALID_RARITY = LangText.of("Error.InvalidRarity",
RED.enclose("Invalid rarity!")); RED.enclose("Invalid rarity!"));
public static final LangString ITEM_CATEGORY_HELMET = LangString.of("ItemCategory.Helmet", "Helmet");
public static final LangString ITEM_CATEGORY_CHESTPLATE = LangString.of("ItemCategory.Chestplate", "Chestplate");
public static final LangString ITEM_CATEGORY_LEGGINGS = LangString.of("ItemCategory.Leggings", "Leggings");
public static final LangString ITEM_CATEGORY_BOOTS = LangString.of("ItemCategory.Boots", "Boots");
public static final LangString ITEM_CATEGORY_ELYTRA = LangString.of("ItemCategory.Elytra", "Elytra");
public static final LangString ITEM_CATEGORY_SWORD = LangString.of("ItemCategory.Sword", "Sword");
public static final LangString ITEM_CATEGORY_AXE = LangString.of("ItemCategory.Axe", "Axe");
public static final LangString ITEM_CATEGORY_HOE = LangString.of("ItemCategory.Hoe", "Hoe");
public static final LangString ITEM_CATEGORY_PICKAXE = LangString.of("ItemCategory.Pickaxe", "Pickaxe");
public static final LangString ITEM_CATEGORY_SHOVEL = LangString.of("ItemCategory.Shovel", "Shovel");
public static final LangString ITEM_CATEGORY_TRIDENT = LangString.of("ItemCategory.Trident", "Trident");
public static final LangString ITEM_CATEGORY_BOW = LangString.of("ItemCategory.Bow", "Bow");
public static final LangString ITEM_CATEGORY_CROSSBOW = LangString.of("ItemCategory.Crossbow", "Crossbow");
public static final LangString ITEM_CATEGORY_FISHING_ROD = LangString.of("ItemCategory.FishingRod", "FishingRod");
public static final LangString ITEM_CATEGORY_SHIELD = LangString.of("ItemCategory.Shield", "Shield");
public static final LangString ITEM_CATEGORY_BREAKABLE = LangString.of("ItemCategory.Breakable", "Breakable");
public static final LangString ITEM_CATEGORY_ARMOR = LangString.of("ItemCategory.Armor", "Armor");
public static final LangString ITEM_CATEGORY_TOOL = LangString.of("ItemCategory.Tool", "Tool");
public static final LangString ITEM_CATEGORY_WEAPON = LangString.of("ItemCategory.Weapon", "Sword/Axe");
public static final LangString ITEM_CATEGORY_BOWS = LangString.of("ItemCategory.Bows", "Bow/Crossbow");
public static final LangString ITEM_CATEGORY_TORSO = LangString.of("ItemCategory.Torso", "Chestplate/Elytra");
public static final LangString ITEM_CATEGORY_ALL_WEAPON = LangString.of("ItemCategory.AllWeapon", "All Weapon");
public static final LangString ITEM_CATEGORY_MINING_TOOLS = LangString.of("ItemCategory.MiningTools", "Mining Tools");
} }

View File

@ -16,7 +16,7 @@ public class Perms {
public static final UniPermission COMMAND_ENCHANT = new UniPermission(PREFIX_COMMAND + "enchant"); public static final UniPermission COMMAND_ENCHANT = new UniPermission(PREFIX_COMMAND + "enchant");
public static final UniPermission COMMAND_GET_FUEL = new UniPermission(PREFIX_COMMAND + "getfuel"); public static final UniPermission COMMAND_GET_FUEL = new UniPermission(PREFIX_COMMAND + "getfuel");
public static final UniPermission COMMAND_LIST = new UniPermission(PREFIX_COMMAND + "list", PermissionDefault.TRUE); public static final UniPermission COMMAND_LIST = new UniPermission(PREFIX_COMMAND + "list", PermissionDefault.TRUE);
public static final UniPermission COMMAND_LIST_OTHERS = new UniPermission(PREFIX_COMMAND + "list.others"); public static final UniPermission COMMAND_LIST_OTHERS = new UniPermission(PREFIX_COMMAND + "list.others");
public static final UniPermission COMMAND_RARITY_BOOK = new UniPermission(PREFIX_COMMAND + "raritybook"); public static final UniPermission COMMAND_RARITY_BOOK = new UniPermission(PREFIX_COMMAND + "raritybook");
public static final UniPermission COMMAND_RELOAD = new UniPermission(PREFIX_COMMAND + "reload"); public static final UniPermission COMMAND_RELOAD = new UniPermission(PREFIX_COMMAND + "reload");

View File

@ -17,6 +17,7 @@ import su.nightexpress.excellentenchants.enchantment.registry.EnchantRegistry;
import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils; import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils;
import su.nightexpress.nightcore.manager.AbstractManager; import su.nightexpress.nightcore.manager.AbstractManager;
import su.nightexpress.nightcore.util.Pair; import su.nightexpress.nightcore.util.Pair;
import su.nightexpress.nightcore.util.Version;
import java.util.*; import java.util.*;
@ -48,7 +49,7 @@ public class EnchantManager extends AbstractManager<EnchantsPlugin> {
this.plugin.info("Using custom distribution system. Applying patches..."); this.plugin.info("Using custom distribution system. Applying patches...");
this.addListener(new EnchantPopulationListener(this.plugin)); this.addListener(new EnchantPopulationListener(this.plugin));
} }
else { else if (Version.isBehind(Version.MC_1_21)) {
this.plugin.info("Using vanilla distribution. Applying enchanting table patches..."); this.plugin.info("Using vanilla distribution. Applying enchanting table patches...");
this.addListener(new EnchantVanillaListener(this.plugin)); this.addListener(new EnchantVanillaListener(this.plugin));
} }

View File

@ -253,9 +253,9 @@ public class EnchantPopulator {
} }
}); });
if (status.get()) { /*if (status.get()) {
EnchantUtils.updateDisplay(item); EnchantUtils.updateDisplay(item);
} }*/
return status.get(); return status.get();
} }

View File

@ -4,9 +4,7 @@ import org.bukkit.Material;
import org.bukkit.NamespacedKey; import org.bukkit.NamespacedKey;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.Enchantment;
import org.bukkit.enchantments.EnchantmentTarget;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.ItemMeta;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -16,7 +14,6 @@ import su.nightexpress.excellentenchants.api.DistributionWay;
import su.nightexpress.excellentenchants.api.Modifier; import su.nightexpress.excellentenchants.api.Modifier;
import su.nightexpress.excellentenchants.api.enchantment.Cost; import su.nightexpress.excellentenchants.api.enchantment.Cost;
import su.nightexpress.excellentenchants.api.enchantment.EnchantmentData; import su.nightexpress.excellentenchants.api.enchantment.EnchantmentData;
import su.nightexpress.excellentenchants.api.enchantment.ItemCategory;
import su.nightexpress.excellentenchants.api.enchantment.Rarity; import su.nightexpress.excellentenchants.api.enchantment.Rarity;
import su.nightexpress.excellentenchants.api.enchantment.data.ChanceData; import su.nightexpress.excellentenchants.api.enchantment.data.ChanceData;
import su.nightexpress.excellentenchants.api.enchantment.data.PeriodicData; import su.nightexpress.excellentenchants.api.enchantment.data.PeriodicData;
@ -41,7 +38,6 @@ import java.io.File;
import java.util.*; import java.util.*;
import java.util.function.Function; import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream;
import static su.nightexpress.excellentenchants.Placeholders.*; import static su.nightexpress.excellentenchants.Placeholders.*;
@ -184,7 +180,7 @@ public abstract class AbstractEnchantmentData extends AbstractFileData<EnchantsP
// TODO Check what actually does // TODO Check what actually does
this.setAnvilCost(ConfigValue.create("Anvil.Cost", this.setAnvilCost(ConfigValue.create("Anvil.Cost",
Rnd.get(8) + 1, Rnd.get(8) + 1,
"Sets enchantment anvil cost.", "The cost when applying this enchantment using an anvil. Halved when adding to a book, multiplied by the level of the enchantment.",
"[*] Works for 1.20.6+ only!" "[*] Works for 1.20.6+ only!"
).read(cfg)); ).read(cfg));
@ -192,19 +188,6 @@ public abstract class AbstractEnchantmentData extends AbstractFileData<EnchantsP
/*this.setAnvilMergeCost(Modifier.read(cfg, "Anvil.Merge.Cost",
Modifier.add(1, 1, 1),
"Sets XP cost to apply or transfer this enchantment using anvils."
));
this.setMaxMergeLevel(ConfigValue.create("Anvil.Merge.Max_Level",
-1,
"Max. enchantment level that can be obtained by combining 2 items with this enchantment.",
"Set to '-1' to remove limit and cap to max. enchantment level."
).read(cfg));*/
if (Config.ENCHANTMENTS_CHARGES_ENABLED.get() && !this.isCurse()) { if (Config.ENCHANTMENTS_CHARGES_ENABLED.get() && !this.isCurse()) {
this.setChargesEnabled(ConfigValue.create("Charges.Enabled", this.setChargesEnabled(ConfigValue.create("Charges.Enabled",
false, false,
@ -250,11 +233,7 @@ public abstract class AbstractEnchantmentData extends AbstractFileData<EnchantsP
.add(ENCHANTMENT_LEVEL_MIN, () -> String.valueOf(1)) .add(ENCHANTMENT_LEVEL_MIN, () -> String.valueOf(1))
.add(ENCHANTMENT_LEVEL_MAX, () -> String.valueOf(this.getMaxLevel())) .add(ENCHANTMENT_LEVEL_MAX, () -> String.valueOf(this.getMaxLevel()))
.add(ENCHANTMENT_RARITY, () -> plugin.getLangManager().getEnum(this.getRarity())) .add(ENCHANTMENT_RARITY, () -> plugin.getLangManager().getEnum(this.getRarity()))
.add(ENCHANTMENT_FIT_ITEM_TYPES, () -> { .add(ENCHANTMENT_FIT_ITEM_TYPES, () -> this.getSupportedItems().getLocalized())
if (this.getItemCategories().length == 0) return plugin.getLangManager().getEnum(this.getCategory());
return String.join(", ", Stream.of(this.getItemCategories()).map(type -> plugin.getLangManager().getEnum(type)).toList());
})
.add(ENCHANTMENT_CHARGES_MAX_AMOUNT, level -> NumberUtil.format(this.getChargesMax(level))) .add(ENCHANTMENT_CHARGES_MAX_AMOUNT, level -> NumberUtil.format(this.getChargesMax(level)))
.add(ENCHANTMENT_CHARGES_CONSUME_AMOUNT, level -> NumberUtil.format(this.getChargesConsumeAmount(level))) .add(ENCHANTMENT_CHARGES_CONSUME_AMOUNT, level -> NumberUtil.format(this.getChargesConsumeAmount(level)))
.add(ENCHANTMENT_CHARGES_RECHARGE_AMOUNT, level -> NumberUtil.format(this.getChargesRechargeAmount(level))) .add(ENCHANTMENT_CHARGES_RECHARGE_AMOUNT, level -> NumberUtil.format(this.getChargesRechargeAmount(level)))
@ -316,13 +295,13 @@ public abstract class AbstractEnchantmentData extends AbstractFileData<EnchantsP
this.placeholders.add(key, replacer); this.placeholders.add(key, replacer);
} }
@Override // @Override
@NotNull // @NotNull
public ItemCategory[] getItemCategories() { // public ItemCategory[] getItemCategories() {
return new ItemCategory[0]; // return new ItemCategory[0];
} // }
@Override /*@Override
public EquipmentSlot[] getSlots() { public EquipmentSlot[] getSlots() {
return switch (this.getCategory()) { return switch (this.getCategory()) {
case BOW, CROSSBOW, TRIDENT, FISHING_ROD, WEAPON, TOOL -> new EquipmentSlot[]{EquipmentSlot.HAND}; case BOW, CROSSBOW, TRIDENT, FISHING_ROD, WEAPON, TOOL -> new EquipmentSlot[]{EquipmentSlot.HAND};
@ -335,7 +314,7 @@ public abstract class AbstractEnchantmentData extends AbstractFileData<EnchantsP
case VANISHABLE -> EnchantUtils.EQUIPMENT_SLOTS; case VANISHABLE -> EnchantUtils.EQUIPMENT_SLOTS;
default -> throw new IllegalStateException("Unexpected value: " + this.getCategory()); default -> throw new IllegalStateException("Unexpected value: " + this.getCategory());
}; };
} }*/
@Override @Override
public boolean isAvailableToUse(@NotNull World world) { public boolean isAvailableToUse(@NotNull World world) {
@ -358,7 +337,7 @@ public abstract class AbstractEnchantmentData extends AbstractFileData<EnchantsP
return !EnchantUtils.hasMaximumEnchants(item); return !EnchantUtils.hasMaximumEnchants(item);
} }
@Override /*@Override
public final boolean checkEnchantCategory(@NotNull ItemStack item) { public final boolean checkEnchantCategory(@NotNull ItemStack item) {
EnchantmentTarget category = this.getCategory(); EnchantmentTarget category = this.getCategory();
@ -377,7 +356,7 @@ public abstract class AbstractEnchantmentData extends AbstractFileData<EnchantsP
@Override @Override
public boolean checkItemCategory(@NotNull ItemStack item) { public boolean checkItemCategory(@NotNull ItemStack item) {
return !this.hasItemCategory() || Stream.of(this.getItemCategories()).anyMatch(itemCategory -> itemCategory.isIncluded(item)); return !this.hasItemCategory() || Stream.of(this.getItemCategories()).anyMatch(itemCategory -> itemCategory.isIncluded(item));
} }*/
public int generateLevel() { public int generateLevel() {
return Rnd.get(1, this.getMaxLevel()); return Rnd.get(1, this.getMaxLevel());
@ -386,28 +365,9 @@ public abstract class AbstractEnchantmentData extends AbstractFileData<EnchantsP
@Override @Override
@NotNull @NotNull
public String getNameFormatted(int level, int charges) { public String getNameFormatted(int level, int charges) {
String rarityFormat = this.isCurse() ? Config.ENCHANTMENTS_DISPLAY_NAME_CURSE_FORMAT.get() : Config.ENCHANTMENTS_DISPLAY_NAME_RARITY_FORMAT.get().getOrDefault(this.getRarity(), GENERIC_NAME); String rarityFormat = this.isCurse() ? Config.ENCHANTMENTS_DISPLAY_NAME_CURSE_FORMAT.get() : Config.ENCHANTMENTS_DISPLAY_NAME_RARITY_FORMAT.get()
String chargesFormat = ""; .getOrDefault(this.getRarity(), GENERIC_NAME);
boolean showLevel = !Config.ENCHANTMENTS_DISPLAY_NAME_HIDE_1ST_LEVEL.get() || level > 1; String nameFormat = this.formatComponents(Config.ENCHANTMENTS_DISPLAY_NAME_FORMAT.get(), level, charges);
boolean showCharges = this.isChargesEnabled() && charges >= 0;
if (showCharges) {
int chargesMax = this.getChargesMax(level);
int percent = (int) Math.ceil((double) charges / (double) chargesMax * 100D);
Map.Entry<Integer, String> entry = Config.ENCHANTMENTS_CHARGES_FORMAT.get().floorEntry(percent);
if (entry != null) {
chargesFormat = entry.getValue().replace(GENERIC_AMOUNT, String.valueOf(charges));
}
}
String compName = Config.ENCHANTMENTS_DISPLAY_NAME_COMPONENT_NAME.get().replace(GENERIC_VALUE, this.getName());
String compLevel = showLevel ? Config.ENCHANTMENTS_DISPLAY_NAME_COMPONENT_LEVEL.get().replace(GENERIC_VALUE, NumberUtil.toRoman(level)) : "";
String compChrages = showCharges ? Config.ENCHANTMENTS_DISPLAY_NAME_COMPONENT_CHARGES.get().replace(GENERIC_VALUE, chargesFormat) : "";
String nameFormat = Config.ENCHANTMENTS_DISPLAY_NAME_FORMAT.get().
replace(ENCHANTMENT_NAME, compName)
.replace(ENCHANTMENT_LEVEL, compLevel)
.replace(ENCHANTMENT_CHARGES, compChrages);
return rarityFormat.replace(GENERIC_NAME, nameFormat); return rarityFormat.replace(GENERIC_NAME, nameFormat);
} }
@ -423,11 +383,42 @@ public abstract class AbstractEnchantmentData extends AbstractFileData<EnchantsP
@Override @Override
@NotNull @NotNull
public List<String> getDescriptionReplaced(int level) { public List<String> getDescriptionReplaced(int level) {
return this.getDescriptionReplaced(level, 0);
}
@Override
@NotNull
public List<String> getDescriptionReplaced(int level, int charges) {
List<String> description = new ArrayList<>(this.getDescriptionFormatted()); List<String> description = new ArrayList<>(this.getDescriptionFormatted());
description.replaceAll(this.getPlaceholders(level).replacer()); description.replaceAll(line -> this.getPlaceholders(level).replacer().apply(this.formatComponents(line, level, charges)));
return description; return description;
} }
@NotNull
private String formatComponents(@NotNull String string, int level, int charges) {
String chargesFormat = "";
boolean showLevel = this.getMaxLevel() > 1;
boolean showCharges = this.isChargesEnabled() && charges >= 0;
if (showCharges) {
int chargesMax = this.getChargesMax(level);
int percent = (int) Math.ceil((double) charges / (double) chargesMax * 100D);
Map.Entry<Integer, String> entry = Config.ENCHANTMENTS_CHARGES_FORMAT.get().floorEntry(percent);
if (entry != null) {
chargesFormat = entry.getValue().replace(GENERIC_AMOUNT, String.valueOf(charges));
}
}
String compName = Config.ENCHANTMENTS_DISPLAY_NAME_COMPONENT_NAME.get().replace(GENERIC_VALUE, this.getName());
String compLevel = showLevel ? Config.ENCHANTMENTS_DISPLAY_NAME_COMPONENT_LEVEL.get().replace(GENERIC_VALUE, NumberUtil.toRoman(level)) : "";
String compChrages = showCharges ? Config.ENCHANTMENTS_DISPLAY_NAME_COMPONENT_CHARGES.get().replace(GENERIC_VALUE, chargesFormat) : "";
return string
.replace(ENCHANTMENT_NAME, compName)
.replace(ENCHANTMENT_LEVEL, compLevel)
.replace(ENCHANTMENT_CHARGES, compChrages);
}
@Override @Override
public int getMinCost(int level) { public int getMinCost(int level) {
return this.getMinCost().calculate(level); return this.getMinCost().calculate(level);
@ -525,7 +516,7 @@ public abstract class AbstractEnchantmentData extends AbstractFileData<EnchantsP
if (!this.isChargesEnabled()) return; if (!this.isChargesEnabled()) return;
this.consumeChargesNoUpdate(item, level); this.consumeChargesNoUpdate(item, level);
EnchantUtils.updateDisplay(item); //EnchantUtils.updateDisplay(item);
} }
@Override @Override

View File

@ -0,0 +1,171 @@
package su.nightexpress.excellentenchants.enchantment.data;
import org.bukkit.Material;
import org.bukkit.Tag;
import org.bukkit.enchantments.EnchantmentTarget;
import org.bukkit.inventory.EquipmentSlot;
import org.jetbrains.annotations.NotNull;
import su.nightexpress.excellentenchants.api.enchantment.ItemsCategory;
import su.nightexpress.excellentenchants.config.Config;
import su.nightexpress.excellentenchants.config.Lang;
import su.nightexpress.nightcore.util.BukkitThing;
import java.util.HashSet;
import java.util.Set;
public class ItemCategories {
public static final ItemsCategory HELMET = ItemsCategory.buildDirect(getItemsBySlot(EquipmentSlot.HEAD)).slots(EquipmentSlot.HEAD)
.localized(Lang.ITEM_CATEGORY_HELMET)
.target(EnchantmentTarget.ARMOR_HEAD).build();
public static final ItemsCategory CHESTPLATE = ItemsCategory.buildDirect(getItemsBySlot(EquipmentSlot.CHEST)).slots(EquipmentSlot.CHEST)
.localized(Lang.ITEM_CATEGORY_CHESTPLATE)
.target(EnchantmentTarget.ARMOR_TORSO).build();
public static final ItemsCategory LEGGINGS = ItemsCategory.buildDirect(getItemsBySlot(EquipmentSlot.LEGS)).slots(EquipmentSlot.LEGS)
.localized(Lang.ITEM_CATEGORY_LEGGINGS)
.target(EnchantmentTarget.ARMOR_LEGS).build();
public static final ItemsCategory BOOTS = ItemsCategory.buildDirect(getItemsBySlot(EquipmentSlot.FEET)).slots(EquipmentSlot.FEET)
.localized(Lang.ITEM_CATEGORY_BOOTS)
.target(EnchantmentTarget.ARMOR_FEET).build();
public static final ItemsCategory ELYTRA = ItemsCategory.buildDirect(Material.ELYTRA).slots(EquipmentSlot.CHEST)
.localized(Lang.ITEM_CATEGORY_ELYTRA)
.target(EnchantmentTarget.ARMOR_TORSO).build();
public static final ItemsCategory SWORD = ItemsCategory.buildDirect(Tag.ITEMS_SWORDS).slots(EquipmentSlot.HAND)
.localized(Lang.ITEM_CATEGORY_SWORD)
.target(EnchantmentTarget.WEAPON).build();
public static final ItemsCategory AXE = ItemsCategory.buildDirect(Tag.ITEMS_AXES).slots(EquipmentSlot.HAND)
.localized(Lang.ITEM_CATEGORY_AXE)
.target(EnchantmentTarget.TOOL).build();
public static final ItemsCategory HOE = ItemsCategory.buildDirect(Tag.ITEMS_HOES).slots(EquipmentSlot.HAND)
.localized(Lang.ITEM_CATEGORY_HOE)
.target(EnchantmentTarget.TOOL).build();
public static final ItemsCategory PICKAXE = ItemsCategory.buildDirect(Tag.ITEMS_PICKAXES).slots(EquipmentSlot.HAND)
.localized(Lang.ITEM_CATEGORY_PICKAXE)
.target(EnchantmentTarget.TOOL).build();
public static final ItemsCategory SHOVEL = ItemsCategory.buildDirect(Tag.ITEMS_SHOVELS).slots(EquipmentSlot.HAND)
.localized(Lang.ITEM_CATEGORY_SHOVEL)
.target(EnchantmentTarget.TOOL).build();
public static final ItemsCategory TRIDENT = ItemsCategory.buildDirect(Material.TRIDENT).slots(EquipmentSlot.HAND, EquipmentSlot.OFF_HAND)
.localized(Lang.ITEM_CATEGORY_TRIDENT)
.target(EnchantmentTarget.TRIDENT).build();
public static final ItemsCategory BOW = ItemsCategory.buildDirect(Material.BOW).slots(EquipmentSlot.HAND, EquipmentSlot.OFF_HAND)
.localized(Lang.ITEM_CATEGORY_BOW)
.target(EnchantmentTarget.BOW).build();
public static final ItemsCategory CROSSBOW = ItemsCategory.buildDirect(Material.CROSSBOW).slots(EquipmentSlot.HAND, EquipmentSlot.OFF_HAND)
.localized(Lang.ITEM_CATEGORY_CROSSBOW)
.target(EnchantmentTarget.CROSSBOW).build();
public static final ItemsCategory FISHING_ROD = ItemsCategory.buildDirect(Material.FISHING_ROD).slots(EquipmentSlot.HAND, EquipmentSlot.OFF_HAND)
.localized(Lang.ITEM_CATEGORY_FISHING_ROD)
.target(EnchantmentTarget.FISHING_ROD).build();
public static final ItemsCategory SHIELD = ItemsCategory.buildDirect(Material.SHIELD).slots(EquipmentSlot.OFF_HAND)
.localized(Lang.ITEM_CATEGORY_SHIELD)
.target(EnchantmentTarget.BREAKABLE).build();
public static final ItemsCategory BREAKABLE = ItemsCategory.buildDirect(getItemsWithDurability()).slots(EquipmentSlot.values())
.localized(Lang.ITEM_CATEGORY_BREAKABLE)
.target(EnchantmentTarget.BREAKABLE).build();
public static final ItemsCategory ARMOR = ItemsCategory.buildRef(() -> {
Set<Material> materials = new HashSet<>();
materials.addAll(getItemsBySlot(EquipmentSlot.HEAD));
materials.addAll(getItemsBySlot(EquipmentSlot.CHEST));
materials.addAll(getItemsBySlot(EquipmentSlot.LEGS));
materials.addAll(getItemsBySlot(EquipmentSlot.FEET));
return materials;
}).slots(EquipmentSlot.HEAD, EquipmentSlot.CHEST, EquipmentSlot.LEGS, EquipmentSlot.FEET).target(EnchantmentTarget.ARMOR).localized(Lang.ITEM_CATEGORY_ARMOR).build();
public static final ItemsCategory TOOL = ItemsCategory.buildDirect(
Tag.ITEMS_AXES,
Tag.ITEMS_HOES,
Tag.ITEMS_PICKAXES,
Tag.ITEMS_SHOVELS
).slots(EquipmentSlot.HAND).target(EnchantmentTarget.TOOL).localized(Lang.ITEM_CATEGORY_TOOL).build();
public static final ItemsCategory WEAPON = ItemsCategory.buildRef(() -> {
Set<Material> materials = new HashSet<>(SWORD.getMaterials());
if (Config.CORE_SWORD_ENCHANTS_TO_AXES.get()) {
materials.addAll(AXE.getMaterials());
}
return materials;
}).slots(EquipmentSlot.HAND).target(EnchantmentTarget.WEAPON).localized(Lang.ITEM_CATEGORY_WEAPON).build();
public static final ItemsCategory BOWS = ItemsCategory.buildRef(() -> {
Set<Material> materials = new HashSet<>(BOW.getMaterials());
if (Config.CORE_BOW_ENCHANTS_TO_CROSSBOW.get()) {
materials.addAll(CROSSBOW.getMaterials());
}
return materials;
}).slots(EquipmentSlot.HAND, EquipmentSlot.OFF_HAND).target(EnchantmentTarget.BOW).localized(Lang.ITEM_CATEGORY_BOWS).build();
public static final ItemsCategory TORSO = ItemsCategory.buildRef(() -> {
Set<Material> materials = new HashSet<>(CHESTPLATE.getMaterials());
if (Config.CORE_CHESTPLATE_ENCHANTS_TO_ELYTRA.get()) {
materials.addAll(ELYTRA.getMaterials());
}
return materials;
}).slots(EquipmentSlot.CHEST).target(EnchantmentTarget.ARMOR_TORSO).localized(Lang.ITEM_CATEGORY_TORSO).build();
public static final ItemsCategory ALL_RANGE_WEAPON = ItemsCategory.buildRef(() -> {
Set<Material> materials = new HashSet<>();
materials.addAll(WEAPON.getMaterials());
materials.addAll(BOWS.getMaterials());
materials.addAll(TRIDENT.getMaterials());
materials.addAll(TOOL.getMaterials());
return materials;
}).slots(EquipmentSlot.HAND).target(EnchantmentTarget.BREAKABLE).localized(Lang.ITEM_CATEGORY_ALL_WEAPON).build();
public static final ItemsCategory MINING_TOOLS = ItemsCategory.buildRef(() -> {
Set<Material> materials = new HashSet<>();
materials.addAll(AXE.getMaterials());
materials.addAll(PICKAXE.getMaterials());
materials.addAll(SHOVEL.getMaterials());
return materials;
}).slots(EquipmentSlot.HAND).target(EnchantmentTarget.TOOL).localized(Lang.ITEM_CATEGORY_MINING_TOOLS).build();
@NotNull
private static Set<Material> getItemsBySlot(@NotNull EquipmentSlot slot) {
Set<Material> materials = new HashSet<>();
BukkitThing.getMaterials().forEach(material -> {
if (material.isItem() && material.getEquipmentSlot() == slot) {
materials.add(material);
}
});
return materials;
}
@NotNull
private static Set<Material> getItemsWithDurability() {
Set<Material> materials = new HashSet<>();
BukkitThing.getMaterials().forEach(material -> {
if (material.isItem() && material.getMaxDurability() > 0) {
materials.add(material);
}
});
return materials;
}
}

View File

@ -1,6 +1,5 @@
package su.nightexpress.excellentenchants.enchantment.impl.armor; package su.nightexpress.excellentenchants.enchantment.impl.armor;
import org.bukkit.enchantments.EnchantmentTarget;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
@ -9,6 +8,7 @@ import org.bukkit.potion.PotionEffectType;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import su.nightexpress.excellentenchants.EnchantsPlugin; import su.nightexpress.excellentenchants.EnchantsPlugin;
import su.nightexpress.excellentenchants.api.Modifier; import su.nightexpress.excellentenchants.api.Modifier;
import su.nightexpress.excellentenchants.api.enchantment.ItemsCategory;
import su.nightexpress.excellentenchants.api.enchantment.Rarity; import su.nightexpress.excellentenchants.api.enchantment.Rarity;
import su.nightexpress.excellentenchants.api.enchantment.data.ChanceData; import su.nightexpress.excellentenchants.api.enchantment.data.ChanceData;
import su.nightexpress.excellentenchants.api.enchantment.data.ChanceSettings; import su.nightexpress.excellentenchants.api.enchantment.data.ChanceSettings;
@ -17,6 +17,7 @@ import su.nightexpress.excellentenchants.api.enchantment.data.PotionSettings;
import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant;
import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData; import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData;
import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl; import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl;
import su.nightexpress.excellentenchants.enchantment.data.ItemCategories;
import su.nightexpress.excellentenchants.enchantment.data.PotionSettingsImpl; import su.nightexpress.excellentenchants.enchantment.data.PotionSettingsImpl;
import su.nightexpress.nightcore.config.FileConfig; import su.nightexpress.nightcore.config.FileConfig;
@ -62,10 +63,16 @@ public class ColdSteelEnchant extends AbstractEnchantmentData implements ChanceD
@Override @Override
@NotNull @NotNull
public EnchantmentTarget getCategory() { public ItemsCategory getSupportedItems() {
return EnchantmentTarget.ARMOR_TORSO; return ItemCategories.TORSO;
} }
// @Override
// @NotNull
// public EnchantmentTarget getCategory() {
// return EnchantmentTarget.ARMOR_TORSO;
// }
@NotNull @NotNull
@Override @Override
public EventPriority getProtectPriority() { public EventPriority getProtectPriority() {

View File

@ -1,7 +1,6 @@
package su.nightexpress.excellentenchants.enchantment.impl.armor; package su.nightexpress.excellentenchants.enchantment.impl.armor;
import org.bukkit.Particle; import org.bukkit.Particle;
import org.bukkit.enchantments.EnchantmentTarget;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
@ -10,6 +9,7 @@ import org.bukkit.potion.PotionEffectType;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import su.nightexpress.excellentenchants.EnchantsPlugin; import su.nightexpress.excellentenchants.EnchantsPlugin;
import su.nightexpress.excellentenchants.api.Modifier; import su.nightexpress.excellentenchants.api.Modifier;
import su.nightexpress.excellentenchants.api.enchantment.ItemsCategory;
import su.nightexpress.excellentenchants.api.enchantment.Rarity; import su.nightexpress.excellentenchants.api.enchantment.Rarity;
import su.nightexpress.excellentenchants.api.enchantment.data.ChanceData; import su.nightexpress.excellentenchants.api.enchantment.data.ChanceData;
import su.nightexpress.excellentenchants.api.enchantment.data.ChanceSettings; import su.nightexpress.excellentenchants.api.enchantment.data.ChanceSettings;
@ -18,6 +18,7 @@ import su.nightexpress.excellentenchants.api.enchantment.data.PotionSettings;
import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant;
import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData; import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData;
import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl; import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl;
import su.nightexpress.excellentenchants.enchantment.data.ItemCategories;
import su.nightexpress.excellentenchants.enchantment.data.PotionSettingsImpl; import su.nightexpress.excellentenchants.enchantment.data.PotionSettingsImpl;
import su.nightexpress.nightcore.config.FileConfig; import su.nightexpress.nightcore.config.FileConfig;
import su.nightexpress.nightcore.util.wrapper.UniParticle; import su.nightexpress.nightcore.util.wrapper.UniParticle;
@ -64,10 +65,16 @@ public class DarknessCloakEnchant extends AbstractEnchantmentData implements Cha
@Override @Override
@NotNull @NotNull
public EnchantmentTarget getCategory() { public ItemsCategory getSupportedItems() {
return EnchantmentTarget.ARMOR_TORSO; return ItemCategories.TORSO;
} }
// @Override
// @NotNull
// public EnchantmentTarget getCategory() {
// return EnchantmentTarget.ARMOR_TORSO;
// }
@NotNull @NotNull
@Override @Override
public EventPriority getProtectPriority() { public EventPriority getProtectPriority() {

View File

@ -1,6 +1,5 @@
package su.nightexpress.excellentenchants.enchantment.impl.armor; package su.nightexpress.excellentenchants.enchantment.impl.armor;
import org.bukkit.enchantments.EnchantmentTarget;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
@ -9,19 +8,23 @@ import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import su.nightexpress.excellentenchants.EnchantsPlugin; import su.nightexpress.excellentenchants.EnchantsPlugin;
import su.nightexpress.excellentenchants.api.Modifier; import su.nightexpress.excellentenchants.api.Modifier;
import su.nightexpress.excellentenchants.api.enchantment.ItemsCategory;
import su.nightexpress.excellentenchants.api.enchantment.Rarity; import su.nightexpress.excellentenchants.api.enchantment.Rarity;
import su.nightexpress.excellentenchants.api.enchantment.type.GenericEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.GenericEnchant;
import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData; import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData;
import su.nightexpress.excellentenchants.enchantment.data.ItemCategories;
import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils; import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils;
import su.nightexpress.nightcore.config.ConfigValue; import su.nightexpress.nightcore.config.ConfigValue;
import su.nightexpress.nightcore.config.FileConfig; import su.nightexpress.nightcore.config.FileConfig;
import su.nightexpress.nightcore.manager.SimpeListener; import su.nightexpress.nightcore.manager.SimpeListener;
import su.nightexpress.nightcore.util.EntityUtil;
import su.nightexpress.nightcore.util.NumberUtil; import su.nightexpress.nightcore.util.NumberUtil;
import java.io.File; import java.io.File;
import java.util.Set; import java.util.Set;
import static su.nightexpress.excellentenchants.Placeholders.*; import static su.nightexpress.excellentenchants.Placeholders.GENERIC_AMOUNT;
import static su.nightexpress.excellentenchants.Placeholders.GENERIC_MAX;
public class ElementalProtectionEnchant extends AbstractEnchantmentData implements SimpeListener, GenericEnchant { public class ElementalProtectionEnchant extends AbstractEnchantmentData implements SimpeListener, GenericEnchant {
@ -62,12 +65,18 @@ public class ElementalProtectionEnchant extends AbstractEnchantmentData implemen
this.addPlaceholder(GENERIC_MAX, level -> NumberUtil.format(this.getProtectionCapacity())); this.addPlaceholder(GENERIC_MAX, level -> NumberUtil.format(this.getProtectionCapacity()));
} }
@NotNull
@Override @Override
public EnchantmentTarget getCategory() { @NotNull
return EnchantmentTarget.ARMOR; public ItemsCategory getSupportedItems() {
return ItemCategories.ARMOR;
} }
// @NotNull
// @Override
// public EnchantmentTarget getCategory() {
// return EnchantmentTarget.ARMOR;
// }
public double getProtectionAmount(int level) { public double getProtectionAmount(int level) {
return this.protectionAmount.getValue(level); return this.protectionAmount.getValue(level);
} }
@ -86,8 +95,12 @@ public class ElementalProtectionEnchant extends AbstractEnchantmentData implemen
if (!(event.getEntity() instanceof LivingEntity entity)) return; if (!(event.getEntity() instanceof LivingEntity entity)) return;
if (!this.isAvailableToUse(entity)) return; if (!this.isAvailableToUse(entity)) return;
// TODO Work as percent to ignore damage
double protectionAmount = 0D; double protectionAmount = 0D;
for (ItemStack armor : EnchantUtils.getEnchantedEquipment(entity).values()) { for (ItemStack armor : EntityUtil.getEquippedArmor(entity).values()) {
if (armor == null || armor.getType().isAir()) continue;
int level = EnchantUtils.getLevel(armor, this.getEnchantment()); int level = EnchantUtils.getLevel(armor, this.getEnchantment());
if (level <= 0) continue; if (level <= 0) continue;

View File

@ -2,7 +2,6 @@ package su.nightexpress.excellentenchants.enchantment.impl.armor;
import org.bukkit.Particle; import org.bukkit.Particle;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.enchantments.EnchantmentTarget;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
@ -10,12 +9,14 @@ import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import su.nightexpress.excellentenchants.EnchantsPlugin; import su.nightexpress.excellentenchants.EnchantsPlugin;
import su.nightexpress.excellentenchants.api.Modifier; import su.nightexpress.excellentenchants.api.Modifier;
import su.nightexpress.excellentenchants.api.enchantment.ItemsCategory;
import su.nightexpress.excellentenchants.api.enchantment.Rarity; import su.nightexpress.excellentenchants.api.enchantment.Rarity;
import su.nightexpress.excellentenchants.api.enchantment.data.ChanceData; import su.nightexpress.excellentenchants.api.enchantment.data.ChanceData;
import su.nightexpress.excellentenchants.api.enchantment.data.ChanceSettings; import su.nightexpress.excellentenchants.api.enchantment.data.ChanceSettings;
import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant;
import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData; import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData;
import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl; import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl;
import su.nightexpress.excellentenchants.enchantment.data.ItemCategories;
import su.nightexpress.nightcore.config.FileConfig; import su.nightexpress.nightcore.config.FileConfig;
import su.nightexpress.nightcore.util.NumberUtil; import su.nightexpress.nightcore.util.NumberUtil;
import su.nightexpress.nightcore.util.wrapper.UniParticle; import su.nightexpress.nightcore.util.wrapper.UniParticle;
@ -23,7 +24,8 @@ import su.nightexpress.nightcore.util.wrapper.UniSound;
import java.io.File; import java.io.File;
import static su.nightexpress.excellentenchants.Placeholders.*; import static su.nightexpress.excellentenchants.Placeholders.ENCHANTMENT_CHANCE;
import static su.nightexpress.excellentenchants.Placeholders.GENERIC_DURATION;
public class FireShieldEnchant extends AbstractEnchantmentData implements ChanceData, CombatEnchant { public class FireShieldEnchant extends AbstractEnchantmentData implements ChanceData, CombatEnchant {
@ -58,12 +60,18 @@ public class FireShieldEnchant extends AbstractEnchantmentData implements Chance
return chanceSettings; return chanceSettings;
} }
@NotNull
@Override @Override
public EnchantmentTarget getCategory() { @NotNull
return EnchantmentTarget.ARMOR; public ItemsCategory getSupportedItems() {
return ItemCategories.ARMOR;
} }
// @NotNull
// @Override
// public EnchantmentTarget getCategory() {
// return EnchantmentTarget.ARMOR;
// }
@NotNull @NotNull
@Override @Override
public EventPriority getProtectPriority() { public EventPriority getProtectPriority() {

View File

@ -5,7 +5,6 @@ import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.Enchantment;
import org.bukkit.enchantments.EnchantmentTarget;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
@ -20,9 +19,11 @@ import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import su.nightexpress.excellentenchants.EnchantsPlugin; import su.nightexpress.excellentenchants.EnchantsPlugin;
import su.nightexpress.excellentenchants.api.Modifier; import su.nightexpress.excellentenchants.api.Modifier;
import su.nightexpress.excellentenchants.api.enchantment.ItemsCategory;
import su.nightexpress.excellentenchants.api.enchantment.Rarity; import su.nightexpress.excellentenchants.api.enchantment.Rarity;
import su.nightexpress.excellentenchants.api.enchantment.type.GenericEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.GenericEnchant;
import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData; import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData;
import su.nightexpress.excellentenchants.enchantment.data.ItemCategories;
import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils; import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils;
import su.nightexpress.nightcore.config.FileConfig; import su.nightexpress.nightcore.config.FileConfig;
import su.nightexpress.nightcore.manager.SimpeListener; import su.nightexpress.nightcore.manager.SimpeListener;
@ -107,10 +108,16 @@ public class FlameWalkerEnchant extends AbstractEnchantmentData implements Gener
@Override @Override
@NotNull @NotNull
public EnchantmentTarget getCategory() { public ItemsCategory getSupportedItems() {
return EnchantmentTarget.ARMOR_FEET; return ItemCategories.BOOTS;
} }
// @Override
// @NotNull
// public EnchantmentTarget getCategory() {
// return EnchantmentTarget.ARMOR_FEET;
// }
public double getBlockDecayTime(int level) { public double getBlockDecayTime(int level) {
return this.blockDecayTime.getValue(level); return this.blockDecayTime.getValue(level);
} }

View File

@ -1,6 +1,5 @@
package su.nightexpress.excellentenchants.enchantment.impl.armor; package su.nightexpress.excellentenchants.enchantment.impl.armor;
import org.bukkit.enchantments.EnchantmentTarget;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
@ -9,6 +8,7 @@ import org.bukkit.potion.PotionEffectType;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import su.nightexpress.excellentenchants.EnchantsPlugin; import su.nightexpress.excellentenchants.EnchantsPlugin;
import su.nightexpress.excellentenchants.api.Modifier; import su.nightexpress.excellentenchants.api.Modifier;
import su.nightexpress.excellentenchants.api.enchantment.ItemsCategory;
import su.nightexpress.excellentenchants.api.enchantment.Rarity; import su.nightexpress.excellentenchants.api.enchantment.Rarity;
import su.nightexpress.excellentenchants.api.enchantment.data.ChanceData; import su.nightexpress.excellentenchants.api.enchantment.data.ChanceData;
import su.nightexpress.excellentenchants.api.enchantment.data.ChanceSettings; import su.nightexpress.excellentenchants.api.enchantment.data.ChanceSettings;
@ -17,6 +17,7 @@ import su.nightexpress.excellentenchants.api.enchantment.data.PotionSettings;
import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant;
import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData; import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData;
import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl; import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl;
import su.nightexpress.excellentenchants.enchantment.data.ItemCategories;
import su.nightexpress.excellentenchants.enchantment.data.PotionSettingsImpl; import su.nightexpress.excellentenchants.enchantment.data.PotionSettingsImpl;
import su.nightexpress.nightcore.config.FileConfig; import su.nightexpress.nightcore.config.FileConfig;
@ -62,10 +63,16 @@ public class HardenedEnchant extends AbstractEnchantmentData implements ChanceDa
@Override @Override
@NotNull @NotNull
public EnchantmentTarget getCategory() { public ItemsCategory getSupportedItems() {
return EnchantmentTarget.ARMOR_TORSO; return ItemCategories.TORSO;
} }
// @Override
// @NotNull
// public EnchantmentTarget getCategory() {
// return EnchantmentTarget.ARMOR_TORSO;
// }
@NotNull @NotNull
@Override @Override
public EventPriority getProtectPriority() { public EventPriority getProtectPriority() {

View File

@ -3,7 +3,6 @@ package su.nightexpress.excellentenchants.enchantment.impl.armor;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Particle; import org.bukkit.Particle;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.enchantments.EnchantmentTarget;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
@ -12,6 +11,7 @@ import org.bukkit.potion.PotionEffectType;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import su.nightexpress.excellentenchants.EnchantsPlugin; import su.nightexpress.excellentenchants.EnchantsPlugin;
import su.nightexpress.excellentenchants.api.Modifier; import su.nightexpress.excellentenchants.api.Modifier;
import su.nightexpress.excellentenchants.api.enchantment.ItemsCategory;
import su.nightexpress.excellentenchants.api.enchantment.Rarity; import su.nightexpress.excellentenchants.api.enchantment.Rarity;
import su.nightexpress.excellentenchants.api.enchantment.data.ChanceData; import su.nightexpress.excellentenchants.api.enchantment.data.ChanceData;
import su.nightexpress.excellentenchants.api.enchantment.data.ChanceSettings; import su.nightexpress.excellentenchants.api.enchantment.data.ChanceSettings;
@ -20,6 +20,7 @@ import su.nightexpress.excellentenchants.api.enchantment.data.PotionSettings;
import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant;
import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData; import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData;
import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl; import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl;
import su.nightexpress.excellentenchants.enchantment.data.ItemCategories;
import su.nightexpress.excellentenchants.enchantment.data.PotionSettingsImpl; import su.nightexpress.excellentenchants.enchantment.data.PotionSettingsImpl;
import su.nightexpress.nightcore.config.FileConfig; import su.nightexpress.nightcore.config.FileConfig;
import su.nightexpress.nightcore.util.wrapper.UniParticle; import su.nightexpress.nightcore.util.wrapper.UniParticle;
@ -53,12 +54,18 @@ public class IceShieldEnchant extends AbstractEnchantmentData implements ChanceD
); );
} }
@NotNull
@Override @Override
public EnchantmentTarget getCategory() { @NotNull
return EnchantmentTarget.ARMOR_TORSO; public ItemsCategory getSupportedItems() {
return ItemCategories.TORSO;
} }
// @NotNull
// @Override
// public EnchantmentTarget getCategory() {
// return EnchantmentTarget.ARMOR_TORSO;
// }
@NotNull @NotNull
@Override @Override
public EventPriority getProtectPriority() { public EventPriority getProtectPriority() {

View File

@ -1,24 +1,26 @@
package su.nightexpress.excellentenchants.enchantment.impl.armor; package su.nightexpress.excellentenchants.enchantment.impl.armor;
import org.bukkit.enchantments.EnchantmentTarget;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import su.nightexpress.excellentenchants.EnchantsPlugin; import su.nightexpress.excellentenchants.EnchantsPlugin;
import su.nightexpress.excellentenchants.api.enchantment.ItemsCategory;
import su.nightexpress.excellentenchants.api.enchantment.Rarity; import su.nightexpress.excellentenchants.api.enchantment.Rarity;
import su.nightexpress.excellentenchants.api.enchantment.data.PeriodicSettings; import su.nightexpress.excellentenchants.api.enchantment.data.PeriodicSettings;
import su.nightexpress.excellentenchants.api.enchantment.data.PotionData; import su.nightexpress.excellentenchants.api.enchantment.data.PotionData;
import su.nightexpress.excellentenchants.api.enchantment.data.PotionSettings; import su.nightexpress.excellentenchants.api.enchantment.data.PotionSettings;
import su.nightexpress.excellentenchants.api.enchantment.type.PassiveEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.PassiveEnchant;
import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData; import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData;
import su.nightexpress.excellentenchants.enchantment.data.ItemCategories;
import su.nightexpress.excellentenchants.enchantment.data.PeriodSettingsImpl; import su.nightexpress.excellentenchants.enchantment.data.PeriodSettingsImpl;
import su.nightexpress.excellentenchants.enchantment.data.PotionSettingsImpl; import su.nightexpress.excellentenchants.enchantment.data.PotionSettingsImpl;
import su.nightexpress.nightcore.config.FileConfig; import su.nightexpress.nightcore.config.FileConfig;
import java.io.File; import java.io.File;
import static su.nightexpress.excellentenchants.Placeholders.*; import static su.nightexpress.excellentenchants.Placeholders.ENCHANTMENT_POTION_LEVEL;
import static su.nightexpress.excellentenchants.Placeholders.ENCHANTMENT_POTION_TYPE;
public class JumpingEnchant extends AbstractEnchantmentData implements PotionData, PassiveEnchant { public class JumpingEnchant extends AbstractEnchantmentData implements PotionData, PassiveEnchant {
@ -54,10 +56,16 @@ public class JumpingEnchant extends AbstractEnchantmentData implements PotionDat
@Override @Override
@NotNull @NotNull
public EnchantmentTarget getCategory() { public ItemsCategory getSupportedItems() {
return EnchantmentTarget.ARMOR_FEET; return ItemCategories.BOOTS;
} }
// @Override
// @NotNull
// public EnchantmentTarget getCategory() {
// return EnchantmentTarget.ARMOR_FEET;
// }
@Override @Override
public boolean onTrigger(@NotNull LivingEntity entity, @NotNull ItemStack item, int level) { public boolean onTrigger(@NotNull LivingEntity entity, @NotNull ItemStack item, int level) {
return this.addEffect(entity, level); return this.addEffect(entity, level);

View File

@ -1,7 +1,6 @@
package su.nightexpress.excellentenchants.enchantment.impl.armor; package su.nightexpress.excellentenchants.enchantment.impl.armor;
import org.bukkit.Particle; import org.bukkit.Particle;
import org.bukkit.enchantments.EnchantmentTarget;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.Item; import org.bukkit.entity.Item;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
@ -15,12 +14,14 @@ import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import su.nightexpress.excellentenchants.EnchantsPlugin; import su.nightexpress.excellentenchants.EnchantsPlugin;
import su.nightexpress.excellentenchants.api.Modifier; import su.nightexpress.excellentenchants.api.Modifier;
import su.nightexpress.excellentenchants.api.enchantment.ItemsCategory;
import su.nightexpress.excellentenchants.api.enchantment.Rarity; import su.nightexpress.excellentenchants.api.enchantment.Rarity;
import su.nightexpress.excellentenchants.api.enchantment.data.ChanceData; import su.nightexpress.excellentenchants.api.enchantment.data.ChanceData;
import su.nightexpress.excellentenchants.api.enchantment.data.ChanceSettings; import su.nightexpress.excellentenchants.api.enchantment.data.ChanceSettings;
import su.nightexpress.excellentenchants.api.enchantment.type.DeathEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.DeathEnchant;
import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData; import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData;
import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl; import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl;
import su.nightexpress.excellentenchants.enchantment.data.ItemCategories;
import su.nightexpress.nightcore.config.ConfigValue; import su.nightexpress.nightcore.config.ConfigValue;
import su.nightexpress.nightcore.config.FileConfig; import su.nightexpress.nightcore.config.FileConfig;
import su.nightexpress.nightcore.manager.SimpeListener; import su.nightexpress.nightcore.manager.SimpeListener;
@ -28,7 +29,7 @@ import su.nightexpress.nightcore.util.wrapper.UniParticle;
import java.io.File; import java.io.File;
import static su.nightexpress.excellentenchants.Placeholders.*; import static su.nightexpress.excellentenchants.Placeholders.ENCHANTMENT_CHANCE;
public class KamikadzeEnchant extends AbstractEnchantmentData implements ChanceData, DeathEnchant, SimpeListener { public class KamikadzeEnchant extends AbstractEnchantmentData implements ChanceData, DeathEnchant, SimpeListener {
@ -70,10 +71,16 @@ public class KamikadzeEnchant extends AbstractEnchantmentData implements ChanceD
@Override @Override
@NotNull @NotNull
public EnchantmentTarget getCategory() { public ItemsCategory getSupportedItems() {
return EnchantmentTarget.ARMOR_TORSO; return ItemCategories.TORSO;
} }
// @Override
// @NotNull
// public EnchantmentTarget getCategory() {
// return EnchantmentTarget.ARMOR_TORSO;
// }
public boolean isApplyOnResurrect() { public boolean isApplyOnResurrect() {
return this.applyOnResurrect; return this.applyOnResurrect;
} }

View File

@ -1,24 +1,26 @@
package su.nightexpress.excellentenchants.enchantment.impl.armor; package su.nightexpress.excellentenchants.enchantment.impl.armor;
import org.bukkit.enchantments.EnchantmentTarget;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import su.nightexpress.excellentenchants.EnchantsPlugin; import su.nightexpress.excellentenchants.EnchantsPlugin;
import su.nightexpress.excellentenchants.api.enchantment.ItemsCategory;
import su.nightexpress.excellentenchants.api.enchantment.Rarity; import su.nightexpress.excellentenchants.api.enchantment.Rarity;
import su.nightexpress.excellentenchants.api.enchantment.data.PeriodicSettings; import su.nightexpress.excellentenchants.api.enchantment.data.PeriodicSettings;
import su.nightexpress.excellentenchants.api.enchantment.data.PotionData; import su.nightexpress.excellentenchants.api.enchantment.data.PotionData;
import su.nightexpress.excellentenchants.api.enchantment.data.PotionSettings; import su.nightexpress.excellentenchants.api.enchantment.data.PotionSettings;
import su.nightexpress.excellentenchants.api.enchantment.type.PassiveEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.PassiveEnchant;
import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData; import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData;
import su.nightexpress.excellentenchants.enchantment.data.ItemCategories;
import su.nightexpress.excellentenchants.enchantment.data.PeriodSettingsImpl; import su.nightexpress.excellentenchants.enchantment.data.PeriodSettingsImpl;
import su.nightexpress.excellentenchants.enchantment.data.PotionSettingsImpl; import su.nightexpress.excellentenchants.enchantment.data.PotionSettingsImpl;
import su.nightexpress.nightcore.config.FileConfig; import su.nightexpress.nightcore.config.FileConfig;
import java.io.File; import java.io.File;
import static su.nightexpress.excellentenchants.Placeholders.*; import static su.nightexpress.excellentenchants.Placeholders.ENCHANTMENT_POTION_LEVEL;
import static su.nightexpress.excellentenchants.Placeholders.ENCHANTMENT_POTION_TYPE;
public class NightVisionEnchant extends AbstractEnchantmentData implements PotionData, PassiveEnchant { public class NightVisionEnchant extends AbstractEnchantmentData implements PotionData, PassiveEnchant {
@ -54,10 +56,16 @@ public class NightVisionEnchant extends AbstractEnchantmentData implements Potio
@Override @Override
@NotNull @NotNull
public EnchantmentTarget getCategory() { public ItemsCategory getSupportedItems() {
return EnchantmentTarget.ARMOR_HEAD; return ItemCategories.HELMET;
} }
// @Override
// @NotNull
// public EnchantmentTarget getCategory() {
// return EnchantmentTarget.ARMOR_HEAD;
// }
@Override @Override
public boolean onTrigger(@NotNull LivingEntity entity, @NotNull ItemStack item, int level) { public boolean onTrigger(@NotNull LivingEntity entity, @NotNull ItemStack item, int level) {
return this.addEffect(entity, level); return this.addEffect(entity, level);

View File

@ -2,12 +2,12 @@ package su.nightexpress.excellentenchants.enchantment.impl.armor;
import org.bukkit.Particle; import org.bukkit.Particle;
import org.bukkit.attribute.Attribute; import org.bukkit.attribute.Attribute;
import org.bukkit.enchantments.EnchantmentTarget;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import su.nightexpress.excellentenchants.EnchantsPlugin; import su.nightexpress.excellentenchants.EnchantsPlugin;
import su.nightexpress.excellentenchants.api.Modifier; import su.nightexpress.excellentenchants.api.Modifier;
import su.nightexpress.excellentenchants.api.enchantment.ItemsCategory;
import su.nightexpress.excellentenchants.api.enchantment.Rarity; import su.nightexpress.excellentenchants.api.enchantment.Rarity;
import su.nightexpress.excellentenchants.api.enchantment.data.ChanceData; import su.nightexpress.excellentenchants.api.enchantment.data.ChanceData;
import su.nightexpress.excellentenchants.api.enchantment.data.ChanceSettings; import su.nightexpress.excellentenchants.api.enchantment.data.ChanceSettings;
@ -15,6 +15,7 @@ import su.nightexpress.excellentenchants.api.enchantment.data.PeriodicSettings;
import su.nightexpress.excellentenchants.api.enchantment.type.PassiveEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.PassiveEnchant;
import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData; import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData;
import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl; import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl;
import su.nightexpress.excellentenchants.enchantment.data.ItemCategories;
import su.nightexpress.excellentenchants.enchantment.data.PeriodSettingsImpl; import su.nightexpress.excellentenchants.enchantment.data.PeriodSettingsImpl;
import su.nightexpress.nightcore.config.FileConfig; import su.nightexpress.nightcore.config.FileConfig;
import su.nightexpress.nightcore.util.EntityUtil; import su.nightexpress.nightcore.util.EntityUtil;
@ -81,12 +82,18 @@ public class RegrowthEnchant extends AbstractEnchantmentData implements ChanceDa
return periodSettings; return periodSettings;
} }
@NotNull
@Override @Override
public EnchantmentTarget getCategory() { @NotNull
return EnchantmentTarget.ARMOR_TORSO; public ItemsCategory getSupportedItems() {
return ItemCategories.TORSO;
} }
// @NotNull
// @Override
// public EnchantmentTarget getCategory() {
// return EnchantmentTarget.ARMOR_TORSO;
// }
public double getHealAmount(int level) { public double getHealAmount(int level) {
return this.healAmount.getValue(level); return this.healAmount.getValue(level);
} }

View File

@ -1,23 +1,25 @@
package su.nightexpress.excellentenchants.enchantment.impl.armor; package su.nightexpress.excellentenchants.enchantment.impl.armor;
import org.bukkit.enchantments.EnchantmentTarget;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import su.nightexpress.excellentenchants.EnchantsPlugin; import su.nightexpress.excellentenchants.EnchantsPlugin;
import su.nightexpress.excellentenchants.api.Modifier; import su.nightexpress.excellentenchants.api.Modifier;
import su.nightexpress.excellentenchants.api.enchantment.ItemsCategory;
import su.nightexpress.excellentenchants.api.enchantment.Rarity; import su.nightexpress.excellentenchants.api.enchantment.Rarity;
import su.nightexpress.excellentenchants.api.enchantment.data.PeriodicSettings; import su.nightexpress.excellentenchants.api.enchantment.data.PeriodicSettings;
import su.nightexpress.excellentenchants.api.enchantment.type.PassiveEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.PassiveEnchant;
import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData; import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData;
import su.nightexpress.excellentenchants.enchantment.data.ItemCategories;
import su.nightexpress.excellentenchants.enchantment.data.PeriodSettingsImpl; import su.nightexpress.excellentenchants.enchantment.data.PeriodSettingsImpl;
import su.nightexpress.nightcore.config.FileConfig; import su.nightexpress.nightcore.config.FileConfig;
import su.nightexpress.nightcore.util.NumberUtil; import su.nightexpress.nightcore.util.NumberUtil;
import java.io.File; import java.io.File;
import static su.nightexpress.excellentenchants.Placeholders.*; import static su.nightexpress.excellentenchants.Placeholders.GENERIC_AMOUNT;
import static su.nightexpress.excellentenchants.Placeholders.GENERIC_MAX;
public class SaturationEnchant extends AbstractEnchantmentData implements PassiveEnchant { public class SaturationEnchant extends AbstractEnchantmentData implements PassiveEnchant {
@ -59,10 +61,16 @@ public class SaturationEnchant extends AbstractEnchantmentData implements Passiv
@Override @Override
@NotNull @NotNull
public EnchantmentTarget getCategory() { public ItemsCategory getSupportedItems() {
return EnchantmentTarget.ARMOR_HEAD; return ItemCategories.HELMET;
} }
// @Override
// @NotNull
// public EnchantmentTarget getCategory() {
// return EnchantmentTarget.ARMOR_HEAD;
// }
public final int getFeedAmount(int level) { public final int getFeedAmount(int level) {
return (int) this.feedAmount.getValue(level); return (int) this.feedAmount.getValue(level);
} }

View File

@ -1,24 +1,26 @@
package su.nightexpress.excellentenchants.enchantment.impl.armor; package su.nightexpress.excellentenchants.enchantment.impl.armor;
import org.bukkit.enchantments.EnchantmentTarget;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import su.nightexpress.excellentenchants.EnchantsPlugin; import su.nightexpress.excellentenchants.EnchantsPlugin;
import su.nightexpress.excellentenchants.api.enchantment.ItemsCategory;
import su.nightexpress.excellentenchants.api.enchantment.Rarity; import su.nightexpress.excellentenchants.api.enchantment.Rarity;
import su.nightexpress.excellentenchants.api.enchantment.data.PeriodicSettings; import su.nightexpress.excellentenchants.api.enchantment.data.PeriodicSettings;
import su.nightexpress.excellentenchants.api.enchantment.data.PotionData; import su.nightexpress.excellentenchants.api.enchantment.data.PotionData;
import su.nightexpress.excellentenchants.api.enchantment.data.PotionSettings; import su.nightexpress.excellentenchants.api.enchantment.data.PotionSettings;
import su.nightexpress.excellentenchants.api.enchantment.type.PassiveEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.PassiveEnchant;
import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData; import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData;
import su.nightexpress.excellentenchants.enchantment.data.ItemCategories;
import su.nightexpress.excellentenchants.enchantment.data.PeriodSettingsImpl; import su.nightexpress.excellentenchants.enchantment.data.PeriodSettingsImpl;
import su.nightexpress.excellentenchants.enchantment.data.PotionSettingsImpl; import su.nightexpress.excellentenchants.enchantment.data.PotionSettingsImpl;
import su.nightexpress.nightcore.config.FileConfig; import su.nightexpress.nightcore.config.FileConfig;
import java.io.File; import java.io.File;
import static su.nightexpress.excellentenchants.Placeholders.*; import static su.nightexpress.excellentenchants.Placeholders.ENCHANTMENT_POTION_LEVEL;
import static su.nightexpress.excellentenchants.Placeholders.ENCHANTMENT_POTION_TYPE;
public class SpeedyEnchant extends AbstractEnchantmentData implements PotionData, PassiveEnchant { public class SpeedyEnchant extends AbstractEnchantmentData implements PotionData, PassiveEnchant {
@ -54,10 +56,16 @@ public class SpeedyEnchant extends AbstractEnchantmentData implements PotionData
@Override @Override
@NotNull @NotNull
public EnchantmentTarget getCategory() { public ItemsCategory getSupportedItems() {
return EnchantmentTarget.ARMOR_FEET; return ItemCategories.BOOTS;
} }
// @Override
// @NotNull
// public EnchantmentTarget getCategory() {
// return EnchantmentTarget.ARMOR_FEET;
// }
@Override @Override
public boolean onTrigger(@NotNull LivingEntity entity, @NotNull ItemStack item, int level) { public boolean onTrigger(@NotNull LivingEntity entity, @NotNull ItemStack item, int level) {
return this.addEffect(entity, level); return this.addEffect(entity, level);

View File

@ -1,6 +1,5 @@
package su.nightexpress.excellentenchants.enchantment.impl.armor; package su.nightexpress.excellentenchants.enchantment.impl.armor;
import org.bukkit.enchantments.EnchantmentTarget;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
@ -8,18 +7,21 @@ import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import su.nightexpress.excellentenchants.EnchantsPlugin; import su.nightexpress.excellentenchants.EnchantsPlugin;
import su.nightexpress.excellentenchants.api.Modifier; import su.nightexpress.excellentenchants.api.Modifier;
import su.nightexpress.excellentenchants.api.enchantment.ItemsCategory;
import su.nightexpress.excellentenchants.api.enchantment.Rarity; import su.nightexpress.excellentenchants.api.enchantment.Rarity;
import su.nightexpress.excellentenchants.api.enchantment.data.ChanceData; import su.nightexpress.excellentenchants.api.enchantment.data.ChanceData;
import su.nightexpress.excellentenchants.api.enchantment.data.ChanceSettings; import su.nightexpress.excellentenchants.api.enchantment.data.ChanceSettings;
import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant;
import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData; import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData;
import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl; import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl;
import su.nightexpress.excellentenchants.enchantment.data.ItemCategories;
import su.nightexpress.nightcore.config.FileConfig; import su.nightexpress.nightcore.config.FileConfig;
import su.nightexpress.nightcore.util.NumberUtil; import su.nightexpress.nightcore.util.NumberUtil;
import java.io.File; import java.io.File;
import static su.nightexpress.excellentenchants.Placeholders.*; import static su.nightexpress.excellentenchants.Placeholders.ENCHANTMENT_CHANCE;
import static su.nightexpress.excellentenchants.Placeholders.GENERIC_AMOUNT;
public class StoppingForceEnchant extends AbstractEnchantmentData implements ChanceData, CombatEnchant { public class StoppingForceEnchant extends AbstractEnchantmentData implements ChanceData, CombatEnchant {
@ -50,10 +52,16 @@ public class StoppingForceEnchant extends AbstractEnchantmentData implements Cha
return this.knockbackModifier.getValue(level); return this.knockbackModifier.getValue(level);
} }
@NotNull // @NotNull
// @Override
// public EnchantmentTarget getCategory() {
// return EnchantmentTarget.ARMOR_LEGS;
// }
@Override @Override
public EnchantmentTarget getCategory() { @NotNull
return EnchantmentTarget.ARMOR_LEGS; public ItemsCategory getSupportedItems() {
return ItemCategories.LEGGINGS;
} }
@NotNull @NotNull

View File

@ -1,6 +1,5 @@
package su.nightexpress.excellentenchants.enchantment.impl.armor; package su.nightexpress.excellentenchants.enchantment.impl.armor;
import org.bukkit.enchantments.EnchantmentTarget;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
@ -13,12 +12,14 @@ import org.bukkit.loot.LootTables;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import su.nightexpress.excellentenchants.EnchantsPlugin; import su.nightexpress.excellentenchants.EnchantsPlugin;
import su.nightexpress.excellentenchants.api.Modifier; import su.nightexpress.excellentenchants.api.Modifier;
import su.nightexpress.excellentenchants.api.enchantment.ItemsCategory;
import su.nightexpress.excellentenchants.api.enchantment.Rarity; import su.nightexpress.excellentenchants.api.enchantment.Rarity;
import su.nightexpress.excellentenchants.api.enchantment.data.ChanceData; import su.nightexpress.excellentenchants.api.enchantment.data.ChanceData;
import su.nightexpress.excellentenchants.api.enchantment.data.ChanceSettings; import su.nightexpress.excellentenchants.api.enchantment.data.ChanceSettings;
import su.nightexpress.excellentenchants.api.enchantment.type.GenericEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.GenericEnchant;
import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData; import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData;
import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl; import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl;
import su.nightexpress.excellentenchants.enchantment.data.ItemCategories;
import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils; import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils;
import su.nightexpress.nightcore.config.ConfigValue; import su.nightexpress.nightcore.config.ConfigValue;
import su.nightexpress.nightcore.config.FileConfig; import su.nightexpress.nightcore.config.FileConfig;
@ -27,9 +28,12 @@ import su.nightexpress.nightcore.util.StringUtil;
import su.nightexpress.nightcore.util.random.Rnd; import su.nightexpress.nightcore.util.random.Rnd;
import java.io.File; import java.io.File;
import java.util.*; import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import static su.nightexpress.excellentenchants.Placeholders.*; import static su.nightexpress.excellentenchants.Placeholders.ENCHANTMENT_CHANCE;
public class TreasureHunterEnchant extends AbstractEnchantmentData implements ChanceData, GenericEnchant, SimpeListener { public class TreasureHunterEnchant extends AbstractEnchantmentData implements ChanceData, GenericEnchant, SimpeListener {
@ -92,10 +96,16 @@ public class TreasureHunterEnchant extends AbstractEnchantmentData implements Ch
@Override @Override
@NotNull @NotNull
public EnchantmentTarget getCategory() { public ItemsCategory getSupportedItems() {
return EnchantmentTarget.ARMOR_HEAD; return ItemCategories.HELMET;
} }
// @Override
// @NotNull
// public EnchantmentTarget getCategory() {
// return EnchantmentTarget.ARMOR_HEAD;
// }
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onLootExplore(LootGenerateEvent event) { public void onLootExplore(LootGenerateEvent event) {
if (this.lootTables.isEmpty()) return; if (this.lootTables.isEmpty()) return;

View File

@ -1,24 +1,26 @@
package su.nightexpress.excellentenchants.enchantment.impl.armor; package su.nightexpress.excellentenchants.enchantment.impl.armor;
import org.bukkit.enchantments.EnchantmentTarget;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import su.nightexpress.excellentenchants.EnchantsPlugin; import su.nightexpress.excellentenchants.EnchantsPlugin;
import su.nightexpress.excellentenchants.api.enchantment.ItemsCategory;
import su.nightexpress.excellentenchants.api.enchantment.Rarity; import su.nightexpress.excellentenchants.api.enchantment.Rarity;
import su.nightexpress.excellentenchants.api.enchantment.data.PeriodicSettings; import su.nightexpress.excellentenchants.api.enchantment.data.PeriodicSettings;
import su.nightexpress.excellentenchants.api.enchantment.data.PotionData; import su.nightexpress.excellentenchants.api.enchantment.data.PotionData;
import su.nightexpress.excellentenchants.api.enchantment.data.PotionSettings; import su.nightexpress.excellentenchants.api.enchantment.data.PotionSettings;
import su.nightexpress.excellentenchants.api.enchantment.type.PassiveEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.PassiveEnchant;
import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData; import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData;
import su.nightexpress.excellentenchants.enchantment.data.ItemCategories;
import su.nightexpress.excellentenchants.enchantment.data.PeriodSettingsImpl; import su.nightexpress.excellentenchants.enchantment.data.PeriodSettingsImpl;
import su.nightexpress.excellentenchants.enchantment.data.PotionSettingsImpl; import su.nightexpress.excellentenchants.enchantment.data.PotionSettingsImpl;
import su.nightexpress.nightcore.config.FileConfig; import su.nightexpress.nightcore.config.FileConfig;
import java.io.File; import java.io.File;
import static su.nightexpress.excellentenchants.Placeholders.*; import static su.nightexpress.excellentenchants.Placeholders.ENCHANTMENT_POTION_LEVEL;
import static su.nightexpress.excellentenchants.Placeholders.ENCHANTMENT_POTION_TYPE;
public class WaterBreathingEnchant extends AbstractEnchantmentData implements PotionData, PassiveEnchant { public class WaterBreathingEnchant extends AbstractEnchantmentData implements PotionData, PassiveEnchant {
@ -54,10 +56,16 @@ public class WaterBreathingEnchant extends AbstractEnchantmentData implements Po
@Override @Override
@NotNull @NotNull
public EnchantmentTarget getCategory() { public ItemsCategory getSupportedItems() {
return EnchantmentTarget.ARMOR_HEAD; return ItemCategories.HELMET;
} }
// @Override
// @NotNull
// public EnchantmentTarget getCategory() {
// return EnchantmentTarget.ARMOR_HEAD;
// }
@Override @Override
public boolean onTrigger(@NotNull LivingEntity entity, @NotNull ItemStack item, int level) { public boolean onTrigger(@NotNull LivingEntity entity, @NotNull ItemStack item, int level) {
return this.addEffect(entity, level); return this.addEffect(entity, level);

View File

@ -1,7 +1,6 @@
package su.nightexpress.excellentenchants.enchantment.impl.bow; package su.nightexpress.excellentenchants.enchantment.impl.bow;
import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.Enchantment;
import org.bukkit.enchantments.EnchantmentTarget;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Projectile; import org.bukkit.entity.Projectile;
import org.bukkit.entity.TNTPrimed; import org.bukkit.entity.TNTPrimed;
@ -13,18 +12,21 @@ import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import su.nightexpress.excellentenchants.EnchantsPlugin; import su.nightexpress.excellentenchants.EnchantsPlugin;
import su.nightexpress.excellentenchants.api.Modifier; import su.nightexpress.excellentenchants.api.Modifier;
import su.nightexpress.excellentenchants.api.enchantment.ItemsCategory;
import su.nightexpress.excellentenchants.api.enchantment.Rarity; import su.nightexpress.excellentenchants.api.enchantment.Rarity;
import su.nightexpress.excellentenchants.api.enchantment.data.ChanceData; import su.nightexpress.excellentenchants.api.enchantment.data.ChanceData;
import su.nightexpress.excellentenchants.api.enchantment.data.ChanceSettings; import su.nightexpress.excellentenchants.api.enchantment.data.ChanceSettings;
import su.nightexpress.excellentenchants.api.enchantment.type.BowEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.BowEnchant;
import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData; import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData;
import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl; import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl;
import su.nightexpress.excellentenchants.enchantment.data.ItemCategories;
import su.nightexpress.nightcore.config.FileConfig; import su.nightexpress.nightcore.config.FileConfig;
import su.nightexpress.nightcore.util.NumberUtil; import su.nightexpress.nightcore.util.NumberUtil;
import java.io.File; import java.io.File;
import static su.nightexpress.excellentenchants.Placeholders.*; import static su.nightexpress.excellentenchants.Placeholders.ENCHANTMENT_CHANCE;
import static su.nightexpress.excellentenchants.Placeholders.GENERIC_TIME;
public class BomberEnchant extends AbstractEnchantmentData implements ChanceData, BowEnchant { public class BomberEnchant extends AbstractEnchantmentData implements ChanceData, BowEnchant {
@ -73,10 +75,16 @@ public class BomberEnchant extends AbstractEnchantmentData implements ChanceData
@Override @Override
@NotNull @NotNull
public EnchantmentTarget getCategory() { public ItemsCategory getSupportedItems() {
return EnchantmentTarget.BOW; return ItemCategories.BOWS;
} }
// @Override
// @NotNull
// public EnchantmentTarget getCategory() {
// return EnchantmentTarget.BOW;
// }
@NotNull @NotNull
@Override @Override
public EventPriority getShootPriority() { public EventPriority getShootPriority() {

View File

@ -1,7 +1,6 @@
package su.nightexpress.excellentenchants.enchantment.impl.bow; package su.nightexpress.excellentenchants.enchantment.impl.bow;
import org.bukkit.Particle; import org.bukkit.Particle;
import org.bukkit.enchantments.EnchantmentTarget;
import org.bukkit.entity.AbstractArrow; import org.bukkit.entity.AbstractArrow;
import org.bukkit.entity.Arrow; import org.bukkit.entity.Arrow;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
@ -14,13 +13,11 @@ import org.bukkit.potion.PotionEffectType;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import su.nightexpress.excellentenchants.EnchantsPlugin; import su.nightexpress.excellentenchants.EnchantsPlugin;
import su.nightexpress.excellentenchants.api.Modifier; import su.nightexpress.excellentenchants.api.Modifier;
import su.nightexpress.excellentenchants.api.enchantment.ItemsCategory;
import su.nightexpress.excellentenchants.api.enchantment.Rarity; import su.nightexpress.excellentenchants.api.enchantment.Rarity;
import su.nightexpress.excellentenchants.api.enchantment.data.*; import su.nightexpress.excellentenchants.api.enchantment.data.*;
import su.nightexpress.excellentenchants.api.enchantment.type.BowEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.BowEnchant;
import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData; import su.nightexpress.excellentenchants.enchantment.data.*;
import su.nightexpress.excellentenchants.enchantment.data.ArrowSettingsImpl;
import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl;
import su.nightexpress.excellentenchants.enchantment.data.PotionSettingsImpl;
import su.nightexpress.nightcore.config.FileConfig; import su.nightexpress.nightcore.config.FileConfig;
import su.nightexpress.nightcore.util.wrapper.UniParticle; import su.nightexpress.nightcore.util.wrapper.UniParticle;
@ -74,12 +71,18 @@ public class ConfusingArrowsEnchant extends AbstractEnchantmentData implements C
return potionSettings; return potionSettings;
} }
@NotNull
@Override @Override
public EnchantmentTarget getCategory() { @NotNull
return EnchantmentTarget.BOW; public ItemsCategory getSupportedItems() {
return ItemCategories.BOWS;
} }
// @NotNull
// @Override
// public EnchantmentTarget getCategory() {
// return EnchantmentTarget.BOW;
// }
@Override @Override
public boolean onShoot(@NotNull EntityShootBowEvent event, @NotNull LivingEntity shooter, @NotNull ItemStack bow, int level) { public boolean onShoot(@NotNull EntityShootBowEvent event, @NotNull LivingEntity shooter, @NotNull ItemStack bow, int level) {
if (!(event.getProjectile() instanceof Arrow arrow)) return false; if (!(event.getProjectile() instanceof Arrow arrow)) return false;

View File

@ -1,7 +1,6 @@
package su.nightexpress.excellentenchants.enchantment.impl.bow; package su.nightexpress.excellentenchants.enchantment.impl.bow;
import org.bukkit.Particle; import org.bukkit.Particle;
import org.bukkit.enchantments.EnchantmentTarget;
import org.bukkit.entity.AbstractArrow; import org.bukkit.entity.AbstractArrow;
import org.bukkit.entity.Arrow; import org.bukkit.entity.Arrow;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
@ -14,13 +13,11 @@ import org.bukkit.potion.PotionEffectType;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import su.nightexpress.excellentenchants.EnchantsPlugin; import su.nightexpress.excellentenchants.EnchantsPlugin;
import su.nightexpress.excellentenchants.api.Modifier; import su.nightexpress.excellentenchants.api.Modifier;
import su.nightexpress.excellentenchants.api.enchantment.ItemsCategory;
import su.nightexpress.excellentenchants.api.enchantment.Rarity; import su.nightexpress.excellentenchants.api.enchantment.Rarity;
import su.nightexpress.excellentenchants.api.enchantment.data.*; import su.nightexpress.excellentenchants.api.enchantment.data.*;
import su.nightexpress.excellentenchants.api.enchantment.type.BowEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.BowEnchant;
import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData; import su.nightexpress.excellentenchants.enchantment.data.*;
import su.nightexpress.excellentenchants.enchantment.data.ArrowSettingsImpl;
import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl;
import su.nightexpress.excellentenchants.enchantment.data.PotionSettingsImpl;
import su.nightexpress.nightcore.config.FileConfig; import su.nightexpress.nightcore.config.FileConfig;
import su.nightexpress.nightcore.util.wrapper.UniParticle; import su.nightexpress.nightcore.util.wrapper.UniParticle;
@ -74,12 +71,18 @@ public class DarknessArrowsEnchant extends AbstractEnchantmentData implements Ch
return potionSettings; return potionSettings;
} }
@NotNull
@Override @Override
public EnchantmentTarget getCategory() { @NotNull
return EnchantmentTarget.BOW; public ItemsCategory getSupportedItems() {
return ItemCategories.BOWS;
} }
// @NotNull
// @Override
// public EnchantmentTarget getCategory() {
// return EnchantmentTarget.BOW;
// }
@Override @Override
public boolean onShoot(@NotNull EntityShootBowEvent event, @NotNull LivingEntity shooter, @NotNull ItemStack bow, int level) { public boolean onShoot(@NotNull EntityShootBowEvent event, @NotNull LivingEntity shooter, @NotNull ItemStack bow, int level) {
if (!(event.getProjectile() instanceof Arrow arrow)) return false; if (!(event.getProjectile() instanceof Arrow arrow)) return false;

View File

@ -6,7 +6,6 @@ import org.bukkit.Particle;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.enchantments.EnchantmentTarget;
import org.bukkit.entity.*; import org.bukkit.entity.*;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityShootBowEvent; import org.bukkit.event.entity.EntityShootBowEvent;
@ -21,6 +20,7 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import su.nightexpress.excellentenchants.EnchantsPlugin; import su.nightexpress.excellentenchants.EnchantsPlugin;
import su.nightexpress.excellentenchants.api.Modifier; import su.nightexpress.excellentenchants.api.Modifier;
import su.nightexpress.excellentenchants.api.enchantment.ItemsCategory;
import su.nightexpress.excellentenchants.api.enchantment.Rarity; import su.nightexpress.excellentenchants.api.enchantment.Rarity;
import su.nightexpress.excellentenchants.api.enchantment.data.ArrowData; import su.nightexpress.excellentenchants.api.enchantment.data.ArrowData;
import su.nightexpress.excellentenchants.api.enchantment.data.ArrowSettings; import su.nightexpress.excellentenchants.api.enchantment.data.ArrowSettings;
@ -30,6 +30,7 @@ import su.nightexpress.excellentenchants.api.enchantment.type.BowEnchant;
import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData; import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData;
import su.nightexpress.excellentenchants.enchantment.data.ArrowSettingsImpl; import su.nightexpress.excellentenchants.enchantment.data.ArrowSettingsImpl;
import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl; import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl;
import su.nightexpress.excellentenchants.enchantment.data.ItemCategories;
import su.nightexpress.nightcore.config.FileConfig; import su.nightexpress.nightcore.config.FileConfig;
import su.nightexpress.nightcore.util.ItemUtil; import su.nightexpress.nightcore.util.ItemUtil;
import su.nightexpress.nightcore.util.NumberUtil; import su.nightexpress.nightcore.util.NumberUtil;
@ -88,12 +89,18 @@ public class DragonfireArrowsEnchant extends AbstractEnchantmentData implements
return chanceSettings; return chanceSettings;
} }
@NotNull
@Override @Override
public EnchantmentTarget getCategory() { @NotNull
return EnchantmentTarget.BOW; public ItemsCategory getSupportedItems() {
return ItemCategories.BOWS;
} }
// @NotNull
// @Override
// public EnchantmentTarget getCategory() {
// return EnchantmentTarget.BOW;
// }
public int getFireDuration(int level) { public int getFireDuration(int level) {
return (int) this.fireDuration.getValue(level); return (int) this.fireDuration.getValue(level);
} }

View File

@ -4,7 +4,6 @@ import org.bukkit.Location;
import org.bukkit.Particle; import org.bukkit.Particle;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.enchantments.EnchantmentTarget;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Projectile; import org.bukkit.entity.Projectile;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
@ -14,6 +13,7 @@ import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import su.nightexpress.excellentenchants.EnchantsPlugin; import su.nightexpress.excellentenchants.EnchantsPlugin;
import su.nightexpress.excellentenchants.api.Modifier; import su.nightexpress.excellentenchants.api.Modifier;
import su.nightexpress.excellentenchants.api.enchantment.ItemsCategory;
import su.nightexpress.excellentenchants.api.enchantment.Rarity; import su.nightexpress.excellentenchants.api.enchantment.Rarity;
import su.nightexpress.excellentenchants.api.enchantment.data.ArrowData; import su.nightexpress.excellentenchants.api.enchantment.data.ArrowData;
import su.nightexpress.excellentenchants.api.enchantment.data.ArrowSettings; import su.nightexpress.excellentenchants.api.enchantment.data.ArrowSettings;
@ -23,6 +23,7 @@ import su.nightexpress.excellentenchants.api.enchantment.type.BowEnchant;
import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData; import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData;
import su.nightexpress.excellentenchants.enchantment.data.ArrowSettingsImpl; import su.nightexpress.excellentenchants.enchantment.data.ArrowSettingsImpl;
import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl; import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl;
import su.nightexpress.excellentenchants.enchantment.data.ItemCategories;
import su.nightexpress.nightcore.config.ConfigValue; import su.nightexpress.nightcore.config.ConfigValue;
import su.nightexpress.nightcore.config.FileConfig; import su.nightexpress.nightcore.config.FileConfig;
import su.nightexpress.nightcore.util.LocationUtil; import su.nightexpress.nightcore.util.LocationUtil;
@ -90,11 +91,17 @@ public class ElectrifiedArrowsEnchant extends AbstractEnchantmentData implements
return this.damageModifier.getValue(level); return this.damageModifier.getValue(level);
} }
@NotNull
@Override @Override
public EnchantmentTarget getCategory() { @NotNull
return EnchantmentTarget.BOW; public ItemsCategory getSupportedItems() {
return ItemCategories.BOWS;
} }
//
// @NotNull
// @Override
// public EnchantmentTarget getCategory() {
// return EnchantmentTarget.BOW;
// }
private void summonLightning(@NotNull Block block) { private void summonLightning(@NotNull Block block) {
Location location = block.getLocation(); Location location = block.getLocation();

View File

@ -1,7 +1,6 @@
package su.nightexpress.excellentenchants.enchantment.impl.bow; package su.nightexpress.excellentenchants.enchantment.impl.bow;
import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.Enchantment;
import org.bukkit.enchantments.EnchantmentTarget;
import org.bukkit.entity.EnderPearl; import org.bukkit.entity.EnderPearl;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Projectile; import org.bukkit.entity.Projectile;
@ -12,12 +11,14 @@ import org.bukkit.event.entity.ProjectileHitEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import su.nightexpress.excellentenchants.EnchantsPlugin; import su.nightexpress.excellentenchants.EnchantsPlugin;
import su.nightexpress.excellentenchants.api.enchantment.ItemsCategory;
import su.nightexpress.excellentenchants.api.enchantment.Rarity; import su.nightexpress.excellentenchants.api.enchantment.Rarity;
import su.nightexpress.excellentenchants.api.enchantment.data.ChanceData; import su.nightexpress.excellentenchants.api.enchantment.data.ChanceData;
import su.nightexpress.excellentenchants.api.enchantment.data.ChanceSettings; import su.nightexpress.excellentenchants.api.enchantment.data.ChanceSettings;
import su.nightexpress.excellentenchants.api.enchantment.type.BowEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.BowEnchant;
import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData; import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData;
import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl; import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl;
import su.nightexpress.excellentenchants.enchantment.data.ItemCategories;
import su.nightexpress.nightcore.config.FileConfig; import su.nightexpress.nightcore.config.FileConfig;
import java.io.File; import java.io.File;
@ -59,10 +60,16 @@ public class EnderBowEnchant extends AbstractEnchantmentData implements ChanceDa
@Override @Override
@NotNull @NotNull
public EnchantmentTarget getCategory() { public ItemsCategory getSupportedItems() {
return EnchantmentTarget.BOW; return ItemCategories.BOWS;
} }
// @Override
// @NotNull
// public EnchantmentTarget getCategory() {
// return EnchantmentTarget.BOW;
// }
@NotNull @NotNull
@Override @Override
public EventPriority getShootPriority() { public EventPriority getShootPriority() {

View File

@ -2,7 +2,6 @@ package su.nightexpress.excellentenchants.enchantment.impl.bow;
import org.bukkit.Particle; import org.bukkit.Particle;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.enchantments.EnchantmentTarget;
import org.bukkit.entity.*; import org.bukkit.entity.*;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
@ -14,6 +13,7 @@ import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import su.nightexpress.excellentenchants.EnchantsPlugin; import su.nightexpress.excellentenchants.EnchantsPlugin;
import su.nightexpress.excellentenchants.api.Modifier; import su.nightexpress.excellentenchants.api.Modifier;
import su.nightexpress.excellentenchants.api.enchantment.ItemsCategory;
import su.nightexpress.excellentenchants.api.enchantment.Rarity; import su.nightexpress.excellentenchants.api.enchantment.Rarity;
import su.nightexpress.excellentenchants.api.enchantment.data.ArrowData; import su.nightexpress.excellentenchants.api.enchantment.data.ArrowData;
import su.nightexpress.excellentenchants.api.enchantment.data.ArrowSettings; import su.nightexpress.excellentenchants.api.enchantment.data.ArrowSettings;
@ -23,6 +23,7 @@ import su.nightexpress.excellentenchants.api.enchantment.type.BowEnchant;
import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData; import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData;
import su.nightexpress.excellentenchants.enchantment.data.ArrowSettingsImpl; import su.nightexpress.excellentenchants.enchantment.data.ArrowSettingsImpl;
import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl; import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl;
import su.nightexpress.excellentenchants.enchantment.data.ItemCategories;
import su.nightexpress.nightcore.config.ConfigValue; import su.nightexpress.nightcore.config.ConfigValue;
import su.nightexpress.nightcore.config.FileConfig; import su.nightexpress.nightcore.config.FileConfig;
import su.nightexpress.nightcore.manager.SimpeListener; import su.nightexpress.nightcore.manager.SimpeListener;
@ -31,7 +32,8 @@ import su.nightexpress.nightcore.util.wrapper.UniParticle;
import java.io.File; import java.io.File;
import static su.nightexpress.excellentenchants.Placeholders.*; import static su.nightexpress.excellentenchants.Placeholders.ENCHANTMENT_CHANCE;
import static su.nightexpress.excellentenchants.Placeholders.GENERIC_RADIUS;
public class ExplosiveArrowsEnchant extends AbstractEnchantmentData implements ChanceData, ArrowData, BowEnchant, SimpeListener { public class ExplosiveArrowsEnchant extends AbstractEnchantmentData implements ChanceData, ArrowData, BowEnchant, SimpeListener {
@ -92,12 +94,18 @@ public class ExplosiveArrowsEnchant extends AbstractEnchantmentData implements C
return chanceSettings; return chanceSettings;
} }
@NotNull
@Override @Override
public EnchantmentTarget getCategory() { @NotNull
return EnchantmentTarget.BOW; public ItemsCategory getSupportedItems() {
return ItemCategories.BOWS;
} }
// @NotNull
// @Override
// public EnchantmentTarget getCategory() {
// return EnchantmentTarget.BOW;
// }
public final double getExplosionSize(int level) { public final double getExplosionSize(int level) {
return this.explosionSize.getValue(level); return this.explosionSize.getValue(level);
} }

View File

@ -5,7 +5,6 @@ import org.bukkit.Particle;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.block.data.Directional; import org.bukkit.block.data.Directional;
import org.bukkit.enchantments.EnchantmentTarget;
import org.bukkit.entity.Arrow; import org.bukkit.entity.Arrow;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -19,6 +18,7 @@ import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import su.nightexpress.excellentenchants.EnchantsPlugin; import su.nightexpress.excellentenchants.EnchantsPlugin;
import su.nightexpress.excellentenchants.api.enchantment.ItemsCategory;
import su.nightexpress.excellentenchants.api.enchantment.Rarity; import su.nightexpress.excellentenchants.api.enchantment.Rarity;
import su.nightexpress.excellentenchants.api.enchantment.data.ArrowData; import su.nightexpress.excellentenchants.api.enchantment.data.ArrowData;
import su.nightexpress.excellentenchants.api.enchantment.data.ArrowSettings; import su.nightexpress.excellentenchants.api.enchantment.data.ArrowSettings;
@ -28,12 +28,13 @@ import su.nightexpress.excellentenchants.api.enchantment.type.BowEnchant;
import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData; import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData;
import su.nightexpress.excellentenchants.enchantment.data.ArrowSettingsImpl; import su.nightexpress.excellentenchants.enchantment.data.ArrowSettingsImpl;
import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl; import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl;
import su.nightexpress.excellentenchants.enchantment.data.ItemCategories;
import su.nightexpress.nightcore.config.FileConfig; import su.nightexpress.nightcore.config.FileConfig;
import su.nightexpress.nightcore.util.wrapper.UniParticle; import su.nightexpress.nightcore.util.wrapper.UniParticle;
import java.io.File; import java.io.File;
import static su.nightexpress.excellentenchants.Placeholders.*; import static su.nightexpress.excellentenchants.Placeholders.ENCHANTMENT_CHANCE;
public class FlareEnchant extends AbstractEnchantmentData implements ChanceData, ArrowData, BowEnchant { public class FlareEnchant extends AbstractEnchantmentData implements ChanceData, ArrowData, BowEnchant {
@ -56,12 +57,18 @@ public class FlareEnchant extends AbstractEnchantmentData implements ChanceData,
this.arrowSettings = ArrowSettingsImpl.create(config, UniParticle.of(Particle.FIREWORKS_SPARK)); this.arrowSettings = ArrowSettingsImpl.create(config, UniParticle.of(Particle.FIREWORKS_SPARK));
} }
@NotNull
@Override @Override
public EnchantmentTarget getCategory() { @NotNull
return EnchantmentTarget.BOW; public ItemsCategory getSupportedItems() {
return ItemCategories.BOWS;
} }
// @NotNull
// @Override
// public EnchantmentTarget getCategory() {
// return EnchantmentTarget.BOW;
// }
@NotNull @NotNull
@Override @Override
public EventPriority getHitPriority() { public EventPriority getHitPriority() {

View File

@ -1,7 +1,6 @@
package su.nightexpress.excellentenchants.enchantment.impl.bow; package su.nightexpress.excellentenchants.enchantment.impl.bow;
import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.Enchantment;
import org.bukkit.enchantments.EnchantmentTarget;
import org.bukkit.entity.Fireball; import org.bukkit.entity.Fireball;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Projectile; import org.bukkit.entity.Projectile;
@ -14,12 +13,14 @@ import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import su.nightexpress.excellentenchants.EnchantsPlugin; import su.nightexpress.excellentenchants.EnchantsPlugin;
import su.nightexpress.excellentenchants.api.Modifier; import su.nightexpress.excellentenchants.api.Modifier;
import su.nightexpress.excellentenchants.api.enchantment.ItemsCategory;
import su.nightexpress.excellentenchants.api.enchantment.Rarity; import su.nightexpress.excellentenchants.api.enchantment.Rarity;
import su.nightexpress.excellentenchants.api.enchantment.data.ChanceData; import su.nightexpress.excellentenchants.api.enchantment.data.ChanceData;
import su.nightexpress.excellentenchants.api.enchantment.data.ChanceSettings; import su.nightexpress.excellentenchants.api.enchantment.data.ChanceSettings;
import su.nightexpress.excellentenchants.api.enchantment.type.BowEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.BowEnchant;
import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData; import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData;
import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl; import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl;
import su.nightexpress.excellentenchants.enchantment.data.ItemCategories;
import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils; import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils;
import su.nightexpress.nightcore.config.ConfigValue; import su.nightexpress.nightcore.config.ConfigValue;
import su.nightexpress.nightcore.config.FileConfig; import su.nightexpress.nightcore.config.FileConfig;
@ -81,10 +82,16 @@ public class GhastEnchant extends AbstractEnchantmentData implements ChanceData,
@Override @Override
@NotNull @NotNull
public EnchantmentTarget getCategory() { public ItemsCategory getSupportedItems() {
return EnchantmentTarget.BOW; return ItemCategories.BOWS;
} }
// @Override
// @NotNull
// public EnchantmentTarget getCategory() {
// return EnchantmentTarget.BOW;
// }
@NotNull @NotNull
@Override @Override
public EventPriority getShootPriority() { public EventPriority getShootPriority() {

View File

@ -1,7 +1,6 @@
package su.nightexpress.excellentenchants.enchantment.impl.bow; package su.nightexpress.excellentenchants.enchantment.impl.bow;
import org.bukkit.Particle; import org.bukkit.Particle;
import org.bukkit.enchantments.EnchantmentTarget;
import org.bukkit.entity.AbstractArrow; import org.bukkit.entity.AbstractArrow;
import org.bukkit.entity.Arrow; import org.bukkit.entity.Arrow;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
@ -14,13 +13,11 @@ import org.bukkit.potion.PotionEffectType;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import su.nightexpress.excellentenchants.EnchantsPlugin; import su.nightexpress.excellentenchants.EnchantsPlugin;
import su.nightexpress.excellentenchants.api.Modifier; import su.nightexpress.excellentenchants.api.Modifier;
import su.nightexpress.excellentenchants.api.enchantment.ItemsCategory;
import su.nightexpress.excellentenchants.api.enchantment.Rarity; import su.nightexpress.excellentenchants.api.enchantment.Rarity;
import su.nightexpress.excellentenchants.api.enchantment.data.*; import su.nightexpress.excellentenchants.api.enchantment.data.*;
import su.nightexpress.excellentenchants.api.enchantment.type.BowEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.BowEnchant;
import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData; import su.nightexpress.excellentenchants.enchantment.data.*;
import su.nightexpress.excellentenchants.enchantment.data.ArrowSettingsImpl;
import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl;
import su.nightexpress.excellentenchants.enchantment.data.PotionSettingsImpl;
import su.nightexpress.nightcore.config.FileConfig; import su.nightexpress.nightcore.config.FileConfig;
import su.nightexpress.nightcore.util.wrapper.UniParticle; import su.nightexpress.nightcore.util.wrapper.UniParticle;
@ -74,12 +71,18 @@ public class HoverEnchant extends AbstractEnchantmentData implements ChanceData,
return potionSettings; return potionSettings;
} }
@NotNull
@Override @Override
public EnchantmentTarget getCategory() { @NotNull
return EnchantmentTarget.BOW; public ItemsCategory getSupportedItems() {
return ItemCategories.BOWS;
} }
// @NotNull
// @Override
// public EnchantmentTarget getCategory() {
// return EnchantmentTarget.BOW;
// }
@Override @Override
public boolean onShoot(@NotNull EntityShootBowEvent event, @NotNull LivingEntity shooter, @NotNull ItemStack bow, int level) { public boolean onShoot(@NotNull EntityShootBowEvent event, @NotNull LivingEntity shooter, @NotNull ItemStack bow, int level) {
if (!(event.getProjectile() instanceof Arrow arrow)) return false; if (!(event.getProjectile() instanceof Arrow arrow)) return false;

View File

@ -1,7 +1,6 @@
package su.nightexpress.excellentenchants.enchantment.impl.bow; package su.nightexpress.excellentenchants.enchantment.impl.bow;
import org.bukkit.Particle; import org.bukkit.Particle;
import org.bukkit.enchantments.EnchantmentTarget;
import org.bukkit.entity.AbstractArrow; import org.bukkit.entity.AbstractArrow;
import org.bukkit.entity.Arrow; import org.bukkit.entity.Arrow;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
@ -14,13 +13,11 @@ import org.bukkit.potion.PotionEffectType;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import su.nightexpress.excellentenchants.EnchantsPlugin; import su.nightexpress.excellentenchants.EnchantsPlugin;
import su.nightexpress.excellentenchants.api.Modifier; import su.nightexpress.excellentenchants.api.Modifier;
import su.nightexpress.excellentenchants.api.enchantment.ItemsCategory;
import su.nightexpress.excellentenchants.api.enchantment.Rarity; import su.nightexpress.excellentenchants.api.enchantment.Rarity;
import su.nightexpress.excellentenchants.api.enchantment.data.*; import su.nightexpress.excellentenchants.api.enchantment.data.*;
import su.nightexpress.excellentenchants.api.enchantment.type.BowEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.BowEnchant;
import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData; import su.nightexpress.excellentenchants.enchantment.data.*;
import su.nightexpress.excellentenchants.enchantment.data.ArrowSettingsImpl;
import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl;
import su.nightexpress.excellentenchants.enchantment.data.PotionSettingsImpl;
import su.nightexpress.nightcore.config.FileConfig; import su.nightexpress.nightcore.config.FileConfig;
import su.nightexpress.nightcore.util.wrapper.UniParticle; import su.nightexpress.nightcore.util.wrapper.UniParticle;
@ -74,12 +71,18 @@ public class PoisonedArrowsEnchant extends AbstractEnchantmentData implements Ch
return potionSettings; return potionSettings;
} }
@NotNull
@Override @Override
public EnchantmentTarget getCategory() { @NotNull
return EnchantmentTarget.BOW; public ItemsCategory getSupportedItems() {
return ItemCategories.BOWS;
} }
// @NotNull
// @Override
// public EnchantmentTarget getCategory() {
// return EnchantmentTarget.BOW;
// }
@Override @Override
public boolean onShoot(@NotNull EntityShootBowEvent event, @NotNull LivingEntity shooter, @NotNull ItemStack bow, int level) { public boolean onShoot(@NotNull EntityShootBowEvent event, @NotNull LivingEntity shooter, @NotNull ItemStack bow, int level) {
if (!(event.getProjectile() instanceof Arrow arrow)) return false; if (!(event.getProjectile() instanceof Arrow arrow)) return false;

View File

@ -1,6 +1,5 @@
package su.nightexpress.excellentenchants.enchantment.impl.bow; package su.nightexpress.excellentenchants.enchantment.impl.bow;
import org.bukkit.enchantments.EnchantmentTarget;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Projectile; import org.bukkit.entity.Projectile;
@ -13,18 +12,20 @@ import org.bukkit.util.Vector;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import su.nightexpress.excellentenchants.EnchantsPlugin; import su.nightexpress.excellentenchants.EnchantsPlugin;
import su.nightexpress.excellentenchants.api.Modifier; import su.nightexpress.excellentenchants.api.Modifier;
import su.nightexpress.excellentenchants.api.enchantment.ItemsCategory;
import su.nightexpress.excellentenchants.api.enchantment.Rarity; import su.nightexpress.excellentenchants.api.enchantment.Rarity;
import su.nightexpress.excellentenchants.api.enchantment.data.ChanceData; import su.nightexpress.excellentenchants.api.enchantment.data.ChanceData;
import su.nightexpress.excellentenchants.api.enchantment.data.ChanceSettings; import su.nightexpress.excellentenchants.api.enchantment.data.ChanceSettings;
import su.nightexpress.excellentenchants.api.enchantment.type.BowEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.BowEnchant;
import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData; import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData;
import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl; import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl;
import su.nightexpress.excellentenchants.enchantment.data.ItemCategories;
import su.nightexpress.nightcore.config.FileConfig; import su.nightexpress.nightcore.config.FileConfig;
import su.nightexpress.nightcore.util.NumberUtil; import su.nightexpress.nightcore.util.NumberUtil;
import java.io.File; import java.io.File;
import static su.nightexpress.excellentenchants.Placeholders.*; import static su.nightexpress.excellentenchants.Placeholders.GENERIC_AMOUNT;
public class SniperEnchant extends AbstractEnchantmentData implements BowEnchant, ChanceData { public class SniperEnchant extends AbstractEnchantmentData implements BowEnchant, ChanceData {
@ -62,12 +63,18 @@ public class SniperEnchant extends AbstractEnchantmentData implements BowEnchant
return this.speedModifier.getValue(level); return this.speedModifier.getValue(level);
} }
@NotNull
@Override @Override
public EnchantmentTarget getCategory() { @NotNull
return EnchantmentTarget.BOW; public ItemsCategory getSupportedItems() {
return ItemCategories.BOWS;
} }
// @NotNull
// @Override
// public EnchantmentTarget getCategory() {
// return EnchantmentTarget.BOW;
// }
@NotNull @NotNull
@Override @Override
public EventPriority getShootPriority() { public EventPriority getShootPriority() {

View File

@ -3,7 +3,6 @@ package su.nightexpress.excellentenchants.enchantment.impl.bow;
import org.bukkit.Color; import org.bukkit.Color;
import org.bukkit.Particle; import org.bukkit.Particle;
import org.bukkit.attribute.Attribute; import org.bukkit.attribute.Attribute;
import org.bukkit.enchantments.EnchantmentTarget;
import org.bukkit.entity.Arrow; import org.bukkit.entity.Arrow;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Projectile; import org.bukkit.entity.Projectile;
@ -16,6 +15,7 @@ import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import su.nightexpress.excellentenchants.EnchantsPlugin; import su.nightexpress.excellentenchants.EnchantsPlugin;
import su.nightexpress.excellentenchants.api.Modifier; import su.nightexpress.excellentenchants.api.Modifier;
import su.nightexpress.excellentenchants.api.enchantment.ItemsCategory;
import su.nightexpress.excellentenchants.api.enchantment.Rarity; import su.nightexpress.excellentenchants.api.enchantment.Rarity;
import su.nightexpress.excellentenchants.api.enchantment.data.ArrowData; import su.nightexpress.excellentenchants.api.enchantment.data.ArrowData;
import su.nightexpress.excellentenchants.api.enchantment.data.ArrowSettings; import su.nightexpress.excellentenchants.api.enchantment.data.ArrowSettings;
@ -25,6 +25,7 @@ import su.nightexpress.excellentenchants.api.enchantment.type.BowEnchant;
import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData; import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData;
import su.nightexpress.excellentenchants.enchantment.data.ArrowSettingsImpl; import su.nightexpress.excellentenchants.enchantment.data.ArrowSettingsImpl;
import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl; import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl;
import su.nightexpress.excellentenchants.enchantment.data.ItemCategories;
import su.nightexpress.nightcore.config.FileConfig; import su.nightexpress.nightcore.config.FileConfig;
import su.nightexpress.nightcore.util.EntityUtil; import su.nightexpress.nightcore.util.EntityUtil;
import su.nightexpress.nightcore.util.NumberUtil; import su.nightexpress.nightcore.util.NumberUtil;
@ -32,7 +33,8 @@ import su.nightexpress.nightcore.util.wrapper.UniParticle;
import java.io.File; import java.io.File;
import static su.nightexpress.excellentenchants.Placeholders.*; import static su.nightexpress.excellentenchants.Placeholders.ENCHANTMENT_CHANCE;
import static su.nightexpress.excellentenchants.Placeholders.GENERIC_AMOUNT;
public class VampiricArrowsEnchant extends AbstractEnchantmentData implements BowEnchant, ArrowData, ChanceData { public class VampiricArrowsEnchant extends AbstractEnchantmentData implements BowEnchant, ArrowData, ChanceData {
@ -64,12 +66,18 @@ public class VampiricArrowsEnchant extends AbstractEnchantmentData implements Bo
this.addPlaceholder(GENERIC_AMOUNT, level -> NumberUtil.format(this.getHealAmount(level))); this.addPlaceholder(GENERIC_AMOUNT, level -> NumberUtil.format(this.getHealAmount(level)));
} }
@NotNull
@Override @Override
public EnchantmentTarget getCategory() { @NotNull
return EnchantmentTarget.BOW; public ItemsCategory getSupportedItems() {
return ItemCategories.BOWS;
} }
// @NotNull
// @Override
// public EnchantmentTarget getCategory() {
// return EnchantmentTarget.BOW;
// }
@NotNull @NotNull
@Override @Override
public ArrowSettings getArrowSettings() { public ArrowSettings getArrowSettings() {

View File

@ -1,7 +1,6 @@
package su.nightexpress.excellentenchants.enchantment.impl.bow; package su.nightexpress.excellentenchants.enchantment.impl.bow;
import org.bukkit.Particle; import org.bukkit.Particle;
import org.bukkit.enchantments.EnchantmentTarget;
import org.bukkit.entity.AbstractArrow; import org.bukkit.entity.AbstractArrow;
import org.bukkit.entity.Arrow; import org.bukkit.entity.Arrow;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
@ -14,13 +13,11 @@ import org.bukkit.potion.PotionEffectType;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import su.nightexpress.excellentenchants.EnchantsPlugin; import su.nightexpress.excellentenchants.EnchantsPlugin;
import su.nightexpress.excellentenchants.api.Modifier; import su.nightexpress.excellentenchants.api.Modifier;
import su.nightexpress.excellentenchants.api.enchantment.ItemsCategory;
import su.nightexpress.excellentenchants.api.enchantment.Rarity; import su.nightexpress.excellentenchants.api.enchantment.Rarity;
import su.nightexpress.excellentenchants.api.enchantment.data.*; import su.nightexpress.excellentenchants.api.enchantment.data.*;
import su.nightexpress.excellentenchants.api.enchantment.type.BowEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.BowEnchant;
import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData; import su.nightexpress.excellentenchants.enchantment.data.*;
import su.nightexpress.excellentenchants.enchantment.data.ArrowSettingsImpl;
import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl;
import su.nightexpress.excellentenchants.enchantment.data.PotionSettingsImpl;
import su.nightexpress.nightcore.config.FileConfig; import su.nightexpress.nightcore.config.FileConfig;
import su.nightexpress.nightcore.util.wrapper.UniParticle; import su.nightexpress.nightcore.util.wrapper.UniParticle;
@ -74,12 +71,18 @@ public class WitheredArrowsEnchant extends AbstractEnchantmentData implements Ch
return potionSettings; return potionSettings;
} }
@NotNull
@Override @Override
public EnchantmentTarget getCategory() { @NotNull
return EnchantmentTarget.BOW; public ItemsCategory getSupportedItems() {
return ItemCategories.BOWS;
} }
// @NotNull
// @Override
// public EnchantmentTarget getCategory() {
// return EnchantmentTarget.BOW;
// }
@Override @Override
public boolean onShoot(@NotNull EntityShootBowEvent event, @NotNull LivingEntity shooter, @NotNull ItemStack bow, int level) { public boolean onShoot(@NotNull EntityShootBowEvent event, @NotNull LivingEntity shooter, @NotNull ItemStack bow, int level) {
if (!(event.getProjectile() instanceof Arrow arrow)) return false; if (!(event.getProjectile() instanceof Arrow arrow)) return false;

View File

@ -1,16 +1,17 @@
package su.nightexpress.excellentenchants.enchantment.impl.fishing; package su.nightexpress.excellentenchants.enchantment.impl.fishing;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.enchantments.EnchantmentTarget;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerFishEvent; import org.bukkit.event.player.PlayerFishEvent;
import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import su.nightexpress.excellentenchants.EnchantsPlugin; import su.nightexpress.excellentenchants.EnchantsPlugin;
import su.nightexpress.excellentenchants.api.enchantment.ItemsCategory;
import su.nightexpress.excellentenchants.api.enchantment.Rarity; import su.nightexpress.excellentenchants.api.enchantment.Rarity;
import su.nightexpress.excellentenchants.api.enchantment.type.FishingEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.FishingEnchant;
import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData; import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData;
import su.nightexpress.excellentenchants.enchantment.data.ItemCategories;
import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils; import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils;
import su.nightexpress.nightcore.config.FileConfig; import su.nightexpress.nightcore.config.FileConfig;
@ -32,12 +33,18 @@ public class AutoReelEnchant extends AbstractEnchantmentData implements FishingE
} }
@NotNull
@Override @Override
public EnchantmentTarget getCategory() { @NotNull
return EnchantmentTarget.FISHING_ROD; public ItemsCategory getSupportedItems() {
return ItemCategories.FISHING_ROD;
} }
// @NotNull
// @Override
// public EnchantmentTarget getCategory() {
// return EnchantmentTarget.FISHING_ROD;
// }
@Override @Override
public boolean onFishing(@NotNull PlayerFishEvent event, @NotNull ItemStack item, int level) { public boolean onFishing(@NotNull PlayerFishEvent event, @NotNull ItemStack item, int level) {
if (event.getState() != PlayerFishEvent.State.BITE) return false; if (event.getState() != PlayerFishEvent.State.BITE) return false;

View File

@ -2,7 +2,6 @@ package su.nightexpress.excellentenchants.enchantment.impl.fishing;
import org.bukkit.Particle; import org.bukkit.Particle;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.enchantments.EnchantmentTarget;
import org.bukkit.entity.Drowned; import org.bukkit.entity.Drowned;
import org.bukkit.entity.FishHook; import org.bukkit.entity.FishHook;
import org.bukkit.event.player.PlayerFishEvent; import org.bukkit.event.player.PlayerFishEvent;
@ -10,19 +9,21 @@ import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import su.nightexpress.excellentenchants.EnchantsPlugin; import su.nightexpress.excellentenchants.EnchantsPlugin;
import su.nightexpress.excellentenchants.api.Modifier; import su.nightexpress.excellentenchants.api.Modifier;
import su.nightexpress.excellentenchants.api.enchantment.ItemsCategory;
import su.nightexpress.excellentenchants.api.enchantment.Rarity; import su.nightexpress.excellentenchants.api.enchantment.Rarity;
import su.nightexpress.excellentenchants.api.enchantment.data.ChanceData; import su.nightexpress.excellentenchants.api.enchantment.data.ChanceData;
import su.nightexpress.excellentenchants.api.enchantment.data.ChanceSettings; import su.nightexpress.excellentenchants.api.enchantment.data.ChanceSettings;
import su.nightexpress.excellentenchants.api.enchantment.type.FishingEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.FishingEnchant;
import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData; import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData;
import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl; import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl;
import su.nightexpress.excellentenchants.enchantment.data.ItemCategories;
import su.nightexpress.nightcore.config.FileConfig; import su.nightexpress.nightcore.config.FileConfig;
import su.nightexpress.nightcore.util.wrapper.UniParticle; import su.nightexpress.nightcore.util.wrapper.UniParticle;
import su.nightexpress.nightcore.util.wrapper.UniSound; import su.nightexpress.nightcore.util.wrapper.UniSound;
import java.io.File; import java.io.File;
import static su.nightexpress.excellentenchants.Placeholders.*; import static su.nightexpress.excellentenchants.Placeholders.ENCHANTMENT_CHANCE;
public class CurseOfDrownedEnchant extends AbstractEnchantmentData implements FishingEnchant, ChanceData { public class CurseOfDrownedEnchant extends AbstractEnchantmentData implements FishingEnchant, ChanceData {
@ -48,12 +49,18 @@ public class CurseOfDrownedEnchant extends AbstractEnchantmentData implements Fi
return chanceSettings; return chanceSettings;
} }
@NotNull
@Override @Override
public EnchantmentTarget getCategory() { @NotNull
return EnchantmentTarget.FISHING_ROD; public ItemsCategory getSupportedItems() {
return ItemCategories.FISHING_ROD;
} }
// @NotNull
// @Override
// public EnchantmentTarget getCategory() {
// return EnchantmentTarget.FISHING_ROD;
// }
@Override @Override
public boolean isCurse() { public boolean isCurse() {
return true; return true;

View File

@ -1,6 +1,5 @@
package su.nightexpress.excellentenchants.enchantment.impl.fishing; package su.nightexpress.excellentenchants.enchantment.impl.fishing;
import org.bukkit.enchantments.EnchantmentTarget;
import org.bukkit.entity.Item; import org.bukkit.entity.Item;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerFishEvent; import org.bukkit.event.player.PlayerFishEvent;
@ -8,17 +7,19 @@ import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import su.nightexpress.excellentenchants.EnchantsPlugin; import su.nightexpress.excellentenchants.EnchantsPlugin;
import su.nightexpress.excellentenchants.api.Modifier; import su.nightexpress.excellentenchants.api.Modifier;
import su.nightexpress.excellentenchants.api.enchantment.ItemsCategory;
import su.nightexpress.excellentenchants.api.enchantment.Rarity; import su.nightexpress.excellentenchants.api.enchantment.Rarity;
import su.nightexpress.excellentenchants.api.enchantment.data.ChanceData; import su.nightexpress.excellentenchants.api.enchantment.data.ChanceData;
import su.nightexpress.excellentenchants.api.enchantment.data.ChanceSettings; import su.nightexpress.excellentenchants.api.enchantment.data.ChanceSettings;
import su.nightexpress.excellentenchants.api.enchantment.type.FishingEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.FishingEnchant;
import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData; import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData;
import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl; import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl;
import su.nightexpress.excellentenchants.enchantment.data.ItemCategories;
import su.nightexpress.nightcore.config.FileConfig; import su.nightexpress.nightcore.config.FileConfig;
import java.io.File; import java.io.File;
import static su.nightexpress.excellentenchants.Placeholders.*; import static su.nightexpress.excellentenchants.Placeholders.ENCHANTMENT_CHANCE;
public class DoubleCatchEnchant extends AbstractEnchantmentData implements FishingEnchant, ChanceData { public class DoubleCatchEnchant extends AbstractEnchantmentData implements FishingEnchant, ChanceData {
@ -38,12 +39,18 @@ public class DoubleCatchEnchant extends AbstractEnchantmentData implements Fishi
this.chanceSettings = ChanceSettingsImpl.create(config, Modifier.add(4, 2, 1, 100)); this.chanceSettings = ChanceSettingsImpl.create(config, Modifier.add(4, 2, 1, 100));
} }
@NotNull
@Override @Override
public EnchantmentTarget getCategory() { @NotNull
return EnchantmentTarget.FISHING_ROD; public ItemsCategory getSupportedItems() {
return ItemCategories.FISHING_ROD;
} }
// @NotNull
// @Override
// public EnchantmentTarget getCategory() {
// return EnchantmentTarget.FISHING_ROD;
// }
@NotNull @NotNull
@Override @Override
public EventPriority getFishingPriority() { public EventPriority getFishingPriority() {

View File

@ -1,6 +1,6 @@
package su.nightexpress.excellentenchants.enchantment.impl.fishing; package su.nightexpress.excellentenchants.enchantment.impl.fishing;
import org.bukkit.enchantments.EnchantmentTarget; import org.bukkit.Material;
import org.bukkit.entity.FishHook; import org.bukkit.entity.FishHook;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
@ -10,9 +10,11 @@ import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import su.nightexpress.excellentenchants.EnchantsPlugin; import su.nightexpress.excellentenchants.EnchantsPlugin;
import su.nightexpress.excellentenchants.api.Modifier; import su.nightexpress.excellentenchants.api.Modifier;
import su.nightexpress.excellentenchants.api.enchantment.ItemsCategory;
import su.nightexpress.excellentenchants.api.enchantment.Rarity; import su.nightexpress.excellentenchants.api.enchantment.Rarity;
import su.nightexpress.excellentenchants.api.enchantment.type.GenericEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.GenericEnchant;
import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData; import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData;
import su.nightexpress.excellentenchants.enchantment.data.ItemCategories;
import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils; import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils;
import su.nightexpress.nightcore.config.FileConfig; import su.nightexpress.nightcore.config.FileConfig;
import su.nightexpress.nightcore.manager.SimpeListener; import su.nightexpress.nightcore.manager.SimpeListener;
@ -41,12 +43,18 @@ public class RiverMasterEnchant extends AbstractEnchantmentData implements Gener
); );
} }
@NotNull
@Override @Override
public EnchantmentTarget getCategory() { @NotNull
return EnchantmentTarget.FISHING_ROD; public ItemsCategory getSupportedItems() {
return ItemCategories.FISHING_ROD;
} }
// @NotNull
// @Override
// public EnchantmentTarget getCategory() {
// return EnchantmentTarget.FISHING_ROD;
// }
public double getDistanceMod(int level) { public double getDistanceMod(int level) {
return this.distanceMod.getValue(level); return this.distanceMod.getValue(level);
} }
@ -56,7 +64,7 @@ public class RiverMasterEnchant extends AbstractEnchantmentData implements Gener
if (!(event.getEntity() instanceof FishHook hook)) return; if (!(event.getEntity() instanceof FishHook hook)) return;
if (!(hook.getShooter() instanceof Player player)) return; if (!(hook.getShooter() instanceof Player player)) return;
ItemStack rod = EnchantUtils.getFishingRod(player); ItemStack rod = EnchantUtils.getHandItem(player, Material.FISHING_ROD);
if (rod == null) return; if (rod == null) return;
int level = EnchantUtils.getLevel(rod, this.getEnchantment()); int level = EnchantUtils.getLevel(rod, this.getEnchantment());

View File

@ -1,20 +1,21 @@
package su.nightexpress.excellentenchants.enchantment.impl.fishing; package su.nightexpress.excellentenchants.enchantment.impl.fishing;
import org.bukkit.enchantments.EnchantmentTarget;
import org.bukkit.event.player.PlayerFishEvent; import org.bukkit.event.player.PlayerFishEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import su.nightexpress.excellentenchants.EnchantsPlugin; import su.nightexpress.excellentenchants.EnchantsPlugin;
import su.nightexpress.excellentenchants.api.Modifier; import su.nightexpress.excellentenchants.api.Modifier;
import su.nightexpress.excellentenchants.api.enchantment.ItemsCategory;
import su.nightexpress.excellentenchants.api.enchantment.Rarity; import su.nightexpress.excellentenchants.api.enchantment.Rarity;
import su.nightexpress.excellentenchants.api.enchantment.type.FishingEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.FishingEnchant;
import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData; import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData;
import su.nightexpress.excellentenchants.enchantment.data.ItemCategories;
import su.nightexpress.nightcore.config.FileConfig; import su.nightexpress.nightcore.config.FileConfig;
import su.nightexpress.nightcore.util.NumberUtil; import su.nightexpress.nightcore.util.NumberUtil;
import java.io.File; import java.io.File;
import static su.nightexpress.excellentenchants.Placeholders.*; import static su.nightexpress.excellentenchants.Placeholders.GENERIC_AMOUNT;
public class SeasonedAnglerEnchant extends AbstractEnchantmentData implements FishingEnchant { public class SeasonedAnglerEnchant extends AbstractEnchantmentData implements FishingEnchant {
@ -42,12 +43,18 @@ public class SeasonedAnglerEnchant extends AbstractEnchantmentData implements Fi
return (int) this.xpModifier.getValue(level); return (int) this.xpModifier.getValue(level);
} }
@NotNull
@Override @Override
public EnchantmentTarget getCategory() { @NotNull
return EnchantmentTarget.FISHING_ROD; public ItemsCategory getSupportedItems() {
return ItemCategories.FISHING_ROD;
} }
// @NotNull
// @Override
// public EnchantmentTarget getCategory() {
// return EnchantmentTarget.FISHING_ROD;
// }
@Override @Override
public boolean onFishing(@NotNull PlayerFishEvent event, @NotNull ItemStack item, int level) { public boolean onFishing(@NotNull PlayerFishEvent event, @NotNull ItemStack item, int level) {
if (event.getState() != PlayerFishEvent.State.CAUGHT_FISH) return false; if (event.getState() != PlayerFishEvent.State.CAUGHT_FISH) return false;

View File

@ -1,6 +1,5 @@
package su.nightexpress.excellentenchants.enchantment.impl.fishing; package su.nightexpress.excellentenchants.enchantment.impl.fishing;
import org.bukkit.enchantments.EnchantmentTarget;
import org.bukkit.entity.Item; import org.bukkit.entity.Item;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerFishEvent; import org.bukkit.event.player.PlayerFishEvent;
@ -8,12 +7,14 @@ import org.bukkit.inventory.CookingRecipe;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import su.nightexpress.excellentenchants.EnchantsPlugin; import su.nightexpress.excellentenchants.EnchantsPlugin;
import su.nightexpress.excellentenchants.api.enchantment.ItemsCategory;
import su.nightexpress.excellentenchants.api.enchantment.Rarity; import su.nightexpress.excellentenchants.api.enchantment.Rarity;
import su.nightexpress.excellentenchants.api.enchantment.data.ChanceData; import su.nightexpress.excellentenchants.api.enchantment.data.ChanceData;
import su.nightexpress.excellentenchants.api.enchantment.data.ChanceSettings; import su.nightexpress.excellentenchants.api.enchantment.data.ChanceSettings;
import su.nightexpress.excellentenchants.api.enchantment.type.FishingEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.FishingEnchant;
import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData; import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData;
import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl; import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl;
import su.nightexpress.excellentenchants.enchantment.data.ItemCategories;
import su.nightexpress.nightcore.config.FileConfig; import su.nightexpress.nightcore.config.FileConfig;
import java.io.File; import java.io.File;
@ -59,12 +60,18 @@ public class SurvivalistEnchant extends AbstractEnchantmentData implements Fishi
return chanceSettings; return chanceSettings;
} }
@NotNull
@Override @Override
public EnchantmentTarget getCategory() { @NotNull
return EnchantmentTarget.FISHING_ROD; public ItemsCategory getSupportedItems() {
return ItemCategories.FISHING_ROD;
} }
// @NotNull
// @Override
// public EnchantmentTarget getCategory() {
// return EnchantmentTarget.FISHING_ROD;
// }
@NotNull @NotNull
@Override @Override
public EventPriority getFishingPriority() { public EventPriority getFishingPriority() {

View File

@ -1,7 +1,6 @@
package su.nightexpress.excellentenchants.enchantment.impl.tool; package su.nightexpress.excellentenchants.enchantment.impl.tool;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.enchantments.EnchantmentTarget;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
@ -15,13 +14,14 @@ import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import su.nightexpress.excellentenchants.EnchantsPlugin; import su.nightexpress.excellentenchants.EnchantsPlugin;
import su.nightexpress.excellentenchants.api.Modifier; import su.nightexpress.excellentenchants.api.Modifier;
import su.nightexpress.excellentenchants.api.enchantment.ItemCategory; import su.nightexpress.excellentenchants.api.enchantment.ItemsCategory;
import su.nightexpress.excellentenchants.api.enchantment.Rarity; import su.nightexpress.excellentenchants.api.enchantment.Rarity;
import su.nightexpress.excellentenchants.api.enchantment.data.ChanceData; import su.nightexpress.excellentenchants.api.enchantment.data.ChanceData;
import su.nightexpress.excellentenchants.api.enchantment.data.ChanceSettings; import su.nightexpress.excellentenchants.api.enchantment.data.ChanceSettings;
import su.nightexpress.excellentenchants.api.enchantment.type.BlockBreakEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.BlockBreakEnchant;
import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData; import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData;
import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl; import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl;
import su.nightexpress.excellentenchants.enchantment.data.ItemCategories;
import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils; import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils;
import su.nightexpress.nightcore.config.FileConfig; import su.nightexpress.nightcore.config.FileConfig;
import su.nightexpress.nightcore.manager.SimpeListener; import su.nightexpress.nightcore.manager.SimpeListener;
@ -89,16 +89,28 @@ public class BlastMiningEnchant extends AbstractEnchantmentData implements Chanc
@Override @Override
@NotNull @NotNull
public ItemCategory[] getItemCategories() { public ItemsCategory getSupportedItems() {
return new ItemCategory[]{ItemCategory.PICKAXE}; return ItemCategories.TOOL;
} }
@Override @Override
@NotNull @NotNull
public EnchantmentTarget getCategory() { public ItemsCategory getPrimaryItems() {
return EnchantmentTarget.TOOL; return ItemCategories.PICKAXE;
} }
// @Override
// @NotNull
// public ItemCategory[] getItemCategories() {
// return new ItemCategory[]{ItemCategory.PICKAXE};
// }
//
// @Override
// @NotNull
// public EnchantmentTarget getCategory() {
// return EnchantmentTarget.TOOL;
// }
@Override @Override
public boolean onBreak(@NotNull BlockBreakEvent event, @NotNull LivingEntity entity, @NotNull ItemStack item, int level) { public boolean onBreak(@NotNull BlockBreakEvent event, @NotNull LivingEntity entity, @NotNull ItemStack item, int level) {
if (!(entity instanceof Player player)) return false; if (!(entity instanceof Player player)) return false;

View File

@ -1,6 +1,5 @@
package su.nightexpress.excellentenchants.enchantment.impl.tool; package su.nightexpress.excellentenchants.enchantment.impl.tool;
import org.bukkit.enchantments.EnchantmentTarget;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
@ -9,12 +8,14 @@ import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import su.nightexpress.excellentenchants.EnchantsPlugin; import su.nightexpress.excellentenchants.EnchantsPlugin;
import su.nightexpress.excellentenchants.api.Modifier; import su.nightexpress.excellentenchants.api.Modifier;
import su.nightexpress.excellentenchants.api.enchantment.ItemsCategory;
import su.nightexpress.excellentenchants.api.enchantment.Rarity; import su.nightexpress.excellentenchants.api.enchantment.Rarity;
import su.nightexpress.excellentenchants.api.enchantment.data.ChanceData; import su.nightexpress.excellentenchants.api.enchantment.data.ChanceData;
import su.nightexpress.excellentenchants.api.enchantment.data.ChanceSettings; import su.nightexpress.excellentenchants.api.enchantment.data.ChanceSettings;
import su.nightexpress.excellentenchants.api.enchantment.type.GenericEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.GenericEnchant;
import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData; import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData;
import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl; import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl;
import su.nightexpress.excellentenchants.enchantment.data.ItemCategories;
import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils; import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils;
import su.nightexpress.nightcore.config.FileConfig; import su.nightexpress.nightcore.config.FileConfig;
import su.nightexpress.nightcore.manager.SimpeListener; import su.nightexpress.nightcore.manager.SimpeListener;
@ -22,7 +23,8 @@ import su.nightexpress.nightcore.util.NumberUtil;
import java.io.File; import java.io.File;
import static su.nightexpress.excellentenchants.Placeholders.*; import static su.nightexpress.excellentenchants.Placeholders.ENCHANTMENT_CHANCE;
import static su.nightexpress.excellentenchants.Placeholders.GENERIC_AMOUNT;
public class CurseOfBreakingEnchant extends AbstractEnchantmentData implements GenericEnchant, SimpeListener, ChanceData { public class CurseOfBreakingEnchant extends AbstractEnchantmentData implements GenericEnchant, SimpeListener, ChanceData {
@ -64,12 +66,18 @@ public class CurseOfBreakingEnchant extends AbstractEnchantmentData implements G
return (int) this.durabilityAmount.getValue(level); return (int) this.durabilityAmount.getValue(level);
} }
@NotNull
@Override @Override
public EnchantmentTarget getCategory() { @NotNull
return EnchantmentTarget.BREAKABLE; public ItemsCategory getSupportedItems() {
return ItemCategories.BREAKABLE;
} }
// @NotNull
// @Override
// public EnchantmentTarget getCategory() {
// return EnchantmentTarget.BREAKABLE;
// }
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onItemDurability(PlayerItemDamageEvent event) { public void onItemDurability(PlayerItemDamageEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();

View File

@ -1,6 +1,5 @@
package su.nightexpress.excellentenchants.enchantment.impl.tool; package su.nightexpress.excellentenchants.enchantment.impl.tool;
import org.bukkit.enchantments.EnchantmentTarget;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
@ -10,8 +9,8 @@ import org.bukkit.event.entity.EntityResurrectEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import su.nightexpress.excellentenchants.EnchantsPlugin; import su.nightexpress.excellentenchants.EnchantsPlugin;
import su.nightexpress.excellentenchants.api.enchantment.ItemCategory;
import su.nightexpress.excellentenchants.api.Modifier; import su.nightexpress.excellentenchants.api.Modifier;
import su.nightexpress.excellentenchants.api.enchantment.ItemsCategory;
import su.nightexpress.excellentenchants.api.enchantment.Rarity; import su.nightexpress.excellentenchants.api.enchantment.Rarity;
import su.nightexpress.excellentenchants.api.enchantment.data.ChanceData; import su.nightexpress.excellentenchants.api.enchantment.data.ChanceData;
import su.nightexpress.excellentenchants.api.enchantment.data.ChanceSettings; import su.nightexpress.excellentenchants.api.enchantment.data.ChanceSettings;
@ -19,13 +18,14 @@ import su.nightexpress.excellentenchants.api.enchantment.type.BlockDropEnchant;
import su.nightexpress.excellentenchants.api.enchantment.type.DeathEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.DeathEnchant;
import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData; import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData;
import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl; import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl;
import su.nightexpress.excellentenchants.enchantment.data.ItemCategories;
import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils; import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils;
import su.nightexpress.nightcore.config.FileConfig; import su.nightexpress.nightcore.config.FileConfig;
import su.nightexpress.nightcore.util.ItemUtil; import su.nightexpress.nightcore.util.ItemUtil;
import java.io.File; import java.io.File;
import static su.nightexpress.excellentenchants.Placeholders.*; import static su.nightexpress.excellentenchants.Placeholders.ENCHANTMENT_CHANCE;
public class CurseOfMediocrityEnchant extends AbstractEnchantmentData implements ChanceData, BlockDropEnchant, DeathEnchant { public class CurseOfMediocrityEnchant extends AbstractEnchantmentData implements ChanceData, BlockDropEnchant, DeathEnchant {
@ -45,20 +45,32 @@ public class CurseOfMediocrityEnchant extends AbstractEnchantmentData implements
this.chanceSettings = ChanceSettingsImpl.create(config, Modifier.multiply(15, 1, 1, 100)); this.chanceSettings = ChanceSettingsImpl.create(config, Modifier.multiply(15, 1, 1, 100));
} }
@NotNull
@Override @Override
public EnchantmentTarget getCategory() { @NotNull
return EnchantmentTarget.BREAKABLE; public ItemsCategory getSupportedItems() {
return ItemCategories.BREAKABLE;
} }
@Override @Override
@NotNull @NotNull
public ItemCategory[] getItemCategories() { public ItemsCategory getPrimaryItems() {
return new ItemCategory[] { return ItemCategories.ALL_RANGE_WEAPON;
ItemCategory.SWORD, ItemCategory.BOW, ItemCategory.CROSSBOW, ItemCategory.TRIDENT, ItemCategory.TOOL
};
} }
// @NotNull
// @Override
// public EnchantmentTarget getCategory() {
// return EnchantmentTarget.BREAKABLE;
// }
//
// @Override
// @NotNull
// public ItemCategory[] getItemCategories() {
// return new ItemCategory[] {
// ItemCategory.SWORD, ItemCategory.BOW, ItemCategory.CROSSBOW, ItemCategory.TRIDENT, ItemCategory.TOOL
// };
// }
@NotNull @NotNull
@Override @Override
public EventPriority getDropPriority() { public EventPriority getDropPriority() {

View File

@ -1,7 +1,6 @@
package su.nightexpress.excellentenchants.enchantment.impl.tool; package su.nightexpress.excellentenchants.enchantment.impl.tool;
import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.Enchantment;
import org.bukkit.enchantments.EnchantmentTarget;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
@ -11,8 +10,8 @@ import org.bukkit.event.entity.EntityResurrectEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import su.nightexpress.excellentenchants.EnchantsPlugin; import su.nightexpress.excellentenchants.EnchantsPlugin;
import su.nightexpress.excellentenchants.api.enchantment.ItemCategory;
import su.nightexpress.excellentenchants.api.Modifier; import su.nightexpress.excellentenchants.api.Modifier;
import su.nightexpress.excellentenchants.api.enchantment.ItemsCategory;
import su.nightexpress.excellentenchants.api.enchantment.Rarity; import su.nightexpress.excellentenchants.api.enchantment.Rarity;
import su.nightexpress.excellentenchants.api.enchantment.data.ChanceData; import su.nightexpress.excellentenchants.api.enchantment.data.ChanceData;
import su.nightexpress.excellentenchants.api.enchantment.data.ChanceSettings; import su.nightexpress.excellentenchants.api.enchantment.data.ChanceSettings;
@ -20,12 +19,13 @@ import su.nightexpress.excellentenchants.api.enchantment.type.BlockBreakEnchant;
import su.nightexpress.excellentenchants.api.enchantment.type.DeathEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.DeathEnchant;
import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData; import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData;
import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl; import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl;
import su.nightexpress.excellentenchants.enchantment.data.ItemCategories;
import su.nightexpress.nightcore.config.ConfigValue; import su.nightexpress.nightcore.config.ConfigValue;
import su.nightexpress.nightcore.config.FileConfig; import su.nightexpress.nightcore.config.FileConfig;
import java.io.File; import java.io.File;
import static su.nightexpress.excellentenchants.Placeholders.*; import static su.nightexpress.excellentenchants.Placeholders.ENCHANTMENT_CHANCE;
public class CurseOfMisfortuneEnchant extends AbstractEnchantmentData implements ChanceData, BlockBreakEnchant, DeathEnchant { public class CurseOfMisfortuneEnchant extends AbstractEnchantmentData implements ChanceData, BlockBreakEnchant, DeathEnchant {
@ -67,18 +67,30 @@ public class CurseOfMisfortuneEnchant extends AbstractEnchantmentData implements
@Override @Override
@NotNull @NotNull
public ItemCategory[] getItemCategories() { public ItemsCategory getSupportedItems() {
return new ItemCategory[] { return ItemCategories.BREAKABLE;
ItemCategory.SWORD, ItemCategory.BOW, ItemCategory.CROSSBOW, ItemCategory.TRIDENT, ItemCategory.TOOL
};
} }
@NotNull
@Override @Override
public EnchantmentTarget getCategory() { @NotNull
return EnchantmentTarget.BREAKABLE; public ItemsCategory getPrimaryItems() {
return ItemCategories.ALL_RANGE_WEAPON;
} }
// @Override
// @NotNull
// public ItemCategory[] getItemCategories() {
// return new ItemCategory[] {
// ItemCategory.SWORD, ItemCategory.BOW, ItemCategory.CROSSBOW, ItemCategory.TRIDENT, ItemCategory.TOOL
// };
// }
//
// @NotNull
// @Override
// public EnchantmentTarget getCategory() {
// return EnchantmentTarget.BREAKABLE;
// }
@NotNull @NotNull
@Override @Override
public EventPriority getBreakPriority() { public EventPriority getBreakPriority() {

View File

@ -1,24 +1,26 @@
package su.nightexpress.excellentenchants.enchantment.impl.tool; package su.nightexpress.excellentenchants.enchantment.impl.tool;
import org.bukkit.enchantments.EnchantmentTarget;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import su.nightexpress.excellentenchants.EnchantsPlugin; import su.nightexpress.excellentenchants.EnchantsPlugin;
import su.nightexpress.excellentenchants.api.enchantment.ItemsCategory;
import su.nightexpress.excellentenchants.api.enchantment.Rarity; import su.nightexpress.excellentenchants.api.enchantment.Rarity;
import su.nightexpress.excellentenchants.api.enchantment.data.PeriodicSettings; import su.nightexpress.excellentenchants.api.enchantment.data.PeriodicSettings;
import su.nightexpress.excellentenchants.api.enchantment.data.PotionData; import su.nightexpress.excellentenchants.api.enchantment.data.PotionData;
import su.nightexpress.excellentenchants.api.enchantment.data.PotionSettings; import su.nightexpress.excellentenchants.api.enchantment.data.PotionSettings;
import su.nightexpress.excellentenchants.api.enchantment.type.PassiveEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.PassiveEnchant;
import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData; import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData;
import su.nightexpress.excellentenchants.enchantment.data.ItemCategories;
import su.nightexpress.excellentenchants.enchantment.data.PeriodSettingsImpl; import su.nightexpress.excellentenchants.enchantment.data.PeriodSettingsImpl;
import su.nightexpress.excellentenchants.enchantment.data.PotionSettingsImpl; import su.nightexpress.excellentenchants.enchantment.data.PotionSettingsImpl;
import su.nightexpress.nightcore.config.FileConfig; import su.nightexpress.nightcore.config.FileConfig;
import java.io.File; import java.io.File;
import static su.nightexpress.excellentenchants.Placeholders.*; import static su.nightexpress.excellentenchants.Placeholders.ENCHANTMENT_POTION_LEVEL;
import static su.nightexpress.excellentenchants.Placeholders.ENCHANTMENT_POTION_TYPE;
public class HasteEnchant extends AbstractEnchantmentData implements PotionData, PassiveEnchant { public class HasteEnchant extends AbstractEnchantmentData implements PotionData, PassiveEnchant {
@ -54,10 +56,16 @@ public class HasteEnchant extends AbstractEnchantmentData implements PotionData,
@Override @Override
@NotNull @NotNull
public EnchantmentTarget getCategory() { public ItemsCategory getSupportedItems() {
return EnchantmentTarget.TOOL; return ItemCategories.TOOL;
} }
// @Override
// @NotNull
// public EnchantmentTarget getCategory() {
// return EnchantmentTarget.TOOL;
// }
@Override @Override
public boolean onTrigger(@NotNull LivingEntity entity, @NotNull ItemStack item, int level) { public boolean onTrigger(@NotNull LivingEntity entity, @NotNull ItemStack item, int level) {
return this.addEffect(entity, level); return this.addEffect(entity, level);

View File

@ -1,25 +1,26 @@
package su.nightexpress.excellentenchants.enchantment.impl.tool; package su.nightexpress.excellentenchants.enchantment.impl.tool;
import org.bukkit.enchantments.EnchantmentTarget;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import su.nightexpress.excellentenchants.EnchantsPlugin; import su.nightexpress.excellentenchants.EnchantsPlugin;
import su.nightexpress.excellentenchants.api.enchantment.ItemCategory;
import su.nightexpress.excellentenchants.api.Modifier; import su.nightexpress.excellentenchants.api.Modifier;
import su.nightexpress.excellentenchants.api.enchantment.ItemsCategory;
import su.nightexpress.excellentenchants.api.enchantment.Rarity; import su.nightexpress.excellentenchants.api.enchantment.Rarity;
import su.nightexpress.excellentenchants.api.enchantment.data.ChanceData; import su.nightexpress.excellentenchants.api.enchantment.data.ChanceData;
import su.nightexpress.excellentenchants.api.enchantment.data.ChanceSettings; import su.nightexpress.excellentenchants.api.enchantment.data.ChanceSettings;
import su.nightexpress.excellentenchants.api.enchantment.type.BlockBreakEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.BlockBreakEnchant;
import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData; import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData;
import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl; import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl;
import su.nightexpress.excellentenchants.enchantment.data.ItemCategories;
import su.nightexpress.nightcore.config.FileConfig; import su.nightexpress.nightcore.config.FileConfig;
import su.nightexpress.nightcore.util.NumberUtil; import su.nightexpress.nightcore.util.NumberUtil;
import java.io.File; import java.io.File;
import static su.nightexpress.excellentenchants.Placeholders.*; import static su.nightexpress.excellentenchants.Placeholders.ENCHANTMENT_CHANCE;
import static su.nightexpress.excellentenchants.Placeholders.GENERIC_AMOUNT;
public class LuckyMinerEnchant extends AbstractEnchantmentData implements ChanceData, BlockBreakEnchant { public class LuckyMinerEnchant extends AbstractEnchantmentData implements ChanceData, BlockBreakEnchant {
@ -59,16 +60,28 @@ public class LuckyMinerEnchant extends AbstractEnchantmentData implements Chance
@Override @Override
@NotNull @NotNull
public ItemCategory[] getItemCategories() { public ItemsCategory getSupportedItems() {
return new ItemCategory[]{ItemCategory.PICKAXE}; return ItemCategories.TOOL;
} }
@Override @Override
@NotNull @NotNull
public EnchantmentTarget getCategory() { public ItemsCategory getPrimaryItems() {
return EnchantmentTarget.TOOL; return ItemCategories.PICKAXE;
} }
// @Override
// @NotNull
// public ItemCategory[] getItemCategories() {
// return new ItemCategory[]{ItemCategory.PICKAXE};
// }
//
// @Override
// @NotNull
// public EnchantmentTarget getCategory() {
// return EnchantmentTarget.TOOL;
// }
@Override @Override
public boolean onBreak(@NotNull BlockBreakEvent event, @NotNull LivingEntity player, @NotNull ItemStack item, int level) { public boolean onBreak(@NotNull BlockBreakEvent event, @NotNull LivingEntity player, @NotNull ItemStack item, int level) {
if (!this.checkTriggerChance(level)) return false; if (!this.checkTriggerChance(level)) return false;

View File

@ -6,7 +6,6 @@ import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.block.data.Ageable; import org.bukkit.block.data.Ageable;
import org.bukkit.block.data.BlockData; import org.bukkit.block.data.BlockData;
import org.bukkit.enchantments.EnchantmentTarget;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
@ -17,7 +16,7 @@ import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import su.nightexpress.excellentenchants.EnchantsPlugin; import su.nightexpress.excellentenchants.EnchantsPlugin;
import su.nightexpress.excellentenchants.api.enchantment.ItemCategory; import su.nightexpress.excellentenchants.api.enchantment.ItemsCategory;
import su.nightexpress.excellentenchants.api.enchantment.Rarity; import su.nightexpress.excellentenchants.api.enchantment.Rarity;
import su.nightexpress.excellentenchants.api.enchantment.data.ChanceData; import su.nightexpress.excellentenchants.api.enchantment.data.ChanceData;
import su.nightexpress.excellentenchants.api.enchantment.data.ChanceSettings; import su.nightexpress.excellentenchants.api.enchantment.data.ChanceSettings;
@ -25,6 +24,7 @@ import su.nightexpress.excellentenchants.api.enchantment.type.BlockBreakEnchant;
import su.nightexpress.excellentenchants.api.enchantment.type.InteractEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.InteractEnchant;
import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData; import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData;
import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl; import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl;
import su.nightexpress.excellentenchants.enchantment.data.ItemCategories;
import su.nightexpress.nightcore.config.ConfigValue; import su.nightexpress.nightcore.config.ConfigValue;
import su.nightexpress.nightcore.config.FileConfig; import su.nightexpress.nightcore.config.FileConfig;
import su.nightexpress.nightcore.util.wrapper.UniSound; import su.nightexpress.nightcore.util.wrapper.UniSound;
@ -100,16 +100,28 @@ public class ReplanterEnchant extends AbstractEnchantmentData implements ChanceD
@Override @Override
@NotNull @NotNull
public ItemCategory[] getItemCategories() { public ItemsCategory getSupportedItems() {
return new ItemCategory[]{ItemCategory.HOE}; return ItemCategories.TOOL;
} }
@Override @Override
@NotNull @NotNull
public EnchantmentTarget getCategory() { public ItemsCategory getPrimaryItems() {
return EnchantmentTarget.TOOL; return ItemCategories.HOE;
} }
// @Override
// @NotNull
// public ItemCategory[] getItemCategories() {
// return new ItemCategory[]{ItemCategory.HOE};
// }
//
// @Override
// @NotNull
// public EnchantmentTarget getCategory() {
// return EnchantmentTarget.TOOL;
// }
@NotNull @NotNull
@Override @Override
public EventPriority getInteractPriority() { public EventPriority getInteractPriority() {

View File

@ -4,7 +4,6 @@ import org.bukkit.NamespacedKey;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockState; import org.bukkit.block.BlockState;
import org.bukkit.block.Chest; import org.bukkit.block.Chest;
import org.bukkit.enchantments.EnchantmentTarget;
import org.bukkit.entity.Item; import org.bukkit.entity.Item;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -22,10 +21,11 @@ import org.bukkit.inventory.meta.BlockStateMeta;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import su.nightexpress.excellentenchants.EnchantsPlugin; import su.nightexpress.excellentenchants.EnchantsPlugin;
import su.nightexpress.excellentenchants.Placeholders; import su.nightexpress.excellentenchants.Placeholders;
import su.nightexpress.excellentenchants.api.enchantment.ItemCategory; import su.nightexpress.excellentenchants.api.enchantment.ItemsCategory;
import su.nightexpress.excellentenchants.api.enchantment.Rarity; import su.nightexpress.excellentenchants.api.enchantment.Rarity;
import su.nightexpress.excellentenchants.api.enchantment.type.BlockDropEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.BlockDropEnchant;
import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData; import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData;
import su.nightexpress.excellentenchants.enchantment.data.ItemCategories;
import su.nightexpress.nightcore.config.ConfigValue; import su.nightexpress.nightcore.config.ConfigValue;
import su.nightexpress.nightcore.config.FileConfig; import su.nightexpress.nightcore.config.FileConfig;
import su.nightexpress.nightcore.manager.SimpeListener; import su.nightexpress.nightcore.manager.SimpeListener;
@ -80,16 +80,28 @@ public class SilkChestEnchant extends AbstractEnchantmentData implements BlockDr
@Override @Override
@NotNull @NotNull
public ItemCategory[] getItemCategories() { public ItemsCategory getSupportedItems() {
return new ItemCategory[]{ItemCategory.AXE}; return ItemCategories.TOOL;
} }
@Override @Override
@NotNull @NotNull
public EnchantmentTarget getCategory() { public ItemsCategory getPrimaryItems() {
return EnchantmentTarget.TOOL; return ItemCategories.AXE;
} }
// @Override
// @NotNull
// public ItemCategory[] getItemCategories() {
// return new ItemCategory[]{ItemCategory.AXE};
// }
//
// @Override
// @NotNull
// public EnchantmentTarget getCategory() {
// return EnchantmentTarget.TOOL;
// }
public boolean isSilkChest(@NotNull ItemStack item) { public boolean isSilkChest(@NotNull ItemStack item) {
return PDCUtil.getBoolean(item, this.keyChest).isPresent(); return PDCUtil.getBoolean(item, this.keyChest).isPresent();
} }

View File

@ -7,7 +7,6 @@ import org.bukkit.Particle;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockState; import org.bukkit.block.BlockState;
import org.bukkit.block.CreatureSpawner; import org.bukkit.block.CreatureSpawner;
import org.bukkit.enchantments.EnchantmentTarget;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
@ -20,7 +19,7 @@ import org.bukkit.inventory.meta.BlockStateMeta;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import su.nightexpress.excellentenchants.EnchantsPlugin; import su.nightexpress.excellentenchants.EnchantsPlugin;
import su.nightexpress.excellentenchants.api.Modifier; import su.nightexpress.excellentenchants.api.Modifier;
import su.nightexpress.excellentenchants.api.enchantment.ItemCategory; import su.nightexpress.excellentenchants.api.enchantment.ItemsCategory;
import su.nightexpress.excellentenchants.api.enchantment.Rarity; import su.nightexpress.excellentenchants.api.enchantment.Rarity;
import su.nightexpress.excellentenchants.api.enchantment.data.ChanceData; import su.nightexpress.excellentenchants.api.enchantment.data.ChanceData;
import su.nightexpress.excellentenchants.api.enchantment.data.ChanceSettings; import su.nightexpress.excellentenchants.api.enchantment.data.ChanceSettings;
@ -28,6 +27,7 @@ import su.nightexpress.excellentenchants.api.enchantment.type.BlockBreakEnchant;
import su.nightexpress.excellentenchants.api.enchantment.type.BlockDropEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.BlockDropEnchant;
import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData; import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData;
import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl; import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl;
import su.nightexpress.excellentenchants.enchantment.data.ItemCategories;
import su.nightexpress.nightcore.config.ConfigValue; import su.nightexpress.nightcore.config.ConfigValue;
import su.nightexpress.nightcore.config.FileConfig; import su.nightexpress.nightcore.config.FileConfig;
import su.nightexpress.nightcore.language.LangAssets; import su.nightexpress.nightcore.language.LangAssets;
@ -35,11 +35,13 @@ import su.nightexpress.nightcore.manager.SimpeListener;
import su.nightexpress.nightcore.util.LocationUtil; import su.nightexpress.nightcore.util.LocationUtil;
import su.nightexpress.nightcore.util.PDCUtil; import su.nightexpress.nightcore.util.PDCUtil;
import su.nightexpress.nightcore.util.Plugins; import su.nightexpress.nightcore.util.Plugins;
import su.nightexpress.nightcore.util.text.NightMessage;
import su.nightexpress.nightcore.util.wrapper.UniParticle; import su.nightexpress.nightcore.util.wrapper.UniParticle;
import java.io.File; import java.io.File;
import static su.nightexpress.excellentenchants.Placeholders.*; import static su.nightexpress.excellentenchants.Placeholders.ENCHANTMENT_CHANCE;
import static su.nightexpress.excellentenchants.Placeholders.GENERIC_TYPE;
import static su.nightexpress.nightcore.util.text.tag.Tags.*; import static su.nightexpress.nightcore.util.text.tag.Tags.*;
public class SilkSpawnerEnchant extends AbstractEnchantmentData implements ChanceData, BlockBreakEnchant, BlockDropEnchant, SimpeListener { public class SilkSpawnerEnchant extends AbstractEnchantmentData implements ChanceData, BlockBreakEnchant, BlockDropEnchant, SimpeListener {
@ -91,16 +93,28 @@ public class SilkSpawnerEnchant extends AbstractEnchantmentData implements Chanc
@Override @Override
@NotNull @NotNull
public ItemCategory[] getItemCategories() { public ItemsCategory getSupportedItems() {
return new ItemCategory[]{ItemCategory.PICKAXE}; return ItemCategories.TOOL;
} }
@Override @Override
@NotNull @NotNull
public EnchantmentTarget getCategory() { public ItemsCategory getPrimaryItems() {
return EnchantmentTarget.TOOL; return ItemCategories.PICKAXE;
} }
// @Override
// @NotNull
// public ItemCategory[] getItemCategories() {
// return new ItemCategory[]{ItemCategory.PICKAXE};
// }
//
// @Override
// @NotNull
// public EnchantmentTarget getCategory() {
// return EnchantmentTarget.TOOL;
// }
@NotNull @NotNull
public ItemStack getSpawner(@NotNull CreatureSpawner spawnerBlock) { public ItemStack getSpawner(@NotNull CreatureSpawner spawnerBlock) {
ItemStack itemSpawner = new ItemStack(Material.SPAWNER); ItemStack itemSpawner = new ItemStack(Material.SPAWNER);
@ -111,7 +125,7 @@ public class SilkSpawnerEnchant extends AbstractEnchantmentData implements Chanc
spawnerItem.setSpawnedType(spawnerBlock.getSpawnedType()); spawnerItem.setSpawnedType(spawnerBlock.getSpawnedType());
spawnerItem.update(true); spawnerItem.update(true);
stateItem.setBlockState(spawnerItem); stateItem.setBlockState(spawnerItem);
stateItem.setDisplayName(this.spawnerName.replace(GENERIC_TYPE, LangAssets.get(spawnerBlock.getSpawnedType()))); stateItem.setDisplayName(NightMessage.asLegacy(this.spawnerName.replace(GENERIC_TYPE, LangAssets.get(spawnerBlock.getSpawnedType()))));
itemSpawner.setItemMeta(stateItem); itemSpawner.setItemMeta(stateItem);
PDCUtil.set(itemSpawner, this.spawnerKey, true); PDCUtil.set(itemSpawner, this.spawnerKey, true);

View File

@ -8,7 +8,6 @@ import org.bukkit.block.Block;
import org.bukkit.block.BlockState; import org.bukkit.block.BlockState;
import org.bukkit.block.Container; import org.bukkit.block.Container;
import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.Enchantment;
import org.bukkit.enchantments.EnchantmentTarget;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.block.BlockDropItemEvent; import org.bukkit.event.block.BlockDropItemEvent;
@ -16,14 +15,15 @@ import org.bukkit.inventory.FurnaceRecipe;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import su.nightexpress.excellentenchants.EnchantsPlugin; import su.nightexpress.excellentenchants.EnchantsPlugin;
import su.nightexpress.excellentenchants.api.enchantment.ItemCategory;
import su.nightexpress.excellentenchants.api.Modifier; import su.nightexpress.excellentenchants.api.Modifier;
import su.nightexpress.excellentenchants.api.enchantment.ItemsCategory;
import su.nightexpress.excellentenchants.api.enchantment.Rarity; import su.nightexpress.excellentenchants.api.enchantment.Rarity;
import su.nightexpress.excellentenchants.api.enchantment.data.ChanceData; import su.nightexpress.excellentenchants.api.enchantment.data.ChanceData;
import su.nightexpress.excellentenchants.api.enchantment.data.ChanceSettings; import su.nightexpress.excellentenchants.api.enchantment.data.ChanceSettings;
import su.nightexpress.excellentenchants.api.enchantment.type.BlockDropEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.BlockDropEnchant;
import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData; import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData;
import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl; import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl;
import su.nightexpress.excellentenchants.enchantment.data.ItemCategories;
import su.nightexpress.nightcore.config.ConfigValue; import su.nightexpress.nightcore.config.ConfigValue;
import su.nightexpress.nightcore.config.FileConfig; import su.nightexpress.nightcore.config.FileConfig;
import su.nightexpress.nightcore.util.BukkitThing; import su.nightexpress.nightcore.util.BukkitThing;
@ -33,9 +33,12 @@ import su.nightexpress.nightcore.util.wrapper.UniParticle;
import su.nightexpress.nightcore.util.wrapper.UniSound; import su.nightexpress.nightcore.util.wrapper.UniSound;
import java.io.File; import java.io.File;
import java.util.*; import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import static su.nightexpress.excellentenchants.Placeholders.*; import static su.nightexpress.excellentenchants.Placeholders.ENCHANTMENT_CHANCE;
public class SmelterEnchant extends AbstractEnchantmentData implements ChanceData, BlockDropEnchant { public class SmelterEnchant extends AbstractEnchantmentData implements ChanceData, BlockDropEnchant {
@ -107,16 +110,28 @@ public class SmelterEnchant extends AbstractEnchantmentData implements ChanceDat
@Override @Override
@NotNull @NotNull
public ItemCategory[] getItemCategories() { public ItemsCategory getSupportedItems() {
return new ItemCategory[]{ItemCategory.PICKAXE, ItemCategory.AXE, ItemCategory.SHOVEL}; return ItemCategories.TOOL;
} }
@Override @Override
@NotNull @NotNull
public EnchantmentTarget getCategory() { public ItemsCategory getPrimaryItems() {
return EnchantmentTarget.TOOL; return ItemCategories.MINING_TOOLS;
} }
// @Override
// @NotNull
// public ItemCategory[] getItemCategories() {
// return new ItemCategory[]{ItemCategory.PICKAXE, ItemCategory.AXE, ItemCategory.SHOVEL};
// }
//
// @Override
// @NotNull
// public EnchantmentTarget getCategory() {
// return EnchantmentTarget.TOOL;
// }
@Override @Override
public boolean onDrop(@NotNull BlockDropItemEvent event, @NotNull LivingEntity entity, @NotNull ItemStack item, int level) { public boolean onDrop(@NotNull BlockDropItemEvent event, @NotNull LivingEntity entity, @NotNull ItemStack item, int level) {
if (this.disableOnCrouch && entity instanceof Player player && player.isSneaking()) return false; if (this.disableOnCrouch && entity instanceof Player player && player.isSneaking()) return false;

View File

@ -1,6 +1,5 @@
package su.nightexpress.excellentenchants.enchantment.impl.tool; package su.nightexpress.excellentenchants.enchantment.impl.tool;
import org.bukkit.enchantments.EnchantmentTarget;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
@ -8,13 +7,14 @@ import org.bukkit.event.block.BlockDropItemEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import su.nightexpress.excellentenchants.EnchantsPlugin; import su.nightexpress.excellentenchants.EnchantsPlugin;
import su.nightexpress.excellentenchants.api.enchantment.ItemCategory; import su.nightexpress.excellentenchants.api.enchantment.ItemsCategory;
import su.nightexpress.excellentenchants.api.enchantment.Rarity; import su.nightexpress.excellentenchants.api.enchantment.Rarity;
import su.nightexpress.excellentenchants.api.enchantment.data.ChanceData; import su.nightexpress.excellentenchants.api.enchantment.data.ChanceData;
import su.nightexpress.excellentenchants.api.enchantment.data.ChanceSettings; import su.nightexpress.excellentenchants.api.enchantment.data.ChanceSettings;
import su.nightexpress.excellentenchants.api.enchantment.type.BlockDropEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.BlockDropEnchant;
import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData; import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData;
import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl; import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl;
import su.nightexpress.excellentenchants.enchantment.data.ItemCategories;
import su.nightexpress.nightcore.config.FileConfig; import su.nightexpress.nightcore.config.FileConfig;
import su.nightexpress.nightcore.util.Players; import su.nightexpress.nightcore.util.Players;
@ -47,15 +47,21 @@ public class TelekinesisEnchant extends AbstractEnchantmentData implements Chanc
@Override @Override
@NotNull @NotNull
public ItemCategory[] getItemCategories() { public ItemsCategory getSupportedItems() {
return new ItemCategory[]{ItemCategory.TOOL}; return ItemCategories.TOOL;
} }
@Override // @Override
@NotNull // @NotNull
public EnchantmentTarget getCategory() { // public ItemCategory[] getItemCategories() {
return EnchantmentTarget.TOOL; // return new ItemCategory[]{ItemCategory.TOOL};
} // }
//
// @Override
// @NotNull
// public EnchantmentTarget getCategory() {
// return EnchantmentTarget.TOOL;
// }
@NotNull @NotNull
@Override @Override

View File

@ -3,17 +3,17 @@ package su.nightexpress.excellentenchants.enchantment.impl.tool;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.enchantments.EnchantmentTarget;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import su.nightexpress.excellentenchants.EnchantsPlugin; import su.nightexpress.excellentenchants.EnchantsPlugin;
import su.nightexpress.excellentenchants.api.enchantment.ItemCategory; import su.nightexpress.excellentenchants.api.enchantment.ItemsCategory;
import su.nightexpress.excellentenchants.api.enchantment.Rarity; import su.nightexpress.excellentenchants.api.enchantment.Rarity;
import su.nightexpress.excellentenchants.api.enchantment.type.BlockBreakEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.BlockBreakEnchant;
import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData; import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData;
import su.nightexpress.excellentenchants.enchantment.data.ItemCategories;
import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils; import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils;
import su.nightexpress.nightcore.config.ConfigValue; import su.nightexpress.nightcore.config.ConfigValue;
import su.nightexpress.nightcore.config.FileConfig; import su.nightexpress.nightcore.config.FileConfig;
@ -56,16 +56,28 @@ public class TunnelEnchant extends AbstractEnchantmentData implements BlockBreak
@Override @Override
@NotNull @NotNull
public ItemCategory[] getItemCategories() { public ItemsCategory getSupportedItems() {
return new ItemCategory[]{ItemCategory.PICKAXE, ItemCategory.SHOVEL}; return ItemCategories.TOOL;
} }
@Override @Override
@NotNull @NotNull
public EnchantmentTarget getCategory() { public ItemsCategory getPrimaryItems() {
return EnchantmentTarget.TOOL; return ItemCategories.PICKAXE;
} }
// @Override
// @NotNull
// public ItemCategory[] getItemCategories() {
// return new ItemCategory[]{ItemCategory.PICKAXE, ItemCategory.SHOVEL};
// }
//
// @Override
// @NotNull
// public EnchantmentTarget getCategory() {
// return EnchantmentTarget.TOOL;
// }
@Override @Override
public boolean onBreak(@NotNull BlockBreakEvent event, @NotNull LivingEntity entity, @NotNull ItemStack item, int level) { public boolean onBreak(@NotNull BlockBreakEvent event, @NotNull LivingEntity entity, @NotNull ItemStack item, int level) {
if (!(entity instanceof Player player)) return false; if (!(entity instanceof Player player)) return false;

View File

@ -4,7 +4,6 @@ import org.bukkit.Material;
import org.bukkit.Tag; import org.bukkit.Tag;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.enchantments.EnchantmentTarget;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockBreakEvent;
@ -12,10 +11,11 @@ import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import su.nightexpress.excellentenchants.EnchantsPlugin; import su.nightexpress.excellentenchants.EnchantsPlugin;
import su.nightexpress.excellentenchants.api.Modifier; import su.nightexpress.excellentenchants.api.Modifier;
import su.nightexpress.excellentenchants.api.enchantment.ItemCategory; import su.nightexpress.excellentenchants.api.enchantment.ItemsCategory;
import su.nightexpress.excellentenchants.api.enchantment.Rarity; import su.nightexpress.excellentenchants.api.enchantment.Rarity;
import su.nightexpress.excellentenchants.api.enchantment.type.BlockBreakEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.BlockBreakEnchant;
import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData; import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData;
import su.nightexpress.excellentenchants.enchantment.data.ItemCategories;
import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils; import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils;
import su.nightexpress.nightcore.config.ConfigValue; import su.nightexpress.nightcore.config.ConfigValue;
import su.nightexpress.nightcore.config.FileConfig; import su.nightexpress.nightcore.config.FileConfig;
@ -96,16 +96,28 @@ public class VeinminerEnchant extends AbstractEnchantmentData implements BlockBr
@Override @Override
@NotNull @NotNull
public ItemCategory[] getItemCategories() { public ItemsCategory getSupportedItems() {
return new ItemCategory[]{ItemCategory.PICKAXE}; return ItemCategories.TOOL;
} }
@NotNull
@Override @Override
public EnchantmentTarget getCategory() { @NotNull
return EnchantmentTarget.TOOL; public ItemsCategory getPrimaryItems() {
return ItemCategories.PICKAXE;
} }
// @Override
// @NotNull
// public ItemCategory[] getItemCategories() {
// return new ItemCategory[]{ItemCategory.PICKAXE};
// }
//
// @NotNull
// @Override
// public EnchantmentTarget getCategory() {
// return EnchantmentTarget.TOOL;
// }
@NotNull @NotNull
private Set<Block> getNearby(@NotNull Block block) { private Set<Block> getNearby(@NotNull Block block) {
return Stream.of(AREA).map(block::getRelative) return Stream.of(AREA).map(block::getRelative)

View File

@ -1,6 +1,5 @@
package su.nightexpress.excellentenchants.enchantment.impl.universal; package su.nightexpress.excellentenchants.enchantment.impl.universal;
import org.bukkit.enchantments.EnchantmentTarget;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryClickEvent;
@ -12,9 +11,11 @@ import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import su.nightexpress.excellentenchants.EnchantsPlugin; import su.nightexpress.excellentenchants.EnchantsPlugin;
import su.nightexpress.excellentenchants.api.enchantment.ItemsCategory;
import su.nightexpress.excellentenchants.api.enchantment.Rarity; import su.nightexpress.excellentenchants.api.enchantment.Rarity;
import su.nightexpress.excellentenchants.api.enchantment.type.GenericEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.GenericEnchant;
import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData; import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData;
import su.nightexpress.excellentenchants.enchantment.data.ItemCategories;
import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils; import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils;
import su.nightexpress.nightcore.config.FileConfig; import su.nightexpress.nightcore.config.FileConfig;
import su.nightexpress.nightcore.manager.SimpeListener; import su.nightexpress.nightcore.manager.SimpeListener;
@ -37,12 +38,24 @@ public class CurseOfFragilityEnchant extends AbstractEnchantmentData implements
} }
@NotNull
@Override @Override
public EnchantmentTarget getCategory() { @NotNull
return EnchantmentTarget.BREAKABLE; public ItemsCategory getSupportedItems() {
return ItemCategories.BREAKABLE;
} }
// @Override
// @NotNull
// public ItemsCategory getPrimaryItems() {
// return ItemCategories.PICKAXE;
// }
//
// @NotNull
// @Override
// public EnchantmentTarget getCategory() {
// return EnchantmentTarget.BREAKABLE;
// }
@Override @Override
public boolean isCurse() { public boolean isCurse() {
return true; return true;

View File

@ -1,7 +1,6 @@
package su.nightexpress.excellentenchants.enchantment.impl.universal; package su.nightexpress.excellentenchants.enchantment.impl.universal;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.enchantments.EnchantmentTarget;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerItemDamageEvent; import org.bukkit.event.player.PlayerItemDamageEvent;
@ -10,12 +9,14 @@ import org.bukkit.inventory.meta.Damageable;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import su.nightexpress.excellentenchants.EnchantsPlugin; import su.nightexpress.excellentenchants.EnchantsPlugin;
import su.nightexpress.excellentenchants.api.Modifier; import su.nightexpress.excellentenchants.api.Modifier;
import su.nightexpress.excellentenchants.api.enchantment.ItemsCategory;
import su.nightexpress.excellentenchants.api.enchantment.Rarity; import su.nightexpress.excellentenchants.api.enchantment.Rarity;
import su.nightexpress.excellentenchants.api.enchantment.data.ChanceData; import su.nightexpress.excellentenchants.api.enchantment.data.ChanceData;
import su.nightexpress.excellentenchants.api.enchantment.data.ChanceSettings; import su.nightexpress.excellentenchants.api.enchantment.data.ChanceSettings;
import su.nightexpress.excellentenchants.api.enchantment.type.GenericEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.GenericEnchant;
import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData; import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData;
import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl; import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl;
import su.nightexpress.excellentenchants.enchantment.data.ItemCategories;
import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils; import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils;
import su.nightexpress.nightcore.config.FileConfig; import su.nightexpress.nightcore.config.FileConfig;
import su.nightexpress.nightcore.manager.SimpeListener; import su.nightexpress.nightcore.manager.SimpeListener;
@ -24,7 +25,8 @@ import su.nightexpress.nightcore.util.wrapper.UniSound;
import java.io.File; import java.io.File;
import static su.nightexpress.excellentenchants.Placeholders.*; import static su.nightexpress.excellentenchants.Placeholders.ENCHANTMENT_CHANCE;
import static su.nightexpress.excellentenchants.Placeholders.GENERIC_AMOUNT;
public class RestoreEnchant extends AbstractEnchantmentData implements GenericEnchant, ChanceData, SimpeListener { public class RestoreEnchant extends AbstractEnchantmentData implements GenericEnchant, ChanceData, SimpeListener {
@ -57,12 +59,18 @@ public class RestoreEnchant extends AbstractEnchantmentData implements GenericEn
return chanceSettings; return chanceSettings;
} }
@NotNull
@Override @Override
public EnchantmentTarget getCategory() { @NotNull
return EnchantmentTarget.BREAKABLE; public ItemsCategory getSupportedItems() {
return ItemCategories.BREAKABLE;
} }
// @NotNull
// @Override
// public EnchantmentTarget getCategory() {
// return EnchantmentTarget.BREAKABLE;
// }
public double getDurabilityRestore(int level) { public double getDurabilityRestore(int level) {
return this.durabilityRestore.getValue(level); return this.durabilityRestore.getValue(level);
} }

View File

@ -3,7 +3,6 @@ package su.nightexpress.excellentenchants.enchantment.impl.universal;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.Enchantment;
import org.bukkit.enchantments.EnchantmentTarget;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
@ -11,9 +10,11 @@ import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import su.nightexpress.excellentenchants.EnchantsPlugin; import su.nightexpress.excellentenchants.EnchantsPlugin;
import su.nightexpress.excellentenchants.api.enchantment.ItemsCategory;
import su.nightexpress.excellentenchants.api.enchantment.Rarity; import su.nightexpress.excellentenchants.api.enchantment.Rarity;
import su.nightexpress.excellentenchants.api.enchantment.type.GenericEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.GenericEnchant;
import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData; import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData;
import su.nightexpress.excellentenchants.enchantment.data.ItemCategories;
import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils; import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils;
import su.nightexpress.nightcore.config.FileConfig; import su.nightexpress.nightcore.config.FileConfig;
import su.nightexpress.nightcore.manager.SimpeListener; import su.nightexpress.nightcore.manager.SimpeListener;
@ -39,12 +40,18 @@ public class SoulboundEnchant extends AbstractEnchantmentData implements Generic
} }
@NotNull
@Override @Override
public EnchantmentTarget getCategory() { @NotNull
return EnchantmentTarget.BREAKABLE; public ItemsCategory getSupportedItems() {
return ItemCategories.BREAKABLE;
} }
// @NotNull
// @Override
// public EnchantmentTarget getCategory() {
// return EnchantmentTarget.BREAKABLE;
// }
@EventHandler(priority = EventPriority.MONITOR) @EventHandler(priority = EventPriority.MONITOR)
public void onDeath(@NotNull PlayerDeathEvent deathEvent) { public void onDeath(@NotNull PlayerDeathEvent deathEvent) {
Player player = deathEvent.getEntity(); Player player = deathEvent.getEntity();

View File

@ -1,7 +1,6 @@
package su.nightexpress.excellentenchants.enchantment.impl.weapon; package su.nightexpress.excellentenchants.enchantment.impl.weapon;
import org.bukkit.Particle; import org.bukkit.Particle;
import org.bukkit.enchantments.EnchantmentTarget;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
@ -9,9 +8,11 @@ import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import su.nightexpress.excellentenchants.EnchantsPlugin; import su.nightexpress.excellentenchants.EnchantsPlugin;
import su.nightexpress.excellentenchants.api.Modifier; import su.nightexpress.excellentenchants.api.Modifier;
import su.nightexpress.excellentenchants.api.enchantment.ItemsCategory;
import su.nightexpress.excellentenchants.api.enchantment.Rarity; import su.nightexpress.excellentenchants.api.enchantment.Rarity;
import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant;
import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData; import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData;
import su.nightexpress.excellentenchants.enchantment.data.ItemCategories;
import su.nightexpress.nightcore.config.ConfigValue; import su.nightexpress.nightcore.config.ConfigValue;
import su.nightexpress.nightcore.config.FileConfig; import su.nightexpress.nightcore.config.FileConfig;
import su.nightexpress.nightcore.util.Lists; import su.nightexpress.nightcore.util.Lists;
@ -21,7 +22,7 @@ import su.nightexpress.nightcore.util.wrapper.UniParticle;
import java.io.File; import java.io.File;
import java.util.Set; import java.util.Set;
import static su.nightexpress.excellentenchants.Placeholders.*; import static su.nightexpress.excellentenchants.Placeholders.GENERIC_DAMAGE;
public class BaneOfNetherspawnEnchant extends AbstractEnchantmentData implements CombatEnchant { public class BaneOfNetherspawnEnchant extends AbstractEnchantmentData implements CombatEnchant {
@ -64,10 +65,16 @@ public class BaneOfNetherspawnEnchant extends AbstractEnchantmentData implements
@Override @Override
@NotNull @NotNull
public EnchantmentTarget getCategory() { public ItemsCategory getSupportedItems() {
return EnchantmentTarget.WEAPON; return ItemCategories.WEAPON;
} }
// @Override
// @NotNull
// public EnchantmentTarget getCategory() {
// return EnchantmentTarget.WEAPON;
// }
@Override @Override
public boolean onAttack(@NotNull EntityDamageByEntityEvent event, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { public boolean onAttack(@NotNull EntityDamageByEntityEvent event, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) {
if (!ENTITY_TYPES.contains(victim.getType())) return false; if (!ENTITY_TYPES.contains(victim.getType())) return false;

View File

@ -1,7 +1,6 @@
package su.nightexpress.excellentenchants.enchantment.impl.weapon; package su.nightexpress.excellentenchants.enchantment.impl.weapon;
import org.bukkit.Particle; import org.bukkit.Particle;
import org.bukkit.enchantments.EnchantmentTarget;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
@ -10,6 +9,7 @@ import org.bukkit.potion.PotionEffectType;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import su.nightexpress.excellentenchants.EnchantsPlugin; import su.nightexpress.excellentenchants.EnchantsPlugin;
import su.nightexpress.excellentenchants.api.Modifier; import su.nightexpress.excellentenchants.api.Modifier;
import su.nightexpress.excellentenchants.api.enchantment.ItemsCategory;
import su.nightexpress.excellentenchants.api.enchantment.Rarity; import su.nightexpress.excellentenchants.api.enchantment.Rarity;
import su.nightexpress.excellentenchants.api.enchantment.data.ChanceData; import su.nightexpress.excellentenchants.api.enchantment.data.ChanceData;
import su.nightexpress.excellentenchants.api.enchantment.data.ChanceSettings; import su.nightexpress.excellentenchants.api.enchantment.data.ChanceSettings;
@ -18,6 +18,7 @@ import su.nightexpress.excellentenchants.api.enchantment.data.PotionSettings;
import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant;
import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData; import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData;
import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl; import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl;
import su.nightexpress.excellentenchants.enchantment.data.ItemCategories;
import su.nightexpress.excellentenchants.enchantment.data.PotionSettingsImpl; import su.nightexpress.excellentenchants.enchantment.data.PotionSettingsImpl;
import su.nightexpress.nightcore.config.FileConfig; import su.nightexpress.nightcore.config.FileConfig;
import su.nightexpress.nightcore.util.wrapper.UniParticle; import su.nightexpress.nightcore.util.wrapper.UniParticle;
@ -61,12 +62,18 @@ public class BlindnessEnchant extends AbstractEnchantmentData implements ChanceD
return potionSettings; return potionSettings;
} }
@NotNull
@Override @Override
public EnchantmentTarget getCategory() { @NotNull
return EnchantmentTarget.WEAPON; public ItemsCategory getSupportedItems() {
return ItemCategories.WEAPON;
} }
// @NotNull
// @Override
// public EnchantmentTarget getCategory() {
// return EnchantmentTarget.WEAPON;
// }
@NotNull @NotNull
@Override @Override
public EventPriority getAttackPriority() { public EventPriority getAttackPriority() {

View File

@ -1,7 +1,6 @@
package su.nightexpress.excellentenchants.enchantment.impl.weapon; package su.nightexpress.excellentenchants.enchantment.impl.weapon;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.enchantments.EnchantmentTarget;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
@ -10,6 +9,7 @@ import org.bukkit.potion.PotionEffectType;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import su.nightexpress.excellentenchants.EnchantsPlugin; import su.nightexpress.excellentenchants.EnchantsPlugin;
import su.nightexpress.excellentenchants.api.Modifier; import su.nightexpress.excellentenchants.api.Modifier;
import su.nightexpress.excellentenchants.api.enchantment.ItemsCategory;
import su.nightexpress.excellentenchants.api.enchantment.Rarity; import su.nightexpress.excellentenchants.api.enchantment.Rarity;
import su.nightexpress.excellentenchants.api.enchantment.data.ChanceData; import su.nightexpress.excellentenchants.api.enchantment.data.ChanceData;
import su.nightexpress.excellentenchants.api.enchantment.data.ChanceSettings; import su.nightexpress.excellentenchants.api.enchantment.data.ChanceSettings;
@ -18,6 +18,7 @@ import su.nightexpress.excellentenchants.api.enchantment.data.PotionSettings;
import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant;
import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData; import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData;
import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl; import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl;
import su.nightexpress.excellentenchants.enchantment.data.ItemCategories;
import su.nightexpress.excellentenchants.enchantment.data.PotionSettingsImpl; import su.nightexpress.excellentenchants.enchantment.data.PotionSettingsImpl;
import su.nightexpress.nightcore.config.FileConfig; import su.nightexpress.nightcore.config.FileConfig;
import su.nightexpress.nightcore.util.wrapper.UniParticle; import su.nightexpress.nightcore.util.wrapper.UniParticle;
@ -61,12 +62,18 @@ public class ConfusionEnchant extends AbstractEnchantmentData implements ChanceD
return potionSettings; return potionSettings;
} }
@NotNull
@Override @Override
public EnchantmentTarget getCategory() { @NotNull
return EnchantmentTarget.WEAPON; public ItemsCategory getSupportedItems() {
return ItemCategories.WEAPON;
} }
// @NotNull
// @Override
// public EnchantmentTarget getCategory() {
// return EnchantmentTarget.WEAPON;
// }
@NotNull @NotNull
@Override @Override
public EventPriority getAttackPriority() { public EventPriority getAttackPriority() {

View File

@ -2,7 +2,6 @@ package su.nightexpress.excellentenchants.enchantment.impl.weapon;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import org.bukkit.Particle; import org.bukkit.Particle;
import org.bukkit.enchantments.EnchantmentTarget;
import org.bukkit.entity.*; import org.bukkit.entity.*;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
@ -10,19 +9,21 @@ import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import su.nightexpress.excellentenchants.EnchantsPlugin; import su.nightexpress.excellentenchants.EnchantsPlugin;
import su.nightexpress.excellentenchants.api.Modifier; import su.nightexpress.excellentenchants.api.Modifier;
import su.nightexpress.excellentenchants.api.enchantment.ItemsCategory;
import su.nightexpress.excellentenchants.api.enchantment.Rarity; import su.nightexpress.excellentenchants.api.enchantment.Rarity;
import su.nightexpress.excellentenchants.api.enchantment.data.ChanceData; import su.nightexpress.excellentenchants.api.enchantment.data.ChanceData;
import su.nightexpress.excellentenchants.api.enchantment.data.ChanceSettings; import su.nightexpress.excellentenchants.api.enchantment.data.ChanceSettings;
import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant;
import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData; import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData;
import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl; import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl;
import su.nightexpress.excellentenchants.enchantment.data.ItemCategories;
import su.nightexpress.nightcore.config.FileConfig; import su.nightexpress.nightcore.config.FileConfig;
import su.nightexpress.nightcore.util.wrapper.UniParticle; import su.nightexpress.nightcore.util.wrapper.UniParticle;
import java.io.File; import java.io.File;
import java.util.Set; import java.util.Set;
import static su.nightexpress.excellentenchants.Placeholders.*; import static su.nightexpress.excellentenchants.Placeholders.ENCHANTMENT_CHANCE;
public class CureEnchant extends AbstractEnchantmentData implements ChanceData, CombatEnchant { public class CureEnchant extends AbstractEnchantmentData implements ChanceData, CombatEnchant {
@ -52,10 +53,16 @@ public class CureEnchant extends AbstractEnchantmentData implements ChanceData,
@Override @Override
@NotNull @NotNull
public EnchantmentTarget getCategory() { public ItemsCategory getSupportedItems() {
return EnchantmentTarget.WEAPON; return ItemCategories.WEAPON;
} }
// @Override
// @NotNull
// public EnchantmentTarget getCategory() {
// return EnchantmentTarget.WEAPON;
// }
@NotNull @NotNull
@Override @Override
public EventPriority getAttackPriority() { public EventPriority getAttackPriority() {

View File

@ -1,6 +1,5 @@
package su.nightexpress.excellentenchants.enchantment.impl.weapon; package su.nightexpress.excellentenchants.enchantment.impl.weapon;
import org.bukkit.enchantments.EnchantmentTarget;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.event.entity.EntityDeathEvent;
@ -9,12 +8,14 @@ import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import su.nightexpress.excellentenchants.EnchantsPlugin; import su.nightexpress.excellentenchants.EnchantsPlugin;
import su.nightexpress.excellentenchants.api.Modifier; import su.nightexpress.excellentenchants.api.Modifier;
import su.nightexpress.excellentenchants.api.enchantment.ItemsCategory;
import su.nightexpress.excellentenchants.api.enchantment.Rarity; import su.nightexpress.excellentenchants.api.enchantment.Rarity;
import su.nightexpress.excellentenchants.api.enchantment.data.ChanceData; import su.nightexpress.excellentenchants.api.enchantment.data.ChanceData;
import su.nightexpress.excellentenchants.api.enchantment.data.ChanceSettings; import su.nightexpress.excellentenchants.api.enchantment.data.ChanceSettings;
import su.nightexpress.excellentenchants.api.enchantment.type.DeathEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.DeathEnchant;
import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData; import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData;
import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl; import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl;
import su.nightexpress.excellentenchants.enchantment.data.ItemCategories;
import su.nightexpress.nightcore.config.FileConfig; import su.nightexpress.nightcore.config.FileConfig;
import java.io.File; import java.io.File;
@ -37,12 +38,18 @@ public class CurseOfDeathEnchant extends AbstractEnchantmentData implements Deat
this.chanceSettings = ChanceSettingsImpl.create(config, Modifier.add(0.5, 0.15, 1, 100)); this.chanceSettings = ChanceSettingsImpl.create(config, Modifier.add(0.5, 0.15, 1, 100));
} }
@NotNull
@Override @Override
public EnchantmentTarget getCategory() { @NotNull
return EnchantmentTarget.WEAPON; public ItemsCategory getSupportedItems() {
return ItemCategories.WEAPON;
} }
// @NotNull
// @Override
// public EnchantmentTarget getCategory() {
// return EnchantmentTarget.WEAPON;
// }
@NotNull @NotNull
@Override @Override
public ChanceSettings getChanceSettings() { public ChanceSettings getChanceSettings() {

View File

@ -1,7 +1,6 @@
package su.nightexpress.excellentenchants.enchantment.impl.weapon; package su.nightexpress.excellentenchants.enchantment.impl.weapon;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.enchantments.EnchantmentTarget;
import org.bukkit.entity.Item; import org.bukkit.entity.Item;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -14,12 +13,14 @@ import org.bukkit.inventory.meta.ItemMeta;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import su.nightexpress.excellentenchants.EnchantsPlugin; import su.nightexpress.excellentenchants.EnchantsPlugin;
import su.nightexpress.excellentenchants.api.Modifier; import su.nightexpress.excellentenchants.api.Modifier;
import su.nightexpress.excellentenchants.api.enchantment.ItemsCategory;
import su.nightexpress.excellentenchants.api.enchantment.Rarity; import su.nightexpress.excellentenchants.api.enchantment.Rarity;
import su.nightexpress.excellentenchants.api.enchantment.data.ChanceData; import su.nightexpress.excellentenchants.api.enchantment.data.ChanceData;
import su.nightexpress.excellentenchants.api.enchantment.data.ChanceSettings; import su.nightexpress.excellentenchants.api.enchantment.data.ChanceSettings;
import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant;
import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData; import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData;
import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl; import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl;
import su.nightexpress.excellentenchants.enchantment.data.ItemCategories;
import su.nightexpress.nightcore.config.ConfigValue; import su.nightexpress.nightcore.config.ConfigValue;
import su.nightexpress.nightcore.config.FileConfig; import su.nightexpress.nightcore.config.FileConfig;
import su.nightexpress.nightcore.util.NumberUtil; import su.nightexpress.nightcore.util.NumberUtil;
@ -29,7 +30,8 @@ import su.nightexpress.nightcore.util.wrapper.UniSound;
import java.io.File; import java.io.File;
import static su.nightexpress.excellentenchants.Placeholders.*; import static su.nightexpress.excellentenchants.Placeholders.ENCHANTMENT_CHANCE;
import static su.nightexpress.excellentenchants.Placeholders.GENERIC_DAMAGE;
public class CutterEnchant extends AbstractEnchantmentData implements ChanceData, CombatEnchant { public class CutterEnchant extends AbstractEnchantmentData implements ChanceData, CombatEnchant {
@ -78,10 +80,16 @@ public class CutterEnchant extends AbstractEnchantmentData implements ChanceData
@Override @Override
@NotNull @NotNull
public EnchantmentTarget getCategory() { public ItemsCategory getSupportedItems() {
return EnchantmentTarget.WEAPON; return ItemCategories.WEAPON;
} }
// @Override
// @NotNull
// public EnchantmentTarget getCategory() {
// return EnchantmentTarget.WEAPON;
// }
@NotNull @NotNull
@Override @Override
public EventPriority getAttackPriority() { public EventPriority getAttackPriority() {

View File

@ -4,7 +4,6 @@ package su.nightexpress.excellentenchants.enchantment.impl.weapon;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.NamespacedKey; import org.bukkit.NamespacedKey;
import org.bukkit.block.Skull; import org.bukkit.block.Skull;
import org.bukkit.enchantments.EnchantmentTarget;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -19,12 +18,14 @@ import org.bukkit.inventory.meta.SkullMeta;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import su.nightexpress.excellentenchants.EnchantsPlugin; import su.nightexpress.excellentenchants.EnchantsPlugin;
import su.nightexpress.excellentenchants.api.Modifier; import su.nightexpress.excellentenchants.api.Modifier;
import su.nightexpress.excellentenchants.api.enchantment.ItemsCategory;
import su.nightexpress.excellentenchants.api.enchantment.Rarity; import su.nightexpress.excellentenchants.api.enchantment.Rarity;
import su.nightexpress.excellentenchants.api.enchantment.data.ChanceData; import su.nightexpress.excellentenchants.api.enchantment.data.ChanceData;
import su.nightexpress.excellentenchants.api.enchantment.data.ChanceSettings; import su.nightexpress.excellentenchants.api.enchantment.data.ChanceSettings;
import su.nightexpress.excellentenchants.api.enchantment.type.DeathEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.DeathEnchant;
import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData; import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData;
import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl; import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl;
import su.nightexpress.excellentenchants.enchantment.data.ItemCategories;
import su.nightexpress.excellentenchants.hook.HookPlugin; import su.nightexpress.excellentenchants.hook.HookPlugin;
import su.nightexpress.excellentenchants.hook.impl.MythicMobsHook; import su.nightexpress.excellentenchants.hook.impl.MythicMobsHook;
import su.nightexpress.nightcore.config.ConfigValue; import su.nightexpress.nightcore.config.ConfigValue;
@ -41,8 +42,9 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import static su.nightexpress.excellentenchants.Placeholders.*; import static su.nightexpress.excellentenchants.Placeholders.ENCHANTMENT_CHANCE;
import static su.nightexpress.nightcore.util.text.tag.Tags.*; import static su.nightexpress.excellentenchants.Placeholders.GENERIC_TYPE;
import static su.nightexpress.nightcore.util.text.tag.Tags.LIGHT_YELLOW;
public class DecapitatorEnchant extends AbstractEnchantmentData implements ChanceData, DeathEnchant { public class DecapitatorEnchant extends AbstractEnchantmentData implements ChanceData, DeathEnchant {
@ -172,10 +174,16 @@ public class DecapitatorEnchant extends AbstractEnchantmentData implements Chanc
@Override @Override
@NotNull @NotNull
public EnchantmentTarget getCategory() { public ItemsCategory getSupportedItems() {
return EnchantmentTarget.WEAPON; return ItemCategories.WEAPON;
} }
// @Override
// @NotNull
// public EnchantmentTarget getCategory() {
// return EnchantmentTarget.WEAPON;
// }
@Override @Override
public boolean onDeath(@NotNull EntityDeathEvent event, @NotNull LivingEntity entity, ItemStack item, int level) { public boolean onDeath(@NotNull EntityDeathEvent event, @NotNull LivingEntity entity, ItemStack item, int level) {
return false; return false;

View File

@ -2,7 +2,6 @@ package su.nightexpress.excellentenchants.enchantment.impl.weapon;
import org.bukkit.Particle; import org.bukkit.Particle;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.enchantments.EnchantmentTarget;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
@ -10,19 +9,21 @@ import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import su.nightexpress.excellentenchants.EnchantsPlugin; import su.nightexpress.excellentenchants.EnchantsPlugin;
import su.nightexpress.excellentenchants.api.Modifier; import su.nightexpress.excellentenchants.api.Modifier;
import su.nightexpress.excellentenchants.api.enchantment.ItemsCategory;
import su.nightexpress.excellentenchants.api.enchantment.Rarity; import su.nightexpress.excellentenchants.api.enchantment.Rarity;
import su.nightexpress.excellentenchants.api.enchantment.data.ChanceData; import su.nightexpress.excellentenchants.api.enchantment.data.ChanceData;
import su.nightexpress.excellentenchants.api.enchantment.data.ChanceSettings; import su.nightexpress.excellentenchants.api.enchantment.data.ChanceSettings;
import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant;
import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData; import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData;
import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl; import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl;
import su.nightexpress.excellentenchants.enchantment.data.ItemCategories;
import su.nightexpress.nightcore.config.FileConfig; import su.nightexpress.nightcore.config.FileConfig;
import su.nightexpress.nightcore.util.wrapper.UniParticle; import su.nightexpress.nightcore.util.wrapper.UniParticle;
import su.nightexpress.nightcore.util.wrapper.UniSound; import su.nightexpress.nightcore.util.wrapper.UniSound;
import java.io.File; import java.io.File;
import static su.nightexpress.excellentenchants.Placeholders.*; import static su.nightexpress.excellentenchants.Placeholders.ENCHANTMENT_CHANCE;
public class DoubleStrikeEnchant extends AbstractEnchantmentData implements ChanceData, CombatEnchant { public class DoubleStrikeEnchant extends AbstractEnchantmentData implements ChanceData, CombatEnchant {
@ -50,10 +51,16 @@ public class DoubleStrikeEnchant extends AbstractEnchantmentData implements Chan
@Override @Override
@NotNull @NotNull
public EnchantmentTarget getCategory() { public ItemsCategory getSupportedItems() {
return EnchantmentTarget.WEAPON; return ItemCategories.WEAPON;
} }
// @Override
// @NotNull
// public EnchantmentTarget getCategory() {
// return EnchantmentTarget.WEAPON;
// }
@NotNull @NotNull
@Override @Override
public EventPriority getAttackPriority() { public EventPriority getAttackPriority() {

View File

@ -1,7 +1,6 @@
package su.nightexpress.excellentenchants.enchantment.impl.weapon; package su.nightexpress.excellentenchants.enchantment.impl.weapon;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.enchantments.EnchantmentTarget;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
@ -10,6 +9,7 @@ import org.bukkit.potion.PotionEffectType;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import su.nightexpress.excellentenchants.EnchantsPlugin; import su.nightexpress.excellentenchants.EnchantsPlugin;
import su.nightexpress.excellentenchants.api.Modifier; import su.nightexpress.excellentenchants.api.Modifier;
import su.nightexpress.excellentenchants.api.enchantment.ItemsCategory;
import su.nightexpress.excellentenchants.api.enchantment.Rarity; import su.nightexpress.excellentenchants.api.enchantment.Rarity;
import su.nightexpress.excellentenchants.api.enchantment.data.ChanceData; import su.nightexpress.excellentenchants.api.enchantment.data.ChanceData;
import su.nightexpress.excellentenchants.api.enchantment.data.ChanceSettings; import su.nightexpress.excellentenchants.api.enchantment.data.ChanceSettings;
@ -18,6 +18,7 @@ import su.nightexpress.excellentenchants.api.enchantment.data.PotionSettings;
import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant;
import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData; import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData;
import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl; import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl;
import su.nightexpress.excellentenchants.enchantment.data.ItemCategories;
import su.nightexpress.excellentenchants.enchantment.data.PotionSettingsImpl; import su.nightexpress.excellentenchants.enchantment.data.PotionSettingsImpl;
import su.nightexpress.nightcore.config.FileConfig; import su.nightexpress.nightcore.config.FileConfig;
import su.nightexpress.nightcore.util.wrapper.UniParticle; import su.nightexpress.nightcore.util.wrapper.UniParticle;
@ -62,12 +63,18 @@ public class ExhaustEnchant extends AbstractEnchantmentData implements ChanceDat
return potionSettings; return potionSettings;
} }
@NotNull
@Override @Override
public EnchantmentTarget getCategory() { @NotNull
return EnchantmentTarget.WEAPON; public ItemsCategory getSupportedItems() {
return ItemCategories.WEAPON;
} }
// @NotNull
// @Override
// public EnchantmentTarget getCategory() {
// return EnchantmentTarget.WEAPON;
// }
@NotNull @NotNull
@Override @Override
public EventPriority getAttackPriority() { public EventPriority getAttackPriority() {

View File

@ -3,7 +3,6 @@ package su.nightexpress.excellentenchants.enchantment.impl.weapon;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Particle; import org.bukkit.Particle;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.enchantments.EnchantmentTarget;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
@ -12,6 +11,7 @@ import org.bukkit.potion.PotionEffectType;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import su.nightexpress.excellentenchants.EnchantsPlugin; import su.nightexpress.excellentenchants.EnchantsPlugin;
import su.nightexpress.excellentenchants.api.Modifier; import su.nightexpress.excellentenchants.api.Modifier;
import su.nightexpress.excellentenchants.api.enchantment.ItemsCategory;
import su.nightexpress.excellentenchants.api.enchantment.Rarity; import su.nightexpress.excellentenchants.api.enchantment.Rarity;
import su.nightexpress.excellentenchants.api.enchantment.data.ChanceData; import su.nightexpress.excellentenchants.api.enchantment.data.ChanceData;
import su.nightexpress.excellentenchants.api.enchantment.data.ChanceSettings; import su.nightexpress.excellentenchants.api.enchantment.data.ChanceSettings;
@ -20,6 +20,7 @@ import su.nightexpress.excellentenchants.api.enchantment.data.PotionSettings;
import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant;
import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData; import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData;
import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl; import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl;
import su.nightexpress.excellentenchants.enchantment.data.ItemCategories;
import su.nightexpress.excellentenchants.enchantment.data.PotionSettingsImpl; import su.nightexpress.excellentenchants.enchantment.data.PotionSettingsImpl;
import su.nightexpress.nightcore.config.FileConfig; import su.nightexpress.nightcore.config.FileConfig;
import su.nightexpress.nightcore.util.wrapper.UniParticle; import su.nightexpress.nightcore.util.wrapper.UniParticle;
@ -65,12 +66,18 @@ public class IceAspectEnchant extends AbstractEnchantmentData implements ChanceD
return potionSettings; return potionSettings;
} }
@NotNull
@Override @Override
public EnchantmentTarget getCategory() { @NotNull
return EnchantmentTarget.WEAPON; public ItemsCategory getSupportedItems() {
return ItemCategories.WEAPON;
} }
// @NotNull
// @Override
// public EnchantmentTarget getCategory() {
// return EnchantmentTarget.WEAPON;
// }
@NotNull @NotNull
@Override @Override
public EventPriority getAttackPriority() { public EventPriority getAttackPriority() {

View File

@ -1,6 +1,5 @@
package su.nightexpress.excellentenchants.enchantment.impl.weapon; package su.nightexpress.excellentenchants.enchantment.impl.weapon;
import org.bukkit.enchantments.EnchantmentTarget;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Trident; import org.bukkit.entity.Trident;
@ -12,9 +11,11 @@ import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import su.nightexpress.excellentenchants.EnchantsPlugin; import su.nightexpress.excellentenchants.EnchantsPlugin;
import su.nightexpress.excellentenchants.api.Modifier; import su.nightexpress.excellentenchants.api.Modifier;
import su.nightexpress.excellentenchants.api.enchantment.ItemsCategory;
import su.nightexpress.excellentenchants.api.enchantment.Rarity; import su.nightexpress.excellentenchants.api.enchantment.Rarity;
import su.nightexpress.excellentenchants.api.enchantment.type.GenericEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.GenericEnchant;
import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData; import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData;
import su.nightexpress.excellentenchants.enchantment.data.ItemCategories;
import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils; import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils;
import su.nightexpress.nightcore.config.FileConfig; import su.nightexpress.nightcore.config.FileConfig;
import su.nightexpress.nightcore.manager.SimpeListener; import su.nightexpress.nightcore.manager.SimpeListener;
@ -22,7 +23,7 @@ import su.nightexpress.nightcore.util.NumberUtil;
import java.io.File; import java.io.File;
import static su.nightexpress.excellentenchants.Placeholders.*; import static su.nightexpress.excellentenchants.Placeholders.GENERIC_TIME;
public class InfernusEnchant extends AbstractEnchantmentData implements GenericEnchant, SimpeListener { public class InfernusEnchant extends AbstractEnchantmentData implements GenericEnchant, SimpeListener {
@ -52,10 +53,16 @@ public class InfernusEnchant extends AbstractEnchantmentData implements GenericE
@Override @Override
@NotNull @NotNull
public EnchantmentTarget getCategory() { public ItemsCategory getSupportedItems() {
return EnchantmentTarget.TRIDENT; return ItemCategories.TRIDENT;
} }
// @Override
// @NotNull
// public EnchantmentTarget getCategory() {
// return EnchantmentTarget.TRIDENT;
// }
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onInfernusTridentLaunch(ProjectileLaunchEvent event) { public void onInfernusTridentLaunch(ProjectileLaunchEvent event) {
Entity entity = event.getEntity(); Entity entity = event.getEntity();

View File

@ -1,6 +1,5 @@
package su.nightexpress.excellentenchants.enchantment.impl.weapon; package su.nightexpress.excellentenchants.enchantment.impl.weapon;
import org.bukkit.enchantments.EnchantmentTarget;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
@ -9,12 +8,14 @@ import org.bukkit.event.entity.EntityResurrectEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import su.nightexpress.excellentenchants.EnchantsPlugin; import su.nightexpress.excellentenchants.EnchantsPlugin;
import su.nightexpress.excellentenchants.api.enchantment.ItemsCategory;
import su.nightexpress.excellentenchants.api.enchantment.Rarity; import su.nightexpress.excellentenchants.api.enchantment.Rarity;
import su.nightexpress.excellentenchants.api.enchantment.data.ChanceData; import su.nightexpress.excellentenchants.api.enchantment.data.ChanceData;
import su.nightexpress.excellentenchants.api.enchantment.data.ChanceSettings; import su.nightexpress.excellentenchants.api.enchantment.data.ChanceSettings;
import su.nightexpress.excellentenchants.api.enchantment.type.DeathEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.DeathEnchant;
import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData; import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData;
import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl; import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl;
import su.nightexpress.excellentenchants.enchantment.data.ItemCategories;
import su.nightexpress.nightcore.config.FileConfig; import su.nightexpress.nightcore.config.FileConfig;
import su.nightexpress.nightcore.util.Players; import su.nightexpress.nightcore.util.Players;
@ -44,11 +45,17 @@ public class NimbleEnchant extends AbstractEnchantmentData implements ChanceData
return chanceSettings; return chanceSettings;
} }
@NotNull
@Override @Override
public EnchantmentTarget getCategory() { @NotNull
return EnchantmentTarget.WEAPON; public ItemsCategory getSupportedItems() {
return ItemCategories.WEAPON;
} }
//
// @NotNull
// @Override
// public EnchantmentTarget getCategory() {
// return EnchantmentTarget.WEAPON;
// }
@NotNull @NotNull
@Override @Override

View File

@ -1,7 +1,6 @@
package su.nightexpress.excellentenchants.enchantment.impl.weapon; package su.nightexpress.excellentenchants.enchantment.impl.weapon;
import org.bukkit.Particle; import org.bukkit.Particle;
import org.bukkit.enchantments.EnchantmentTarget;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
@ -10,6 +9,7 @@ import org.bukkit.potion.PotionEffectType;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import su.nightexpress.excellentenchants.EnchantsPlugin; import su.nightexpress.excellentenchants.EnchantsPlugin;
import su.nightexpress.excellentenchants.api.Modifier; import su.nightexpress.excellentenchants.api.Modifier;
import su.nightexpress.excellentenchants.api.enchantment.ItemsCategory;
import su.nightexpress.excellentenchants.api.enchantment.Rarity; import su.nightexpress.excellentenchants.api.enchantment.Rarity;
import su.nightexpress.excellentenchants.api.enchantment.data.ChanceData; import su.nightexpress.excellentenchants.api.enchantment.data.ChanceData;
import su.nightexpress.excellentenchants.api.enchantment.data.ChanceSettings; import su.nightexpress.excellentenchants.api.enchantment.data.ChanceSettings;
@ -18,6 +18,7 @@ import su.nightexpress.excellentenchants.api.enchantment.data.PotionSettings;
import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant;
import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData; import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData;
import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl; import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl;
import su.nightexpress.excellentenchants.enchantment.data.ItemCategories;
import su.nightexpress.excellentenchants.enchantment.data.PotionSettingsImpl; import su.nightexpress.excellentenchants.enchantment.data.PotionSettingsImpl;
import su.nightexpress.nightcore.config.FileConfig; import su.nightexpress.nightcore.config.FileConfig;
import su.nightexpress.nightcore.util.wrapper.UniParticle; import su.nightexpress.nightcore.util.wrapper.UniParticle;
@ -62,12 +63,18 @@ public class ParalyzeEnchant extends AbstractEnchantmentData implements ChanceDa
return potionSettings; return potionSettings;
} }
@NotNull
@Override @Override
public EnchantmentTarget getCategory() { @NotNull
return EnchantmentTarget.WEAPON; public ItemsCategory getSupportedItems() {
return ItemCategories.WEAPON;
} }
// @NotNull
// @Override
// public EnchantmentTarget getCategory() {
// return EnchantmentTarget.WEAPON;
// }
@NotNull @NotNull
@Override @Override
public EventPriority getAttackPriority() { public EventPriority getAttackPriority() {

View File

@ -1,7 +1,6 @@
package su.nightexpress.excellentenchants.enchantment.impl.weapon; package su.nightexpress.excellentenchants.enchantment.impl.weapon;
import org.bukkit.Particle; import org.bukkit.Particle;
import org.bukkit.enchantments.EnchantmentTarget;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
@ -10,6 +9,7 @@ import org.bukkit.potion.PotionEffectType;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import su.nightexpress.excellentenchants.EnchantsPlugin; import su.nightexpress.excellentenchants.EnchantsPlugin;
import su.nightexpress.excellentenchants.api.Modifier; import su.nightexpress.excellentenchants.api.Modifier;
import su.nightexpress.excellentenchants.api.enchantment.ItemsCategory;
import su.nightexpress.excellentenchants.api.enchantment.Rarity; import su.nightexpress.excellentenchants.api.enchantment.Rarity;
import su.nightexpress.excellentenchants.api.enchantment.data.ChanceData; import su.nightexpress.excellentenchants.api.enchantment.data.ChanceData;
import su.nightexpress.excellentenchants.api.enchantment.data.ChanceSettings; import su.nightexpress.excellentenchants.api.enchantment.data.ChanceSettings;
@ -18,6 +18,7 @@ import su.nightexpress.excellentenchants.api.enchantment.data.PotionSettings;
import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant;
import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData; import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData;
import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl; import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl;
import su.nightexpress.excellentenchants.enchantment.data.ItemCategories;
import su.nightexpress.excellentenchants.enchantment.data.PotionSettingsImpl; import su.nightexpress.excellentenchants.enchantment.data.PotionSettingsImpl;
import su.nightexpress.nightcore.config.FileConfig; import su.nightexpress.nightcore.config.FileConfig;
import su.nightexpress.nightcore.util.wrapper.UniParticle; import su.nightexpress.nightcore.util.wrapper.UniParticle;
@ -62,12 +63,18 @@ public class RageEnchant extends AbstractEnchantmentData implements ChanceData,
return potionSettings; return potionSettings;
} }
@NotNull
@Override @Override
public EnchantmentTarget getCategory() { @NotNull
return EnchantmentTarget.WEAPON; public ItemsCategory getSupportedItems() {
return ItemCategories.WEAPON;
} }
// @NotNull
// @Override
// public EnchantmentTarget getCategory() {
// return EnchantmentTarget.WEAPON;
// }
@NotNull @NotNull
@Override @Override
public EventPriority getAttackPriority() { public EventPriority getAttackPriority() {

View File

@ -1,7 +1,6 @@
package su.nightexpress.excellentenchants.enchantment.impl.weapon; package su.nightexpress.excellentenchants.enchantment.impl.weapon;
import org.bukkit.*; import org.bukkit.*;
import org.bukkit.enchantments.EnchantmentTarget;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.bukkit.entity.Firework; import org.bukkit.entity.Firework;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
@ -12,19 +11,21 @@ import org.bukkit.inventory.meta.FireworkMeta;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import su.nightexpress.excellentenchants.EnchantsPlugin; import su.nightexpress.excellentenchants.EnchantsPlugin;
import su.nightexpress.excellentenchants.api.Modifier; import su.nightexpress.excellentenchants.api.Modifier;
import su.nightexpress.excellentenchants.api.enchantment.ItemsCategory;
import su.nightexpress.excellentenchants.api.enchantment.Rarity; import su.nightexpress.excellentenchants.api.enchantment.Rarity;
import su.nightexpress.excellentenchants.api.enchantment.data.ChanceData; import su.nightexpress.excellentenchants.api.enchantment.data.ChanceData;
import su.nightexpress.excellentenchants.api.enchantment.data.ChanceSettings; import su.nightexpress.excellentenchants.api.enchantment.data.ChanceSettings;
import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant;
import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData; import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData;
import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl; import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl;
import su.nightexpress.excellentenchants.enchantment.data.ItemCategories;
import su.nightexpress.nightcore.config.FileConfig; import su.nightexpress.nightcore.config.FileConfig;
import su.nightexpress.nightcore.util.random.Rnd; import su.nightexpress.nightcore.util.random.Rnd;
import su.nightexpress.nightcore.util.wrapper.UniSound; import su.nightexpress.nightcore.util.wrapper.UniSound;
import java.io.File; import java.io.File;
import static su.nightexpress.excellentenchants.Placeholders.*; import static su.nightexpress.excellentenchants.Placeholders.ENCHANTMENT_CHANCE;
public class RocketEnchant extends AbstractEnchantmentData implements ChanceData, CombatEnchant { public class RocketEnchant extends AbstractEnchantmentData implements ChanceData, CombatEnchant {
@ -61,10 +62,16 @@ public class RocketEnchant extends AbstractEnchantmentData implements ChanceData
@Override @Override
@NotNull @NotNull
public EnchantmentTarget getCategory() { public ItemsCategory getSupportedItems() {
return EnchantmentTarget.WEAPON; return ItemCategories.WEAPON;
} }
// @Override
// @NotNull
// public EnchantmentTarget getCategory() {
// return EnchantmentTarget.WEAPON;
// }
@NotNull @NotNull
@Override @Override
public EventPriority getAttackPriority() { public EventPriority getAttackPriority() {

View File

@ -1,6 +1,5 @@
package su.nightexpress.excellentenchants.enchantment.impl.weapon; package su.nightexpress.excellentenchants.enchantment.impl.weapon;
import org.bukkit.enchantments.EnchantmentTarget;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -14,12 +13,14 @@ import org.bukkit.loot.LootTables;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import su.nightexpress.excellentenchants.EnchantsPlugin; import su.nightexpress.excellentenchants.EnchantsPlugin;
import su.nightexpress.excellentenchants.api.Modifier; import su.nightexpress.excellentenchants.api.Modifier;
import su.nightexpress.excellentenchants.api.enchantment.ItemsCategory;
import su.nightexpress.excellentenchants.api.enchantment.Rarity; import su.nightexpress.excellentenchants.api.enchantment.Rarity;
import su.nightexpress.excellentenchants.api.enchantment.data.ChanceData; import su.nightexpress.excellentenchants.api.enchantment.data.ChanceData;
import su.nightexpress.excellentenchants.api.enchantment.data.ChanceSettings; import su.nightexpress.excellentenchants.api.enchantment.data.ChanceSettings;
import su.nightexpress.excellentenchants.api.enchantment.type.DeathEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.DeathEnchant;
import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData; import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData;
import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl; import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl;
import su.nightexpress.excellentenchants.enchantment.data.ItemCategories;
import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils; import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils;
import su.nightexpress.nightcore.config.ConfigValue; import su.nightexpress.nightcore.config.ConfigValue;
import su.nightexpress.nightcore.config.FileConfig; import su.nightexpress.nightcore.config.FileConfig;
@ -27,9 +28,12 @@ import su.nightexpress.nightcore.util.StringUtil;
import su.nightexpress.nightcore.util.random.Rnd; import su.nightexpress.nightcore.util.random.Rnd;
import java.io.File; import java.io.File;
import java.util.*; import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import static su.nightexpress.excellentenchants.Placeholders.*; import static su.nightexpress.excellentenchants.Placeholders.ENCHANTMENT_CHANCE;
public class ScavengerEnchant extends AbstractEnchantmentData implements ChanceData, DeathEnchant { public class ScavengerEnchant extends AbstractEnchantmentData implements ChanceData, DeathEnchant {
@ -119,10 +123,16 @@ public class ScavengerEnchant extends AbstractEnchantmentData implements ChanceD
@Override @Override
@NotNull @NotNull
public EnchantmentTarget getCategory() { public ItemsCategory getSupportedItems() {
return EnchantmentTarget.WEAPON; return ItemCategories.WEAPON;
} }
// @Override
// @NotNull
// public EnchantmentTarget getCategory() {
// return EnchantmentTarget.WEAPON;
// }
@Override @Override
public boolean onKill(@NotNull EntityDeathEvent event, @NotNull LivingEntity entity, @NotNull Player killer, @NotNull ItemStack weapon, int level) { public boolean onKill(@NotNull EntityDeathEvent event, @NotNull LivingEntity entity, @NotNull Player killer, @NotNull ItemStack weapon, int level) {
if (this.lootTables.isEmpty()) return false; if (this.lootTables.isEmpty()) return false;

View File

@ -3,7 +3,6 @@ package su.nightexpress.excellentenchants.enchantment.impl.weapon;
import org.bukkit.Color; import org.bukkit.Color;
import org.bukkit.Particle; import org.bukkit.Particle;
import org.bukkit.Registry; import org.bukkit.Registry;
import org.bukkit.enchantments.EnchantmentTarget;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
@ -13,6 +12,7 @@ import org.bukkit.potion.PotionEffectType;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import su.nightexpress.excellentenchants.EnchantsPlugin; import su.nightexpress.excellentenchants.EnchantsPlugin;
import su.nightexpress.excellentenchants.api.Modifier; import su.nightexpress.excellentenchants.api.Modifier;
import su.nightexpress.excellentenchants.api.enchantment.ItemsCategory;
import su.nightexpress.excellentenchants.api.enchantment.Rarity; import su.nightexpress.excellentenchants.api.enchantment.Rarity;
import su.nightexpress.excellentenchants.api.enchantment.data.ChanceData; import su.nightexpress.excellentenchants.api.enchantment.data.ChanceData;
import su.nightexpress.excellentenchants.api.enchantment.data.ChanceSettings; import su.nightexpress.excellentenchants.api.enchantment.data.ChanceSettings;
@ -21,6 +21,7 @@ import su.nightexpress.excellentenchants.api.enchantment.data.PotionSettings;
import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant;
import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData; import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData;
import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl; import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl;
import su.nightexpress.excellentenchants.enchantment.data.ItemCategories;
import su.nightexpress.excellentenchants.enchantment.data.PotionSettingsImpl; import su.nightexpress.excellentenchants.enchantment.data.PotionSettingsImpl;
import su.nightexpress.nightcore.config.FileConfig; import su.nightexpress.nightcore.config.FileConfig;
import su.nightexpress.nightcore.util.BukkitThing; import su.nightexpress.nightcore.util.BukkitThing;
@ -30,7 +31,7 @@ import su.nightexpress.nightcore.util.wrapper.UniParticle;
import java.io.File; import java.io.File;
import static su.nightexpress.excellentenchants.Placeholders.*; import static su.nightexpress.excellentenchants.Placeholders.ENCHANTMENT_CHANCE;
public class SurpriseEnchant extends AbstractEnchantmentData implements ChanceData, PotionData, CombatEnchant { public class SurpriseEnchant extends AbstractEnchantmentData implements ChanceData, PotionData, CombatEnchant {
@ -77,12 +78,18 @@ public class SurpriseEnchant extends AbstractEnchantmentData implements ChanceDa
return potionSettings; return potionSettings;
} }
@NotNull
@Override @Override
public EnchantmentTarget getCategory() { @NotNull
return EnchantmentTarget.WEAPON; public ItemsCategory getSupportedItems() {
return ItemCategories.WEAPON;
} }
// @NotNull
// @Override
// public EnchantmentTarget getCategory() {
// return EnchantmentTarget.WEAPON;
// }
@NotNull @NotNull
@Override @Override
public EventPriority getAttackPriority() { public EventPriority getAttackPriority() {

View File

@ -1,6 +1,5 @@
package su.nightexpress.excellentenchants.enchantment.impl.weapon; package su.nightexpress.excellentenchants.enchantment.impl.weapon;
import org.bukkit.enchantments.EnchantmentTarget;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
@ -8,18 +7,20 @@ import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import su.nightexpress.excellentenchants.EnchantsPlugin; import su.nightexpress.excellentenchants.EnchantsPlugin;
import su.nightexpress.excellentenchants.api.Modifier; import su.nightexpress.excellentenchants.api.Modifier;
import su.nightexpress.excellentenchants.api.enchantment.ItemsCategory;
import su.nightexpress.excellentenchants.api.enchantment.Rarity; import su.nightexpress.excellentenchants.api.enchantment.Rarity;
import su.nightexpress.excellentenchants.api.enchantment.data.ChanceData; import su.nightexpress.excellentenchants.api.enchantment.data.ChanceData;
import su.nightexpress.excellentenchants.api.enchantment.data.ChanceSettings; import su.nightexpress.excellentenchants.api.enchantment.data.ChanceSettings;
import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant;
import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData; import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData;
import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl; import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl;
import su.nightexpress.excellentenchants.enchantment.data.ItemCategories;
import su.nightexpress.nightcore.config.FileConfig; import su.nightexpress.nightcore.config.FileConfig;
import su.nightexpress.nightcore.util.NumberUtil; import su.nightexpress.nightcore.util.NumberUtil;
import java.io.File; import java.io.File;
import static su.nightexpress.excellentenchants.Placeholders.*; import static su.nightexpress.excellentenchants.Placeholders.ENCHANTMENT_CHANCE;
public class SwiperEnchant extends AbstractEnchantmentData implements CombatEnchant, ChanceData { public class SwiperEnchant extends AbstractEnchantmentData implements CombatEnchant, ChanceData {
@ -48,12 +49,18 @@ public class SwiperEnchant extends AbstractEnchantmentData implements CombatEnch
this.addPlaceholder(PLACEHOLER_XP_AMOUNT, level -> NumberUtil.format(this.getXPAmount(level))); this.addPlaceholder(PLACEHOLER_XP_AMOUNT, level -> NumberUtil.format(this.getXPAmount(level)));
} }
@NotNull
@Override @Override
public EnchantmentTarget getCategory() { @NotNull
return EnchantmentTarget.WEAPON; public ItemsCategory getSupportedItems() {
return ItemCategories.WEAPON;
} }
// @NotNull
// @Override
// public EnchantmentTarget getCategory() {
// return EnchantmentTarget.WEAPON;
// }
@NotNull @NotNull
@Override @Override
public ChanceSettings getChanceSettings() { public ChanceSettings getChanceSettings() {

View File

@ -1,23 +1,25 @@
package su.nightexpress.excellentenchants.enchantment.impl.weapon; package su.nightexpress.excellentenchants.enchantment.impl.weapon;
import org.bukkit.attribute.Attribute; import org.bukkit.attribute.Attribute;
import org.bukkit.enchantments.EnchantmentTarget;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import su.nightexpress.excellentenchants.EnchantsPlugin; import su.nightexpress.excellentenchants.EnchantsPlugin;
import su.nightexpress.excellentenchants.api.Modifier; import su.nightexpress.excellentenchants.api.Modifier;
import su.nightexpress.excellentenchants.api.enchantment.ItemsCategory;
import su.nightexpress.excellentenchants.api.enchantment.Rarity; import su.nightexpress.excellentenchants.api.enchantment.Rarity;
import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant;
import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData; import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData;
import su.nightexpress.excellentenchants.enchantment.data.ItemCategories;
import su.nightexpress.nightcore.config.FileConfig; import su.nightexpress.nightcore.config.FileConfig;
import su.nightexpress.nightcore.util.EntityUtil; import su.nightexpress.nightcore.util.EntityUtil;
import su.nightexpress.nightcore.util.NumberUtil; import su.nightexpress.nightcore.util.NumberUtil;
import java.io.File; import java.io.File;
import static su.nightexpress.excellentenchants.Placeholders.*; import static su.nightexpress.excellentenchants.Placeholders.GENERIC_AMOUNT;
import static su.nightexpress.excellentenchants.Placeholders.GENERIC_RADIUS;
public class TemperEnchant extends AbstractEnchantmentData implements CombatEnchant { public class TemperEnchant extends AbstractEnchantmentData implements CombatEnchant {
@ -57,11 +59,17 @@ public class TemperEnchant extends AbstractEnchantmentData implements CombatEnch
return this.damageStep.getValue(level); return this.damageStep.getValue(level);
} }
@NotNull
@Override @Override
public EnchantmentTarget getCategory() { @NotNull
return EnchantmentTarget.WEAPON; public ItemsCategory getSupportedItems() {
return ItemCategories.WEAPON;
} }
//
// @NotNull
// @Override
// public EnchantmentTarget getCategory() {
// return EnchantmentTarget.WEAPON;
// }
@Override @Override
public boolean onAttack(@NotNull EntityDamageByEntityEvent event, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { public boolean onAttack(@NotNull EntityDamageByEntityEvent event, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) {

View File

@ -1,7 +1,6 @@
package su.nightexpress.excellentenchants.enchantment.impl.weapon; package su.nightexpress.excellentenchants.enchantment.impl.weapon;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.enchantments.EnchantmentTarget;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -11,12 +10,14 @@ import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import su.nightexpress.excellentenchants.EnchantsPlugin; import su.nightexpress.excellentenchants.EnchantsPlugin;
import su.nightexpress.excellentenchants.api.Modifier; import su.nightexpress.excellentenchants.api.Modifier;
import su.nightexpress.excellentenchants.api.enchantment.ItemsCategory;
import su.nightexpress.excellentenchants.api.enchantment.Rarity; import su.nightexpress.excellentenchants.api.enchantment.Rarity;
import su.nightexpress.excellentenchants.api.enchantment.data.ChanceData; import su.nightexpress.excellentenchants.api.enchantment.data.ChanceData;
import su.nightexpress.excellentenchants.api.enchantment.data.ChanceSettings; import su.nightexpress.excellentenchants.api.enchantment.data.ChanceSettings;
import su.nightexpress.excellentenchants.api.enchantment.type.DeathEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.DeathEnchant;
import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData; import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData;
import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl; import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl;
import su.nightexpress.excellentenchants.enchantment.data.ItemCategories;
import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils; import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils;
import su.nightexpress.excellentenchants.hook.HookPlugin; import su.nightexpress.excellentenchants.hook.HookPlugin;
import su.nightexpress.excellentenchants.hook.impl.MythicMobsHook; import su.nightexpress.excellentenchants.hook.impl.MythicMobsHook;
@ -30,8 +31,8 @@ import su.nightexpress.nightcore.util.Version;
import java.io.File; import java.io.File;
import java.util.Set; import java.util.Set;
import static su.nightexpress.excellentenchants.Placeholders.*;
import static org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; import static org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
import static su.nightexpress.excellentenchants.Placeholders.ENCHANTMENT_CHANCE;
public class ThriftyEnchant extends AbstractEnchantmentData implements ChanceData, DeathEnchant { public class ThriftyEnchant extends AbstractEnchantmentData implements ChanceData, DeathEnchant {
@ -96,10 +97,16 @@ public class ThriftyEnchant extends AbstractEnchantmentData implements ChanceDat
@Override @Override
@NotNull @NotNull
public EnchantmentTarget getCategory() { public ItemsCategory getSupportedItems() {
return EnchantmentTarget.WEAPON; return ItemCategories.WEAPON;
} }
// @Override
// @NotNull
// public EnchantmentTarget getCategory() {
// return EnchantmentTarget.WEAPON;
// }
@Override @Override
public boolean onKill(@NotNull EntityDeathEvent event, @NotNull LivingEntity entity, @NotNull Player killer, ItemStack weapon, int level) { public boolean onKill(@NotNull EntityDeathEvent event, @NotNull LivingEntity entity, @NotNull Player killer, ItemStack weapon, int level) {
if (this.ignoredEntityTypes.contains(entity.getType())) return false; if (this.ignoredEntityTypes.contains(entity.getType())) return false;

View File

@ -4,19 +4,20 @@ import org.bukkit.Location;
import org.bukkit.Particle; import org.bukkit.Particle;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.enchantments.EnchantmentTarget;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import su.nightexpress.excellentenchants.EnchantsPlugin; import su.nightexpress.excellentenchants.EnchantsPlugin;
import su.nightexpress.excellentenchants.api.Modifier; import su.nightexpress.excellentenchants.api.Modifier;
import su.nightexpress.excellentenchants.api.enchantment.ItemsCategory;
import su.nightexpress.excellentenchants.api.enchantment.Rarity; import su.nightexpress.excellentenchants.api.enchantment.Rarity;
import su.nightexpress.excellentenchants.api.enchantment.data.ChanceData; import su.nightexpress.excellentenchants.api.enchantment.data.ChanceData;
import su.nightexpress.excellentenchants.api.enchantment.data.ChanceSettings; import su.nightexpress.excellentenchants.api.enchantment.data.ChanceSettings;
import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant;
import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData; import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData;
import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl; import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl;
import su.nightexpress.excellentenchants.enchantment.data.ItemCategories;
import su.nightexpress.nightcore.config.ConfigValue; import su.nightexpress.nightcore.config.ConfigValue;
import su.nightexpress.nightcore.config.FileConfig; import su.nightexpress.nightcore.config.FileConfig;
import su.nightexpress.nightcore.util.LocationUtil; import su.nightexpress.nightcore.util.LocationUtil;
@ -25,7 +26,8 @@ import su.nightexpress.nightcore.util.wrapper.UniParticle;
import java.io.File; import java.io.File;
import static su.nightexpress.excellentenchants.Placeholders.*; import static su.nightexpress.excellentenchants.Placeholders.ENCHANTMENT_CHANCE;
import static su.nightexpress.excellentenchants.Placeholders.GENERIC_DAMAGE;
public class ThunderEnchant extends AbstractEnchantmentData implements ChanceData, CombatEnchant { public class ThunderEnchant extends AbstractEnchantmentData implements ChanceData, CombatEnchant {
@ -75,10 +77,16 @@ public class ThunderEnchant extends AbstractEnchantmentData implements ChanceDat
@Override @Override
@NotNull @NotNull
public EnchantmentTarget getCategory() { public ItemsCategory getSupportedItems() {
return EnchantmentTarget.WEAPON; return ItemCategories.WEAPON;
} }
// @Override
// @NotNull
// public EnchantmentTarget getCategory() {
// return EnchantmentTarget.WEAPON;
// }
@Override @Override
public boolean onAttack(@NotNull EntityDamageByEntityEvent event, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { public boolean onAttack(@NotNull EntityDamageByEntityEvent event, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) {
if (this.isDuringThunderstormOnly() && !victim.getWorld().isThundering()) return false; if (this.isDuringThunderstormOnly() && !victim.getWorld().isThundering()) return false;

View File

@ -2,7 +2,6 @@ package su.nightexpress.excellentenchants.enchantment.impl.weapon;
import org.bukkit.Particle; import org.bukkit.Particle;
import org.bukkit.attribute.Attribute; import org.bukkit.attribute.Attribute;
import org.bukkit.enchantments.EnchantmentTarget;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
@ -11,12 +10,14 @@ import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import su.nightexpress.excellentenchants.EnchantsPlugin; import su.nightexpress.excellentenchants.EnchantsPlugin;
import su.nightexpress.excellentenchants.api.Modifier; import su.nightexpress.excellentenchants.api.Modifier;
import su.nightexpress.excellentenchants.api.enchantment.ItemsCategory;
import su.nightexpress.excellentenchants.api.enchantment.Rarity; import su.nightexpress.excellentenchants.api.enchantment.Rarity;
import su.nightexpress.excellentenchants.api.enchantment.data.ChanceData; import su.nightexpress.excellentenchants.api.enchantment.data.ChanceData;
import su.nightexpress.excellentenchants.api.enchantment.data.ChanceSettings; import su.nightexpress.excellentenchants.api.enchantment.data.ChanceSettings;
import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant;
import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData; import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData;
import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl; import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl;
import su.nightexpress.excellentenchants.enchantment.data.ItemCategories;
import su.nightexpress.nightcore.config.ConfigValue; import su.nightexpress.nightcore.config.ConfigValue;
import su.nightexpress.nightcore.config.FileConfig; import su.nightexpress.nightcore.config.FileConfig;
import su.nightexpress.nightcore.util.EntityUtil; import su.nightexpress.nightcore.util.EntityUtil;
@ -25,7 +26,8 @@ import su.nightexpress.nightcore.util.wrapper.UniParticle;
import java.io.File; import java.io.File;
import static su.nightexpress.excellentenchants.Placeholders.*; import static su.nightexpress.excellentenchants.Placeholders.ENCHANTMENT_CHANCE;
import static su.nightexpress.excellentenchants.Placeholders.GENERIC_AMOUNT;
public class VampireEnchant extends AbstractEnchantmentData implements ChanceData, CombatEnchant { public class VampireEnchant extends AbstractEnchantmentData implements ChanceData, CombatEnchant {
@ -74,10 +76,16 @@ public class VampireEnchant extends AbstractEnchantmentData implements ChanceDat
@Override @Override
@NotNull @NotNull
public EnchantmentTarget getCategory() { public ItemsCategory getSupportedItems() {
return EnchantmentTarget.WEAPON; return ItemCategories.WEAPON;
} }
// @Override
// @NotNull
// public EnchantmentTarget getCategory() {
// return EnchantmentTarget.WEAPON;
// }
@NotNull @NotNull
@Override @Override
public EventPriority getAttackPriority() { public EventPriority getAttackPriority() {

View File

@ -1,7 +1,6 @@
package su.nightexpress.excellentenchants.enchantment.impl.weapon; package su.nightexpress.excellentenchants.enchantment.impl.weapon;
import org.bukkit.Particle; import org.bukkit.Particle;
import org.bukkit.enchantments.EnchantmentTarget;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
@ -10,6 +9,7 @@ import org.bukkit.potion.PotionEffectType;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import su.nightexpress.excellentenchants.EnchantsPlugin; import su.nightexpress.excellentenchants.EnchantsPlugin;
import su.nightexpress.excellentenchants.api.Modifier; import su.nightexpress.excellentenchants.api.Modifier;
import su.nightexpress.excellentenchants.api.enchantment.ItemsCategory;
import su.nightexpress.excellentenchants.api.enchantment.Rarity; import su.nightexpress.excellentenchants.api.enchantment.Rarity;
import su.nightexpress.excellentenchants.api.enchantment.data.ChanceData; import su.nightexpress.excellentenchants.api.enchantment.data.ChanceData;
import su.nightexpress.excellentenchants.api.enchantment.data.ChanceSettings; import su.nightexpress.excellentenchants.api.enchantment.data.ChanceSettings;
@ -18,6 +18,7 @@ import su.nightexpress.excellentenchants.api.enchantment.data.PotionSettings;
import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant;
import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData; import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData;
import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl; import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl;
import su.nightexpress.excellentenchants.enchantment.data.ItemCategories;
import su.nightexpress.excellentenchants.enchantment.data.PotionSettingsImpl; import su.nightexpress.excellentenchants.enchantment.data.PotionSettingsImpl;
import su.nightexpress.nightcore.config.FileConfig; import su.nightexpress.nightcore.config.FileConfig;
import su.nightexpress.nightcore.util.wrapper.UniParticle; import su.nightexpress.nightcore.util.wrapper.UniParticle;
@ -62,12 +63,18 @@ public class VenomEnchant extends AbstractEnchantmentData implements ChanceData,
return potionSettings; return potionSettings;
} }
@NotNull
@Override @Override
public EnchantmentTarget getCategory() { @NotNull
return EnchantmentTarget.WEAPON; public ItemsCategory getSupportedItems() {
return ItemCategories.WEAPON;
} }
// @NotNull
// @Override
// public EnchantmentTarget getCategory() {
// return EnchantmentTarget.WEAPON;
// }
@NotNull @NotNull
@Override @Override
public EventPriority getAttackPriority() { public EventPriority getAttackPriority() {

View File

@ -1,7 +1,6 @@
package su.nightexpress.excellentenchants.enchantment.impl.weapon; package su.nightexpress.excellentenchants.enchantment.impl.weapon;
import org.bukkit.Particle; import org.bukkit.Particle;
import org.bukkit.enchantments.EnchantmentTarget;
import org.bukkit.entity.Illager; import org.bukkit.entity.Illager;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
@ -9,9 +8,11 @@ import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import su.nightexpress.excellentenchants.EnchantsPlugin; import su.nightexpress.excellentenchants.EnchantsPlugin;
import su.nightexpress.excellentenchants.api.Modifier; import su.nightexpress.excellentenchants.api.Modifier;
import su.nightexpress.excellentenchants.api.enchantment.ItemsCategory;
import su.nightexpress.excellentenchants.api.enchantment.Rarity; import su.nightexpress.excellentenchants.api.enchantment.Rarity;
import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant;
import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData; import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData;
import su.nightexpress.excellentenchants.enchantment.data.ItemCategories;
import su.nightexpress.nightcore.config.ConfigValue; import su.nightexpress.nightcore.config.ConfigValue;
import su.nightexpress.nightcore.config.FileConfig; import su.nightexpress.nightcore.config.FileConfig;
import su.nightexpress.nightcore.util.NumberUtil; import su.nightexpress.nightcore.util.NumberUtil;
@ -19,7 +20,7 @@ import su.nightexpress.nightcore.util.wrapper.UniParticle;
import java.io.File; import java.io.File;
import static su.nightexpress.excellentenchants.Placeholders.*; import static su.nightexpress.excellentenchants.Placeholders.GENERIC_AMOUNT;
public class VillageDefenderEnchant extends AbstractEnchantmentData implements CombatEnchant { public class VillageDefenderEnchant extends AbstractEnchantmentData implements CombatEnchant {
@ -59,10 +60,16 @@ public class VillageDefenderEnchant extends AbstractEnchantmentData implements C
@Override @Override
@NotNull @NotNull
public EnchantmentTarget getCategory() { public ItemsCategory getSupportedItems() {
return EnchantmentTarget.WEAPON; return ItemCategories.WEAPON;
} }
// @Override
// @NotNull
// public EnchantmentTarget getCategory() {
// return EnchantmentTarget.WEAPON;
// }
@Override @Override
public boolean onAttack(@NotNull EntityDamageByEntityEvent event, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { public boolean onAttack(@NotNull EntityDamageByEntityEvent event, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) {
if (!(victim instanceof Illager)) return false; if (!(victim instanceof Illager)) return false;

View File

@ -1,6 +1,5 @@
package su.nightexpress.excellentenchants.enchantment.impl.weapon; package su.nightexpress.excellentenchants.enchantment.impl.weapon;
import org.bukkit.enchantments.EnchantmentTarget;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.event.entity.EntityDeathEvent;
@ -9,15 +8,18 @@ import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import su.nightexpress.excellentenchants.EnchantsPlugin; import su.nightexpress.excellentenchants.EnchantsPlugin;
import su.nightexpress.excellentenchants.api.Modifier; import su.nightexpress.excellentenchants.api.Modifier;
import su.nightexpress.excellentenchants.api.enchantment.ItemsCategory;
import su.nightexpress.excellentenchants.api.enchantment.Rarity; import su.nightexpress.excellentenchants.api.enchantment.Rarity;
import su.nightexpress.excellentenchants.api.enchantment.type.DeathEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.DeathEnchant;
import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData; import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData;
import su.nightexpress.excellentenchants.enchantment.data.ItemCategories;
import su.nightexpress.nightcore.config.FileConfig; import su.nightexpress.nightcore.config.FileConfig;
import su.nightexpress.nightcore.util.NumberUtil; import su.nightexpress.nightcore.util.NumberUtil;
import java.io.File; import java.io.File;
import static su.nightexpress.excellentenchants.Placeholders.*; import static su.nightexpress.excellentenchants.Placeholders.GENERIC_AMOUNT;
import static su.nightexpress.excellentenchants.Placeholders.GENERIC_MODIFIER;
public class WisdomEnchant extends AbstractEnchantmentData implements DeathEnchant { public class WisdomEnchant extends AbstractEnchantmentData implements DeathEnchant {
@ -48,10 +50,16 @@ public class WisdomEnchant extends AbstractEnchantmentData implements DeathEncha
@Override @Override
@NotNull @NotNull
public EnchantmentTarget getCategory() { public ItemsCategory getSupportedItems() {
return EnchantmentTarget.WEAPON; return ItemCategories.WEAPON;
} }
// @Override
// @NotNull
// public EnchantmentTarget getCategory() {
// return EnchantmentTarget.WEAPON;
// }
@Override @Override
public boolean onKill(@NotNull EntityDeathEvent event, @NotNull LivingEntity entity, @NotNull Player killer, ItemStack weapon, int level) { public boolean onKill(@NotNull EntityDeathEvent event, @NotNull LivingEntity entity, @NotNull Player killer, ItemStack weapon, int level) {
double xpModifier = this.getXPModifier(level); double xpModifier = this.getXPModifier(level);

View File

@ -1,7 +1,6 @@
package su.nightexpress.excellentenchants.enchantment.impl.weapon; package su.nightexpress.excellentenchants.enchantment.impl.weapon;
import org.bukkit.Particle; import org.bukkit.Particle;
import org.bukkit.enchantments.EnchantmentTarget;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
@ -10,6 +9,7 @@ import org.bukkit.potion.PotionEffectType;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import su.nightexpress.excellentenchants.EnchantsPlugin; import su.nightexpress.excellentenchants.EnchantsPlugin;
import su.nightexpress.excellentenchants.api.Modifier; import su.nightexpress.excellentenchants.api.Modifier;
import su.nightexpress.excellentenchants.api.enchantment.ItemsCategory;
import su.nightexpress.excellentenchants.api.enchantment.Rarity; import su.nightexpress.excellentenchants.api.enchantment.Rarity;
import su.nightexpress.excellentenchants.api.enchantment.data.ChanceData; import su.nightexpress.excellentenchants.api.enchantment.data.ChanceData;
import su.nightexpress.excellentenchants.api.enchantment.data.ChanceSettings; import su.nightexpress.excellentenchants.api.enchantment.data.ChanceSettings;
@ -18,6 +18,7 @@ import su.nightexpress.excellentenchants.api.enchantment.data.PotionSettings;
import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant;
import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData; import su.nightexpress.excellentenchants.enchantment.data.AbstractEnchantmentData;
import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl; import su.nightexpress.excellentenchants.enchantment.data.ChanceSettingsImpl;
import su.nightexpress.excellentenchants.enchantment.data.ItemCategories;
import su.nightexpress.excellentenchants.enchantment.data.PotionSettingsImpl; import su.nightexpress.excellentenchants.enchantment.data.PotionSettingsImpl;
import su.nightexpress.nightcore.config.FileConfig; import su.nightexpress.nightcore.config.FileConfig;
import su.nightexpress.nightcore.util.wrapper.UniParticle; import su.nightexpress.nightcore.util.wrapper.UniParticle;
@ -62,12 +63,18 @@ public class WitherEnchant extends AbstractEnchantmentData implements ChanceData
return potionSettings; return potionSettings;
} }
@NotNull
@Override @Override
public EnchantmentTarget getCategory() { @NotNull
return EnchantmentTarget.WEAPON; public ItemsCategory getSupportedItems() {
return ItemCategories.WEAPON;
} }
// @NotNull
// @Override
// public EnchantmentTarget getCategory() {
// return EnchantmentTarget.WEAPON;
// }
@NotNull @NotNull
@Override @Override
public EventPriority getAttackPriority() { public EventPriority getAttackPriority() {

Some files were not shown because too many files have changed in this diff Show More