diff --git a/Plugin/build.gradle b/Plugin/build.gradle index 9d8b0645..9947ae46 100644 --- a/Plugin/build.gradle +++ b/Plugin/build.gradle @@ -23,7 +23,7 @@ dependencies { compileOnly 'com.github.TownyAdvanced:Towny:0.96.2.0' compileOnly 'com.github.angeschossen:LandsAPI:4.7.3' compileOnly 'fr.neatmonster:nocheatplus:3.16.1-SNAPSHOT' - compileOnly 'de.janmm14:aac-api:4.2.0' + compileOnly 'de.janmm14:aac-api:5.0.0' compileOnly 'com.github.jiangdashao:matrix-api-repo:317d4635fd' compileOnly 'com.comphenix.protocol:ProtocolLib:4.6.0-SNAPSHOT' compileOnly 'net.ess3:EssentialsX:2.18.1' diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/integrations/anticheat/plugins/AnticheatAAC.java b/Plugin/src/main/java/com/willfp/ecoenchants/integrations/anticheat/plugins/AnticheatAAC.java index 29b01184..5d675bc8 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/integrations/anticheat/plugins/AnticheatAAC.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/integrations/anticheat/plugins/AnticheatAAC.java @@ -1,18 +1,15 @@ package com.willfp.ecoenchants.integrations.anticheat.plugins; import com.willfp.ecoenchants.integrations.anticheat.AnticheatWrapper; -import me.konsolas.aac.api.PlayerViolationEvent; +import me.konsolas.aac.api.AACAPI; +import me.konsolas.aac.api.AACExemption; +import org.bukkit.Bukkit; import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; -import java.util.HashSet; -import java.util.Set; -import java.util.UUID; - public class AnticheatAAC implements AnticheatWrapper, Listener { - private final Set exempt = new HashSet<>(); + private final AACExemption ECOENCHANTS = new AACExemption("EcoEnchants"); + private final AACAPI api = Bukkit.getServicesManager().load(AACAPI.class); @Override public String getPluginName() { @@ -21,20 +18,11 @@ public class AnticheatAAC implements AnticheatWrapper, Listener { @Override public void exempt(Player player) { - this.exempt.add(player.getUniqueId()); + api.addExemption(player, ECOENCHANTS); } @Override public void unexempt(Player player) { - this.exempt.remove(player.getUniqueId()); - } - - @EventHandler(priority = EventPriority.LOWEST) - private void onViolate(PlayerViolationEvent event) { - if (!exempt.contains(event.getPlayer().getUniqueId())) { - return; - } - - event.setCancelled(true); + api.removeExemption(player, ECOENCHANTS); } } diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/util/internal/drops/FastCollatedDropQueue.java b/Plugin/src/main/java/com/willfp/ecoenchants/util/internal/drops/FastCollatedDropQueue.java index cab570cb..4b0c8129 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/util/internal/drops/FastCollatedDropQueue.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/util/internal/drops/FastCollatedDropQueue.java @@ -8,7 +8,6 @@ import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -34,15 +33,7 @@ public class FastCollatedDropQueue extends InternalDropQueue { @Override public void push() { - CollatedDrops collatedDrops; - if(COLLATED_MAP.containsKey(player)) { - List dropSet = COLLATED_MAP.get(player).getDrops(); - dropSet.addAll(items); - collatedDrops = new FastCollatedDropQueue.CollatedDrops(dropSet, loc, xp); - } else { - collatedDrops = new FastCollatedDropQueue.CollatedDrops(new ArrayList<>(items), loc, xp); - } - + CollatedDrops collatedDrops = COLLATED_MAP.containsKey(player) ? COLLATED_MAP.get(player).addDrops(items) : new CollatedDrops(items, loc, xp); COLLATED_MAP.put(player, collatedDrops); } @@ -56,7 +47,6 @@ public class FastCollatedDropQueue extends InternalDropQueue { static { Bukkit.getScheduler().runTaskTimer(EcoEnchantsPlugin.getInstance(), () -> { - if (!collate) return; for (Map.Entry entry : COLLATED_MAP.entrySet()) { new InternalDropQueue(entry.getKey()) .setLocation(entry.getValue().getLocation()) @@ -92,5 +82,10 @@ public class FastCollatedDropQueue extends InternalDropQueue { public int getXp() { return xp; } + + public CollatedDrops addDrops(List toAdd) { + drops.addAll(toAdd); + return this; + } } } diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/util/internal/drops/InternalDropQueue.java b/Plugin/src/main/java/com/willfp/ecoenchants/util/internal/drops/InternalDropQueue.java index 87a3004d..e5cd743d 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/util/internal/drops/InternalDropQueue.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/util/internal/drops/InternalDropQueue.java @@ -31,7 +31,7 @@ public class InternalDropQueue implements AbstractDropQueue { private static boolean useOrb; /** - * Create {@link com.willfp.ecoenchants.util.internal.DropQueue} linked to player + * Create {@link com.willfp.ecoenchants.util.internal.drops.InternalDropQueue} linked to player * * @param player The player */