mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-03 06:28:52 +00:00
Refactored a buttload of stuff. This may get rid of the spotty bug, it fixes logging to file and to console, fixes color in console, adds ability to specify the event levels, and changing gamemode while in the air.
This commit is contained in:
1 parent
531b7a4985
commit
28964850e3
15 files changed
+539
-494
No files matched your search
@@ -33,25 +33,26 @@ public class EventListener implements Listener
|
||||
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 PlayerManager PLAYER_MANAGER = Anticheat.getManager().getPlayerManager();
|
||||
private static final UserManager USER_MANAGER = Anticheat.getManager().getUserManager();
|
||||
|
||||
public static void log(String message, Player player, CheckType type)
|
||||
{
|
||||
if (PLAYER_MANAGER.increaseLevel(player,type))
|
||||
User user = getUserManager().getUser(player.getName());
|
||||
if (user.increaseLevel(type))
|
||||
{
|
||||
Anticheat.getManager().log(player.getName() + " " + message);
|
||||
Anticheat.getManager().log(user.getName() + " " + message);
|
||||
}
|
||||
removeDecrease(player);
|
||||
logCheat(type, player);
|
||||
removeDecrease(user);
|
||||
logCheat(type, user);
|
||||
}
|
||||
|
||||
private static void logCheat(CheckType type, Player player)
|
||||
private static void logCheat(CheckType type, User user)
|
||||
{
|
||||
USAGE_LIST.put(type, getCheats(type) + 1);
|
||||
type.logUse(player);
|
||||
if (Anticheat.getManager().getConfiguration().getFileLogLevel() == 2 && type.getUses(player) % 10 == 0)
|
||||
type.logUse(user.getName());
|
||||
if (Anticheat.getManager().getConfiguration().getFileLogLevel() == 2 && type.getUses(user.getName()) % 10 == 0)
|
||||
{
|
||||
Anticheat.getManager().fileLog(player.getName() + " has triggered multiple " + type + " checks.");
|
||||
Anticheat.getManager().fileLog(user.getName() + " has triggered multiple " + type + " checks.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,34 +71,35 @@ public class EventListener implements Listener
|
||||
return x;
|
||||
}
|
||||
|
||||
private static void removeDecrease(Player player)
|
||||
private static void removeDecrease(User user)
|
||||
{
|
||||
int x = 0;
|
||||
if (DECREASE_LIST.get(player.getName()) != null)
|
||||
if (DECREASE_LIST.get(user.getName()) != null)
|
||||
{
|
||||
x = DECREASE_LIST.get(player.getName());
|
||||
x = DECREASE_LIST.get(user.getName());
|
||||
x -= 2;
|
||||
if (x < 0)
|
||||
{
|
||||
x = 0;
|
||||
}
|
||||
}
|
||||
DECREASE_LIST.put(player.getName(), x);
|
||||
DECREASE_LIST.put(user.getName(), x);
|
||||
}
|
||||
|
||||
public static void decrease(Player player)
|
||||
{
|
||||
User user = getUserManager().getUser(player.getName());
|
||||
int x = 0;
|
||||
if (DECREASE_LIST.get(player.getName()) != null)
|
||||
if (DECREASE_LIST.get(user.getName()) != null)
|
||||
{
|
||||
x = DECREASE_LIST.get(player.getName());
|
||||
x = DECREASE_LIST.get(user.getName());
|
||||
}
|
||||
x += 1;
|
||||
DECREASE_LIST.put(player.getName(), x);
|
||||
DECREASE_LIST.put(user.getName(), x);
|
||||
if (x >= 10)
|
||||
{
|
||||
PLAYER_MANAGER.decreaseLevel(player);
|
||||
DECREASE_LIST.put(player.getName(), 0);
|
||||
user.decreaseLevel();
|
||||
DECREASE_LIST.put(user.getName(), 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,9 +118,9 @@ public class EventListener implements Listener
|
||||
return BACKEND;
|
||||
}
|
||||
|
||||
public static PlayerManager getPlayerManager()
|
||||
public static UserManager getUserManager()
|
||||
{
|
||||
return PLAYER_MANAGER;
|
||||
return USER_MANAGER;
|
||||
}
|
||||
|
||||
public static Anticheat getPlugin()
|
||||
|
||||
@@ -22,10 +22,12 @@ import net.h31ix.anticheat.Anticheat;
|
||||
import net.h31ix.anticheat.manage.Backend;
|
||||
import net.h31ix.anticheat.manage.CheckManager;
|
||||
import net.h31ix.anticheat.manage.CheckType;
|
||||
import net.h31ix.anticheat.manage.User;
|
||||
import net.h31ix.anticheat.util.Configuration;
|
||||
import net.h31ix.anticheat.util.Distance;
|
||||
import net.h31ix.anticheat.util.Utilities;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
@@ -68,6 +70,15 @@ public class PlayerListener extends EventListener
|
||||
backend.logEnterExit(event.getPlayer());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerGameModeChange(PlayerGameModeChangeEvent event)
|
||||
{
|
||||
if(event.getNewGameMode() != GameMode.CREATIVE)
|
||||
{
|
||||
backend.logEnterExit(event.getPlayer());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onProjectileLaunch(ProjectileLaunchEvent event)
|
||||
@@ -205,18 +216,6 @@ public class PlayerListener extends EventListener
|
||||
{
|
||||
Distance distance = new Distance(player.getLocation(), block.getLocation());
|
||||
backend.checkLongReachBlock(player, distance.getXDifference(), distance.getYDifference(), distance.getZDifference());
|
||||
|
||||
/* Visuals Check */
|
||||
|
||||
/**
|
||||
* if (checkManager.willCheck(player, CheckType.VISUAL) &&
|
||||
* event.getAction() != Action.PHYSICAL) { if
|
||||
* (backend.checkVisuals(player, block, playerClick)) {
|
||||
* event.setCancelled(!config.silentMode());
|
||||
* log("tried to interact with an object that they couldn't see",
|
||||
* player, CheckType.VISUAL); } else {
|
||||
* backend.logInteraction(player); } }
|
||||
**/
|
||||
}
|
||||
}
|
||||
|
||||
@@ -274,9 +273,13 @@ public class PlayerListener extends EventListener
|
||||
player.sendMessage(section + "f " + section + "f " + section + "4 " + section + "0 " + section + "9 " + section + "6");
|
||||
}
|
||||
backend.logJoin(event.getPlayer());
|
||||
if (!getPlayerManager().hasLevel(player))
|
||||
if (getUserManager().getUser(player.getName()) == null)
|
||||
{
|
||||
getPlayerManager().setLevel(player, getManager().getConfiguration().getLevel(player.getName()));
|
||||
getUserManager().addUser(new User(player.getName()));
|
||||
}
|
||||
else
|
||||
{
|
||||
getUserManager().addUserFromFile(player.getName());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user