mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-03 06:28:52 +00:00
Implement Rules. Adds #154
This commit is contained in:
1 parent
5db99578ff
commit
2ceb16dcd2
10 files changed
+435
-102
No files matched your search
@@ -27,94 +27,97 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
public class EventListener implements Listener {
|
||||
private static final Map<CheckType, Integer> USAGE_LIST = new EnumMap<CheckType, Integer>(CheckType.class);
|
||||
private static final Map<String, Integer> DECREASE_LIST = new HashMap<String, Integer>();
|
||||
private static final CheckManager CHECK_MANAGER = Anticheat.getManager().getCheckManager();
|
||||
private static final Backend BACKEND = Anticheat.getManager().getBackend();
|
||||
private static final Anticheat PLUGIN = Anticheat.getManager().getPlugin();
|
||||
private static final UserManager USER_MANAGER = Anticheat.getManager().getUserManager();
|
||||
|
||||
public static void log(String message, Player player, CheckType type) {
|
||||
User user = getUserManager().getUser(player.getName());
|
||||
if (user.increaseLevel(type)) {
|
||||
Anticheat.getManager().log(message);
|
||||
}
|
||||
removeDecrease(user);
|
||||
logCheat(type, user);
|
||||
}
|
||||
|
||||
private static void logCheat(CheckType type, User user) {
|
||||
USAGE_LIST.put(type, getCheats(type) + 1);
|
||||
type.logUse(user.getName());
|
||||
// Ignore plugins that are creating NPCs with no names (why the hell)
|
||||
if (user.getName() != null) {
|
||||
if (Anticheat.getManager().getConfiguration().getFileLogLevel() == 2 && type.getUses(user.getName()) % 10 == 0) {
|
||||
Anticheat.getManager().fileLog(user.getName() + " has triggered multiple " + type + " checks.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void resetCheck(CheckType type) {
|
||||
USAGE_LIST.put(type, 0);
|
||||
}
|
||||
|
||||
public static int getCheats(CheckType type) {
|
||||
int x = 0;
|
||||
if (USAGE_LIST.get(type) != null) {
|
||||
x = USAGE_LIST.get(type);
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
private static void removeDecrease(User user) {
|
||||
int x = 0;
|
||||
// Ignore plugins that are creating NPCs with no names
|
||||
if (user.getName() != null) {
|
||||
if (DECREASE_LIST.get(user.getName()) != null) {
|
||||
x = DECREASE_LIST.get(user.getName());
|
||||
x -= 2;
|
||||
if (x < 0) {
|
||||
x = 0;
|
||||
}
|
||||
}
|
||||
DECREASE_LIST.put(user.getName(), x);
|
||||
}
|
||||
}
|
||||
|
||||
public static void decrease(Player player) {
|
||||
User user = getUserManager().getUser(player.getName());
|
||||
// Ignore plugins that are creating NPCs with no names
|
||||
if (user.getName() != null) {
|
||||
int x = 0;
|
||||
if (DECREASE_LIST.get(user.getName()) != null) {
|
||||
x = DECREASE_LIST.get(user.getName());
|
||||
}
|
||||
x += 1;
|
||||
DECREASE_LIST.put(user.getName(), x);
|
||||
if (x >= 10) {
|
||||
user.decreaseLevel();
|
||||
DECREASE_LIST.put(user.getName(), 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static CheckManager getCheckManager() {
|
||||
return CHECK_MANAGER;
|
||||
}
|
||||
|
||||
public static AnticheatManager getManager() {
|
||||
return Anticheat.getManager();
|
||||
}
|
||||
|
||||
public static Backend getBackend() {
|
||||
return BACKEND;
|
||||
}
|
||||
|
||||
public static UserManager getUserManager() {
|
||||
return USER_MANAGER;
|
||||
}
|
||||
|
||||
public static Anticheat getPlugin() {
|
||||
return PLUGIN;
|
||||
}
|
||||
private static final Map<CheckType, Integer> USAGE_LIST = new EnumMap<CheckType, Integer>(CheckType.class);
|
||||
private static final Map<String, Integer> DECREASE_LIST = new HashMap<String, Integer>();
|
||||
private static final CheckManager CHECK_MANAGER = Anticheat.getManager().getCheckManager();
|
||||
private static final Backend BACKEND = Anticheat.getManager().getBackend();
|
||||
private static final Anticheat PLUGIN = Anticheat.getManager().getPlugin();
|
||||
private static final UserManager USER_MANAGER = Anticheat.getManager().getUserManager();
|
||||
|
||||
public static void log(String message, Player player, CheckType type) {
|
||||
User user = getUserManager().getUser(player.getName());
|
||||
logCheat(type, user);
|
||||
if (user.increaseLevel(type)) {
|
||||
Anticheat.getManager().log(message);
|
||||
}
|
||||
removeDecrease(user);
|
||||
}
|
||||
|
||||
private static void logCheat(CheckType type, User user) {
|
||||
USAGE_LIST.put(type, getCheats(type) + 1);
|
||||
type.logUse(user.getName());
|
||||
// Ignore plugins that are creating NPCs with no names (why the hell)
|
||||
if (user.getName() != null) {
|
||||
if (Anticheat.getManager().getConfiguration().getFileLogLevel() == 2 && type.getUses(user.getName()) % 10 == 0) {
|
||||
Anticheat.getManager().fileLog(user.getName() + " has triggered multiple " + type + " checks.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void resetCheck(CheckType type) {
|
||||
USAGE_LIST.put(type, 0);
|
||||
}
|
||||
|
||||
public static int getCheats(CheckType type) {
|
||||
int x = 0;
|
||||
if (USAGE_LIST.get(type) != null) {
|
||||
x = USAGE_LIST.get(type);
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
private static void removeDecrease(User user) {
|
||||
int x = 0;
|
||||
// Ignore plugins that are creating NPCs with no names
|
||||
if (user.getName() != null) {
|
||||
if (DECREASE_LIST.get(user.getName()) != null) {
|
||||
x = DECREASE_LIST.get(user.getName());
|
||||
x -= 2;
|
||||
if (x < 0) {
|
||||
x = 0;
|
||||
}
|
||||
}
|
||||
DECREASE_LIST.put(user.getName(), x);
|
||||
}
|
||||
}
|
||||
|
||||
public static void decrease(Player player) {
|
||||
User user = getUserManager().getUser(player.getName());
|
||||
// Ignore plugins that are creating NPCs with no names
|
||||
if (user.getName() != null) {
|
||||
int x = 0;
|
||||
|
||||
if (DECREASE_LIST.get(user.getName()) != null) {
|
||||
x = DECREASE_LIST.get(user.getName());
|
||||
}
|
||||
|
||||
x += 1;
|
||||
DECREASE_LIST.put(user.getName(), x);
|
||||
|
||||
if (x >= 10) {
|
||||
user.decreaseLevel();
|
||||
DECREASE_LIST.put(user.getName(), 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static CheckManager getCheckManager() {
|
||||
return CHECK_MANAGER;
|
||||
}
|
||||
|
||||
public static AnticheatManager getManager() {
|
||||
return Anticheat.getManager();
|
||||
}
|
||||
|
||||
public static Backend getBackend() {
|
||||
return BACKEND;
|
||||
}
|
||||
|
||||
public static UserManager getUserManager() {
|
||||
return USER_MANAGER;
|
||||
}
|
||||
|
||||
public static Anticheat getPlugin() {
|
||||
return PLUGIN;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user