mirror of
https://github.com/funkemunky/KauriV3.git
synced 2026-06-01 22:12:19 +00:00
Adding API, new checks, false positive fixes
- New Order (Place) and Order (Use) check - New Autoclicker (A) and Autoclicker (B) check. - Event system for checks has changed to use lambdas instead of reflection (IE WAction and TimedWAction) - Added configurable commands for punishments - Added punishments - Added title command (wont show in help menu) - Added new AnticheatAPI project - Implemented flag, punish, and cancel listeners for API uses.
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
package dev.brighten.ac.api;
|
||||
|
||||
import dev.brighten.ac.api.event.AnticheatEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class AnticheatAPI {
|
||||
|
||||
public static AnticheatAPI INSTANCE;
|
||||
private final Map<String, List<AnticheatEvent>> registeredEvents = new HashMap<>();
|
||||
public AnticheatAPI() {
|
||||
INSTANCE = this;
|
||||
}
|
||||
|
||||
public void registerEvent(Plugin plugin, AnticheatEvent event) {
|
||||
registeredEvents.compute(plugin.getName(), (key, list) -> {
|
||||
if(list == null) {
|
||||
list = new ArrayList<>();
|
||||
}
|
||||
|
||||
list.add(event);
|
||||
return list;
|
||||
});
|
||||
}
|
||||
|
||||
public void unregisterEvents(Plugin plugin) {
|
||||
registeredEvents.remove(plugin.getName());
|
||||
}
|
||||
|
||||
public List<AnticheatEvent> getAllEvents() {
|
||||
final List<AnticheatEvent> allEvents = new ArrayList<>();
|
||||
|
||||
synchronized (registeredEvents) {
|
||||
for (List<AnticheatEvent> events : registeredEvents.values()) {
|
||||
allEvents.addAll(events);
|
||||
}
|
||||
}
|
||||
|
||||
allEvents.sort(Comparator.comparing(e -> e.priority().getSlot()));
|
||||
|
||||
return allEvents;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package dev.brighten.ac.api.check;
|
||||
|
||||
public enum CheckType {
|
||||
COMBAT,
|
||||
AUTOCLICKER,
|
||||
MOVEMENT,
|
||||
BLOCK,
|
||||
INTERACT,
|
||||
ORDER
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package dev.brighten.ac.api.check;
|
||||
|
||||
public interface ECheck {
|
||||
String getName();
|
||||
|
||||
float getVl();
|
||||
|
||||
CheckType getCheckType();
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package dev.brighten.ac.api.event;
|
||||
|
||||
|
||||
import dev.brighten.ac.api.check.ECheck;
|
||||
import dev.brighten.ac.api.event.result.CancelResult;
|
||||
import dev.brighten.ac.api.event.result.FlagResult;
|
||||
import dev.brighten.ac.api.event.result.PunishResult;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventPriority;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface AnticheatEvent {
|
||||
|
||||
PunishResult onPunish(Player player, ECheck check, List<String> commands, boolean cancelled);
|
||||
|
||||
FlagResult onFlag(Player player, ECheck check, String information, boolean cancelled);
|
||||
|
||||
CancelResult onCancel(Player player, ECheck check, boolean cancelled);
|
||||
|
||||
EventPriority priority();
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package dev.brighten.ac.api.event.result;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
|
||||
@Builder
|
||||
@Getter
|
||||
public class CancelResult {
|
||||
private final boolean cancelled;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package dev.brighten.ac.api.event.result;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@Builder
|
||||
public class FlagResult {
|
||||
private final boolean cancelled;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package dev.brighten.ac.api.event.result;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Builder
|
||||
@Getter
|
||||
public class PunishResult {
|
||||
private final boolean cancelled;
|
||||
private String broadcastMessage;
|
||||
private List<String> commands;
|
||||
}
|
||||
Reference in New Issue
Block a user