Updated AAC exemptions and DropQueue

This commit is contained in:
Auxilor
2020-12-18 14:59:07 +00:00
parent 55c6505473
commit 796513627b
4 changed files with 15 additions and 32 deletions

View File

@@ -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'

View File

@@ -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<UUID> 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);
}
}

View File

@@ -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<ItemStack> 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<Player, CollatedDrops> 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<ItemStack> toAdd) {
drops.addAll(toAdd);
return this;
}
}
}

View File

@@ -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
*/