Fixed anticheat support for Buckshot, Succession, Tripleshot, and Pentashot

This commit is contained in:
Auxilor 2022-03-09 14:09:20 +00:00
parent 80cef44de5
commit df47705274
4 changed files with 39 additions and 2 deletions

View File

@ -1,5 +1,6 @@
package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.eco.core.integrations.anticheat.AnticheatManager;
import com.willfp.eco.util.NumberUtils;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
@ -29,8 +30,8 @@ public class Buckshot extends EcoEnchant {
final int level,
@NotNull final EntityShootBowEvent event) {
this.getPlugin().getScheduler().runLater(1, () -> event.getProjectile().remove());
if (shooter instanceof Player) {
((Player) shooter).playSound(shooter.getLocation(), Sound.ENTITY_ARROW_SHOOT, SoundCategory.PLAYERS, 1.0f, 1.0f);
if (shooter instanceof Player player) {
player.playSound(shooter.getLocation(), Sound.ENTITY_ARROW_SHOOT, SoundCategory.PLAYERS, 1.0f, 1.0f);
}
int number = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "amount-per-level");
@ -39,6 +40,10 @@ public class Buckshot extends EcoEnchant {
double spread = Math.abs(this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "spread-per-level"));
spread *= level;
if (shooter instanceof Player player) {
AnticheatManager.exemptPlayer(player);
}
for (int i = 0; i < number; i++) {
Vector velocity = event.getProjectile().getVelocity().clone();
@ -53,5 +58,9 @@ public class Buckshot extends EcoEnchant {
}
arrow1.setPickupStatus(AbstractArrow.PickupStatus.DISALLOWED);
}
if (shooter instanceof Player player) {
AnticheatManager.unexemptPlayer(player);
}
}
}

View File

@ -1,5 +1,6 @@
package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.eco.core.integrations.anticheat.AnticheatManager;
import com.willfp.eco.util.DurabilityUtils;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
@ -29,6 +30,10 @@ public class Succession extends EcoEnchant {
boolean fire = EnchantChecks.mainhand(shooter, Enchantment.ARROW_FIRE);
if (shooter instanceof Player player) {
AnticheatManager.exemptPlayer(player);
}
for (int i = 1; i <= amount; i++) {
this.getPlugin().getScheduler().runLater(() -> {
Arrow arrow1 = shooter.launchProjectile(Arrow.class, event.getProjectile().getVelocity());
@ -42,5 +47,8 @@ public class Succession extends EcoEnchant {
}
}, (long) i * this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "delay-between-arrows"));
}
if (shooter instanceof Player player) {
AnticheatManager.unexemptPlayer(player);
}
}
}

View File

@ -1,5 +1,6 @@
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;
@ -9,6 +10,7 @@ import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.AbstractArrow;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityShootBowEvent;
import org.bukkit.util.Vector;
import org.jetbrains.annotations.NotNull;
@ -29,6 +31,10 @@ public class Tripleshot extends EcoEnchant {
return;
}
if (shooter instanceof Player player) {
AnticheatManager.exemptPlayer(player);
}
for (int i = -1; i < 2; i += 2) {
Vector velocity = event.getProjectile().getVelocity();
@ -41,5 +47,9 @@ public class Tripleshot extends EcoEnchant {
}
arrow1.setPickupStatus(AbstractArrow.PickupStatus.DISALLOWED);
}
if (shooter instanceof Player player) {
AnticheatManager.unexemptPlayer(player);
}
}
}

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.EcoEnchants;
import com.willfp.ecoenchants.enchantments.meta.EnchantmentType;
@ -9,6 +10,7 @@ import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.AbstractArrow;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityShootBowEvent;
import org.bukkit.util.Vector;
import org.jetbrains.annotations.NotNull;
@ -31,6 +33,10 @@ public class Pentashot extends EcoEnchant {
int bonusPerSide = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "side-arrows-per-level") * level;
if (shooter instanceof Player player) {
AnticheatManager.exemptPlayer(player);
}
for (int i = -bonusPerSide; i <= bonusPerSide; i += 1) {
if (i == 0) {
continue;
@ -47,5 +53,9 @@ public class Pentashot extends EcoEnchant {
}
arrow1.setPickupStatus(AbstractArrow.PickupStatus.DISALLOWED);
}
if (shooter instanceof Player player) {
AnticheatManager.unexemptPlayer(player);
}
}
}