Merge remote-tracking branch 'origin/master'

This commit is contained in:
Auxilor 2021-09-12 19:58:40 +01:00
commit 28bc9846f5
11 changed files with 37 additions and 13 deletions

View File

@ -189,15 +189,16 @@ public class EnchantDisplay extends DisplayModule {
return;
}
FastItemStack fast = FastItemStack.wrap(itemStack);
List<String> lore = fast.getLore();
lore.removeIf(s -> s.startsWith("§w"));
fast.setLore(lore);
ItemMeta meta = itemStack.getItemMeta();
assert meta != null;
List<String> lore = meta.getLore() == null ? new ArrayList<>() : new ArrayList<>(meta.getLore());
lore.removeIf(s -> s.startsWith("§w"));
meta.setLore(lore);
meta.getPersistentDataContainer().remove(legacyV);
if (!meta.getPersistentDataContainer().has(keySkip, PersistentDataType.INTEGER)) {

View File

@ -55,6 +55,10 @@ public class Necrotic extends EcoEnchant {
return;
}
if (!event.getEntity().getMetadata("eco-target").isEmpty()) {
return;
}
ItemStack item = new ItemStack(Material.WITHER_SKELETON_SKULL, 1);
new DropQueue(player)

View File

@ -1,10 +1,12 @@
package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.eco.core.integrations.anticheat.AnticheatManager;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.meta.EnchantmentType;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityShootBowEvent;
import org.jetbrains.annotations.NotNull;
@ -20,6 +22,9 @@ public class Rapid extends EcoEnchant {
@NotNull final Arrow arrow,
final int level,
@NotNull final EntityShootBowEvent event) {
if (shooter instanceof Player player) {
AnticheatManager.exemptPlayer(player);
}
double multiplier = 1 - ((this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "percent-faster-per-level") / 100) * level);
if (event.getForce() < multiplier) {
@ -28,5 +33,9 @@ public class Rapid extends EcoEnchant {
double force = 1 / event.getForce();
event.getProjectile().setVelocity(event.getProjectile().getVelocity().multiply(force));
if (shooter instanceof Player player) {
AnticheatManager.unexemptPlayer(player);
}
}
}

View File

@ -4,6 +4,7 @@ import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.meta.EnchantmentType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Trident;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.jetbrains.annotations.NotNull;
@ -21,6 +22,7 @@ public class Bladed extends EcoEnchant {
@NotNull final Trident trident,
final int level,
@NotNull final EntityDamageByEntityEvent event) {
if (victim instanceof Player && this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "disable-on-players")) return;
double baseDamage = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "base-multiplier");
double damage = event.getDamage();
double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier");

View File

@ -5,6 +5,7 @@ import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.meta.EnchantmentType;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.jetbrains.annotations.NotNull;
@ -21,6 +22,7 @@ public class Force extends EcoEnchant {
@NotNull final Arrow arrow,
final int level,
@NotNull final EntityDamageByEntityEvent event) {
if (victim instanceof Player && this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "disable-on-players")) return;
double damage = event.getDamage();
double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier");
double bonus = (multiplier * (level + 6)) + 1;

View File

@ -20,6 +20,7 @@ public class Razor extends EcoEnchant {
@NotNull final LivingEntity victim,
final int level,
@NotNull final EntityDamageByEntityEvent event) {
if (victim instanceof Player && this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "disable-on-players")) return;
double perLevelMultiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier");
double baseDamage = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "base-damage");
double extra = (level * perLevelMultiplier) + baseDamage;

View File

@ -5,7 +5,7 @@ import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.meta.EnchantmentType;
import com.willfp.ecoenchants.enchantments.util.EnchantChecks;
import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
@ -97,9 +97,10 @@ public class Soulbound extends EcoEnchant {
player.setMetadata("soulbound-items", this.getPlugin().getMetadataValueFactory().create(soulboundItems));
}
public boolean hasEmptyInventory(@NotNull final Player player) {
public boolean hasSoulboundItems(@NotNull final Player player) {
final NamespacedKey soulbound = this.getPlugin().getNamespacedKeyFactory().create("soulbound");
for (ItemStack itemStack : player.getInventory().getContents()) {
if (itemStack != null && itemStack.getType() != Material.AIR) {
if (itemStack != null && itemStack.getItemMeta().getPersistentDataContainer().has(soulbound, PersistentDataType.INTEGER)) {
return false;
}
}
@ -110,8 +111,8 @@ public class Soulbound extends EcoEnchant {
public void onSoulboundRespawn(@NotNull final PlayerRespawnEvent event) {
Player player = event.getPlayer();
this.getPlugin().getScheduler().runLater(() -> {
if (!hasEmptyInventory(player)) {
this.getPlugin().getScheduler().run(() -> {
if (!hasSoulboundItems(player)) {
return;
}
@ -137,11 +138,12 @@ public class Soulbound extends EcoEnchant {
}
player.removeMetadata("soulbound-items", this.getPlugin());
}, 1);
});
}
@EventHandler(priority = EventPriority.HIGHEST)
public void onDeath(@NotNull final PlayerDeathEvent event) {
event.getDrops().removeIf(itemStack -> itemStack.getItemMeta().getPersistentDataContainer().has(this.getPlugin().getNamespacedKeyFactory().create("soulbound"), PersistentDataType.INTEGER));
final NamespacedKey soulbound = this.getPlugin().getNamespacedKeyFactory().create("soulbound");
event.getDrops().removeIf(itemStack -> itemStack.getItemMeta().getPersistentDataContainer().has(soulbound, PersistentDataType.INTEGER));
}
}

View File

@ -31,6 +31,7 @@ general-config:
maximum-level: 5
config:
disable-on-players: false # Should this enchantment only boost damage on mobs
base-multiplier: 1.5 # Percent more damage to do as base
multiplier: 0.5 # 1 + (Level * Multiplier) is multiplied with the damage
# To explain, Bladed V would be 4x more damage: 1.5 + (5*0.5)

View File

@ -30,4 +30,5 @@ general-config:
maximum-level: 8
config:
disable-on-players: false # Should this enchantment only boost damage on mobs
multiplier: 0.25 # Formula is (multiplier * (level + 6) + 1)*damage | Default functions as power 5 + level, eg force 2 = power 7

View File

@ -32,6 +32,7 @@ general-config:
maximum-level: 8
config:
disable-on-players: false # Should this enchantment only boost damage on mobs
multiplier: 0.3 # Vanilla sharpness is 0.5*level + 0.5 extra damage. Razor formula is multiplier*level + base extra damage.
base-damage: 10 # Vanilla Smite 5/BOA 5 extra damage is 12.5
decrease-if-cooldown: true

View File

@ -1,2 +1,2 @@
version = 8.10.9
version = 8.10.11
plugin-name = EcoEnchants