Fixed Anticheat compatibility with Charge and Spring

This commit is contained in:
Auxilor 2021-07-05 15:36:23 +02:00
parent fc8041cb72
commit 7f467a92b4
2 changed files with 10 additions and 0 deletions

View File

@ -1,5 +1,6 @@
package com.willfp.ecoenchants.enchantments.ecoenchants.special;
import com.willfp.eco.core.integrations.anticheat.AnticheatManager;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.meta.EnchantmentType;
import org.bukkit.entity.LivingEntity;
@ -28,7 +29,11 @@ public class Spring extends EcoEnchant {
public void onJump(@NotNull final Player player,
final int level,
@NotNull final PlayerMoveEvent event) {
AnticheatManager.exemptPlayer(player);
double multiplier = 0.5 + ((double) (level * level) / 4 - 0.2) / 3;
player.setVelocity(player.getLocation().getDirection().multiply(multiplier).setY(multiplier));
this.getPlugin().getScheduler().runLater(() -> AnticheatManager.unexemptPlayer(player), 10);
}
}

View File

@ -1,5 +1,6 @@
package com.willfp.ecoenchants.enchantments.ecoenchants.spell;
import com.willfp.eco.core.integrations.anticheat.AnticheatManager;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.itemtypes.Spell;
import org.bukkit.entity.Player;
@ -16,12 +17,16 @@ public class Charge extends Spell {
public boolean onUse(@NotNull final Player player,
final int level,
@NotNull final PlayerInteractEvent event) {
AnticheatManager.exemptPlayer(player);
Vector velocity = player.getEyeLocation().getDirection().clone();
velocity.normalize();
velocity.multiply(level * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "velocity-per-level"));
velocity.setY(player.getEyeLocation().getDirection().clone().getY() + 0.2);
player.setVelocity(velocity);
this.getPlugin().getScheduler().runLater(() -> AnticheatManager.unexemptPlayer(player), 10);
return true;
}
}