v3.5.3
This commit is contained in:
parent
a952a70f01
commit
f753189e5b
12
Core/pom.xml
12
Core/pom.xml
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>ExcellentEnchants</artifactId>
|
||||
<groupId>su.nightexpress.excellentenchants</groupId>
|
||||
<version>3.5.2</version>
|
||||
<version>3.5.3</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@ -81,27 +81,27 @@
|
||||
<dependency>
|
||||
<groupId>su.nightexpress.excellentenchants</groupId>
|
||||
<artifactId>NMS</artifactId>
|
||||
<version>3.5.2</version>
|
||||
<version>3.5.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>su.nightexpress.excellentenchants</groupId>
|
||||
<artifactId>V1_17_R1</artifactId>
|
||||
<version>3.5.2</version>
|
||||
<version>3.5.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>su.nightexpress.excellentenchants</groupId>
|
||||
<artifactId>V1_18_R2</artifactId>
|
||||
<version>3.5.2</version>
|
||||
<version>3.5.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>su.nightexpress.excellentenchants</groupId>
|
||||
<artifactId>V1_19_R3</artifactId>
|
||||
<version>3.5.2</version>
|
||||
<version>3.5.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>su.nightexpress.excellentenchants</groupId>
|
||||
<artifactId>V1_20_R1</artifactId>
|
||||
<version>3.5.2</version>
|
||||
<version>3.5.3</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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());
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
});
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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<ItemStack> 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);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
@ -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();
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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<Material, Pair<int[], Double>> 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;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -232,13 +232,13 @@ public class EnchantHandlerListener extends AbstractListener<ExcellentEnchants>
|
||||
// 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<ExcellentEnchants>
|
||||
|
||||
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);
|
||||
}
|
||||
});
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>ExcellentEnchants</artifactId>
|
||||
<groupId>su.nightexpress.excellentenchants</groupId>
|
||||
<version>3.5.2</version>
|
||||
<version>3.5.3</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>ExcellentEnchants</artifactId>
|
||||
<groupId>su.nightexpress.excellentenchants</groupId>
|
||||
<version>3.5.2</version>
|
||||
<version>3.5.3</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@ -26,7 +26,7 @@
|
||||
<dependency>
|
||||
<groupId>su.nightexpress.excellentenchants</groupId>
|
||||
<artifactId>NMS</artifactId>
|
||||
<version>3.5.2</version>
|
||||
<version>3.5.3</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>ExcellentEnchants</artifactId>
|
||||
<groupId>su.nightexpress.excellentenchants</groupId>
|
||||
<version>3.5.2</version>
|
||||
<version>3.5.3</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@ -26,7 +26,7 @@
|
||||
<dependency>
|
||||
<groupId>su.nightexpress.excellentenchants</groupId>
|
||||
<artifactId>NMS</artifactId>
|
||||
<version>3.5.2</version>
|
||||
<version>3.5.3</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>ExcellentEnchants</artifactId>
|
||||
<groupId>su.nightexpress.excellentenchants</groupId>
|
||||
<version>3.5.2</version>
|
||||
<version>3.5.3</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@ -26,7 +26,7 @@
|
||||
<dependency>
|
||||
<groupId>su.nightexpress.excellentenchants</groupId>
|
||||
<artifactId>NMS</artifactId>
|
||||
<version>3.5.2</version>
|
||||
<version>3.5.3</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>ExcellentEnchants</artifactId>
|
||||
<groupId>su.nightexpress.excellentenchants</groupId>
|
||||
<version>3.5.2</version>
|
||||
<version>3.5.3</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@ -26,7 +26,7 @@
|
||||
<dependency>
|
||||
<groupId>su.nightexpress.excellentenchants</groupId>
|
||||
<artifactId>NMS</artifactId>
|
||||
<version>3.5.2</version>
|
||||
<version>3.5.3</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user