Compare commits
2 Commits
de8dde5533
...
1d508bb581
Author | SHA1 | Date |
---|---|---|
BuildTools | 1d508bb581 | |
BuildTools | 87358cddb4 |
|
@ -12,4 +12,8 @@
|
|||
/V1_20_R1/target/
|
||||
/V1_20_R1/pom.xml.versionsBackup
|
||||
/V1_20_R2/target/
|
||||
/V1_20_R2/pom.xml.versionsBackup
|
||||
/V1_20_R2/pom.xml.versionsBackup
|
||||
/V1_20_R3/target/
|
||||
/V1_20_R3/pom.xml.versionsBackup
|
||||
/API/target/
|
||||
/API/pom.xml.versionsBackup
|
|
@ -0,0 +1,19 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>ExcellentEnchants</artifactId>
|
||||
<groupId>su.nightexpress.excellentenchants</groupId>
|
||||
<version>3.6.5</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>API</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,94 @@
|
|||
package su.nightexpress.excellentenchants.api.enchantment;
|
||||
|
||||
import org.bukkit.Keyed;
|
||||
import org.bukkit.enchantments.EnchantmentTarget;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.inventory.EquipmentSlot;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import su.nexmedia.engine.api.config.JYML;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public interface IEnchantment extends Keyed {
|
||||
|
||||
boolean isAvailableToUse(@NotNull LivingEntity entity);
|
||||
|
||||
@NotNull JYML getConfig();
|
||||
|
||||
@NotNull String getId();
|
||||
|
||||
@NotNull String getDisplayName();
|
||||
|
||||
@NotNull String getNameFormatted(int level);
|
||||
|
||||
@NotNull String getNameFormatted(int level, int charges);
|
||||
|
||||
@NotNull List<String> getDescription();
|
||||
|
||||
@NotNull List<String> getDescription(int level);
|
||||
|
||||
@NotNull Set<String> getConflicts();
|
||||
|
||||
@NotNull ITier getTier();
|
||||
|
||||
@NotNull EnchantmentTarget getCategory();
|
||||
|
||||
ItemCategory[] getFitItemTypes();
|
||||
|
||||
int getMaxLevel();
|
||||
|
||||
int getStartLevel();
|
||||
|
||||
int getLevelByEnchantCost(int expLevel);
|
||||
|
||||
double getObtainChance(@NotNull ObtainType obtainType);
|
||||
|
||||
int getObtainLevelMin(@NotNull ObtainType obtainType);
|
||||
|
||||
int getObtainLevelMax(@NotNull ObtainType obtainType);
|
||||
|
||||
int generateLevel(@NotNull ObtainType obtainType);
|
||||
|
||||
int getAnvilMergeCost(int level);
|
||||
|
||||
//@Deprecated
|
||||
//boolean conflictsWith(@NotNull Enchantment enchantment);
|
||||
|
||||
boolean checkEnchantCategory(@NotNull ItemStack item);
|
||||
|
||||
boolean checkItemCategory(@NotNull ItemStack item);
|
||||
|
||||
boolean isCurse();
|
||||
|
||||
boolean isTreasure();
|
||||
|
||||
boolean isTradeable();
|
||||
|
||||
boolean isDiscoverable();
|
||||
|
||||
boolean isChargesEnabled();
|
||||
|
||||
int getChargesMax(int level);
|
||||
|
||||
int getChargesConsumeAmount(int level);
|
||||
|
||||
int getChargesRechargeAmount(int level);
|
||||
|
||||
@NotNull ItemStack getChargesFuel();
|
||||
|
||||
boolean isChargesFuel(@NotNull ItemStack item);
|
||||
|
||||
int getCharges(@NotNull ItemStack item);
|
||||
|
||||
boolean isFullOfCharges(@NotNull ItemStack item);
|
||||
|
||||
boolean isOutOfCharges(@NotNull ItemStack item);
|
||||
|
||||
void consumeCharges(@NotNull ItemStack item, int level);
|
||||
|
||||
void consumeChargesNoUpdate(@NotNull ItemStack item, int level);
|
||||
|
||||
EquipmentSlot[] getSlots();
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package su.nightexpress.excellentenchants.api.enchantment;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import su.nexmedia.engine.api.placeholder.Placeholder;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface ITier extends Placeholder {
|
||||
|
||||
@NotNull String getId();
|
||||
|
||||
int getPriority();
|
||||
|
||||
@NotNull String getName();
|
||||
|
||||
@NotNull String getColor();
|
||||
|
||||
@NotNull Map<ObtainType, Double> getChance();
|
||||
|
||||
double getChance(@NotNull ObtainType obtainType);
|
||||
}
|
|
@ -0,0 +1,128 @@
|
|||
package su.nightexpress.excellentenchants.api.enchantment;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import su.nexmedia.engine.utils.ItemUtil;
|
||||
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public enum ItemCategory {
|
||||
|
||||
HELMET(ItemUtil::isHelmet),
|
||||
CHESTPLATE(ItemUtil::isChestplate),
|
||||
LEGGINGS(ItemUtil::isLeggings),
|
||||
BOOTS(ItemUtil::isBoots),
|
||||
ELYTRA(item -> item.getType() == Material.ELYTRA),
|
||||
|
||||
SWORD(ItemUtil::isSword),
|
||||
TRIDENT(ItemUtil::isTrident),
|
||||
AXE(ItemUtil::isAxe),
|
||||
BOW(item -> item.getType() == Material.BOW),
|
||||
CROSSBOW(item -> item.getType() == Material.CROSSBOW),
|
||||
HOE(ItemUtil::isHoe),
|
||||
PICKAXE(ItemUtil::isPickaxe),
|
||||
SHOVEL(ItemUtil::isShovel),
|
||||
FISHING_ROD(ItemUtil::isFishingRod),
|
||||
|
||||
//@Deprecated WEAPON(item -> SWORD.isIncluded(item) || TRIDENT.isIncluded(item)),
|
||||
TOOL(ItemUtil::isTool),
|
||||
//@Deprecated ARMOR(ItemUtil::isArmor),
|
||||
//UNIVERSAL(item -> WEAPON.isIncluded(item) || TOOL.isIncluded(item) || ARMOR.isIncluded(item)),
|
||||
;
|
||||
|
||||
private Predicate<ItemStack> predicate;
|
||||
|
||||
ItemCategory(@NotNull Predicate<ItemStack> predicate) {
|
||||
this.setPredicate(predicate);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Predicate<ItemStack> getPredicate() {
|
||||
return predicate;
|
||||
}
|
||||
|
||||
public void setPredicate(@NotNull Predicate<ItemStack> predicate) {
|
||||
this.predicate = predicate;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void patchPredicate(@NotNull Predicate<ItemStack> extra) {
|
||||
//this.setPredicate(item -> this.getPredicate().test(item) || (extra.test(item)));
|
||||
}
|
||||
|
||||
/*public EquipmentSlot[] getSlots() {
|
||||
return switch (this) {
|
||||
case BOW, CROSSBOW, TRIDENT, FISHING_ROD, WEAPON, TOOL, HOE, PICKAXE, AXE, SWORD, SHOVEL ->
|
||||
new EquipmentSlot[]{EquipmentSlot.HAND};
|
||||
case HELMET -> new EquipmentSlot[]{EquipmentSlot.HEAD};
|
||||
case CHESTPLATE, ELYTRA -> new EquipmentSlot[]{EquipmentSlot.CHEST};
|
||||
case LEGGINGS -> new EquipmentSlot[]{EquipmentSlot.LEGS};
|
||||
case BOOTS -> new EquipmentSlot[]{EquipmentSlot.FEET};
|
||||
case ARMOR -> new EquipmentSlot[]{EquipmentSlot.HEAD, EquipmentSlot.CHEST, EquipmentSlot.LEGS, EquipmentSlot.FEET};
|
||||
case UNIVERSAL -> new EquipmentSlot[]{EquipmentSlot.HAND, EquipmentSlot.HEAD, EquipmentSlot.CHEST, EquipmentSlot.LEGS, EquipmentSlot.FEET};
|
||||
};
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public EnchantmentTarget getEnchantmentTarget() {
|
||||
return switch (this) {
|
||||
case ARMOR -> EnchantmentTarget.ARMOR;
|
||||
case BOOTS -> EnchantmentTarget.ARMOR_FEET;
|
||||
case LEGGINGS -> EnchantmentTarget.ARMOR_LEGS;
|
||||
case CHESTPLATE, ELYTRA -> EnchantmentTarget.ARMOR_TORSO;
|
||||
case HELMET -> EnchantmentTarget.ARMOR_HEAD;
|
||||
case WEAPON, SWORD -> EnchantmentTarget.WEAPON;
|
||||
case TOOL, AXE, HOE, SHOVEL, PICKAXE -> EnchantmentTarget.TOOL;
|
||||
case BOW -> EnchantmentTarget.BOW;
|
||||
case FISHING_ROD -> EnchantmentTarget.FISHING_ROD;
|
||||
case TRIDENT -> EnchantmentTarget.TRIDENT;
|
||||
case CROSSBOW -> EnchantmentTarget.CROSSBOW;
|
||||
case UNIVERSAL -> EnchantmentTarget.WEARABLE;
|
||||
};
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static FitItemType getByEnchantmentTarget(@NotNull EnchantmentTarget target) {
|
||||
return switch (target) {
|
||||
case ARMOR -> ARMOR;
|
||||
case ARMOR_FEET -> BOOTS;
|
||||
case ARMOR_LEGS -> LEGGINGS;
|
||||
case ARMOR_TORSO -> CHESTPLATE;
|
||||
case ARMOR_HEAD -> HELMET;
|
||||
case WEAPON -> WEAPON;
|
||||
case TOOL -> TOOL;
|
||||
case BOW -> BOW;
|
||||
case FISHING_ROD -> FISHING_ROD;
|
||||
case TRIDENT -> TRIDENT;
|
||||
case CROSSBOW -> CROSSBOW;
|
||||
case BREAKABLE, WEARABLE -> UNIVERSAL;
|
||||
default -> throw new IllegalStateException("Unexpected value: " + target);
|
||||
};
|
||||
}*/
|
||||
|
||||
public boolean isIncluded(@NotNull ItemStack item) {
|
||||
return this.getPredicate().test(item);
|
||||
|
||||
/*return switch (this) {
|
||||
case UNIVERSAL -> ARMOR.isIncluded(item) || WEAPON.isIncluded(item) || TOOL.isIncluded(item) || BOW.isIncluded(item) || FISHING_ROD.isIncluded(item) || ELYTRA.isIncluded(item);
|
||||
case HELMET -> ItemUtil.isHelmet(item);
|
||||
case CHESTPLATE -> ItemUtil.isChestplate(item) || (Config.ENCHANTMENTS_ITEM_CHESTPLATE_ENCHANTS_TO_ELYTRA.get() && ELYTRA.isIncluded(item));
|
||||
case LEGGINGS -> ItemUtil.isLeggings(item);
|
||||
case BOOTS -> ItemUtil.isBoots(item);
|
||||
case ELYTRA -> item.getType() == Material.ELYTRA;
|
||||
case WEAPON -> SWORD.isIncluded(item) || ItemUtil.isTrident(item);
|
||||
case TOOL -> ItemUtil.isTool(item);
|
||||
case ARMOR -> ItemUtil.isArmor(item);
|
||||
case SWORD -> ItemUtil.isSword(item) || (Config.ENCHANTMENTS_ITEM_SWORD_ENCHANTS_TO_AXES.get() && AXE.isIncluded(item));
|
||||
case TRIDENT -> ItemUtil.isTrident(item);
|
||||
case AXE -> ItemUtil.isAxe(item);
|
||||
case BOW -> item.getType() == Material.BOW || (Config.ENCHANTMENTS_ITEM_BOW_ENCHANTS_TO_CROSSBOW.get() && CROSSBOW.isIncluded(item));
|
||||
case CROSSBOW -> item.getType() == Material.CROSSBOW;
|
||||
case HOE -> ItemUtil.isHoe(item);
|
||||
case PICKAXE -> ItemUtil.isPickaxe(item);
|
||||
case SHOVEL -> ItemUtil.isShovel(item);
|
||||
case FISHING_ROD -> item.getType() == Material.FISHING_ROD;
|
||||
};*/
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package su.nightexpress.excellentenchants.api.enchantment;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public enum ObtainType {
|
||||
|
||||
ENCHANTING("Enchanting_Table"),
|
||||
VILLAGER("Villagers"),
|
||||
LOOT_GENERATION("Loot_Generation"),
|
||||
FISHING("Fishing"),
|
||||
MOB_SPAWNING("Mob_Spawning");
|
||||
|
||||
private final String pathName;
|
||||
|
||||
ObtainType(@NotNull String pathName) {
|
||||
this.pathName = pathName;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getPathName() {
|
||||
return pathName;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package su.nightexpress.excellentenchants.api.enchantment;
|
||||
|
||||
public enum Rarity {
|
||||
|
||||
COMMON(10),
|
||||
UNCOMMON(5),
|
||||
RARE(2),
|
||||
VERY_RARE(1);
|
||||
|
||||
private final int weight;
|
||||
|
||||
Rarity(int weight) {
|
||||
this.weight = weight;
|
||||
}
|
||||
|
||||
public int getWeight() {
|
||||
return this.weight;
|
||||
}
|
||||
}
|
24
Core/pom.xml
24
Core/pom.xml
|
@ -5,7 +5,7 @@
|
|||
<parent>
|
||||
<artifactId>ExcellentEnchants</artifactId>
|
||||
<groupId>su.nightexpress.excellentenchants</groupId>
|
||||
<version>3.6.4</version>
|
||||
<version>3.6.5</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
@ -43,7 +43,7 @@
|
|||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.20.1-R0.1-SNAPSHOT</version>
|
||||
<version>1.20.4-R0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>fr.neatmonster</groupId>
|
||||
|
@ -69,30 +69,40 @@
|
|||
<version>2.11.2</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>su.nightexpress.excellentenchants</groupId>
|
||||
<artifactId>API</artifactId>
|
||||
<version>3.6.5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>su.nightexpress.excellentenchants</groupId>
|
||||
<artifactId>NMS</artifactId>
|
||||
<version>3.6.4</version>
|
||||
<version>3.6.5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>su.nightexpress.excellentenchants</groupId>
|
||||
<artifactId>V1_18_R2</artifactId>
|
||||
<version>3.6.4</version>
|
||||
<version>3.6.5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>su.nightexpress.excellentenchants</groupId>
|
||||
<artifactId>V1_19_R3</artifactId>
|
||||
<version>3.6.4</version>
|
||||
<version>3.6.5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>su.nightexpress.excellentenchants</groupId>
|
||||
<artifactId>V1_20_R1</artifactId>
|
||||
<version>3.6.4</version>
|
||||
<version>3.6.5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>su.nightexpress.excellentenchants</groupId>
|
||||
<artifactId>V1_20_R2</artifactId>
|
||||
<version>3.6.4</version>
|
||||
<version>3.6.5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>su.nightexpress.excellentenchants</groupId>
|
||||
<artifactId>V1_20_R3</artifactId>
|
||||
<version>3.6.5</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package su.nightexpress.excellentenchants;
|
||||
|
||||
import org.bukkit.enchantments.EnchantmentTarget;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import su.nexmedia.engine.NexPlugin;
|
||||
|
@ -7,6 +8,8 @@ import su.nexmedia.engine.Version;
|
|||
import su.nexmedia.engine.api.command.GeneralCommand;
|
||||
import su.nexmedia.engine.command.list.ReloadSubCommand;
|
||||
import su.nexmedia.engine.utils.EngineUtils;
|
||||
import su.nightexpress.excellentenchants.api.enchantment.ItemCategory;
|
||||
import su.nightexpress.excellentenchants.api.enchantment.ObtainType;
|
||||
import su.nightexpress.excellentenchants.command.BookCommand;
|
||||
import su.nightexpress.excellentenchants.command.EnchantCommand;
|
||||
import su.nightexpress.excellentenchants.command.ListCommand;
|
||||
|
@ -16,20 +19,23 @@ import su.nightexpress.excellentenchants.config.Lang;
|
|||
import su.nightexpress.excellentenchants.enchantment.EnchantManager;
|
||||
import su.nightexpress.excellentenchants.enchantment.EnchantPopulator;
|
||||
import su.nightexpress.excellentenchants.enchantment.registry.EnchantRegistry;
|
||||
import su.nightexpress.excellentenchants.enchantment.type.FitItemType;
|
||||
import su.nightexpress.excellentenchants.enchantment.type.ObtainType;
|
||||
import su.nightexpress.excellentenchants.hook.HookId;
|
||||
import su.nightexpress.excellentenchants.hook.impl.PlaceholderHook;
|
||||
import su.nightexpress.excellentenchants.hook.impl.ProtocolHook;
|
||||
import su.nightexpress.excellentenchants.nms.EnchantNMS;
|
||||
import su.nightexpress.excellentenchants.nms.V1_20_R2;
|
||||
import su.nightexpress.excellentenchants.nms.v1_18_R2.V1_18_R2;
|
||||
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_R2.V1_20_R2;
|
||||
import su.nightexpress.excellentenchants.nms.v1_20_R3.V1_20_R3;
|
||||
import su.nightexpress.excellentenchants.tier.TierManager;
|
||||
|
||||
public class ExcellentEnchants extends NexPlugin<ExcellentEnchants> {
|
||||
|
||||
// TODO Config option to use minecraft internal enchanting population
|
||||
// TODO Custom name format for curse enchants
|
||||
// TODO Custom name format for treasure enchants
|
||||
|
||||
private EnchantRegistry registry;
|
||||
private EnchantManager enchantManager;
|
||||
private EnchantNMS enchantNMS;
|
||||
|
@ -44,6 +50,8 @@ public class ExcellentEnchants extends NexPlugin<ExcellentEnchants> {
|
|||
@Override
|
||||
public void onLoad() {
|
||||
super.onLoad();
|
||||
|
||||
//this.updateFitItemTypes();
|
||||
this.registry = new EnchantRegistry(this);
|
||||
}
|
||||
|
||||
|
@ -96,6 +104,7 @@ public class ExcellentEnchants extends NexPlugin<ExcellentEnchants> {
|
|||
case V1_19_R3 -> new V1_19_R3();
|
||||
case V1_20_R1 -> new V1_20_R1();
|
||||
case V1_20_R2 -> new V1_20_R2();
|
||||
case V1_20_R3 -> new V1_20_R3();
|
||||
default -> null;
|
||||
};
|
||||
return this.enchantNMS != null;
|
||||
|
@ -109,7 +118,8 @@ public class ExcellentEnchants extends NexPlugin<ExcellentEnchants> {
|
|||
@Override
|
||||
public void loadLang() {
|
||||
this.getLangManager().loadMissing(Lang.class);
|
||||
this.getLangManager().loadEnum(FitItemType.class);
|
||||
this.getLangManager().loadEnum(ItemCategory.class);
|
||||
this.getLangManager().loadEnum(EnchantmentTarget.class);
|
||||
this.getLangManager().loadEnum(ObtainType.class);
|
||||
this.getLang().saveChanges();
|
||||
}
|
||||
|
|
|
@ -1,53 +1,54 @@
|
|||
/*
|
||||
* Decompiled with CFR 0.151.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* su.nexmedia.engine.utils.Placeholders
|
||||
*/
|
||||
package su.nightexpress.excellentenchants;
|
||||
|
||||
public class Placeholders extends su.nexmedia.engine.utils.Placeholders {
|
||||
|
||||
public static final String URL_WIKI = "https://github.com/nulli0n/ExcellentEnchants-spigot/wiki/";
|
||||
public static final String URL_PLACEHOLDERS = URL_WIKI + "Internal-Placeholders";
|
||||
public class Placeholders
|
||||
extends su.nexmedia.engine.utils.Placeholders {
|
||||
public static final String URL_WIKI = "https://github.com/nulli0n/ExcellentEnchants-spigot/wiki/";
|
||||
public static final String URL_PLACEHOLDERS = "https://github.com/nulli0n/ExcellentEnchants-spigot/wiki/Internal-Placeholders";
|
||||
public static final String URL_ENGINE_SCALER = "https://github.com/nulli0n/NexEngine-spigot/wiki/Configuration-Tips#scalable-sections";
|
||||
public static final String URL_ENGINE_ITEMS = "https://github.com/nulli0n/NexEngine-spigot/wiki/Configuration-Tips#item-sections";
|
||||
|
||||
public static final String GENERIC_TYPE = "%type%";
|
||||
public static final String GENERIC_NAME = "%name%";
|
||||
public static final String GENERIC_ITEM = "%item%";
|
||||
public static final String GENERIC_LEVEL = "%level%";
|
||||
public static final String GENERIC_AMOUNT = "%amount%";
|
||||
public static final String URL_ENGINE_ITEMS = "https://github.com/nulli0n/NexEngine-spigot/wiki/Configuration-Tips#item-sections";
|
||||
public static final String GENERIC_TYPE = "%type%";
|
||||
public static final String GENERIC_NAME = "%name%";
|
||||
public static final String GENERIC_ITEM = "%item%";
|
||||
public static final String GENERIC_LEVEL = "%level%";
|
||||
public static final String GENERIC_AMOUNT = "%amount%";
|
||||
public static final String GENERIC_DESCRIPTION = "%description%";
|
||||
public static final String GENERIC_ENCHANT = "%enchant%";
|
||||
|
||||
public static final String ENCHANTMENT_CHANCE = "%enchantment_trigger_chance%";
|
||||
public static final String ENCHANTMENT_INTERVAL = "%enchantment_trigger_interval%";
|
||||
public static final String ENCHANTMENT_POTION_LEVEL = "%enchantment_potion_level%";
|
||||
public static final String GENERIC_ENCHANT = "%enchant%";
|
||||
public static final String ENCHANTMENT_CHANCE = "%enchantment_trigger_chance%";
|
||||
public static final String ENCHANTMENT_INTERVAL = "%enchantment_trigger_interval%";
|
||||
public static final String ENCHANTMENT_POTION_LEVEL = "%enchantment_potion_level%";
|
||||
public static final String ENCHANTMENT_POTION_DURATION = "%enchantment_potion_duration%";
|
||||
public static final String ENCHANTMENT_POTION_TYPE = "%enchantment_potion_type%";
|
||||
|
||||
public static final String ENCHANTMENT_ID = "%enchantment_id%";
|
||||
public static final String ENCHANTMENT_NAME = "%enchantment_name%";
|
||||
public static final String ENCHANTMENT_NAME_FORMATTED = "%enchantment_name_formatted%";
|
||||
public static final String ENCHANTMENT_DESCRIPTION = "%enchantment_description%";
|
||||
public static final String ENCHANTMENT_LEVEL = "%enchantment_level%";
|
||||
public static final String ENCHANTMENT_LEVEL_MIN = "%enchantment_level_min%";
|
||||
public static final String ENCHANTMENT_LEVEL_MAX = "%enchantment_level_max%";
|
||||
public static final String ENCHANTMENT_TIER = "%enchantment_tier%";
|
||||
public static final String ENCHANTMENT_TIER_COLOR = "%enchantment_tier_color%";
|
||||
public static final String ENCHANTMENT_FIT_ITEM_TYPES = "%enchantment_fit_item_types%";
|
||||
public static final String ENCHANTMENT_OBTAIN_CHANCE_ENCHANTING = "%enchantment_obtain_chance_enchanting%";
|
||||
public static final String ENCHANTMENT_OBTAIN_CHANCE_VILLAGER = "%enchantment_obtain_chance_villager%";
|
||||
public static final String ENCHANTMENT_POTION_TYPE = "%enchantment_potion_type%";
|
||||
public static final String ENCHANTMENT_ID = "%enchantment_id%";
|
||||
public static final String ENCHANTMENT_NAME = "%enchantment_name%";
|
||||
public static final String ENCHANTMENT_NAME_FORMATTED = "%enchantment_name_formatted%";
|
||||
public static final String ENCHANTMENT_DESCRIPTION = "%enchantment_description%";
|
||||
public static final String ENCHANTMENT_LEVEL = "%enchantment_level%";
|
||||
public static final String ENCHANTMENT_LEVEL_MIN = "%enchantment_level_min%";
|
||||
public static final String ENCHANTMENT_LEVEL_MAX = "%enchantment_level_max%";
|
||||
public static final String ENCHANTMENT_TIER = "%enchantment_tier%";
|
||||
public static final String ENCHANTMENT_TIER_COLOR = "%enchantment_tier_color%";
|
||||
public static final String ENCHANTMENT_FIT_ITEM_TYPES = "%enchantment_fit_item_types%";
|
||||
public static final String ENCHANTMENT_OBTAIN_CHANCE_ENCHANTING = "%enchantment_obtain_chance_enchanting%";
|
||||
public static final String ENCHANTMENT_OBTAIN_CHANCE_VILLAGER = "%enchantment_obtain_chance_villager%";
|
||||
public static final String ENCHANTMENT_OBTAIN_CHANCE_LOOT_GENERATION = "%enchantment_obtain_chance_loot_generation%";
|
||||
public static final String ENCHANTMENT_OBTAIN_CHANCE_FISHING = "%enchantment_obtain_chance_fishing%";
|
||||
public static final String ENCHANTMENT_OBTAIN_CHANCE_MOB_SPAWNING = "%enchantment_obtain_chance_mob_spawning%";
|
||||
public static final String ENCHANTMENT_CHARGES_MAX_AMOUNT = "%enchantment_charges_max_amount%";
|
||||
public static final String ENCHANTMENT_CHARGES_CONSUME_AMOUNT = "%enchantment_charges_consume_amount%";
|
||||
public static final String ENCHANTMENT_CHARGES_RECHARGE_AMOUNT = "%enchantment_charges_recharge_amount%";
|
||||
public static final String ENCHANTMENT_CHARGES_FUEL_ITEM = "%enchantment_charges_fuel_item%";
|
||||
|
||||
public static final String TIER_ID = "%tier_id%";
|
||||
public static final String TIER_NAME = "%tier_name%";
|
||||
public static final String TIER_OBTAIN_CHANCE_ENCHANTING = "%tier_obtain_chance_enchanting%";
|
||||
public static final String TIER_OBTAIN_CHANCE_VILLAGER = "%tier_obtain_chance_villager%";
|
||||
public static final String ENCHANTMENT_OBTAIN_CHANCE_FISHING = "%enchantment_obtain_chance_fishing%";
|
||||
public static final String ENCHANTMENT_OBTAIN_CHANCE_MOB_SPAWNING = "%enchantment_obtain_chance_mob_spawning%";
|
||||
public static final String ENCHANTMENT_CHARGES_MAX_AMOUNT = "%enchantment_charges_max_amount%";
|
||||
public static final String ENCHANTMENT_CHARGES_CONSUME_AMOUNT = "%enchantment_charges_consume_amount%";
|
||||
public static final String ENCHANTMENT_CHARGES_RECHARGE_AMOUNT = "%enchantment_charges_recharge_amount%";
|
||||
public static final String ENCHANTMENT_CHARGES_FUEL_ITEM = "%enchantment_charges_fuel_item%";
|
||||
public static final String TIER_ID = "%tier_id%";
|
||||
public static final String TIER_NAME = "%tier_name%";
|
||||
public static final String TIER_OBTAIN_CHANCE_ENCHANTING = "%tier_obtain_chance_enchanting%";
|
||||
public static final String TIER_OBTAIN_CHANCE_VILLAGER = "%tier_obtain_chance_villager%";
|
||||
public static final String TIER_OBTAIN_CHANCE_LOOT_GENERATION = "%tier_obtain_chance_loot_generation%";
|
||||
public static final String TIER_OBTAIN_CHANCE_FISHING = "%tier_obtain_chance_fishing%";
|
||||
public static final String TIER_OBTAIN_CHANCE_MOB_SPAWNING = "%tier_obtain_chance_mob_spawning%";
|
||||
|
||||
|
||||
public static final String TIER_OBTAIN_CHANCE_FISHING = "%tier_obtain_chance_fishing%";
|
||||
public static final String TIER_OBTAIN_CHANCE_MOB_SPAWNING = "%tier_obtain_chance_mob_spawning%";
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ import org.bukkit.entity.LivingEntity;
|
|||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
import org.bukkit.event.entity.EntityResurrectEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import su.nightexpress.excellentenchants.api.enchantment.IEnchantment;
|
||||
|
@ -14,6 +15,8 @@ public interface DeathEnchant extends IEnchantment {
|
|||
|
||||
boolean onKill(@NotNull EntityDeathEvent event, @NotNull LivingEntity entity, @NotNull Player killer, ItemStack weapon, int level);
|
||||
|
||||
boolean onResurrect(@NotNull EntityResurrectEvent event, @NotNull LivingEntity entity, @NotNull ItemStack item, int level);
|
||||
|
||||
@NotNull
|
||||
default EventPriority getDeathPriority() {
|
||||
return EventPriority.NORMAL;
|
||||
|
|
|
@ -78,7 +78,7 @@ public class TierbookCommand extends AbstractCommand<ExcellentEnchants> {
|
|||
}
|
||||
|
||||
ItemStack item = new ItemStack(Material.ENCHANTED_BOOK);
|
||||
EnchantUtils.add(item, enchant, level, true);
|
||||
EnchantUtils.add(item, enchant.getBackend(), level, true);
|
||||
EnchantUtils.updateDisplay(item);
|
||||
PlayerUtil.addItem(player, item);
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ import su.nexmedia.engine.utils.Colorizer;
|
|||
import su.nexmedia.engine.utils.Colors2;
|
||||
import su.nexmedia.engine.utils.StringUtil;
|
||||
import su.nightexpress.excellentenchants.Placeholders;
|
||||
import su.nightexpress.excellentenchants.enchantment.type.ObtainType;
|
||||
import su.nightexpress.excellentenchants.api.enchantment.ObtainType;
|
||||
import su.nightexpress.excellentenchants.tier.Tier;
|
||||
|
||||
import java.util.*;
|
||||
|
@ -34,6 +34,10 @@ public class Config {
|
|||
"--- Global: 50 ticks, Regrowth: 100 ticks; Saturation: 150 ticks;"
|
||||
);
|
||||
|
||||
public static final JOption<Boolean> ENCHANTMENTS_INTERNAL_HANDLER = JOption.create("Enchantments.Internal_Distributor", false,
|
||||
"[EXPERIMENTAL - DO NOT TOUCH]",
|
||||
"Sets whether or not enchantment distribution will be handled by vanilla server mechanics.");
|
||||
|
||||
public static final JOption<Boolean> ENCHANTMENTS_CHARGES_ENABLED = JOption.create("Enchantments.Charges.Enabled",
|
||||
false,
|
||||
"Enables the enchantment Charges feature.",
|
||||
|
@ -104,6 +108,10 @@ public class Config {
|
|||
"When 'true', adds the enchantment description to item lore under enchantment names.",
|
||||
"For Display-Mode = 2 description is not shown while you're in Creative gamemode.");
|
||||
|
||||
public static final JOption<Boolean> ENCHANTMENTS_DESCRIPTION_BOOKS_ONLY = JOption.create("Enchantments.Description.Books_Only",
|
||||
false,
|
||||
"Sets whether or not only enchanted books will have enchantment descriptions.");
|
||||
|
||||
public static final JOption<String> ENCHANTMENTS_DESCRIPTION_FORMAT = JOption.create("Enchantments.Description.Format",
|
||||
"&8▸ " + Placeholders.GENERIC_DESCRIPTION,
|
||||
"Sets the global enchantment description format.").mapReader(Colorizer::apply);
|
||||
|
@ -146,7 +154,6 @@ public class Config {
|
|||
list.add(new Tier("rare", 2, "Rare", Colors2.GREEN, getObtainWeight(25D)));
|
||||
list.add(new Tier("unique", 3, "Unique", Colors2.YELLOW, getObtainWeight(15D)));
|
||||
list.add(new Tier("legendary", 4, "Legendary", Colors2.ORANGE, getObtainWeight(5D)));
|
||||
list.add(new Tier("cursed", 0, "Cursed", Colors2.RED, getObtainWeight(5D)));
|
||||
return list;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,3 +1,12 @@
|
|||
/*
|
||||
* Decompiled with CFR 0.151.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* org.jetbrains.annotations.NotNull
|
||||
* su.nexmedia.engine.NexPlugin
|
||||
* su.nexmedia.engine.api.manager.AbstractManager
|
||||
* su.nexmedia.engine.api.manager.EventListener
|
||||
*/
|
||||
package su.nightexpress.excellentenchants.enchantment;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
@ -9,33 +18,28 @@ import su.nightexpress.excellentenchants.enchantment.menu.EnchantmentsListMenu;
|
|||
import su.nightexpress.excellentenchants.enchantment.task.ArrowTrailsTask;
|
||||
import su.nightexpress.excellentenchants.enchantment.task.PassiveEnchantsTask;
|
||||
|
||||
public class EnchantManager extends AbstractManager<ExcellentEnchants> {
|
||||
public class EnchantManager
|
||||
extends AbstractManager<ExcellentEnchants> {
|
||||
|
||||
public static final String DIR_ENCHANTS = "/enchants/";
|
||||
|
||||
private EnchantmentsListMenu enchantmentsListMenu;
|
||||
|
||||
private ArrowTrailsTask arrowTrailsTask;
|
||||
private ArrowTrailsTask arrowTrailsTask;
|
||||
private PassiveEnchantsTask passiveEnchantsTask;
|
||||
|
||||
public EnchantManager(@NotNull ExcellentEnchants plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onLoad() {
|
||||
this.enchantmentsListMenu = new EnchantmentsListMenu(this.plugin);
|
||||
this.addListener(new EnchantGenericListener(this));
|
||||
this.addListener(new EnchantAnvilListener(this.plugin));
|
||||
|
||||
this.arrowTrailsTask = new ArrowTrailsTask(this.plugin);
|
||||
this.arrowTrailsTask.start();
|
||||
|
||||
this.passiveEnchantsTask = new PassiveEnchantsTask(this.plugin);
|
||||
this.passiveEnchantsTask.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onShutdown() {
|
||||
if (this.enchantmentsListMenu != null) {
|
||||
this.enchantmentsListMenu.clear();
|
||||
|
@ -53,6 +57,7 @@ public class EnchantManager extends AbstractManager<ExcellentEnchants> {
|
|||
|
||||
@NotNull
|
||||
public EnchantmentsListMenu getEnchantsListGUI() {
|
||||
return enchantmentsListMenu;
|
||||
return this.enchantmentsListMenu;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ import su.nightexpress.excellentenchants.config.Config;
|
|||
import su.nightexpress.excellentenchants.config.ObtainSettings;
|
||||
import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant;
|
||||
import su.nightexpress.excellentenchants.enchantment.registry.EnchantRegistry;
|
||||
import su.nightexpress.excellentenchants.enchantment.type.ObtainType;
|
||||
import su.nightexpress.excellentenchants.api.enchantment.ObtainType;
|
||||
import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils;
|
||||
import su.nightexpress.excellentenchants.tier.Tier;
|
||||
|
||||
|
@ -69,7 +69,7 @@ public class EnchantPopulator {
|
|||
Set<ExcellentEnchant> enchants = EnchantRegistry.getOfTier(tier);
|
||||
|
||||
enchants.removeIf(enchant -> {
|
||||
return !enchant.isObtainable(this.getObtainType()) || !enchant.canEnchantItem(this.getItem());
|
||||
return !enchant.isObtainable(this.getObtainType()) || (!enchant.getBackend().canEnchantItem(this.getItem()) && !EnchantUtils.isBook(this.getItem()));
|
||||
});
|
||||
|
||||
this.candidates.put(tier, enchants);
|
||||
|
@ -177,7 +177,7 @@ public class EnchantPopulator {
|
|||
}
|
||||
|
||||
// Remove conflicting enchants.
|
||||
if (population.keySet().stream().anyMatch(has -> has.conflictsWith(enchant) || enchant.conflictsWith(has))) {
|
||||
if (population.keySet().stream().anyMatch(has -> has.conflictsWith(enchant.getBackend()) || enchant.getBackend().conflictsWith(has))) {
|
||||
this.purge(tier, enchant);
|
||||
continue;
|
||||
}
|
||||
|
@ -191,7 +191,7 @@ public class EnchantPopulator {
|
|||
|
||||
// All good!
|
||||
this.purge(tier, enchant);
|
||||
population.put(enchant, level);
|
||||
population.put(enchant.getBackend(), level);
|
||||
enchantsRolled--;
|
||||
}
|
||||
|
||||
|
@ -204,10 +204,17 @@ public class EnchantPopulator {
|
|||
|
||||
var population = this.getPopulation().isEmpty() ? this.createPopulation() : this.getPopulation();
|
||||
|
||||
if (this.getObtainType() == ObtainType.VILLAGER && item.getType() == Material.ENCHANTED_BOOK) {
|
||||
if (Config.ENCHANTMENTS_SINGLE_ENCHANT_IN_VILLAGER_BOOKS.get() && !population.isEmpty()) {
|
||||
boolean singleVillagerBook = this.getObtainType() == ObtainType.VILLAGER
|
||||
&& item.getType() == Material.ENCHANTED_BOOK
|
||||
&& Config.ENCHANTMENTS_SINGLE_ENCHANT_IN_VILLAGER_BOOKS.get();
|
||||
|
||||
if (singleVillagerBook) {
|
||||
if (!population.isEmpty()) {
|
||||
EnchantUtils.getAll(item).keySet().forEach(enchantment -> EnchantUtils.remove(item, enchantment));
|
||||
}
|
||||
while (population.size() > 1) {
|
||||
population.remove(Rnd.get(population.keySet()));
|
||||
}
|
||||
}
|
||||
|
||||
population.forEach((enchantment, level) -> {
|
||||
|
|
|
@ -13,7 +13,7 @@ import su.nightexpress.excellentenchants.ExcellentEnchantsAPI;
|
|||
import su.nightexpress.excellentenchants.Placeholders;
|
||||
import su.nightexpress.excellentenchants.config.Config;
|
||||
import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant;
|
||||
import su.nightexpress.excellentenchants.enchantment.type.ObtainType;
|
||||
import su.nightexpress.excellentenchants.api.enchantment.ObtainType;
|
||||
import su.nightexpress.excellentenchants.tier.Tier;
|
||||
import su.nightexpress.excellentenchants.tier.TierManager;
|
||||
|
||||
|
@ -29,6 +29,8 @@ public class EnchantDefaults {
|
|||
private List<String> description;
|
||||
private boolean hiddenFromList;
|
||||
private boolean isTreasure;
|
||||
private boolean tradeable;
|
||||
private boolean discoverable;
|
||||
private int levelMin;
|
||||
private int levelMax;
|
||||
private int maxMergeLevel;
|
||||
|
@ -50,6 +52,8 @@ public class EnchantDefaults {
|
|||
this.setDescription(new ArrayList<>());
|
||||
this.setHiddenFromList(false);
|
||||
this.setTreasure(false);
|
||||
this.setTradeable(true);
|
||||
this.setDiscoverable(true);
|
||||
this.setLevelMin(1);
|
||||
this.setLevelMax(3);
|
||||
this.setMaxMergeLevel(-1);
|
||||
|
@ -83,6 +87,18 @@ public class EnchantDefaults {
|
|||
"Sets whether this enchantment is a treasure enchantment.",
|
||||
"Treasure enchantments can only be received via looting, trading, or fishing.").read(cfg));
|
||||
|
||||
if (Config.ENCHANTMENTS_INTERNAL_HANDLER.get()) {
|
||||
this.setTradeable(JOption.create("Tradeable", this.isTradeable(),
|
||||
"Sets whether or not this enchantment can be populated in villager trades.").read(cfg));
|
||||
|
||||
this.setDiscoverable(JOption.create("Discoverable", this.isTradeable(),
|
||||
"Sets whether or not this enchantment can be populated in enchanting table.").read(cfg));
|
||||
}
|
||||
else {
|
||||
this.setTradeable(false);
|
||||
this.setDiscoverable(false);
|
||||
}
|
||||
|
||||
this.setLevelMin(JOption.create("Level.Min", this.getLevelMin(),
|
||||
"Sets the minimal (start) enchantment level. Can not be less than 1.").read(cfg));
|
||||
|
||||
|
@ -202,6 +218,22 @@ public class EnchantDefaults {
|
|||
isTreasure = treasure;
|
||||
}
|
||||
|
||||
public boolean isTradeable() {
|
||||
return tradeable;
|
||||
}
|
||||
|
||||
public void setTradeable(boolean tradeable) {
|
||||
this.tradeable = tradeable;
|
||||
}
|
||||
|
||||
public boolean isDiscoverable() {
|
||||
return discoverable;
|
||||
}
|
||||
|
||||
public void setDiscoverable(boolean discoverable) {
|
||||
this.discoverable = discoverable;
|
||||
}
|
||||
|
||||
public void setLevelMin(int levelMin) {
|
||||
this.levelMin = Math.max(1, levelMin);
|
||||
}
|
||||
|
|
|
@ -3,10 +3,10 @@ package su.nightexpress.excellentenchants.enchantment.config;
|
|||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import su.nexmedia.engine.api.config.JYML;
|
||||
import su.nexmedia.engine.utils.Evaluator;
|
||||
import su.nexmedia.engine.utils.StringUtil;
|
||||
import su.nightexpress.excellentenchants.Placeholders;
|
||||
import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant;
|
||||
import su.nightexpress.excellentenchants.enchantment.util.Evaluator;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
|
|
|
@ -4,10 +4,11 @@ import org.bukkit.Material;
|
|||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.enchantments.EnchantmentTarget;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.inventory.EquipmentSlot;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import su.nexmedia.engine.api.config.JYML;
|
||||
import su.nexmedia.engine.api.manager.EventListener;
|
||||
import su.nexmedia.engine.api.placeholder.PlaceholderMap;
|
||||
|
@ -24,8 +25,8 @@ import su.nightexpress.excellentenchants.api.enchantment.meta.Potioned;
|
|||
import su.nightexpress.excellentenchants.config.Config;
|
||||
import su.nightexpress.excellentenchants.enchantment.EnchantManager;
|
||||
import su.nightexpress.excellentenchants.enchantment.config.EnchantDefaults;
|
||||
import su.nightexpress.excellentenchants.enchantment.type.FitItemType;
|
||||
import su.nightexpress.excellentenchants.enchantment.type.ObtainType;
|
||||
import su.nightexpress.excellentenchants.api.enchantment.ItemCategory;
|
||||
import su.nightexpress.excellentenchants.api.enchantment.ObtainType;
|
||||
import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils;
|
||||
import su.nightexpress.excellentenchants.tier.Tier;
|
||||
|
||||
|
@ -33,7 +34,7 @@ import java.util.*;
|
|||
import java.util.function.Function;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public abstract class ExcellentEnchant extends Enchantment implements IEnchantment {
|
||||
public abstract class ExcellentEnchant /*extends Enchantment*/ implements IEnchantment {
|
||||
|
||||
protected final ExcellentEnchants plugin;
|
||||
protected final JYML cfg;
|
||||
|
@ -43,15 +44,21 @@ public abstract class ExcellentEnchant extends Enchantment implements IEnchantme
|
|||
protected final Map<Integer, PlaceholderMap> placeholdersMap;
|
||||
|
||||
public ExcellentEnchant(@NotNull ExcellentEnchants plugin, @NotNull String id) {
|
||||
super(NamespacedKey.minecraft(id.toLowerCase()));
|
||||
//super(NamespacedKey.minecraft(id.toLowerCase()));
|
||||
this.plugin = plugin;
|
||||
this.id = this.getKey().getKey();
|
||||
this.id = id.toLowerCase();//this.getKey().getKey();
|
||||
this.cfg = new JYML(plugin.getDataFolder() + EnchantManager.DIR_ENCHANTS, id + ".yml");
|
||||
this.chargesKey = new NamespacedKey(plugin, this.getId() + ".charges");
|
||||
this.defaults = new EnchantDefaults(this);
|
||||
this.placeholdersMap = new HashMap<>();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public NamespacedKey getKey() {
|
||||
return EnchantUtils.createKey(this.getId());
|
||||
}
|
||||
|
||||
public void loadSettings() {
|
||||
this.cfg.reload();
|
||||
this.placeholdersMap.clear();
|
||||
|
@ -71,7 +78,11 @@ public abstract class ExcellentEnchant extends Enchantment implements IEnchantme
|
|||
.add(Placeholders.ENCHANTMENT_LEVEL_MAX, () -> String.valueOf(this.getMaxLevel()))
|
||||
.add(Placeholders.ENCHANTMENT_TIER, () -> this.getTier().getName())
|
||||
.add(Placeholders.ENCHANTMENT_TIER_COLOR, () -> this.getTier().getColor())
|
||||
.add(Placeholders.ENCHANTMENT_FIT_ITEM_TYPES, () -> String.join(", ", Stream.of(this.getFitItemTypes()).map(type -> plugin.getLangManager().getEnum(type)).toList()))
|
||||
.add(Placeholders.ENCHANTMENT_FIT_ITEM_TYPES, () -> {
|
||||
if (this.getFitItemTypes().length == 0) return plugin.getLangManager().getEnum(this.getCategory());
|
||||
|
||||
return String.join(", ", Stream.of(this.getFitItemTypes()).map(type -> plugin.getLangManager().getEnum(type)).toList());
|
||||
})
|
||||
.add(Placeholders.ENCHANTMENT_OBTAIN_CHANCE_ENCHANTING, () -> NumberUtil.format(this.getObtainChance(ObtainType.ENCHANTING)))
|
||||
.add(Placeholders.ENCHANTMENT_OBTAIN_CHANCE_VILLAGER, () -> NumberUtil.format(this.getObtainChance(ObtainType.VILLAGER)))
|
||||
.add(Placeholders.ENCHANTMENT_OBTAIN_CHANCE_LOOT_GENERATION, () -> NumberUtil.format(this.getObtainChance(ObtainType.LOOT_GENERATION)))
|
||||
|
@ -120,9 +131,34 @@ public abstract class ExcellentEnchant extends Enchantment implements IEnchantme
|
|||
}
|
||||
|
||||
@NotNull
|
||||
public FitItemType[] getFitItemTypes() {
|
||||
FitItemType itemType = FitItemType.getByEnchantmentTarget(this.getItemTarget());
|
||||
return itemType == null ? new FitItemType[0] : new FitItemType[]{itemType};
|
||||
public ItemCategory[] getFitItemTypes() {
|
||||
//FitItemType itemType = FitItemType.getByEnchantmentTarget(this.getCategory());
|
||||
//return new FitItemType[]{itemType};
|
||||
|
||||
return new ItemCategory[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public EquipmentSlot[] getSlots() {
|
||||
return switch (this.getCategory()) {
|
||||
case BOW, CROSSBOW, TRIDENT, FISHING_ROD, WEAPON, TOOL -> new EquipmentSlot[]{EquipmentSlot.HAND};
|
||||
case ARMOR_HEAD -> new EquipmentSlot[]{EquipmentSlot.HEAD};
|
||||
case ARMOR_TORSO -> new EquipmentSlot[]{EquipmentSlot.CHEST};
|
||||
case ARMOR_LEGS -> new EquipmentSlot[]{EquipmentSlot.LEGS};
|
||||
case ARMOR_FEET -> new EquipmentSlot[]{EquipmentSlot.FEET};
|
||||
case ARMOR, WEARABLE -> new EquipmentSlot[]{EquipmentSlot.HEAD, EquipmentSlot.CHEST, EquipmentSlot.LEGS, EquipmentSlot.FEET};
|
||||
case BREAKABLE -> new EquipmentSlot[]{EquipmentSlot.HAND, EquipmentSlot.HEAD, EquipmentSlot.CHEST, EquipmentSlot.LEGS, EquipmentSlot.FEET};
|
||||
case VANISHABLE -> EquipmentSlot.values();
|
||||
default -> throw new IllegalStateException("Unexpected value: " + this.getCategory());
|
||||
};
|
||||
|
||||
/*Set<EquipmentSlot> slots = new HashSet<>();
|
||||
|
||||
for (FitItemType itemType : this.getFitItemTypes()) {
|
||||
slots.addAll(Arrays.asList(itemType.getSlots()));
|
||||
}
|
||||
|
||||
return slots.toArray(new EquipmentSlot[0]);*/
|
||||
}
|
||||
|
||||
public boolean isDisabledInWorld(@NotNull World world) {
|
||||
|
@ -150,11 +186,11 @@ public abstract class ExcellentEnchant extends Enchantment implements IEnchantme
|
|||
return defaults;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
/*@NotNull
|
||||
@Override
|
||||
public String getName() {
|
||||
return getId().toUpperCase();
|
||||
}
|
||||
}*/
|
||||
|
||||
@NotNull
|
||||
public String getDisplayName() {
|
||||
|
@ -246,7 +282,7 @@ public abstract class ExcellentEnchant extends Enchantment implements IEnchantme
|
|||
}
|
||||
|
||||
public boolean isObtainable(@NotNull ObtainType obtainType) {
|
||||
if (obtainType == ObtainType.ENCHANTING && (this.isTreasure() || this.isCursed())) return false;
|
||||
if (obtainType == ObtainType.ENCHANTING && (this.isTreasure() || this.isCurse())) return false;
|
||||
|
||||
return this.getObtainChance(obtainType) > 0D;
|
||||
}
|
||||
|
@ -291,26 +327,43 @@ public abstract class ExcellentEnchant extends Enchantment implements IEnchantme
|
|||
return (int) this.getDefaults().getAnvilMergeCost().getValue(level);
|
||||
}
|
||||
|
||||
@Override
|
||||
/*@Override
|
||||
@Deprecated
|
||||
public final boolean conflictsWith(@NotNull Enchantment enchantment) {
|
||||
return this.getConflicts().contains(enchantment.getKey().getKey());
|
||||
}*/
|
||||
|
||||
@Deprecated
|
||||
public Enchantment getBackend() {
|
||||
return EnchantUtils.getEnchantment(this.getKey());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean canEnchantItem(@Nullable ItemStack item) {
|
||||
if (item == null || item.getType().isAir()) return false;
|
||||
if (EnchantUtils.getAll(item).keySet().stream().anyMatch(e -> e.conflictsWith(this) || this.conflictsWith(e))) return false;
|
||||
if (EnchantUtils.getLevel(item, this) <= 0 && EnchantUtils.getExcellentAmount(item) >= Config.ENCHANTMENTS_ITEM_CUSTOM_MAX.get()) {
|
||||
return false;
|
||||
public final boolean checkEnchantCategory(@NotNull ItemStack item) {
|
||||
EnchantmentTarget category = this.getCategory();
|
||||
|
||||
if (category == EnchantmentTarget.WEAPON && ItemUtil.isAxe(item)) {
|
||||
return Config.ENCHANTMENTS_ITEM_SWORD_ENCHANTS_TO_AXES.get();
|
||||
}
|
||||
if (item.getType() == Material.BOOK || item.getType() == Material.ENCHANTED_BOOK) {
|
||||
return true;
|
||||
if (category == EnchantmentTarget.BOW && item.getType() == Material.CROSSBOW) {
|
||||
return Config.ENCHANTMENTS_ITEM_BOW_ENCHANTS_TO_CROSSBOW.get();
|
||||
}
|
||||
return Stream.of(this.getFitItemTypes()).anyMatch(fitItemType -> fitItemType.isIncluded(item));
|
||||
if ((category == EnchantmentTarget.ARMOR || category == EnchantmentTarget.ARMOR_TORSO) && item.getType() == Material.ELYTRA) {
|
||||
return Config.ENCHANTMENTS_ITEM_CHESTPLATE_ENCHANTS_TO_ELYTRA.get();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCursed() {
|
||||
public boolean checkItemCategory(@NotNull ItemStack item) {
|
||||
ItemCategory[] itemCategories = this.getFitItemTypes();
|
||||
if (itemCategories.length == 0) return false;
|
||||
|
||||
return Stream.of(itemCategories).anyMatch(itemCategory -> itemCategory.isIncluded(item));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCurse() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -319,6 +372,16 @@ public abstract class ExcellentEnchant extends Enchantment implements IEnchantme
|
|||
return this.getDefaults().isTreasure();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTradeable() {
|
||||
return this.getDefaults().isTradeable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDiscoverable() {
|
||||
return this.getDefaults().isDiscoverable();
|
||||
}
|
||||
|
||||
public boolean hasVisualEffects() {
|
||||
return this.getDefaults().isVisualEffects();
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ public class AquamanEnchant extends ExcellentEnchant implements Potioned, Passiv
|
|||
|
||||
@Override
|
||||
@NotNull
|
||||
public EnchantmentTarget getItemTarget() {
|
||||
public EnchantmentTarget getCategory() {
|
||||
return EnchantmentTarget.ARMOR_HEAD;
|
||||
}
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ public class ColdSteelEnchant extends ExcellentEnchant implements Chanced, Potio
|
|||
|
||||
@Override
|
||||
@NotNull
|
||||
public EnchantmentTarget getItemTarget() {
|
||||
public EnchantmentTarget getCategory() {
|
||||
return EnchantmentTarget.ARMOR_TORSO;
|
||||
}
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ public class DarknessCloakEnchant extends ExcellentEnchant implements Chanced, P
|
|||
|
||||
@Override
|
||||
@NotNull
|
||||
public EnchantmentTarget getItemTarget() {
|
||||
public EnchantmentTarget getCategory() {
|
||||
return EnchantmentTarget.ARMOR_TORSO;
|
||||
}
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ public class ElementalProtectionEnchant extends ExcellentEnchant implements Gene
|
|||
|
||||
@NotNull
|
||||
@Override
|
||||
public EnchantmentTarget getItemTarget() {
|
||||
public EnchantmentTarget getCategory() {
|
||||
return EnchantmentTarget.ARMOR;
|
||||
}
|
||||
|
||||
|
@ -84,7 +84,7 @@ public class ElementalProtectionEnchant extends ExcellentEnchant implements Gene
|
|||
|
||||
double protectionAmount = 0D;
|
||||
for (ItemStack armor : EnchantUtils.getEnchantedEquipment(entity).values()) {
|
||||
int level = EnchantUtils.getLevel(armor, this);
|
||||
int level = EnchantUtils.getLevel(armor, this.getBackend());
|
||||
if (level <= 0) continue;
|
||||
|
||||
protectionAmount += this.getProtectionAmount(level);
|
||||
|
|
|
@ -53,7 +53,7 @@ public class FireShieldEnchant extends ExcellentEnchant implements Chanced, Comb
|
|||
|
||||
@NotNull
|
||||
@Override
|
||||
public EnchantmentTarget getItemTarget() {
|
||||
public EnchantmentTarget getCategory() {
|
||||
return EnchantmentTarget.ARMOR;
|
||||
}
|
||||
|
||||
|
|
|
@ -85,7 +85,7 @@ public class FlameWalkerEnchant extends ExcellentEnchant implements GenericEncha
|
|||
|
||||
@Override
|
||||
@NotNull
|
||||
public EnchantmentTarget getItemTarget() {
|
||||
public EnchantmentTarget getCategory() {
|
||||
return EnchantmentTarget.ARMOR_FEET;
|
||||
}
|
||||
|
||||
|
@ -106,7 +106,7 @@ public class FlameWalkerEnchant extends ExcellentEnchant implements GenericEncha
|
|||
ItemStack boots = player.getInventory().getBoots();
|
||||
if (boots == null || boots.getType().isAir()) return;
|
||||
|
||||
int level = EnchantUtils.getLevel(boots, this);
|
||||
int level = EnchantUtils.getLevel(boots, this.getBackend());
|
||||
if (level <= 0) return;
|
||||
|
||||
Block bTo = to.getBlock().getRelative(BlockFace.DOWN);
|
||||
|
@ -159,7 +159,7 @@ public class FlameWalkerEnchant extends ExcellentEnchant implements GenericEncha
|
|||
ItemStack boots = equipment.getBoots();
|
||||
if (boots == null || boots.getType().isAir()) return;
|
||||
|
||||
int level = EnchantUtils.getLevel(boots, this);
|
||||
int level = EnchantUtils.getLevel(boots, this.getBackend());
|
||||
if (level <= 0) return;
|
||||
|
||||
event.setCancelled(true);
|
||||
|
|
|
@ -55,7 +55,7 @@ public class HardenedEnchant extends ExcellentEnchant implements Chanced, Potion
|
|||
|
||||
@Override
|
||||
@NotNull
|
||||
public EnchantmentTarget getItemTarget() {
|
||||
public EnchantmentTarget getCategory() {
|
||||
return EnchantmentTarget.ARMOR_TORSO;
|
||||
}
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ public class IceShieldEnchant extends ExcellentEnchant implements Chanced, Potio
|
|||
|
||||
@NotNull
|
||||
@Override
|
||||
public EnchantmentTarget getItemTarget() {
|
||||
public EnchantmentTarget getCategory() {
|
||||
return EnchantmentTarget.ARMOR_TORSO;
|
||||
}
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ public class JumpingEnchant extends ExcellentEnchant implements Potioned, Passiv
|
|||
|
||||
@Override
|
||||
@NotNull
|
||||
public EnchantmentTarget getItemTarget() {
|
||||
public EnchantmentTarget getCategory() {
|
||||
return EnchantmentTarget.ARMOR_FEET;
|
||||
}
|
||||
|
||||
|
|
|
@ -9,8 +9,11 @@ import org.bukkit.event.EventHandler;
|
|||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
import org.bukkit.event.entity.EntityResurrectEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import su.nexmedia.engine.api.config.JOption;
|
||||
import su.nexmedia.engine.api.manager.EventListener;
|
||||
import su.nexmedia.engine.utils.NumberUtil;
|
||||
import su.nightexpress.excellentenchants.ExcellentEnchants;
|
||||
import su.nightexpress.excellentenchants.Placeholders;
|
||||
|
@ -20,12 +23,13 @@ import su.nightexpress.excellentenchants.enchantment.config.EnchantScaler;
|
|||
import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant;
|
||||
import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation;
|
||||
|
||||
public class KamikadzeEnchant extends ExcellentEnchant implements Chanced, DeathEnchant {
|
||||
public class KamikadzeEnchant extends ExcellentEnchant implements Chanced, DeathEnchant, EventListener {
|
||||
|
||||
public static final String ID = "self_destruction";
|
||||
private static final String PLACEHOLDER_EXPLOSION_POWER = "%enchantment_explosion_power%";
|
||||
|
||||
private EnchantScaler explosionSize;
|
||||
private boolean applyOnResurrect;
|
||||
private ChanceImplementation chanceImplementation;
|
||||
|
||||
private Entity exploder;
|
||||
|
@ -42,6 +46,11 @@ public class KamikadzeEnchant extends ExcellentEnchant implements Chanced, Death
|
|||
super.loadSettings();
|
||||
this.chanceImplementation = ChanceImplementation.create(this,
|
||||
"20.0 + " + Placeholders.ENCHANTMENT_LEVEL + " * 10");
|
||||
|
||||
this.applyOnResurrect = JOption.create("Settings.Apply_On_Resurrect", true,
|
||||
"Sets whether or not enchantment will trigger on resurrect (when a totem is used)."
|
||||
).read(cfg);
|
||||
|
||||
this.explosionSize = EnchantScaler.read(this, "Settings.Explosion.Size",
|
||||
"1.0" + Placeholders.ENCHANTMENT_LEVEL,
|
||||
"A size of the explosion. The more size - the bigger the damage.");
|
||||
|
@ -57,16 +66,19 @@ public class KamikadzeEnchant extends ExcellentEnchant implements Chanced, Death
|
|||
|
||||
@Override
|
||||
@NotNull
|
||||
public EnchantmentTarget getItemTarget() {
|
||||
public EnchantmentTarget getCategory() {
|
||||
return EnchantmentTarget.ARMOR_TORSO;
|
||||
}
|
||||
|
||||
public boolean isApplyOnResurrect() {
|
||||
return this.applyOnResurrect;
|
||||
}
|
||||
|
||||
public final double getExplosionSize(int level) {
|
||||
return this.explosionSize.getValue(level);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onDeath(@NotNull EntityDeathEvent event, @NotNull LivingEntity entity, ItemStack item, int level) {
|
||||
public boolean createExplosion(@NotNull LivingEntity entity, @NotNull ItemStack item, int level) {
|
||||
if (!this.checkTriggerChance(level)) return false;
|
||||
|
||||
float size = (float) this.getExplosionSize(level);
|
||||
|
@ -76,6 +88,16 @@ public class KamikadzeEnchant extends ExcellentEnchant implements Chanced, Death
|
|||
return exploded;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onDeath(@NotNull EntityDeathEvent event, @NotNull LivingEntity entity, ItemStack item, int level) {
|
||||
return this.createExplosion(entity, item, level);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onResurrect(@NotNull EntityResurrectEvent event, @NotNull LivingEntity entity, @NotNull ItemStack item, int level) {
|
||||
return this.isApplyOnResurrect() && this.createExplosion(entity, item, level);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKill(@NotNull EntityDeathEvent event, @NotNull LivingEntity entity, @NotNull Player killer, ItemStack weapon, int level) {
|
||||
return false;
|
||||
|
@ -84,8 +106,9 @@ public class KamikadzeEnchant extends ExcellentEnchant implements Chanced, Death
|
|||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onItemDamage(EntityDamageByEntityEvent event) {
|
||||
if (this.exploder == null || event.getDamager() != this.exploder) return;
|
||||
if (!(event.getEntity() instanceof Item item)) return;
|
||||
|
||||
event.setCancelled(true);
|
||||
if (event.getEntity() instanceof Item || event.getEntity() == this.exploder) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ public class NightVisionEnchant extends ExcellentEnchant implements Potioned, Pa
|
|||
|
||||
@Override
|
||||
@NotNull
|
||||
public EnchantmentTarget getItemTarget() {
|
||||
public EnchantmentTarget getCategory() {
|
||||
return EnchantmentTarget.ARMOR_HEAD;
|
||||
}
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ public class RegrowthEnchant extends ExcellentEnchant implements Chanced, Passiv
|
|||
|
||||
@NotNull
|
||||
@Override
|
||||
public EnchantmentTarget getItemTarget() {
|
||||
public EnchantmentTarget getCategory() {
|
||||
return EnchantmentTarget.ARMOR_TORSO;
|
||||
}
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ public class SaturationEnchant extends ExcellentEnchant implements PassiveEnchan
|
|||
|
||||
@Override
|
||||
@NotNull
|
||||
public EnchantmentTarget getItemTarget() {
|
||||
public EnchantmentTarget getCategory() {
|
||||
return EnchantmentTarget.ARMOR_HEAD;
|
||||
}
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ public class SpeedyEnchant extends ExcellentEnchant implements Potioned, Passive
|
|||
|
||||
@Override
|
||||
@NotNull
|
||||
public EnchantmentTarget getItemTarget() {
|
||||
public EnchantmentTarget getCategory() {
|
||||
return EnchantmentTarget.ARMOR_FEET;
|
||||
}
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ public class StoppingForceEnchant extends ExcellentEnchant implements Chanced, C
|
|||
|
||||
@NotNull
|
||||
@Override
|
||||
public EnchantmentTarget getItemTarget() {
|
||||
public EnchantmentTarget getCategory() {
|
||||
return EnchantmentTarget.ARMOR_LEGS;
|
||||
}
|
||||
|
||||
|
|
|
@ -71,7 +71,7 @@ public class DarknessArrowsEnchant extends ExcellentEnchant implements Chanced,
|
|||
|
||||
@NotNull
|
||||
@Override
|
||||
public EnchantmentTarget getItemTarget() {
|
||||
public EnchantmentTarget getCategory() {
|
||||
return EnchantmentTarget.BOW;
|
||||
}
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@ public class EnchantBomber extends ExcellentEnchant implements Chanced, BowEncha
|
|||
|
||||
@Override
|
||||
@NotNull
|
||||
public EnchantmentTarget getItemTarget() {
|
||||
public EnchantmentTarget getCategory() {
|
||||
return EnchantmentTarget.BOW;
|
||||
}
|
||||
|
||||
|
|
|
@ -71,7 +71,7 @@ public class EnchantConfusingArrows extends ExcellentEnchant implements Chanced,
|
|||
|
||||
@NotNull
|
||||
@Override
|
||||
public EnchantmentTarget getItemTarget() {
|
||||
public EnchantmentTarget getCategory() {
|
||||
return EnchantmentTarget.BOW;
|
||||
}
|
||||
|
||||
|
|
|
@ -84,7 +84,7 @@ public class EnchantDragonfireArrows extends ExcellentEnchant implements Chanced
|
|||
|
||||
@NotNull
|
||||
@Override
|
||||
public EnchantmentTarget getItemTarget() {
|
||||
public EnchantmentTarget getCategory() {
|
||||
return EnchantmentTarget.BOW;
|
||||
}
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ public class EnchantElectrifiedArrows extends ExcellentEnchant implements Chance
|
|||
|
||||
@NotNull
|
||||
@Override
|
||||
public EnchantmentTarget getItemTarget() {
|
||||
public EnchantmentTarget getCategory() {
|
||||
return EnchantmentTarget.BOW;
|
||||
}
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ public class EnchantEnderBow extends ExcellentEnchant implements BowEnchant, Cha
|
|||
|
||||
@Override
|
||||
@NotNull
|
||||
public EnchantmentTarget getItemTarget() {
|
||||
public EnchantmentTarget getCategory() {
|
||||
return EnchantmentTarget.BOW;
|
||||
}
|
||||
|
||||
|
|
|
@ -81,7 +81,7 @@ public class EnchantExplosiveArrows extends ExcellentEnchant implements Chanced,
|
|||
|
||||
@NotNull
|
||||
@Override
|
||||
public EnchantmentTarget getItemTarget() {
|
||||
public EnchantmentTarget getCategory() {
|
||||
return EnchantmentTarget.BOW;
|
||||
}
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ public class EnchantGhast extends ExcellentEnchant implements BowEnchant, Chance
|
|||
|
||||
@Override
|
||||
@NotNull
|
||||
public EnchantmentTarget getItemTarget() {
|
||||
public EnchantmentTarget getCategory() {
|
||||
return EnchantmentTarget.BOW;
|
||||
}
|
||||
|
||||
|
|
|
@ -71,7 +71,7 @@ public class EnchantHover extends ExcellentEnchant implements Chanced, Arrowed,
|
|||
|
||||
@NotNull
|
||||
@Override
|
||||
public EnchantmentTarget getItemTarget() {
|
||||
public EnchantmentTarget getCategory() {
|
||||
return EnchantmentTarget.BOW;
|
||||
}
|
||||
|
||||
|
|
|
@ -71,7 +71,7 @@ public class EnchantPoisonedArrows extends ExcellentEnchant implements Chanced,
|
|||
|
||||
@NotNull
|
||||
@Override
|
||||
public EnchantmentTarget getItemTarget() {
|
||||
public EnchantmentTarget getCategory() {
|
||||
return EnchantmentTarget.BOW;
|
||||
}
|
||||
|
||||
|
|
|
@ -71,7 +71,7 @@ public class EnchantWitheredArrows extends ExcellentEnchant implements Chanced,
|
|||
|
||||
@NotNull
|
||||
@Override
|
||||
public EnchantmentTarget getItemTarget() {
|
||||
public EnchantmentTarget getCategory() {
|
||||
return EnchantmentTarget.BOW;
|
||||
}
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ public class FlareEnchant extends ExcellentEnchant implements Chanced, Arrowed,
|
|||
|
||||
@NotNull
|
||||
@Override
|
||||
public EnchantmentTarget getItemTarget() {
|
||||
public EnchantmentTarget getCategory() {
|
||||
return EnchantmentTarget.BOW;
|
||||
}
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ public class SniperEnchant extends ExcellentEnchant implements BowEnchant, Chanc
|
|||
|
||||
@NotNull
|
||||
@Override
|
||||
public EnchantmentTarget getItemTarget() {
|
||||
public EnchantmentTarget getCategory() {
|
||||
return EnchantmentTarget.BOW;
|
||||
}
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ public class VampiricArrowsEnchant extends ExcellentEnchant implements BowEnchan
|
|||
|
||||
@NotNull
|
||||
@Override
|
||||
public EnchantmentTarget getItemTarget() {
|
||||
public EnchantmentTarget getCategory() {
|
||||
return EnchantmentTarget.BOW;
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ public class AutoReelEnchant extends ExcellentEnchant implements FishingEnchant
|
|||
|
||||
@NotNull
|
||||
@Override
|
||||
public EnchantmentTarget getItemTarget() {
|
||||
public EnchantmentTarget getCategory() {
|
||||
return EnchantmentTarget.FISHING_ROD;
|
||||
}
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ public class CurseOfDrownedEnchant extends ExcellentEnchant implements FishingEn
|
|||
|
||||
@NotNull
|
||||
@Override
|
||||
public EnchantmentTarget getItemTarget() {
|
||||
public EnchantmentTarget getCategory() {
|
||||
return EnchantmentTarget.FISHING_ROD;
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ public class DoubleCatchEnchant extends ExcellentEnchant implements FishingEncha
|
|||
|
||||
@NotNull
|
||||
@Override
|
||||
public EnchantmentTarget getItemTarget() {
|
||||
public EnchantmentTarget getCategory() {
|
||||
return EnchantmentTarget.FISHING_ROD;
|
||||
}
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ public class RiverMasterEnchant extends ExcellentEnchant implements GenericEncha
|
|||
|
||||
@NotNull
|
||||
@Override
|
||||
public EnchantmentTarget getItemTarget() {
|
||||
public EnchantmentTarget getCategory() {
|
||||
return EnchantmentTarget.FISHING_ROD;
|
||||
}
|
||||
|
||||
|
@ -56,7 +56,7 @@ public class RiverMasterEnchant extends ExcellentEnchant implements GenericEncha
|
|||
ItemStack rod = EnchantUtils.getFishingRod(player);
|
||||
if (rod == null) return;
|
||||
|
||||
int level = EnchantUtils.getLevel(rod, this);
|
||||
int level = EnchantUtils.getLevel(rod, this.getBackend());
|
||||
if (level < 1) return;
|
||||
|
||||
if (this.isOutOfCharges(rod)) return;
|
||||
|
|
|
@ -40,7 +40,7 @@ public class SeasonedAnglerEnchant extends ExcellentEnchant implements FishingEn
|
|||
|
||||
@NotNull
|
||||
@Override
|
||||
public EnchantmentTarget getItemTarget() {
|
||||
public EnchantmentTarget getCategory() {
|
||||
return EnchantmentTarget.FISHING_ROD;
|
||||
}
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ public class SurvivalistEnchant extends ExcellentEnchant implements FishingEncha
|
|||
|
||||
@NotNull
|
||||
@Override
|
||||
public EnchantmentTarget getItemTarget() {
|
||||
public EnchantmentTarget getCategory() {
|
||||
return EnchantmentTarget.FISHING_ROD;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ import su.nightexpress.excellentenchants.api.enchantment.type.BlockBreakEnchant;
|
|||
import su.nightexpress.excellentenchants.enchantment.config.EnchantScaler;
|
||||
import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant;
|
||||
import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation;
|
||||
import su.nightexpress.excellentenchants.enchantment.type.FitItemType;
|
||||
import su.nightexpress.excellentenchants.api.enchantment.ItemCategory;
|
||||
import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils;
|
||||
import su.nightexpress.excellentenchants.hook.impl.NoCheatPlusHook;
|
||||
|
||||
|
@ -88,13 +88,13 @@ public class BlastMiningEnchant extends ExcellentEnchant implements Chanced, Blo
|
|||
|
||||
@Override
|
||||
@NotNull
|
||||
public FitItemType[] getFitItemTypes() {
|
||||
return new FitItemType[]{FitItemType.PICKAXE};
|
||||
public ItemCategory[] getFitItemTypes() {
|
||||
return new ItemCategory[]{ItemCategory.PICKAXE};
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public EnchantmentTarget getItemTarget() {
|
||||
public EnchantmentTarget getCategory() {
|
||||
return EnchantmentTarget.TOOL;
|
||||
}
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ public class CurseOfBreakingEnchant extends ExcellentEnchant implements GenericE
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean isCursed() {
|
||||
public boolean isCurse() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -62,7 +62,7 @@ public class CurseOfBreakingEnchant extends ExcellentEnchant implements GenericE
|
|||
|
||||
@NotNull
|
||||
@Override
|
||||
public EnchantmentTarget getItemTarget() {
|
||||
public EnchantmentTarget getCategory() {
|
||||
return EnchantmentTarget.BREAKABLE;
|
||||
}
|
||||
|
||||
|
@ -72,7 +72,7 @@ public class CurseOfBreakingEnchant extends ExcellentEnchant implements GenericE
|
|||
if (!this.isAvailableToUse(player)) return;
|
||||
|
||||
ItemStack item = event.getItem();
|
||||
int level = EnchantUtils.getLevel(item, this);
|
||||
int level = EnchantUtils.getLevel(item, this.getBackend());
|
||||
|
||||
if (level < 1) return;
|
||||
if (!this.checkTriggerChance(level)) return;
|
||||
|
|
|
@ -6,6 +6,7 @@ import org.bukkit.entity.Player;
|
|||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.block.BlockDropItemEvent;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
import org.bukkit.event.entity.EntityResurrectEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import su.nexmedia.engine.utils.ItemUtil;
|
||||
|
@ -16,7 +17,7 @@ import su.nightexpress.excellentenchants.api.enchantment.type.BlockDropEnchant;
|
|||
import su.nightexpress.excellentenchants.api.enchantment.type.DeathEnchant;
|
||||
import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant;
|
||||
import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation;
|
||||
import su.nightexpress.excellentenchants.enchantment.type.FitItemType;
|
||||
import su.nightexpress.excellentenchants.api.enchantment.ItemCategory;
|
||||
|
||||
public class CurseOfMediocrityEnchant extends ExcellentEnchant implements Chanced, BlockDropEnchant, DeathEnchant {
|
||||
|
||||
|
@ -39,14 +40,16 @@ public class CurseOfMediocrityEnchant extends ExcellentEnchant implements Chance
|
|||
|
||||
@NotNull
|
||||
@Override
|
||||
public EnchantmentTarget getItemTarget() {
|
||||
public EnchantmentTarget getCategory() {
|
||||
return EnchantmentTarget.BREAKABLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public FitItemType[] getFitItemTypes() {
|
||||
return new FitItemType[] {FitItemType.WEAPON, FitItemType.TOOL};
|
||||
public ItemCategory[] getFitItemTypes() {
|
||||
return new ItemCategory[] {
|
||||
ItemCategory.SWORD, ItemCategory.BOW, ItemCategory.CROSSBOW, ItemCategory.TRIDENT, ItemCategory.TOOL
|
||||
};
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
@ -62,7 +65,7 @@ public class CurseOfMediocrityEnchant extends ExcellentEnchant implements Chance
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean isCursed() {
|
||||
public boolean isCurse() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -87,6 +90,11 @@ public class CurseOfMediocrityEnchant extends ExcellentEnchant implements Chance
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onResurrect(@NotNull EntityResurrectEvent event, @NotNull LivingEntity entity, @NotNull ItemStack item, int level) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKill(@NotNull EntityDeathEvent event, @NotNull LivingEntity entity, @NotNull Player killer, ItemStack weapon, int level) {
|
||||
if (!this.checkTriggerChance(level)) return false;
|
||||
|
|
|
@ -2,11 +2,13 @@ package su.nightexpress.excellentenchants.enchantment.impl.tool;
|
|||
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.enchantments.EnchantmentTarget;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
import org.bukkit.event.entity.EntityResurrectEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import su.nexmedia.engine.api.config.JOption;
|
||||
|
@ -17,7 +19,7 @@ import su.nightexpress.excellentenchants.api.enchantment.type.BlockBreakEnchant;
|
|||
import su.nightexpress.excellentenchants.api.enchantment.type.DeathEnchant;
|
||||
import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant;
|
||||
import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation;
|
||||
import su.nightexpress.excellentenchants.enchantment.type.FitItemType;
|
||||
import su.nightexpress.excellentenchants.api.enchantment.ItemCategory;
|
||||
|
||||
public class CurseOfMisfortuneEnchant extends ExcellentEnchant implements Chanced, BlockBreakEnchant, DeathEnchant {
|
||||
|
||||
|
@ -58,13 +60,15 @@ public class CurseOfMisfortuneEnchant extends ExcellentEnchant implements Chance
|
|||
|
||||
@Override
|
||||
@NotNull
|
||||
public FitItemType[] getFitItemTypes() {
|
||||
return new FitItemType[] {FitItemType.WEAPON, FitItemType.TOOL};
|
||||
public ItemCategory[] getFitItemTypes() {
|
||||
return new ItemCategory[] {
|
||||
ItemCategory.SWORD, ItemCategory.BOW, ItemCategory.CROSSBOW, ItemCategory.TRIDENT, ItemCategory.TOOL
|
||||
};
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public EnchantmentTarget getItemTarget() {
|
||||
public EnchantmentTarget getCategory() {
|
||||
return EnchantmentTarget.BREAKABLE;
|
||||
}
|
||||
|
||||
|
@ -81,7 +85,7 @@ public class CurseOfMisfortuneEnchant extends ExcellentEnchant implements Chance
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean isCursed() {
|
||||
public boolean isCurse() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -107,4 +111,9 @@ public class CurseOfMisfortuneEnchant extends ExcellentEnchant implements Chance
|
|||
public boolean onDeath(@NotNull EntityDeathEvent event, @NotNull LivingEntity entity, ItemStack item, int level) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onResurrect(@NotNull EntityResurrectEvent event, @NotNull LivingEntity entity, @NotNull ItemStack item, int level) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ import su.nightexpress.excellentenchants.api.enchantment.type.BlockBreakEnchant;
|
|||
import su.nightexpress.excellentenchants.api.enchantment.type.BlockDropEnchant;
|
||||
import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant;
|
||||
import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation;
|
||||
import su.nightexpress.excellentenchants.enchantment.type.FitItemType;
|
||||
import su.nightexpress.excellentenchants.api.enchantment.ItemCategory;
|
||||
import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils;
|
||||
|
||||
public class DivineTouchEnchant extends ExcellentEnchant implements Chanced, BlockBreakEnchant, BlockDropEnchant, EventListener {
|
||||
|
@ -79,13 +79,13 @@ public class DivineTouchEnchant extends ExcellentEnchant implements Chanced, Blo
|
|||
|
||||
@Override
|
||||
@NotNull
|
||||
public FitItemType[] getFitItemTypes() {
|
||||
return new FitItemType[]{FitItemType.PICKAXE};
|
||||
public ItemCategory[] getFitItemTypes() {
|
||||
return new ItemCategory[]{ItemCategory.PICKAXE};
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public EnchantmentTarget getItemTarget() {
|
||||
public EnchantmentTarget getCategory() {
|
||||
return EnchantmentTarget.TOOL;
|
||||
}
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ public class HasteEnchant extends ExcellentEnchant implements Potioned, PassiveE
|
|||
|
||||
@Override
|
||||
@NotNull
|
||||
public EnchantmentTarget getItemTarget() {
|
||||
public EnchantmentTarget getCategory() {
|
||||
return EnchantmentTarget.TOOL;
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ import su.nightexpress.excellentenchants.api.enchantment.type.BlockBreakEnchant;
|
|||
import su.nightexpress.excellentenchants.enchantment.config.EnchantScaler;
|
||||
import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant;
|
||||
import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation;
|
||||
import su.nightexpress.excellentenchants.enchantment.type.FitItemType;
|
||||
import su.nightexpress.excellentenchants.api.enchantment.ItemCategory;
|
||||
|
||||
public class LuckyMinerEnchant extends ExcellentEnchant implements Chanced, BlockBreakEnchant {
|
||||
|
||||
|
@ -54,13 +54,13 @@ public class LuckyMinerEnchant extends ExcellentEnchant implements Chanced, Bloc
|
|||
|
||||
@Override
|
||||
@NotNull
|
||||
public FitItemType[] getFitItemTypes() {
|
||||
return new FitItemType[]{FitItemType.PICKAXE};
|
||||
public ItemCategory[] getFitItemTypes() {
|
||||
return new ItemCategory[]{ItemCategory.PICKAXE};
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public EnchantmentTarget getItemTarget() {
|
||||
public EnchantmentTarget getCategory() {
|
||||
return EnchantmentTarget.TOOL;
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ import su.nightexpress.excellentenchants.api.enchantment.type.BlockBreakEnchant;
|
|||
import su.nightexpress.excellentenchants.api.enchantment.type.InteractEnchant;
|
||||
import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant;
|
||||
import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation;
|
||||
import su.nightexpress.excellentenchants.enchantment.type.FitItemType;
|
||||
import su.nightexpress.excellentenchants.api.enchantment.ItemCategory;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
|
@ -110,13 +110,13 @@ public class ReplanterEnchant extends ExcellentEnchant implements Chanced, Inter
|
|||
|
||||
@Override
|
||||
@NotNull
|
||||
public FitItemType[] getFitItemTypes() {
|
||||
return new FitItemType[]{FitItemType.HOE};
|
||||
public ItemCategory[] getFitItemTypes() {
|
||||
return new ItemCategory[]{ItemCategory.HOE};
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public EnchantmentTarget getItemTarget() {
|
||||
public EnchantmentTarget getCategory() {
|
||||
return EnchantmentTarget.TOOL;
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ import su.nightexpress.excellentenchants.ExcellentEnchants;
|
|||
import su.nightexpress.excellentenchants.Placeholders;
|
||||
import su.nightexpress.excellentenchants.api.enchantment.type.BlockDropEnchant;
|
||||
import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant;
|
||||
import su.nightexpress.excellentenchants.enchantment.type.FitItemType;
|
||||
import su.nightexpress.excellentenchants.api.enchantment.ItemCategory;
|
||||
import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -66,13 +66,13 @@ public class SilkChestEnchant extends ExcellentEnchant implements BlockDropEncha
|
|||
|
||||
@Override
|
||||
@NotNull
|
||||
public FitItemType[] getFitItemTypes() {
|
||||
return new FitItemType[]{FitItemType.AXE};
|
||||
public ItemCategory[] getFitItemTypes() {
|
||||
return new ItemCategory[]{ItemCategory.AXE};
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public EnchantmentTarget getItemTarget() {
|
||||
public EnchantmentTarget getCategory() {
|
||||
return EnchantmentTarget.TOOL;
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced;
|
|||
import su.nightexpress.excellentenchants.api.enchantment.type.BlockDropEnchant;
|
||||
import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant;
|
||||
import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation;
|
||||
import su.nightexpress.excellentenchants.enchantment.type.FitItemType;
|
||||
import su.nightexpress.excellentenchants.api.enchantment.ItemCategory;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -78,13 +78,13 @@ public class SmelterEnchant extends ExcellentEnchant implements Chanced, BlockDr
|
|||
|
||||
@Override
|
||||
@NotNull
|
||||
public FitItemType[] getFitItemTypes() {
|
||||
return new FitItemType[]{FitItemType.PICKAXE, FitItemType.AXE, FitItemType.SHOVEL};
|
||||
public ItemCategory[] getFitItemTypes() {
|
||||
return new ItemCategory[]{ItemCategory.PICKAXE, ItemCategory.AXE, ItemCategory.SHOVEL};
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public EnchantmentTarget getItemTarget() {
|
||||
public EnchantmentTarget getCategory() {
|
||||
return EnchantmentTarget.TOOL;
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced;
|
|||
import su.nightexpress.excellentenchants.api.enchantment.type.BlockDropEnchant;
|
||||
import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant;
|
||||
import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation;
|
||||
import su.nightexpress.excellentenchants.enchantment.type.FitItemType;
|
||||
import su.nightexpress.excellentenchants.api.enchantment.ItemCategory;
|
||||
|
||||
public class TelekinesisEnchant extends ExcellentEnchant implements Chanced, BlockDropEnchant {
|
||||
|
||||
|
@ -42,13 +42,13 @@ public class TelekinesisEnchant extends ExcellentEnchant implements Chanced, Blo
|
|||
|
||||
@Override
|
||||
@NotNull
|
||||
public FitItemType[] getFitItemTypes() {
|
||||
return new FitItemType[]{FitItemType.TOOL};
|
||||
public ItemCategory[] getFitItemTypes() {
|
||||
return new ItemCategory[]{ItemCategory.TOOL};
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public EnchantmentTarget getItemTarget() {
|
||||
public EnchantmentTarget getCategory() {
|
||||
return EnchantmentTarget.TOOL;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ import su.nightexpress.excellentenchants.api.enchantment.type.BlockBreakEnchant;
|
|||
import su.nightexpress.excellentenchants.api.enchantment.type.BlockDropEnchant;
|
||||
import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant;
|
||||
import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation;
|
||||
import su.nightexpress.excellentenchants.enchantment.type.FitItemType;
|
||||
import su.nightexpress.excellentenchants.api.enchantment.ItemCategory;
|
||||
import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils;
|
||||
|
||||
import java.util.*;
|
||||
|
@ -116,13 +116,13 @@ public class TreasuresEnchant extends ExcellentEnchant implements Chanced, Block
|
|||
|
||||
@Override
|
||||
@NotNull
|
||||
public FitItemType[] getFitItemTypes() {
|
||||
return new FitItemType[]{FitItemType.PICKAXE, FitItemType.AXE, FitItemType.SHOVEL};
|
||||
public ItemCategory[] getFitItemTypes() {
|
||||
return new ItemCategory[]{ItemCategory.PICKAXE, ItemCategory.AXE, ItemCategory.SHOVEL};
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public EnchantmentTarget getItemTarget() {
|
||||
public EnchantmentTarget getCategory() {
|
||||
return EnchantmentTarget.TOOL;
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ import su.nexmedia.engine.api.config.JOption;
|
|||
import su.nightexpress.excellentenchants.ExcellentEnchants;
|
||||
import su.nightexpress.excellentenchants.api.enchantment.type.BlockBreakEnchant;
|
||||
import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant;
|
||||
import su.nightexpress.excellentenchants.enchantment.type.FitItemType;
|
||||
import su.nightexpress.excellentenchants.api.enchantment.ItemCategory;
|
||||
import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils;
|
||||
import su.nightexpress.excellentenchants.hook.impl.NoCheatPlusHook;
|
||||
|
||||
|
@ -53,13 +53,13 @@ public class TunnelEnchant extends ExcellentEnchant implements BlockBreakEnchant
|
|||
|
||||
@Override
|
||||
@NotNull
|
||||
public FitItemType[] getFitItemTypes() {
|
||||
return new FitItemType[]{FitItemType.PICKAXE, FitItemType.SHOVEL};
|
||||
public ItemCategory[] getFitItemTypes() {
|
||||
return new ItemCategory[]{ItemCategory.PICKAXE, ItemCategory.SHOVEL};
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public EnchantmentTarget getItemTarget() {
|
||||
public EnchantmentTarget getCategory() {
|
||||
return EnchantmentTarget.TOOL;
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ import su.nightexpress.excellentenchants.Placeholders;
|
|||
import su.nightexpress.excellentenchants.api.enchantment.type.BlockBreakEnchant;
|
||||
import su.nightexpress.excellentenchants.enchantment.config.EnchantScaler;
|
||||
import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant;
|
||||
import su.nightexpress.excellentenchants.enchantment.type.FitItemType;
|
||||
import su.nightexpress.excellentenchants.api.enchantment.ItemCategory;
|
||||
import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils;
|
||||
import su.nightexpress.excellentenchants.hook.impl.NoCheatPlusHook;
|
||||
|
||||
|
@ -90,13 +90,13 @@ public class VeinminerEnchant extends ExcellentEnchant implements BlockBreakEnch
|
|||
|
||||
@Override
|
||||
@NotNull
|
||||
public FitItemType[] getFitItemTypes() {
|
||||
return new FitItemType[]{FitItemType.PICKAXE};
|
||||
public ItemCategory[] getFitItemTypes() {
|
||||
return new ItemCategory[]{ItemCategory.PICKAXE};
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public EnchantmentTarget getItemTarget() {
|
||||
public EnchantmentTarget getCategory() {
|
||||
return EnchantmentTarget.TOOL;
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ public class CurseOfFragilityEnchant extends ExcellentEnchant implements Generic
|
|||
|
||||
@NotNull
|
||||
@Override
|
||||
public EnchantmentTarget getItemTarget() {
|
||||
public EnchantmentTarget getCategory() {
|
||||
return EnchantmentTarget.BREAKABLE;
|
||||
}
|
||||
|
||||
|
@ -40,8 +40,8 @@ public class CurseOfFragilityEnchant extends ExcellentEnchant implements Generic
|
|||
ItemStack first = inventory.getItem(0);
|
||||
ItemStack second = inventory.getItem(1);
|
||||
|
||||
boolean cursedFirst = (first != null && EnchantUtils.getLevel(first, this) >= 1);
|
||||
boolean cursedSecond = (second != null && EnchantUtils.getLevel(second, this) >= 1);
|
||||
boolean cursedFirst = (first != null && EnchantUtils.getLevel(first, this.getBackend()) >= 1);
|
||||
boolean cursedSecond = (second != null && EnchantUtils.getLevel(second, this.getBackend()) >= 1);
|
||||
|
||||
if (cursedFirst || cursedSecond) {
|
||||
e.setResult(null);
|
||||
|
@ -69,8 +69,8 @@ public class CurseOfFragilityEnchant extends ExcellentEnchant implements Generic
|
|||
ItemStack first = inventory.getItem(0);
|
||||
ItemStack second = inventory.getItem(1);
|
||||
|
||||
boolean cursedFirst = (first != null && EnchantUtils.getLevel(first, this) >= 1);
|
||||
boolean cursedSecond = (second != null && EnchantUtils.getLevel(second, this) >= 1);
|
||||
boolean cursedFirst = (first != null && EnchantUtils.getLevel(first, this.getBackend()) >= 1);
|
||||
boolean cursedSecond = (second != null && EnchantUtils.getLevel(second, this.getBackend()) >= 1);
|
||||
|
||||
if (cursedFirst || cursedSecond) {
|
||||
inventory.setItem(2, null);
|
||||
|
|
|
@ -57,7 +57,7 @@ public class RestoreEnchant extends ExcellentEnchant implements GenericEnchant,
|
|||
|
||||
@NotNull
|
||||
@Override
|
||||
public EnchantmentTarget getItemTarget() {
|
||||
public EnchantmentTarget getCategory() {
|
||||
return EnchantmentTarget.BREAKABLE;
|
||||
}
|
||||
|
||||
|
@ -74,7 +74,7 @@ public class RestoreEnchant extends ExcellentEnchant implements GenericEnchant,
|
|||
int maxDurability = item.getType().getMaxDurability();
|
||||
if (damageable.getDamage() + damage < maxDurability) return;
|
||||
|
||||
int level = EnchantUtils.getLevel(item, this);
|
||||
int level = EnchantUtils.getLevel(item, this.getBackend());
|
||||
if (level <= 0) return;
|
||||
|
||||
if (this.isOutOfCharges(item)) return;
|
||||
|
@ -88,7 +88,7 @@ public class RestoreEnchant extends ExcellentEnchant implements GenericEnchant,
|
|||
|
||||
damageable.setDamage(restored);
|
||||
item.setItemMeta(damageable);
|
||||
EnchantUtils.remove(item, this);
|
||||
EnchantUtils.remove(item, this.getBackend());
|
||||
|
||||
if (this.hasVisualEffects()) {
|
||||
UniSound.of(Sound.ITEM_TOTEM_USE).play(event.getPlayer());
|
||||
|
|
|
@ -32,8 +32,8 @@ public class SoulboundEnchant extends ExcellentEnchant implements GenericEnchant
|
|||
|
||||
@NotNull
|
||||
@Override
|
||||
public EnchantmentTarget getItemTarget() {
|
||||
return EnchantmentTarget.WEARABLE;
|
||||
public EnchantmentTarget getCategory() {
|
||||
return EnchantmentTarget.BREAKABLE;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
@ -47,7 +47,7 @@ public class SoulboundEnchant extends ExcellentEnchant implements GenericEnchant
|
|||
World world = player.getWorld();
|
||||
|
||||
deathEvent.getDrops().removeIf(drop -> {
|
||||
if (EnchantUtils.getLevel(drop, this) > 0) {
|
||||
if (EnchantUtils.getLevel(drop, this.getBackend()) > 0) {
|
||||
if (this.isOutOfCharges(drop)) return false;
|
||||
|
||||
saveList.add(drop);
|
||||
|
@ -64,7 +64,7 @@ public class SoulboundEnchant extends ExcellentEnchant implements GenericEnchant
|
|||
world.dropItemNaturally(location, save);
|
||||
}
|
||||
else {
|
||||
this.consumeChargesNoUpdate(save, EnchantUtils.getLevel(save, this));
|
||||
this.consumeChargesNoUpdate(save, EnchantUtils.getLevel(save, this.getBackend()));
|
||||
player.getInventory().addItem(save);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -4,6 +4,7 @@ import org.bukkit.enchantments.EnchantmentTarget;
|
|||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
import org.bukkit.event.entity.EntityResurrectEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import su.nightexpress.excellentenchants.ExcellentEnchants;
|
||||
|
@ -35,7 +36,7 @@ public class CurseOfDeathEnchant extends ExcellentEnchant implements DeathEnchan
|
|||
|
||||
@NotNull
|
||||
@Override
|
||||
public EnchantmentTarget getItemTarget() {
|
||||
public EnchantmentTarget getCategory() {
|
||||
return EnchantmentTarget.WEAPON;
|
||||
}
|
||||
|
||||
|
@ -46,7 +47,7 @@ public class CurseOfDeathEnchant extends ExcellentEnchant implements DeathEnchan
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean isCursed() {
|
||||
public boolean isCurse() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -55,6 +56,11 @@ public class CurseOfDeathEnchant extends ExcellentEnchant implements DeathEnchan
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onResurrect(@NotNull EntityResurrectEvent event, @NotNull LivingEntity entity, @NotNull ItemStack item, int level) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKill(@NotNull EntityDeathEvent event, @NotNull LivingEntity entity, @NotNull Player killer, ItemStack weapon, int level) {
|
||||
if (!(entity instanceof Player dead)) return false;
|
||||
|
|
|
@ -59,7 +59,7 @@ public class EnchantBaneOfNetherspawn extends ExcellentEnchant implements Combat
|
|||
|
||||
@Override
|
||||
@NotNull
|
||||
public EnchantmentTarget getItemTarget() {
|
||||
public EnchantmentTarget getCategory() {
|
||||
return EnchantmentTarget.WEAPON;
|
||||
}
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ public class EnchantBlindness extends ExcellentEnchant implements Chanced, Potio
|
|||
|
||||
@NotNull
|
||||
@Override
|
||||
public EnchantmentTarget getItemTarget() {
|
||||
public EnchantmentTarget getCategory() {
|
||||
return EnchantmentTarget.WEAPON;
|
||||
}
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ public class EnchantConfusion extends ExcellentEnchant implements Chanced, Potio
|
|||
|
||||
@NotNull
|
||||
@Override
|
||||
public EnchantmentTarget getItemTarget() {
|
||||
public EnchantmentTarget getCategory() {
|
||||
return EnchantmentTarget.WEAPON;
|
||||
}
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ public class EnchantCure extends ExcellentEnchant implements Chanced, CombatEnch
|
|||
|
||||
@Override
|
||||
@NotNull
|
||||
public EnchantmentTarget getItemTarget() {
|
||||
public EnchantmentTarget getCategory() {
|
||||
return EnchantmentTarget.WEAPON;
|
||||
}
|
||||
|
||||
|
|
|
@ -72,7 +72,7 @@ public class EnchantCutter extends ExcellentEnchant implements Chanced, CombatEn
|
|||
|
||||
@Override
|
||||
@NotNull
|
||||
public EnchantmentTarget getItemTarget() {
|
||||
public EnchantmentTarget getCategory() {
|
||||
return EnchantmentTarget.WEAPON;
|
||||
}
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ import org.bukkit.event.EventPriority;
|
|||
import org.bukkit.event.block.BlockDropItemEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
import org.bukkit.event.entity.EntityResurrectEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
@ -173,7 +174,7 @@ public class EnchantDecapitator extends ExcellentEnchant implements Chanced, Dea
|
|||
|
||||
@Override
|
||||
@NotNull
|
||||
public EnchantmentTarget getItemTarget() {
|
||||
public EnchantmentTarget getCategory() {
|
||||
return EnchantmentTarget.WEAPON;
|
||||
}
|
||||
|
||||
|
@ -182,6 +183,11 @@ public class EnchantDecapitator extends ExcellentEnchant implements Chanced, Dea
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onResurrect(@NotNull EntityResurrectEvent event, @NotNull LivingEntity entity, @NotNull ItemStack item, int level) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKill(@NotNull EntityDeathEvent event, @NotNull LivingEntity entity, @NotNull Player killer, ItemStack weapon, int level) {
|
||||
EntityType entityType = entity.getType();
|
||||
|
|
|
@ -45,7 +45,7 @@ public class EnchantDoubleStrike extends ExcellentEnchant implements Chanced, Co
|
|||
|
||||
@Override
|
||||
@NotNull
|
||||
public EnchantmentTarget getItemTarget() {
|
||||
public EnchantmentTarget getCategory() {
|
||||
return EnchantmentTarget.WEAPON;
|
||||
}
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ public class EnchantExhaust extends ExcellentEnchant implements Chanced, Potione
|
|||
|
||||
@NotNull
|
||||
@Override
|
||||
public EnchantmentTarget getItemTarget() {
|
||||
public EnchantmentTarget getCategory() {
|
||||
return EnchantmentTarget.WEAPON;
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ import org.bukkit.enchantments.EnchantmentTarget;
|
|||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
import org.bukkit.event.entity.EntityResurrectEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import su.nexmedia.engine.utils.NumberUtil;
|
||||
|
@ -43,7 +44,7 @@ public class EnchantExpHunter extends ExcellentEnchant implements DeathEnchant {
|
|||
|
||||
@Override
|
||||
@NotNull
|
||||
public EnchantmentTarget getItemTarget() {
|
||||
public EnchantmentTarget getCategory() {
|
||||
return EnchantmentTarget.WEAPON;
|
||||
}
|
||||
|
||||
|
@ -60,4 +61,9 @@ public class EnchantExpHunter extends ExcellentEnchant implements DeathEnchant {
|
|||
public boolean onDeath(@NotNull EntityDeathEvent event, @NotNull LivingEntity entity, ItemStack item, int level) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onResurrect(@NotNull EntityResurrectEvent event, @NotNull LivingEntity entity, @NotNull ItemStack item, int level) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ public class EnchantIceAspect extends ExcellentEnchant implements Chanced, Potio
|
|||
|
||||
@NotNull
|
||||
@Override
|
||||
public EnchantmentTarget getItemTarget() {
|
||||
public EnchantmentTarget getCategory() {
|
||||
return EnchantmentTarget.WEAPON;
|
||||
}
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ public class EnchantInfernus extends ExcellentEnchant implements GenericEnchant,
|
|||
|
||||
@Override
|
||||
@NotNull
|
||||
public EnchantmentTarget getItemTarget() {
|
||||
public EnchantmentTarget getCategory() {
|
||||
return EnchantmentTarget.TRIDENT;
|
||||
}
|
||||
|
||||
|
@ -62,7 +62,7 @@ public class EnchantInfernus extends ExcellentEnchant implements GenericEnchant,
|
|||
|
||||
ItemStack item = trident.getItem();
|
||||
|
||||
int level = EnchantUtils.getLevel(item, this);
|
||||
int level = EnchantUtils.getLevel(item, this.getBackend());
|
||||
if (level <= 0) return;
|
||||
|
||||
trident.setFireTicks(Integer.MAX_VALUE);
|
||||
|
@ -75,7 +75,7 @@ public class EnchantInfernus extends ExcellentEnchant implements GenericEnchant,
|
|||
|
||||
ItemStack item = trident.getItem();
|
||||
|
||||
int level = EnchantUtils.getLevel(item, this);
|
||||
int level = EnchantUtils.getLevel(item, this.getBackend());
|
||||
if (level <= 0 || trident.getFireTicks() <= 0) return;
|
||||
|
||||
int ticks = this.getFireTicks(level);
|
||||
|
|
|
@ -5,6 +5,7 @@ import org.bukkit.entity.LivingEntity;
|
|||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
import org.bukkit.event.entity.EntityResurrectEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import su.nexmedia.engine.utils.PlayerUtil;
|
||||
|
@ -41,7 +42,7 @@ public class EnchantNimble extends ExcellentEnchant implements Chanced, DeathEnc
|
|||
|
||||
@NotNull
|
||||
@Override
|
||||
public EnchantmentTarget getItemTarget() {
|
||||
public EnchantmentTarget getCategory() {
|
||||
return EnchantmentTarget.WEAPON;
|
||||
}
|
||||
|
||||
|
@ -64,4 +65,9 @@ public class EnchantNimble extends ExcellentEnchant implements Chanced, DeathEnc
|
|||
public boolean onDeath(@NotNull EntityDeathEvent event, @NotNull LivingEntity entity, ItemStack item, int level) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onResurrect(@NotNull EntityResurrectEvent event, @NotNull LivingEntity entity, @NotNull ItemStack item, int level) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ public class EnchantParalyze extends ExcellentEnchant implements Chanced, Potion
|
|||
|
||||
@NotNull
|
||||
@Override
|
||||
public EnchantmentTarget getItemTarget() {
|
||||
public EnchantmentTarget getCategory() {
|
||||
return EnchantmentTarget.WEAPON;
|
||||
}
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ public class EnchantRage extends ExcellentEnchant implements Chanced, Potioned,
|
|||
|
||||
@NotNull
|
||||
@Override
|
||||
public EnchantmentTarget getItemTarget() {
|
||||
public EnchantmentTarget getCategory() {
|
||||
return EnchantmentTarget.WEAPON;
|
||||
}
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ public class EnchantRocket extends ExcellentEnchant implements Chanced, CombatEn
|
|||
|
||||
@Override
|
||||
@NotNull
|
||||
public EnchantmentTarget getItemTarget() {
|
||||
public EnchantmentTarget getCategory() {
|
||||
return EnchantmentTarget.WEAPON;
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ import org.bukkit.entity.EntityType;
|
|||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
import org.bukkit.event.entity.EntityResurrectEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import su.nexmedia.engine.utils.Pair;
|
||||
|
@ -93,7 +94,7 @@ public class EnchantScavenger extends ExcellentEnchant implements Chanced, Death
|
|||
|
||||
@Override
|
||||
@NotNull
|
||||
public EnchantmentTarget getItemTarget() {
|
||||
public EnchantmentTarget getCategory() {
|
||||
return EnchantmentTarget.WEAPON;
|
||||
}
|
||||
|
||||
|
@ -122,4 +123,9 @@ public class EnchantScavenger extends ExcellentEnchant implements Chanced, Death
|
|||
public boolean onDeath(@NotNull EntityDeathEvent event, @NotNull LivingEntity entity, ItemStack item, int level) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onResurrect(@NotNull EntityResurrectEvent event, @NotNull LivingEntity entity, @NotNull ItemStack item, int level) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ public class EnchantSurprise extends ExcellentEnchant implements Chanced, Potion
|
|||
|
||||
@NotNull
|
||||
@Override
|
||||
public EnchantmentTarget getItemTarget() {
|
||||
public EnchantmentTarget getCategory() {
|
||||
return EnchantmentTarget.WEAPON;
|
||||
}
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ public class EnchantTemper extends ExcellentEnchant implements CombatEnchant {
|
|||
|
||||
@NotNull
|
||||
@Override
|
||||
public EnchantmentTarget getItemTarget() {
|
||||
public EnchantmentTarget getCategory() {
|
||||
return EnchantmentTarget.WEAPON;
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ import org.bukkit.event.EventHandler;
|
|||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
import org.bukkit.event.entity.EntityResurrectEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import su.nexmedia.engine.api.config.JOption;
|
||||
|
@ -85,7 +86,7 @@ public class EnchantThrifty extends ExcellentEnchant implements Chanced, DeathEn
|
|||
|
||||
@Override
|
||||
@NotNull
|
||||
public EnchantmentTarget getItemTarget() {
|
||||
public EnchantmentTarget getCategory() {
|
||||
return EnchantmentTarget.WEAPON;
|
||||
}
|
||||
|
||||
|
@ -108,6 +109,11 @@ public class EnchantThrifty extends ExcellentEnchant implements Chanced, DeathEn
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onResurrect(@NotNull EntityResurrectEvent event, @NotNull LivingEntity entity, @NotNull ItemStack item, int level) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onCreatureSpawn(CreatureSpawnEvent event) {
|
||||
if (!this.ignoredSpawnReasons.contains(event.getSpawnReason())) return;
|
||||
|
|
|
@ -54,7 +54,7 @@ public class EnchantThunder extends ExcellentEnchant implements Chanced, CombatE
|
|||
|
||||
@Override
|
||||
@NotNull
|
||||
public EnchantmentTarget getItemTarget() {
|
||||
public EnchantmentTarget getCategory() {
|
||||
return EnchantmentTarget.WEAPON;
|
||||
}
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ public class EnchantVampire extends ExcellentEnchant implements Chanced, CombatE
|
|||
|
||||
@Override
|
||||
@NotNull
|
||||
public EnchantmentTarget getItemTarget() {
|
||||
public EnchantmentTarget getCategory() {
|
||||
return EnchantmentTarget.WEAPON;
|
||||
}
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ public class EnchantVenom extends ExcellentEnchant implements Chanced, Potioned,
|
|||
|
||||
@NotNull
|
||||
@Override
|
||||
public EnchantmentTarget getItemTarget() {
|
||||
public EnchantmentTarget getCategory() {
|
||||
return EnchantmentTarget.WEAPON;
|
||||
}
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ public class EnchantVillageDefender extends ExcellentEnchant implements CombatEn
|
|||
|
||||
@Override
|
||||
@NotNull
|
||||
public EnchantmentTarget getItemTarget() {
|
||||
public EnchantmentTarget getCategory() {
|
||||
return EnchantmentTarget.WEAPON;
|
||||
}
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ public class EnchantWither extends ExcellentEnchant implements Chanced, Potioned
|
|||
|
||||
@NotNull
|
||||
@Override
|
||||
public EnchantmentTarget getItemTarget() {
|
||||
public EnchantmentTarget getCategory() {
|
||||
return EnchantmentTarget.WEAPON;
|
||||
}
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ public class SwiperEnchant extends ExcellentEnchant implements CombatEnchant, Ch
|
|||
|
||||
@NotNull
|
||||
@Override
|
||||
public EnchantmentTarget getItemTarget() {
|
||||
public EnchantmentTarget getCategory() {
|
||||
return EnchantmentTarget.WEAPON;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,31 @@
|
|||
/*
|
||||
* Decompiled with CFR 0.151.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* org.bukkit.Material
|
||||
* org.bukkit.NamespacedKey
|
||||
* org.bukkit.Sound
|
||||
* org.bukkit.entity.Player
|
||||
* org.bukkit.event.EventHandler
|
||||
* org.bukkit.event.EventPriority
|
||||
* org.bukkit.event.inventory.InventoryClickEvent
|
||||
* org.bukkit.event.inventory.PrepareAnvilEvent
|
||||
* org.bukkit.inventory.AnvilInventory
|
||||
* org.bukkit.inventory.Inventory
|
||||
* org.bukkit.inventory.ItemStack
|
||||
* org.bukkit.plugin.Plugin
|
||||
* org.jetbrains.annotations.NotNull
|
||||
* su.nexmedia.engine.NexPlugin
|
||||
* su.nexmedia.engine.api.manager.AbstractListener
|
||||
* su.nexmedia.engine.utils.PDCUtil
|
||||
* su.nexmedia.engine.utils.values.UniSound
|
||||
*/
|
||||
package su.nightexpress.excellentenchants.enchantment.listener;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.stream.Collectors;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.Sound;
|
||||
|
@ -9,8 +35,11 @@ import org.bukkit.event.EventPriority;
|
|||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.PrepareAnvilEvent;
|
||||
import org.bukkit.inventory.AnvilInventory;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import su.nexmedia.engine.NexPlugin;
|
||||
import su.nexmedia.engine.api.manager.AbstractListener;
|
||||
import su.nexmedia.engine.utils.PDCUtil;
|
||||
import su.nexmedia.engine.utils.values.UniSound;
|
||||
|
@ -19,11 +48,6 @@ import su.nightexpress.excellentenchants.ExcellentEnchantsAPI;
|
|||
import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant;
|
||||
import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class EnchantAnvilListener extends AbstractListener<ExcellentEnchants> {
|
||||
|
||||
private static final NamespacedKey RECHARGED = new NamespacedKey(ExcellentEnchantsAPI.PLUGIN, "item.recharged");
|
||||
|
@ -32,62 +56,65 @@ public class EnchantAnvilListener extends AbstractListener<ExcellentEnchants> {
|
|||
super(plugin);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
@EventHandler(priority=EventPriority.HIGH)
|
||||
public void onAnvilRename(PrepareAnvilEvent event) {
|
||||
AnvilInventory inventory = event.getInventory();
|
||||
|
||||
ItemStack first = inventory.getItem(0);
|
||||
ItemStack second = inventory.getItem(1);
|
||||
ItemStack result = event.getResult();
|
||||
|
||||
if (first == null) first = new ItemStack(Material.AIR);
|
||||
if (second == null) second = new ItemStack(Material.AIR);
|
||||
if (result == null) result = new ItemStack(Material.AIR);
|
||||
|
||||
// Check if source item is an enchantable single item.
|
||||
if (first.getType().isAir() || first.getAmount() > 1 || !EnchantUtils.isEnchantable(first)) return;
|
||||
|
||||
if (this.handleRename(event, first, second, result)) return;
|
||||
if (this.handleRecharge(event, first, second, result)) return;
|
||||
|
||||
if (first == null) {
|
||||
first = new ItemStack(Material.AIR);
|
||||
}
|
||||
if (second == null) {
|
||||
second = new ItemStack(Material.AIR);
|
||||
}
|
||||
if (result == null) {
|
||||
result = new ItemStack(Material.AIR);
|
||||
}
|
||||
if (first.getType().isAir() || first.getAmount() > 1 || !EnchantUtils.isEnchantable(first)) {
|
||||
return;
|
||||
}
|
||||
if (this.handleRename(event, first, second, result)) {
|
||||
return;
|
||||
}
|
||||
if (this.handleRecharge(event, first, second, result)) {
|
||||
return;
|
||||
}
|
||||
this.handleEnchantMerging(event, first, second, result);
|
||||
}
|
||||
|
||||
private boolean handleRename(@NotNull PrepareAnvilEvent event,
|
||||
@NotNull ItemStack first, @NotNull ItemStack second, @NotNull ItemStack result) {
|
||||
|
||||
if (!second.getType().isAir() && (second.getType() == first.getType() || second.getType() == Material.ENCHANTED_BOOK)) return false;
|
||||
if (result.getType() != first.getType()) return false;
|
||||
|
||||
private boolean handleRename(@NotNull PrepareAnvilEvent event, @NotNull ItemStack first, @NotNull ItemStack second, @NotNull ItemStack result) {
|
||||
if (!(second.getType().isAir() || second.getType() != first.getType() && second.getType() != Material.ENCHANTED_BOOK)) {
|
||||
return false;
|
||||
}
|
||||
if (result.getType() != first.getType()) {
|
||||
return false;
|
||||
}
|
||||
ItemStack result2 = new ItemStack(result);
|
||||
EnchantUtils.getExcellents(first).forEach((hasEnch, hasLevel) -> {
|
||||
EnchantUtils.add(result2, hasEnch, hasLevel, true);
|
||||
});
|
||||
EnchantUtils.getExcellents(first).forEach((hasEnch, hasLevel) -> EnchantUtils.add(result2, hasEnch.getBackend(), hasLevel, true));
|
||||
EnchantUtils.updateDisplay(result2);
|
||||
event.setResult(result2);
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean handleRecharge(@NotNull PrepareAnvilEvent event,
|
||||
@NotNull ItemStack first, @NotNull ItemStack second, @NotNull ItemStack result) {
|
||||
if (second.getType().isAir()) return false;
|
||||
|
||||
Map<ExcellentEnchant, Integer> chargable = new HashMap<>();
|
||||
private boolean handleRecharge(@NotNull PrepareAnvilEvent event, @NotNull ItemStack first, @NotNull ItemStack second, @NotNull ItemStack result) {
|
||||
int count;
|
||||
if (second.getType().isAir()) {
|
||||
return false;
|
||||
}
|
||||
HashMap<ExcellentEnchant, Integer> chargable = new HashMap<ExcellentEnchant, Integer>();
|
||||
EnchantUtils.getExcellents(first).forEach((enchant, level) -> {
|
||||
if (enchant.isChargesEnabled() && enchant.isChargesFuel(second) && !enchant.isFullOfCharges(first)) {
|
||||
chargable.put(enchant, level);
|
||||
}
|
||||
});
|
||||
if (chargable.isEmpty()) return false;
|
||||
|
||||
ItemStack result2 = new ItemStack(first);
|
||||
|
||||
int count = 0;
|
||||
while (count < second.getAmount() && !chargable.keySet().stream().allMatch(en -> en.isFullOfCharges(result2))) {
|
||||
chargable.forEach((enchant, level) -> EnchantUtils.rechargeCharges(result2, enchant, level));
|
||||
count++;
|
||||
if (chargable.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
ItemStack result2 = new ItemStack(first);
|
||||
for (count = 0; count < second.getAmount() && !chargable.keySet().stream().allMatch(en -> en.isFullOfCharges(result2)); ++count) {
|
||||
chargable.forEach((enchant, level) -> EnchantUtils.rechargeCharges(result2, enchant, level));
|
||||
}
|
||||
|
||||
PDCUtil.set(result2, RECHARGED, count);
|
||||
EnchantUtils.updateDisplay(result2);
|
||||
event.setResult(result2);
|
||||
|
@ -95,70 +122,70 @@ public class EnchantAnvilListener extends AbstractListener<ExcellentEnchants> {
|
|||
return true;
|
||||
}
|
||||
|
||||
private boolean handleEnchantMerging(@NotNull PrepareAnvilEvent event,
|
||||
@NotNull ItemStack first, @NotNull ItemStack second, @NotNull ItemStack result) {
|
||||
// Validate items in the first two slots.
|
||||
if (second.getType().isAir() || second.getAmount() > 1 || !EnchantUtils.isEnchantable(second)) return false;
|
||||
if (first.getType() == Material.ENCHANTED_BOOK && second.getType() != first.getType()) return false;
|
||||
|
||||
private boolean handleEnchantMerging(@NotNull PrepareAnvilEvent event, @NotNull ItemStack first, @NotNull ItemStack second, @NotNull ItemStack result) {
|
||||
if (second.getType().isAir() || second.getAmount() > 1 || !EnchantUtils.isEnchantable(second)) {
|
||||
return false;
|
||||
}
|
||||
if (first.getType() == Material.ENCHANTED_BOOK && second.getType() != first.getType()) {
|
||||
return false;
|
||||
}
|
||||
ItemStack result2 = new ItemStack(result.getType().isAir() ? first : result);
|
||||
Map<ExcellentEnchant, Integer> enchantments = EnchantUtils.getExcellents(first);
|
||||
Map<ExcellentEnchant, Integer> charges = new HashMap<>(enchantments.keySet().stream().collect(Collectors.toMap(k -> k, v -> v.getCharges(first))));
|
||||
HashMap<ExcellentEnchant, Integer> charges = new HashMap<ExcellentEnchant, Integer>(enchantments.keySet().stream().collect(Collectors.toMap(k -> k, v -> v.getCharges(first))));
|
||||
AtomicInteger repairCost = new AtomicInteger(event.getInventory().getRepairCost());
|
||||
|
||||
// Merge only if it's Item + Item, Item + Enchanted book or Enchanted Book + Enchanted Book
|
||||
if (second.getType() == Material.ENCHANTED_BOOK || second.getType() == first.getType()) {
|
||||
EnchantUtils.getExcellents(second).forEach((enchant, level) -> {
|
||||
enchantments.merge(enchant, level, (oldLvl, newLvl) -> (oldLvl.equals(newLvl)) ? (Math.min(enchant.getMaxMergeLevel(), oldLvl + 1)) : (Math.max(oldLvl, newLvl)));
|
||||
enchantments.merge(enchant, level, (oldLvl, newLvl) -> oldLvl.equals(newLvl) ? Math.min(enchant.getMaxMergeLevel(), oldLvl + 1) : Math.max(oldLvl, newLvl));
|
||||
charges.merge(enchant, enchant.getCharges(second), Integer::sum);
|
||||
});
|
||||
}
|
||||
|
||||
// Recalculate operation cost depends on enchantments merge cost.
|
||||
enchantments.forEach((enchant, level) -> {
|
||||
if (EnchantUtils.add(result2, enchant, level, false)) {
|
||||
if (EnchantUtils.add(result2, enchant.getBackend(), level, false)) {
|
||||
repairCost.addAndGet(enchant.getAnvilMergeCost(level));
|
||||
EnchantUtils.setCharges(result2, enchant, level, charges.getOrDefault(enchant, 0));
|
||||
}
|
||||
});
|
||||
|
||||
if (first.equals(result2)) return false;
|
||||
|
||||
if (first.equals(result2)) {
|
||||
return false;
|
||||
}
|
||||
EnchantUtils.updateDisplay(result2);
|
||||
event.setResult(result2);
|
||||
|
||||
// NMS ContainerAnvil will set level cost to 0 right after calling the event, need 1 tick delay.
|
||||
this.plugin.runTask(task -> event.getInventory().setRepairCost(repairCost.get()));
|
||||
return true;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
@EventHandler(priority=EventPriority.NORMAL)
|
||||
public void onClickAnvil(InventoryClickEvent event) {
|
||||
if (!(event.getInventory() instanceof AnvilInventory inventory)) return;
|
||||
if (event.getRawSlot() != 2) return;
|
||||
|
||||
Inventory inventory = event.getInventory();
|
||||
if (!(inventory instanceof AnvilInventory inventory2)) {
|
||||
return;
|
||||
}
|
||||
if (event.getRawSlot() != 2) {
|
||||
return;
|
||||
}
|
||||
ItemStack item = event.getCurrentItem();
|
||||
if (item == null) return;
|
||||
|
||||
if (item == null) {
|
||||
return;
|
||||
}
|
||||
int count = PDCUtil.getInt(item, RECHARGED).orElse(0);
|
||||
if (count == 0) return;
|
||||
|
||||
Player player = (Player) event.getWhoClicked();
|
||||
if (player.getLevel() < inventory.getRepairCost()) return;
|
||||
|
||||
player.setLevel(player.getLevel() - inventory.getRepairCost());
|
||||
if (count == 0) {
|
||||
return;
|
||||
}
|
||||
Player player = (Player)event.getWhoClicked();
|
||||
if (player.getLevel() < inventory2.getRepairCost()) {
|
||||
return;
|
||||
}
|
||||
player.setLevel(player.getLevel() - inventory2.getRepairCost());
|
||||
PDCUtil.remove(item, RECHARGED);
|
||||
event.getView().setCursor(item);
|
||||
event.setCancelled(false);
|
||||
|
||||
UniSound.of(Sound.BLOCK_ENCHANTMENT_TABLE_USE).play(player);
|
||||
|
||||
ItemStack second = inventory.getItem(1);
|
||||
ItemStack second = inventory2.getItem(1);
|
||||
if (second != null && !second.getType().isAir()) {
|
||||
second.setAmount(second.getAmount() - count);
|
||||
}
|
||||
inventory.setItem(0, null);
|
||||
//inventory.setItem(1, null);
|
||||
inventory.setItem(2, null);
|
||||
inventory2.setItem(0, null);
|
||||
inventory2.setItem(2, null);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ import org.bukkit.inventory.*;
|
|||
import org.bukkit.inventory.meta.EnchantmentStorageMeta;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import su.nexmedia.engine.Version;
|
||||
import su.nexmedia.engine.api.manager.AbstractListener;
|
||||
import su.nexmedia.engine.utils.EngineUtils;
|
||||
import su.nightexpress.excellentenchants.ExcellentEnchants;
|
||||
|
@ -23,7 +24,8 @@ import su.nightexpress.excellentenchants.config.Config;
|
|||
import su.nightexpress.excellentenchants.enchantment.EnchantManager;
|
||||
import su.nightexpress.excellentenchants.enchantment.EnchantPopulator;
|
||||
import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant;
|
||||
import su.nightexpress.excellentenchants.enchantment.type.ObtainType;
|
||||
import su.nightexpress.excellentenchants.api.enchantment.ObtainType;
|
||||
import su.nightexpress.excellentenchants.enchantment.registry.EnchantRegistry;
|
||||
import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils;
|
||||
import su.nightexpress.excellentenchants.hook.HookId;
|
||||
import su.nightexpress.excellentenchants.hook.impl.MythicMobsHook;
|
||||
|
@ -76,17 +78,20 @@ public class EnchantGenericListener extends AbstractListener<ExcellentEnchants>
|
|||
ItemStack result = inventory.getItem(2);
|
||||
if (result == null || result.getType().isAir()) return;
|
||||
|
||||
Map<ExcellentEnchant, Integer> curses = new HashMap<>();
|
||||
for (int slot = 0; slot < 2; slot++) {
|
||||
ItemStack source = inventory.getItem(slot);
|
||||
if (source == null || source.getType().isAir()) continue;
|
||||
// No NMS registration for 1.18.2, server does not know they are curses.
|
||||
if (Version.isBehind(Version.V1_19_R3) && !Config.ENCHANTMENTS_INTERNAL_HANDLER.get()) {
|
||||
Map<ExcellentEnchant, Integer> curses = new HashMap<>();
|
||||
for (int slot = 0; slot < 2; slot++) {
|
||||
ItemStack source = inventory.getItem(slot);
|
||||
if (source == null || source.getType().isAir()) continue;
|
||||
|
||||
curses.putAll(EnchantUtils.getExcellents(source));
|
||||
curses.putAll(EnchantUtils.getExcellents(source));
|
||||
}
|
||||
curses.entrySet().removeIf(entry -> !entry.getKey().isCurse());
|
||||
curses.forEach((excellentEnchant, level) -> {
|
||||
EnchantUtils.add(result, excellentEnchant.getBackend(), level, true);
|
||||
});
|
||||
}
|
||||
curses.entrySet().removeIf(entry -> !entry.getKey().isCursed());
|
||||
curses.forEach((excellentEnchant, level) -> {
|
||||
EnchantUtils.add(result, excellentEnchant, level, true);
|
||||
});
|
||||
EnchantUtils.updateDisplay(result);
|
||||
});
|
||||
}
|
||||
|
@ -110,12 +115,14 @@ public class EnchantGenericListener extends AbstractListener<ExcellentEnchants>
|
|||
ItemStack target = event.getItem();
|
||||
World world = event.getEnchanter().getWorld();
|
||||
|
||||
EnchantPopulator populator = this.plugin.createPopulator(target, ObtainType.ENCHANTING)
|
||||
.withWorld(world)
|
||||
.withLevelGenerator(enchant -> enchant.getLevelByEnchantCost(event.getExpLevelCost()))
|
||||
.withDefaultPopulation(event.getEnchantsToAdd());
|
||||
if (!Config.ENCHANTMENTS_INTERNAL_HANDLER.get()) {
|
||||
EnchantPopulator populator = this.plugin.createPopulator(target, ObtainType.ENCHANTING)
|
||||
.withWorld(world)
|
||||
.withLevelGenerator(enchant -> enchant.getLevelByEnchantCost(event.getExpLevelCost()))
|
||||
.withDefaultPopulation(event.getEnchantsToAdd());
|
||||
|
||||
event.getEnchantsToAdd().putAll(populator.createPopulation());
|
||||
event.getEnchantsToAdd().putAll(populator.createPopulation());
|
||||
}
|
||||
|
||||
plugin.getServer().getScheduler().runTask(plugin, () -> {
|
||||
ItemStack result = event.getInventory().getItem(0);
|
||||
|
@ -124,18 +131,21 @@ public class EnchantGenericListener extends AbstractListener<ExcellentEnchants>
|
|||
// Fix enchantments for Enchant Books.
|
||||
// Enchants are not added on book because they do not exists in NMS.
|
||||
// Server gets enchants from NMS to apply it on Book NBT tags.
|
||||
ItemMeta meta = result.getItemMeta();
|
||||
if (meta instanceof EnchantmentStorageMeta storageMeta) {
|
||||
event.getEnchantsToAdd().forEach((enchantment, level) -> {
|
||||
if (!storageMeta.hasStoredEnchant(enchantment)) {
|
||||
storageMeta.addStoredEnchant(enchantment, level, true);
|
||||
}
|
||||
});
|
||||
result.setItemMeta(storageMeta);
|
||||
if (Version.isBehind(Version.V1_19_R3)) {
|
||||
ItemMeta meta = result.getItemMeta();
|
||||
if (meta instanceof EnchantmentStorageMeta storageMeta) {
|
||||
event.getEnchantsToAdd().forEach((enchantment, level) -> {
|
||||
if (!storageMeta.hasStoredEnchant(enchantment)) {
|
||||
storageMeta.addStoredEnchant(enchantment, level, true);
|
||||
}
|
||||
});
|
||||
result.setItemMeta(storageMeta);
|
||||
}
|
||||
}
|
||||
|
||||
event.getEnchantsToAdd().forEach((enchantment, level) -> {
|
||||
if (enchantment instanceof ExcellentEnchant enchant && enchant.isChargesEnabled()) {
|
||||
ExcellentEnchant enchant = EnchantRegistry.getByKey(enchantment.getKey());
|
||||
if (enchant != null) {
|
||||
EnchantUtils.restoreCharges(result, enchant, level);
|
||||
}
|
||||
});
|
||||
|
@ -150,6 +160,8 @@ public class EnchantGenericListener extends AbstractListener<ExcellentEnchants>
|
|||
// ---------------------------------------------------------------
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onEnchantPopulateVillagerAcquire(VillagerAcquireTradeEvent event) {
|
||||
if (Config.ENCHANTMENTS_INTERNAL_HANDLER.get()) return;
|
||||
|
||||
MerchantRecipe origin = event.getRecipe();
|
||||
ItemStack result = origin.getResult();
|
||||
if (!EnchantUtils.isEnchantable(result)) return;
|
||||
|
@ -174,6 +186,7 @@ public class EnchantGenericListener extends AbstractListener<ExcellentEnchants>
|
|||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onEnchantPopulateLoot(LootGenerateEvent event) {
|
||||
if (Config.ENCHANTMENTS_INTERNAL_HANDLER.get()) return;
|
||||
if (Config.getObtainSettings(ObtainType.LOOT_GENERATION).isEmpty()) return;
|
||||
|
||||
Entity entity = event.getEntity();
|
||||
|
@ -193,6 +206,7 @@ public class EnchantGenericListener extends AbstractListener<ExcellentEnchants>
|
|||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onEnchantPopulateFishing(PlayerFishEvent event) {
|
||||
if (Config.ENCHANTMENTS_INTERNAL_HANDLER.get()) return;
|
||||
if (Config.getObtainSettings(ObtainType.FISHING).isEmpty()) return;
|
||||
if (event.getState() != PlayerFishEvent.State.CAUGHT_FISH) return;
|
||||
if (!(event.getCaught() instanceof Item item)) return;
|
||||
|
@ -206,6 +220,8 @@ public class EnchantGenericListener extends AbstractListener<ExcellentEnchants>
|
|||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onEnchantPopulateSpawn(CreatureSpawnEvent event) {
|
||||
if (Config.ENCHANTMENTS_INTERNAL_HANDLER.get()) return;
|
||||
|
||||
//if (Config.getObtainSettings(ObtainType.MOB_SPAWNING).isEmpty()) return;
|
||||
LivingEntity entity = event.getEntity();
|
||||
if (entity.getType() == EntityType.ARMOR_STAND) return;
|
||||
|
|
|
@ -1,3 +1,32 @@
|
|||
/*
|
||||
* Decompiled with CFR 0.151.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* org.bukkit.Material
|
||||
* org.bukkit.NamespacedKey
|
||||
* org.bukkit.entity.Player
|
||||
* org.bukkit.event.inventory.InventoryType
|
||||
* org.bukkit.inventory.ItemStack
|
||||
* org.bukkit.plugin.Plugin
|
||||
* org.jetbrains.annotations.NotNull
|
||||
* su.nexmedia.engine.NexPlugin
|
||||
* su.nexmedia.engine.api.config.JOption
|
||||
* su.nexmedia.engine.api.config.JYML
|
||||
* su.nexmedia.engine.api.menu.AutoPaged
|
||||
* su.nexmedia.engine.api.menu.MenuItemType
|
||||
* su.nexmedia.engine.api.menu.click.ClickHandler
|
||||
* su.nexmedia.engine.api.menu.click.ItemClick
|
||||
* su.nexmedia.engine.api.menu.impl.ConfigMenu
|
||||
* su.nexmedia.engine.api.menu.impl.Menu
|
||||
* su.nexmedia.engine.api.menu.impl.MenuOptions
|
||||
* su.nexmedia.engine.api.menu.impl.MenuViewer
|
||||
* su.nexmedia.engine.api.menu.item.MenuItem
|
||||
* su.nexmedia.engine.api.placeholder.PlaceholderMap
|
||||
* su.nexmedia.engine.utils.Colorizer
|
||||
* su.nexmedia.engine.utils.ItemReplacer
|
||||
* su.nexmedia.engine.utils.ItemUtil
|
||||
* su.nexmedia.engine.utils.PDCUtil
|
||||
*/
|
||||
package su.nightexpress.excellentenchants.enchantment.menu;
|
||||
|
||||
import org.bukkit.Material;
|
||||
|
@ -8,6 +37,7 @@ import org.bukkit.inventory.ItemStack;
|
|||
import org.jetbrains.annotations.NotNull;
|
||||
import su.nexmedia.engine.api.config.JOption;
|
||||
import su.nexmedia.engine.api.config.JYML;
|
||||
import su.nexmedia.engine.api.editor.EditorLocales;
|
||||
import su.nexmedia.engine.api.menu.AutoPaged;
|
||||
import su.nexmedia.engine.api.menu.MenuItemType;
|
||||
import su.nexmedia.engine.api.menu.click.ClickHandler;
|
||||
|
@ -16,15 +46,15 @@ import su.nexmedia.engine.api.menu.impl.ConfigMenu;
|
|||
import su.nexmedia.engine.api.menu.impl.MenuOptions;
|
||||
import su.nexmedia.engine.api.menu.impl.MenuViewer;
|
||||
import su.nexmedia.engine.api.menu.item.MenuItem;
|
||||
import su.nexmedia.engine.api.placeholder.PlaceholderMap;
|
||||
import su.nexmedia.engine.utils.Colorizer;
|
||||
import su.nexmedia.engine.utils.ItemReplacer;
|
||||
import su.nexmedia.engine.utils.ItemUtil;
|
||||
import su.nexmedia.engine.utils.PDCUtil;
|
||||
import su.nightexpress.excellentenchants.ExcellentEnchants;
|
||||
import su.nightexpress.excellentenchants.config.Config;
|
||||
import su.nightexpress.excellentenchants.api.enchantment.ObtainType;
|
||||
import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant;
|
||||
import su.nightexpress.excellentenchants.enchantment.registry.EnchantRegistry;
|
||||
import su.nightexpress.excellentenchants.enchantment.type.ObtainType;
|
||||
import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils;
|
||||
|
||||
import java.util.*;
|
||||
|
@ -37,160 +67,124 @@ import static su.nightexpress.excellentenchants.Placeholders.*;
|
|||
public class EnchantmentsListMenu extends ConfigMenu<ExcellentEnchants> implements AutoPaged<ExcellentEnchant> {
|
||||
|
||||
private static final String FILE = "enchants.yml";
|
||||
|
||||
private static final String PLACEHOLDER_CONFLICTS = "%conflicts%";
|
||||
private static final String PLACEHOLDER_CHARGES = "%charges%";
|
||||
private static final String PLACEHOLDER_CHARGES = "%charges%";
|
||||
private static final String PLACEHOLDER_OBTAINING = "%obtaining%";
|
||||
|
||||
private final NamespacedKey keyLevel;
|
||||
private final NamespacedKey keyLevel;
|
||||
private final Map<String, Map<Integer, ItemStack>> iconCache;
|
||||
|
||||
private String enchantName;
|
||||
private ItemStack enchantIcon;
|
||||
private String enchantName;
|
||||
private List<String> enchantLoreMain;
|
||||
private List<String> enchantLoreConflicts;
|
||||
private List<String> enchantLoreCharges;
|
||||
private List<String> enchantLoreObtaining;
|
||||
private int[] enchantSlots;
|
||||
private int[] enchantSlots;
|
||||
|
||||
public EnchantmentsListMenu(@NotNull ExcellentEnchants plugin) {
|
||||
super(plugin, new JYML(plugin.getDataFolder() + Config.DIR_MENU, FILE));
|
||||
super(plugin, new JYML(plugin.getDataFolder() + "/menu/", FILE));
|
||||
this.keyLevel = new NamespacedKey(plugin, "list_display_level");
|
||||
this.iconCache = new HashMap<>();
|
||||
|
||||
this.registerHandler(MenuItemType.class)
|
||||
.addClick(MenuItemType.CLOSE, ClickHandler.forClose(this))
|
||||
.addClick(MenuItemType.PAGE_NEXT, ClickHandler.forNextPage(this))
|
||||
.addClick(MenuItemType.PAGE_PREVIOUS, ClickHandler.forPreviousPage(this));
|
||||
|
||||
this.registerHandler(MenuItemType.class).addClick(MenuItemType.CLOSE, ClickHandler.forClose(this)).addClick(MenuItemType.PAGE_NEXT, ClickHandler.forNextPage(this)).addClick(MenuItemType.PAGE_PREVIOUS, ClickHandler.forPreviousPage(this));
|
||||
this.load();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
super.clear();
|
||||
this.iconCache.clear();
|
||||
}
|
||||
|
||||
// ----------
|
||||
|
||||
@Override
|
||||
public boolean isCodeCreation() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadAdditional() {
|
||||
this.enchantName = JOption.create("Enchantment.Name", ENCHANTMENT_NAME_FORMATTED).read(cfg);
|
||||
|
||||
this.enchantIcon = JOption.create("Enchantment.Icon", new ItemStack(Material.ENCHANTED_BOOK)).read(this.cfg);
|
||||
this.enchantName = JOption.create("Enchantment.Name", ENCHANTMENT_NAME_FORMATTED).read(this.cfg);
|
||||
this.enchantLoreMain = JOption.create("Enchantment.Lore.Main",
|
||||
Arrays.asList(
|
||||
ENCHANTMENT_DESCRIPTION,
|
||||
DARK_GRAY + "(click to switch level)",
|
||||
"",
|
||||
DARK_GRAY + "(click to switch level)", "",
|
||||
LIGHT_YELLOW + BOLD + "Info:",
|
||||
LIGHT_YELLOW + "▪ " + LIGHT_GRAY + "Tier: " + LIGHT_YELLOW + ENCHANTMENT_TIER,
|
||||
LIGHT_YELLOW + "▪ " + LIGHT_GRAY + "Applies to: " + LIGHT_YELLOW + ENCHANTMENT_FIT_ITEM_TYPES,
|
||||
LIGHT_YELLOW + "▪ " + LIGHT_GRAY + "Levels: " + LIGHT_YELLOW + ENCHANTMENT_LEVEL_MIN + GRAY + " - " + LIGHT_YELLOW + ENCHANTMENT_LEVEL_MAX,
|
||||
PLACEHOLDER_CHARGES,
|
||||
PLACEHOLDER_CONFLICTS,
|
||||
PLACEHOLDER_OBTAINING
|
||||
)).read(cfg);
|
||||
LIGHT_YELLOW + "▪ " + LIGHT_GRAY + "Levels: " + LIGHT_YELLOW + ENCHANTMENT_LEVEL_MIN + LIGHT_GRAY + " - " + LIGHT_YELLOW + ENCHANTMENT_LEVEL_MAX,
|
||||
PLACEHOLDER_CHARGES, PLACEHOLDER_CONFLICTS, PLACEHOLDER_OBTAINING
|
||||
)).read(this.cfg);
|
||||
|
||||
this.enchantLoreConflicts = JOption.create("Enchantment.Lore.Conflicts",
|
||||
Arrays.asList(
|
||||
"",
|
||||
LIGHT_RED + BOLD + "Conflicts:",
|
||||
"", LIGHT_RED + BOLD + "Conflicts:",
|
||||
LIGHT_RED + "✘ " + LIGHT_GRAY + GENERIC_NAME
|
||||
)).read(cfg);
|
||||
)).read(this.cfg);
|
||||
|
||||
this.enchantLoreCharges = JOption.create("Enchantment.Lore.Charges",
|
||||
Arrays.asList(
|
||||
LIGHT_YELLOW + "▪ " + LIGHT_GRAY + "Charges: " + LIGHT_YELLOW + ENCHANTMENT_CHARGES_MAX_AMOUNT + "⚡" + LIGHT_GRAY + " (" + WHITE + ENCHANTMENT_CHARGES_FUEL_ITEM + LIGHT_GRAY + ")"
|
||||
)).read(cfg);
|
||||
List.of(
|
||||
LIGHT_YELLOW + "▪ " + LIGHT_GRAY + "Charges: " + LIGHT_YELLOW + ENCHANTMENT_CHARGES_MAX_AMOUNT + "⚡" + LIGHT_GRAY + " (" + WHITE + ENCHANTMENT_CHARGES_FUEL_ITEM + LIGHT_GRAY + ")")
|
||||
).read(this.cfg);
|
||||
|
||||
this.enchantLoreObtaining = JOption.create("Enchantment.Lore.Obtaining",
|
||||
Arrays.asList(
|
||||
"",
|
||||
LIGHT_GREEN + BOLD + "Obtaining:",
|
||||
LIGHT_GREEN + "✔ " + LIGHT_GRAY + GENERIC_TYPE
|
||||
)).read(cfg);
|
||||
Arrays.asList("", LIGHT_GREEN + BOLD + "Obtaining:", LIGHT_GREEN + "✔ " + LIGHT_GRAY + GENERIC_TYPE)).read(this.cfg);
|
||||
|
||||
this.enchantSlots = new JOption<int[]>("Enchantment.Slots",
|
||||
(cfg, path, def) -> cfg.getIntArray(path),
|
||||
() -> IntStream.range(0, 27).toArray()
|
||||
).setWriter(JYML::setIntArray).read(cfg);
|
||||
this.enchantSlots = new JOption<int[]>("Enchantment.Slots", (cfg, path, def) -> cfg.getIntArray(path), () -> IntStream.range(0, 27).toArray()).setWriter(JYML::setIntArray).read(this.cfg);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
protected MenuOptions createDefaultOptions() {
|
||||
return new MenuOptions(DARK_GRAY + BOLD + "Custom Enchants", 36, InventoryType.CHEST);
|
||||
return new MenuOptions("#6c6c62&lCustom Enchants", 36, InventoryType.CHEST);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
protected List<MenuItem> createDefaultItems() {
|
||||
List<MenuItem> list = new ArrayList<>();
|
||||
|
||||
ArrayList<MenuItem> list = new ArrayList<>();
|
||||
ItemStack nextPageStack = ItemUtil.createCustomHead("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZjMyY2E2NjA1NmI3Mjg2M2U5OGY3ZjMyYmQ3ZDk0YzdhMGQ3OTZhZjY5MWM5YWMzYTkxMzYzMzEzNTIyODhmOSJ9fX0=");
|
||||
ItemUtil.mapMeta(nextPageStack, meta -> {
|
||||
meta.setDisplayName(WHITE + "Next Page" + LIGHT_GRAY + " (→)");
|
||||
});
|
||||
|
||||
ItemUtil.mapMeta(nextPageStack, meta -> meta.setDisplayName(EditorLocales.NEXT_PAGE.getLocalizedName()));
|
||||
ItemStack prevPageStack = ItemUtil.createCustomHead("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvODY5NzFkZDg4MWRiYWY0ZmQ2YmNhYTkzNjE0NDkzYzYxMmY4Njk2NDFlZDU5ZDFjOTM2M2EzNjY2YTVmYTYifX19");
|
||||
ItemUtil.mapMeta(prevPageStack, meta -> {
|
||||
meta.setDisplayName(LIGHT_GRAY + "(←) " + WHITE + "Previous Page");
|
||||
});
|
||||
|
||||
list.add(new MenuItem(nextPageStack).setSlots(35).setType(MenuItemType.PAGE_NEXT).setPriority(5));
|
||||
list.add(new MenuItem(prevPageStack).setSlots(27).setType(MenuItemType.PAGE_PREVIOUS).setPriority(5));
|
||||
|
||||
ItemUtil.mapMeta(prevPageStack, meta -> meta.setDisplayName(EditorLocales.PREVIOUS_PAGE.getLocalizedName()));
|
||||
list.add(new MenuItem(nextPageStack).setSlots(new int[]{35}).setType(MenuItemType.PAGE_NEXT).setPriority(5));
|
||||
list.add(new MenuItem(prevPageStack).setSlots(new int[]{27}).setType(MenuItemType.PAGE_PREVIOUS).setPriority(5));
|
||||
return list;
|
||||
}
|
||||
|
||||
// -----------
|
||||
|
||||
@Override
|
||||
public void onPrepare(@NotNull MenuViewer viewer, @NotNull MenuOptions options) {
|
||||
super.onPrepare(viewer, options);
|
||||
this.getItemsForPage(viewer).forEach(this::addItem);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getObjectSlots() {
|
||||
return this.enchantSlots;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public List<ExcellentEnchant> getObjects(@NotNull Player player) {
|
||||
return new ArrayList<>(EnchantRegistry.getRegistered().stream()
|
||||
.filter(Predicate.not(enchant -> enchant.getDefaults().isHiddenFromList()))
|
||||
.sorted(Comparator.comparing(e -> Colorizer.restrip(e.getDisplayName()))).toList());
|
||||
return new ArrayList<>(EnchantRegistry.getRegistered().stream().filter(Predicate.not(enchant -> enchant.getDefaults().isHiddenFromList())).sorted(Comparator.comparing(e -> Colorizer.restrip(e.getDisplayName()))).toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public ItemStack getObjectStack(@NotNull Player player, @NotNull ExcellentEnchant enchant) {
|
||||
return this.getEnchantIcon(enchant, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public ItemClick getObjectClick(@NotNull ExcellentEnchant enchant) {
|
||||
return (viewer, event) -> {
|
||||
if (!event.isLeftClick()) return;
|
||||
|
||||
if (!event.isLeftClick()) {
|
||||
return;
|
||||
}
|
||||
ItemStack itemClick = event.getCurrentItem();
|
||||
if (itemClick == null) return;
|
||||
|
||||
if (itemClick == null) {
|
||||
return;
|
||||
}
|
||||
int levelHas = PDCUtil.getInt(itemClick, this.keyLevel).orElse(0);
|
||||
if (levelHas == 0) levelHas = enchant.getStartLevel();
|
||||
|
||||
if (++levelHas > enchant.getMaxLevel()) levelHas = enchant.getStartLevel();
|
||||
if (levelHas == 0) {
|
||||
levelHas = enchant.getStartLevel();
|
||||
}
|
||||
if (++levelHas > enchant.getMaxLevel()) {
|
||||
levelHas = enchant.getStartLevel();
|
||||
}
|
||||
itemClick = this.getEnchantIcon(enchant, levelHas);
|
||||
PDCUtil.set(itemClick, this.keyLevel, levelHas);
|
||||
|
||||
event.setCurrentItem(itemClick);
|
||||
};
|
||||
}
|
||||
|
@ -201,43 +195,31 @@ public class EnchantmentsListMenu extends ConfigMenu<ExcellentEnchants> implemen
|
|||
|
||||
@NotNull
|
||||
private ItemStack buildEnchantIcon(@NotNull ExcellentEnchant enchant, int level) {
|
||||
ItemStack icon = new ItemStack(Material.ENCHANTED_BOOK);
|
||||
|
||||
ItemStack icon = new ItemStack(this.enchantIcon);
|
||||
List<String> conflicts = new ArrayList<>();
|
||||
if (enchant.hasConflicts()) {
|
||||
for (String line : this.enchantLoreConflicts) {
|
||||
if (line.contains(GENERIC_NAME)) {
|
||||
enchant.getConflicts().stream().map(EnchantUtils::getLocalized).filter(Objects::nonNull).forEach(conf -> {
|
||||
conflicts.add(line.replace(GENERIC_NAME, conf));
|
||||
});
|
||||
if (line.contains("%name%")) {
|
||||
enchant.getConflicts().stream().map(EnchantUtils::getLocalized).filter(Objects::nonNull).forEach(conf -> conflicts.add(line.replace("%name%", conf)));
|
||||
continue;
|
||||
}
|
||||
else conflicts.add(line);
|
||||
conflicts.add(line);
|
||||
}
|
||||
}
|
||||
|
||||
List<String> obtaining = new ArrayList<>();
|
||||
for (String line : this.enchantLoreObtaining) {
|
||||
if (line.contains(GENERIC_TYPE)) {
|
||||
if (line.contains("%type%")) {
|
||||
for (ObtainType obtainType : ObtainType.values()) {
|
||||
if (enchant.isObtainable(obtainType)) {
|
||||
obtaining.add(line.replace(GENERIC_TYPE, plugin.getLangManager().getEnum(obtainType)));
|
||||
}
|
||||
if (!enchant.isObtainable(obtainType)) continue;
|
||||
obtaining.add(line.replace("%type%", this.plugin.getLangManager().getEnum(obtainType)));
|
||||
}
|
||||
continue;
|
||||
}
|
||||
else obtaining.add(line);
|
||||
obtaining.add(line);
|
||||
}
|
||||
|
||||
ItemReplacer.create(icon).hideFlags().trimmed()
|
||||
.setDisplayName(this.enchantName)
|
||||
.setLore(this.enchantLoreMain)
|
||||
.replaceLoreExact(PLACEHOLDER_CHARGES, enchant.isChargesEnabled() ? new ArrayList<>(this.enchantLoreCharges) : Collections.emptyList())
|
||||
.replaceLoreExact(PLACEHOLDER_CONFLICTS, conflicts)
|
||||
.replaceLoreExact(PLACEHOLDER_OBTAINING, obtaining)
|
||||
.replaceLoreExact(ENCHANTMENT_DESCRIPTION, enchant.formatDescription())
|
||||
.replace(enchant.getPlaceholders(level))
|
||||
.replace(Colorizer::apply)
|
||||
.writeMeta();
|
||||
|
||||
ItemReplacer.create(icon).hideFlags().trimmed().setDisplayName(this.enchantName).setLore(this.enchantLoreMain).replaceLoreExact(PLACEHOLDER_CHARGES, enchant.isChargesEnabled() ? new ArrayList<>(this.enchantLoreCharges) : Collections.emptyList()).replaceLoreExact(PLACEHOLDER_CONFLICTS, conflicts).replaceLoreExact(PLACEHOLDER_OBTAINING, obtaining).replaceLoreExact("%enchantment_description%", enchant.formatDescription()).replace(new PlaceholderMap[]{enchant.getPlaceholders(level)}).replace(Colorizer::apply).writeMeta();
|
||||
return icon;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,22 +1,17 @@
|
|||
package su.nightexpress.excellentenchants.enchantment.registry;
|
||||
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockDropItemEvent;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
import org.bukkit.event.entity.EntityShootBowEvent;
|
||||
import org.bukkit.event.entity.ProjectileHitEvent;
|
||||
import org.bukkit.event.entity.*;
|
||||
import org.bukkit.event.player.PlayerFishEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import su.nexmedia.engine.Version;
|
||||
import su.nexmedia.engine.api.manager.AbstractManager;
|
||||
import su.nexmedia.engine.utils.Reflex;
|
||||
import su.nightexpress.excellentenchants.ExcellentEnchants;
|
||||
import su.nightexpress.excellentenchants.api.enchantment.IEnchantment;
|
||||
import su.nightexpress.excellentenchants.api.enchantment.type.*;
|
||||
|
@ -65,6 +60,7 @@ public class EnchantRegistry extends AbstractManager<ExcellentEnchants> {
|
|||
this.registerWrapper(EntityDamageByEntityEvent.class, CombatEnchant.class, DataGathers.ENTITY_DAMAGE_DEFENSE);
|
||||
this.registerWrapper(EntityDeathEvent.class, DeathEnchant.class, DataGathers.ENTITY_KILL);
|
||||
this.registerWrapper(EntityDeathEvent.class, DeathEnchant.class, DataGathers.ENTITY_DEATH);
|
||||
this.registerWrapper(EntityResurrectEvent.class, DeathEnchant.class, DataGathers.ENTITY_RESURRECT);
|
||||
this.registerWrapper(PlayerFishEvent.class, FishingEnchant.class, DataGathers.FISHING);
|
||||
this.registerWrapper(PlayerInteractEvent.class, InteractEnchant.class, DataGathers.INTERACT);
|
||||
|
||||
|
@ -77,7 +73,12 @@ public class EnchantRegistry extends AbstractManager<ExcellentEnchants> {
|
|||
return;
|
||||
}
|
||||
|
||||
Reflex.setFieldValue(Enchantment.class, "acceptingNew", true);
|
||||
//if (Version.isAtLeast(Version.V1_20_R3)) {
|
||||
this.plugin.getEnchantNMS().unfreezeRegistry();
|
||||
//}
|
||||
//else {
|
||||
// Reflex.setFieldValue(Enchantment.class, "acceptingNew", true);
|
||||
//}
|
||||
|
||||
// Fishing Enchants
|
||||
this.register(AutoReelEnchant.ID,() -> new AutoReelEnchant(plugin));
|
||||
|
@ -171,7 +172,12 @@ public class EnchantRegistry extends AbstractManager<ExcellentEnchants> {
|
|||
this.register(SoulboundEnchant.ID, () -> new SoulboundEnchant(plugin));
|
||||
this.register(RestoreEnchant.ID, () -> new RestoreEnchant(plugin));
|
||||
|
||||
Enchantment.stopAcceptingRegistrations();
|
||||
//if (Version.isAtLeast(Version.V1_20_R3)) {
|
||||
this.plugin.getEnchantNMS().freezeRegistry();
|
||||
//}
|
||||
//else {
|
||||
// Enchantment.stopAcceptingRegistrations();
|
||||
//}
|
||||
this.plugin.info("Enchantments Registered: " + EnchantRegistry.getRegistered().size());
|
||||
this.isLocked = true;
|
||||
}
|
||||
|
@ -217,7 +223,7 @@ public class EnchantRegistry extends AbstractManager<ExcellentEnchants> {
|
|||
|
||||
|
||||
ExcellentEnchant enchant = supplier.get();
|
||||
if (Enchantment.getByKey(enchant.getKey()) != null) {
|
||||
if (EnchantUtils.getEnchantment(enchant.getKey()) /*Enchantment.getByKey(enchant.getKey())*/ != null) {
|
||||
this.plugin.error("Could not register '" + enchant.getId() + "': Such enchantment already registered.");
|
||||
return;
|
||||
}
|
||||
|
@ -226,7 +232,13 @@ public class EnchantRegistry extends AbstractManager<ExcellentEnchants> {
|
|||
return;
|
||||
}
|
||||
|
||||
Enchantment.registerEnchantment(enchant);
|
||||
//if (Version.isAtLeast(Version.V1_20_R3)) {
|
||||
this.plugin.getEnchantNMS().registerEnchantment(enchant);
|
||||
//}
|
||||
//else {
|
||||
//Enchantment.registerEnchantment(enchant);
|
||||
//}
|
||||
|
||||
REGISTRY_MAP.put(enchant.getKey(), enchant);
|
||||
enchant.loadSettings();
|
||||
enchant.getConfig().saveChanges();
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue