diff --git a/Core/pom.xml b/Core/pom.xml
index 51964ad..54ccd51 100644
--- a/Core/pom.xml
+++ b/Core/pom.xml
@@ -5,7 +5,7 @@
ExcellentEnchants
su.nightexpress.excellentenchants
- 3.5.2
+ 3.5.3
4.0.0
@@ -81,27 +81,27 @@
su.nightexpress.excellentenchants
NMS
- 3.5.2
+ 3.5.3
su.nightexpress.excellentenchants
V1_17_R1
- 3.5.2
+ 3.5.3
su.nightexpress.excellentenchants
V1_18_R2
- 3.5.2
+ 3.5.3
su.nightexpress.excellentenchants
V1_19_R3
- 3.5.2
+ 3.5.3
su.nightexpress.excellentenchants
V1_20_R1
- 3.5.2
+ 3.5.3
diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/DeathEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/DeathEnchant.java
index 0d5af0f..78e3387 100644
--- a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/DeathEnchant.java
+++ b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/DeathEnchant.java
@@ -3,12 +3,13 @@ package su.nightexpress.excellentenchants.api.enchantment.type;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDeathEvent;
+import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import su.nightexpress.excellentenchants.api.enchantment.IEnchantment;
public interface DeathEnchant extends IEnchantment {
- boolean onDeath(@NotNull EntityDeathEvent e, @NotNull LivingEntity entity, int level);
+ boolean onDeath(@NotNull EntityDeathEvent event, @NotNull LivingEntity entity, ItemStack item, int level);
- boolean onKill(@NotNull EntityDeathEvent e, @NotNull LivingEntity entity, @NotNull Player killer, int level);
+ boolean onKill(@NotNull EntityDeathEvent event, @NotNull LivingEntity entity, @NotNull Player killer, int level);
}
diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/EnchantRegistry.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/EnchantRegistry.java
index 4ed5b3e..52fdc55 100644
--- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/EnchantRegistry.java
+++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/EnchantRegistry.java
@@ -14,6 +14,7 @@ import su.nightexpress.excellentenchants.enchantment.impl.bow.*;
import su.nightexpress.excellentenchants.enchantment.impl.fishing.*;
import su.nightexpress.excellentenchants.enchantment.impl.tool.*;
import su.nightexpress.excellentenchants.enchantment.impl.universal.EnchantCurseOfFragility;
+import su.nightexpress.excellentenchants.enchantment.impl.universal.SoulboundEnchant;
import su.nightexpress.excellentenchants.enchantment.impl.weapon.*;
import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils;
import su.nightexpress.excellentenchants.tier.Tier;
@@ -132,6 +133,7 @@ public class EnchantRegistry {
// Universal
this.register(EnchantCurseOfFragility.ID, () -> new EnchantCurseOfFragility(plugin));
this.register(CurseOfMediocrityEnchant.ID, () -> new CurseOfMediocrityEnchant(plugin));
+ this.register(SoulboundEnchant.ID, () -> new SoulboundEnchant(plugin));
Enchantment.stopAcceptingRegistrations();
this.plugin.info("Enchantments Registered: " + getRegistered().size());
diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantSelfDestruction.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantSelfDestruction.java
index eb6a380..688741a 100644
--- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantSelfDestruction.java
+++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantSelfDestruction.java
@@ -8,6 +8,7 @@ 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.inventory.ItemStack;
import org.bukkit.metadata.FixedMetadataValue;
import org.jetbrains.annotations.NotNull;
import su.nexmedia.engine.utils.NumberUtil;
@@ -66,7 +67,7 @@ public class EnchantSelfDestruction extends ExcellentEnchant implements Chanced,
}
@Override
- public boolean onDeath(@NotNull EntityDeathEvent e, @NotNull LivingEntity entity, int level) {
+ public boolean onDeath(@NotNull EntityDeathEvent event, @NotNull LivingEntity entity, ItemStack item, int level) {
if (!this.isAvailableToUse(entity)) return false;
if (!this.checkTriggerChance(level)) return false;
@@ -78,7 +79,7 @@ public class EnchantSelfDestruction extends ExcellentEnchant implements Chanced,
}
@Override
- public boolean onKill(@NotNull EntityDeathEvent e, @NotNull LivingEntity entity, @NotNull Player killer, int level) {
+ public boolean onKill(@NotNull EntityDeathEvent event, @NotNull LivingEntity entity, @NotNull Player killer, int level) {
return false;
}
diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/CurseOfMediocrityEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/CurseOfMediocrityEnchant.java
index 197692e..e4887ff 100644
--- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/CurseOfMediocrityEnchant.java
+++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/CurseOfMediocrityEnchant.java
@@ -85,16 +85,16 @@ public class CurseOfMediocrityEnchant extends ExcellentEnchant implements Chance
}
@Override
- public boolean onDeath(@NotNull EntityDeathEvent e, @NotNull LivingEntity entity, int level) {
+ public boolean onDeath(@NotNull EntityDeathEvent event, @NotNull LivingEntity entity, ItemStack item, int level) {
return false;
}
@Override
- public boolean onKill(@NotNull EntityDeathEvent e, @NotNull LivingEntity entity, @NotNull Player killer, int level) {
+ public boolean onKill(@NotNull EntityDeathEvent event, @NotNull LivingEntity entity, @NotNull Player killer, int level) {
if (!this.isAvailableToUse(killer)) return false;
if (!this.checkTriggerChance(level)) return false;
- e.getDrops().forEach(stack -> {
+ event.getDrops().forEach(stack -> {
ItemUtil.mapMeta(stack, meta -> {
meta.getEnchants().keySet().forEach(meta::removeEnchant);
});
diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantCurseOfMisfortune.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantCurseOfMisfortune.java
index 6fd9b8a..ca40ad4 100644
--- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantCurseOfMisfortune.java
+++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantCurseOfMisfortune.java
@@ -84,17 +84,17 @@ public class EnchantCurseOfMisfortune extends ExcellentEnchant implements Chance
}
@Override
- public boolean onKill(@NotNull EntityDeathEvent e, @NotNull LivingEntity entity, @NotNull Player killer, int level) {
+ public boolean onKill(@NotNull EntityDeathEvent event, @NotNull LivingEntity entity, @NotNull Player killer, int level) {
if (!this.isAvailableToUse(killer)) return false;
if (!this.checkTriggerChance(level)) return false;
- e.getDrops().clear();
- if (!this.isDropExp()) e.setDroppedExp(0);
+ event.getDrops().clear();
+ if (!this.isDropExp()) event.setDroppedExp(0);
return true;
}
@Override
- public boolean onDeath(@NotNull EntityDeathEvent e, @NotNull LivingEntity entity, int level) {
+ public boolean onDeath(@NotNull EntityDeathEvent event, @NotNull LivingEntity entity, ItemStack item, int level) {
return false;
}
}
diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/universal/SoulboundEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/universal/SoulboundEnchant.java
new file mode 100644
index 0000000..680be4c
--- /dev/null
+++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/universal/SoulboundEnchant.java
@@ -0,0 +1,63 @@
+package su.nightexpress.excellentenchants.enchantment.impl.universal;
+
+import org.bukkit.enchantments.Enchantment;
+import org.bukkit.enchantments.EnchantmentTarget;
+import org.bukkit.entity.Player;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.entity.PlayerDeathEvent;
+import org.bukkit.inventory.ItemStack;
+import org.jetbrains.annotations.NotNull;
+import su.nightexpress.excellentenchants.ExcellentEnchants;
+import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant;
+import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority;
+import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class SoulboundEnchant extends ExcellentEnchant {
+
+ public static final String ID = "soulbound";
+
+ public SoulboundEnchant(@NotNull ExcellentEnchants plugin) {
+ super(plugin, ID, EnchantPriority.LOWEST);
+ this.getDefaults().setDescription("Protects from being dropped on death.");
+ this.getDefaults().setLevelMax(1);
+ this.getDefaults().setTier(0.8);
+ this.getDefaults().setConflicts(Enchantment.VANISHING_CURSE.getKey().getKey());
+ }
+
+ @NotNull
+ @Override
+ public EnchantmentTarget getItemTarget() {
+ return EnchantmentTarget.BREAKABLE;
+ }
+
+ @EventHandler
+ public void onDeath(@NotNull PlayerDeathEvent deathEvent) {
+ Player player = deathEvent.getEntity();
+ if (!this.isAvailableToUse(player)) return;
+ if (deathEvent.getKeepInventory()) return;
+
+ List saveList = new ArrayList<>();
+
+ deathEvent.getDrops().removeIf(drop -> {
+ if (EnchantUtils.getLevel(drop, this) > 0) {
+ if (this.isOutOfCharges(drop)) return false;
+
+ saveList.add(drop);
+ return true;
+ }
+ return false;
+ });
+
+ if (saveList.isEmpty()) return;
+
+ this.plugin.runTask(task -> {
+ saveList.forEach(save -> {
+ this.consumeCharges(save, EnchantUtils.getLevel(save, this));
+ player.getInventory().addItem(save);
+ });
+ });
+ }
+}
diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantDecapitator.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantDecapitator.java
index 621ca7b..387b2ab 100644
--- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantDecapitator.java
+++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantDecapitator.java
@@ -180,12 +180,12 @@ public class EnchantDecapitator extends ExcellentEnchant implements Chanced, Dea
}
@Override
- public boolean onDeath(@NotNull EntityDeathEvent e, @NotNull LivingEntity entity, int level) {
+ public boolean onDeath(@NotNull EntityDeathEvent event, @NotNull LivingEntity entity, ItemStack item, int level) {
return false;
}
@Override
- public boolean onKill(@NotNull EntityDeathEvent e, @NotNull LivingEntity entity, @NotNull Player killer, int level) {
+ public boolean onKill(@NotNull EntityDeathEvent event, @NotNull LivingEntity entity, @NotNull Player killer, int level) {
if (!this.isAvailableToUse(entity)) return false;
EntityType entityType = entity.getType();
diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantExpHunter.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantExpHunter.java
index 5a7ddce..64faa91 100644
--- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantExpHunter.java
+++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantExpHunter.java
@@ -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.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import su.nexmedia.engine.utils.NumberUtil;
import su.nightexpress.excellentenchants.ExcellentEnchants;
@@ -48,18 +49,18 @@ public class EnchantExpHunter extends ExcellentEnchant implements DeathEnchant {
}
@Override
- public boolean onKill(@NotNull EntityDeathEvent e, @NotNull LivingEntity entity, @NotNull Player killer, int level) {
+ public boolean onKill(@NotNull EntityDeathEvent event, @NotNull LivingEntity entity, @NotNull Player killer, int level) {
if (!this.isAvailableToUse(entity)) return false;
double expModifier = this.getExpModifier(level);
- double expFinal = Math.ceil((double) e.getDroppedExp() * expModifier);
+ double expFinal = Math.ceil((double) event.getDroppedExp() * expModifier);
- e.setDroppedExp((int) expFinal);
+ event.setDroppedExp((int) expFinal);
return true;
}
@Override
- public boolean onDeath(@NotNull EntityDeathEvent e, @NotNull LivingEntity entity, int level) {
+ public boolean onDeath(@NotNull EntityDeathEvent event, @NotNull LivingEntity entity, ItemStack item, int level) {
return false;
}
}
diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantNimble.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantNimble.java
index f874c47..0e1d620 100644
--- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantNimble.java
+++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantNimble.java
@@ -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.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import su.nexmedia.engine.utils.PlayerUtil;
import su.nightexpress.excellentenchants.ExcellentEnchants;
@@ -45,17 +46,17 @@ public class EnchantNimble extends ExcellentEnchant implements Chanced, DeathEnc
}
@Override
- public boolean onKill(@NotNull EntityDeathEvent e, @NotNull LivingEntity entity, @NotNull Player killer, int level) {
+ public boolean onKill(@NotNull EntityDeathEvent event, @NotNull LivingEntity entity, @NotNull Player killer, int level) {
if (!this.isAvailableToUse(entity)) return false;
if (!this.checkTriggerChance(level)) return false;
- e.getDrops().forEach(item -> PlayerUtil.addItem(killer, item));
- e.getDrops().clear();
+ event.getDrops().forEach(item -> PlayerUtil.addItem(killer, item));
+ event.getDrops().clear();
return true;
}
@Override
- public boolean onDeath(@NotNull EntityDeathEvent e, @NotNull LivingEntity entity, int level) {
+ public boolean onDeath(@NotNull EntityDeathEvent event, @NotNull LivingEntity entity, ItemStack item, int level) {
return false;
}
}
diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantScavenger.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantScavenger.java
index e3be45a..55be0dd 100644
--- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantScavenger.java
+++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantScavenger.java
@@ -99,7 +99,7 @@ public class EnchantScavenger extends ExcellentEnchant implements Chanced, Death
}
@Override
- public boolean onKill(@NotNull EntityDeathEvent e, @NotNull LivingEntity entity, @NotNull Player killer, int level) {
+ public boolean onKill(@NotNull EntityDeathEvent event, @NotNull LivingEntity entity, @NotNull Player killer, int level) {
if (!this.isAvailableToUse(entity)) return false;
Map> items = this.loot.get(entity.getType());
@@ -115,14 +115,14 @@ public class EnchantScavenger extends ExcellentEnchant implements Chanced, Death
if (amount <= 0) return;
ItemStack item = new ItemStack(material);
- e.getDrops().add(item);
+ event.getDrops().add(item);
});
return true;
}
@Override
- public boolean onDeath(@NotNull EntityDeathEvent e, @NotNull LivingEntity entity, int level) {
+ public boolean onDeath(@NotNull EntityDeathEvent event, @NotNull LivingEntity entity, ItemStack item, int level) {
return false;
}
}
diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantThrifty.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantThrifty.java
index 019ad66..e7f2b83 100644
--- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantThrifty.java
+++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantThrifty.java
@@ -81,7 +81,7 @@ public class EnchantThrifty extends ExcellentEnchant implements Chanced, DeathEn
}
@Override
- public boolean onKill(@NotNull EntityDeathEvent e, @NotNull LivingEntity entity, @NotNull Player killer, int level) {
+ public boolean onKill(@NotNull EntityDeathEvent event, @NotNull LivingEntity entity, @NotNull Player killer, int level) {
if (!this.isAvailableToUse(entity)) return false;
if (this.ignoredEntityTypes.contains(entity.getType())) return false;
@@ -91,12 +91,12 @@ public class EnchantThrifty extends ExcellentEnchant implements Chanced, DeathEn
ItemStack eggItem = plugin.getEnchantNMS().getSpawnEgg(entity);
if (eggItem == null) return false;
- e.getDrops().add(eggItem);
+ event.getDrops().add(eggItem);
return true;
}
@Override
- public boolean onDeath(@NotNull EntityDeathEvent e, @NotNull LivingEntity entity, int level) {
+ public boolean onDeath(@NotNull EntityDeathEvent event, @NotNull LivingEntity entity, ItemStack item, int level) {
return false;
}
diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/listener/EnchantHandlerListener.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/listener/EnchantHandlerListener.java
index 56deb54..f3cb69f 100644
--- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/listener/EnchantHandlerListener.java
+++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/listener/EnchantHandlerListener.java
@@ -232,13 +232,13 @@ public class EnchantHandlerListener extends AbstractListener
// Death Related Enchants
// ---------------------------------------------------------------
@EventHandler(priority = EventPriority.HIGHEST)
- public void onEnchantDeath(EntityDeathEvent e) {
- LivingEntity entity = e.getEntity();
+ public void onEnchantDeath(EntityDeathEvent event) {
+ LivingEntity entity = event.getEntity();
EnchantUtils.getEquipped(entity, DeathEnchant.class).forEach((item, enchants) -> {
enchants.forEach(((deathEnchant, level) -> {
if (deathEnchant.isOutOfCharges(item)) return;
- if (deathEnchant.onDeath(e, entity, level)) {
+ if (deathEnchant.onDeath(event, entity, item, level)) {
deathEnchant.consumeChargesNoUpdate(item, level);
}
}));
@@ -253,7 +253,7 @@ public class EnchantHandlerListener extends AbstractListener
EnchantUtils.getExcellents(weapon, DeathEnchant.class).forEach((deathEnchant, level) -> {
if (deathEnchant.isOutOfCharges(weapon)) return;
- if (deathEnchant.onKill(e, entity, killer, level)) {
+ if (deathEnchant.onKill(event, entity, killer, level)) {
deathEnchant.consumeChargesNoUpdate(weapon, level);
}
});
diff --git a/NMS/pom.xml b/NMS/pom.xml
index 9aabc23..83502de 100644
--- a/NMS/pom.xml
+++ b/NMS/pom.xml
@@ -5,7 +5,7 @@
ExcellentEnchants
su.nightexpress.excellentenchants
- 3.5.2
+ 3.5.3
4.0.0
diff --git a/V1_17_R1/pom.xml b/V1_17_R1/pom.xml
index 724ecba..966cfed 100644
--- a/V1_17_R1/pom.xml
+++ b/V1_17_R1/pom.xml
@@ -5,7 +5,7 @@
ExcellentEnchants
su.nightexpress.excellentenchants
- 3.5.2
+ 3.5.3
4.0.0
@@ -26,7 +26,7 @@
su.nightexpress.excellentenchants
NMS
- 3.5.2
+ 3.5.3
diff --git a/V1_18_R2/pom.xml b/V1_18_R2/pom.xml
index e347222..d5af126 100644
--- a/V1_18_R2/pom.xml
+++ b/V1_18_R2/pom.xml
@@ -5,7 +5,7 @@
ExcellentEnchants
su.nightexpress.excellentenchants
- 3.5.2
+ 3.5.3
4.0.0
@@ -26,7 +26,7 @@
su.nightexpress.excellentenchants
NMS
- 3.5.2
+ 3.5.3
diff --git a/V1_19_R3/pom.xml b/V1_19_R3/pom.xml
index 65ca84e..42beb6d 100644
--- a/V1_19_R3/pom.xml
+++ b/V1_19_R3/pom.xml
@@ -5,7 +5,7 @@
ExcellentEnchants
su.nightexpress.excellentenchants
- 3.5.2
+ 3.5.3
4.0.0
@@ -26,7 +26,7 @@
su.nightexpress.excellentenchants
NMS
- 3.5.2
+ 3.5.3
diff --git a/V1_20_R1/pom.xml b/V1_20_R1/pom.xml
index 092c028..c4f881d 100644
--- a/V1_20_R1/pom.xml
+++ b/V1_20_R1/pom.xml
@@ -5,7 +5,7 @@
ExcellentEnchants
su.nightexpress.excellentenchants
- 3.5.2
+ 3.5.3
4.0.0
@@ -26,7 +26,7 @@
su.nightexpress.excellentenchants
NMS
- 3.5.2
+ 3.5.3
diff --git a/pom.xml b/pom.xml
index d6e8cb3..6032ef6 100644
--- a/pom.xml
+++ b/pom.xml
@@ -7,7 +7,7 @@
su.nightexpress.excellentenchants
ExcellentEnchants
pom
- 3.5.2
+ 3.5.3
Core
NMS