mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-02 22:16:03 +00:00
A bit of class refactoring and possibly a fix for visuals check
This commit is contained in:
1 parent
ff368ba431
commit
dd1d13fe41
17 files changed
+34
-38
No files matched your search
@@ -21,7 +21,7 @@ package net.h31ix.anticheat.manage;
|
||||
import java.io.File;
|
||||
import java.util.logging.*;
|
||||
import net.h31ix.anticheat.Anticheat;
|
||||
import net.h31ix.anticheat.Configuration;
|
||||
import net.h31ix.anticheat.util.Configuration;
|
||||
import net.h31ix.anticheat.util.FileFormatter;
|
||||
import net.h31ix.anticheat.xray.XRayTracker;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
|
||||
package net.h31ix.anticheat.manage;
|
||||
|
||||
import net.h31ix.anticheat.util.Distance;
|
||||
import net.h31ix.anticheat.util.CheckType;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -278,23 +280,15 @@ public class Backend
|
||||
|
||||
public boolean checkVisuals(Player player, Block targetBlock, Block playerClick)
|
||||
{
|
||||
if (isInteracting(player) && !Utilities.isInteractable(targetBlock.getType()))
|
||||
if (isInteracting(player))
|
||||
{
|
||||
return false;
|
||||
|
||||
int strikes = 0;
|
||||
|
||||
}
|
||||
double x = targetBlock.getX() - playerClick.getX() * ((targetBlock.getX() - playerClick.getX() * 1) < 0 ? -1 : 1);
|
||||
double y = targetBlock.getY() - playerClick.getY() * ((targetBlock.getY() - playerClick.getY() * 1) < 0 ? -1 : 1);
|
||||
double z = targetBlock.getZ() - playerClick.getZ() * ((targetBlock.getZ() - playerClick.getZ() * 1) < 0 ? -1 : 1);
|
||||
|
||||
if (x >= VISUALS_MAXOFFSET)
|
||||
strikes++;
|
||||
if (y >= VISUALS_MAXOFFSET)
|
||||
strikes++;
|
||||
if (z >= VISUALS_MAXOFFSET)
|
||||
strikes++;
|
||||
|
||||
return strikes > 0;
|
||||
return x >= VISUALS_MAXOFFSET || y >= VISUALS_MAXOFFSET || z >= VISUALS_MAXOFFSET;
|
||||
}
|
||||
|
||||
public boolean checkWaterWalk(Player player, double x, double z)
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package net.h31ix.anticheat.manage;
|
||||
|
||||
import net.h31ix.anticheat.util.CheckType;
|
||||
import com.google.common.collect.ArrayListMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
import java.util.ArrayList;
|
||||
|
||||
@@ -1,104 +0,0 @@
|
||||
/*
|
||||
* AntiCheat for Bukkit.
|
||||
* Copyright (C) 2012 AntiCheat Team | http://h31ix.net
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.h31ix.anticheat.manage;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* All the types of checks and their corresponding permission nodes.
|
||||
*/
|
||||
|
||||
public enum CheckType
|
||||
{
|
||||
ZOMBE_FLY(Permission.CHECK_ZOMBE_FLY),
|
||||
ZOMBE_NOCLIP(Permission.CHECK_ZOMBE_NOCLIP),
|
||||
ZOMBE_CHEAT(Permission.CHECK_ZOMBE_CHEAT),
|
||||
FLY(Permission.CHECK_FLY),
|
||||
WATER_WALK(Permission.CHECK_WATERWALK),
|
||||
NO_SWING(Permission.CHECK_NOSWING),
|
||||
FAST_BREAK(Permission.CHECK_FASTBREAK),
|
||||
FAST_PLACE(Permission.CHECK_FASTPLACE),
|
||||
SPAM(Permission.CHECK_SPAM),
|
||||
SPRINT(Permission.CHECK_SPRINT),
|
||||
SNEAK(Permission.CHECK_SNEAK),
|
||||
SPEED(Permission.CHECK_SPEED),
|
||||
VISUAL(Permission.CHECK_VISUAL),
|
||||
SPIDER(Permission.CHECK_SPIDER),
|
||||
NOFALL(Permission.CHECK_NOFALL),
|
||||
FAST_BOW(Permission.CHECK_FASTBOW),
|
||||
FAST_EAT(Permission.CHECK_FASTEAT),
|
||||
FAST_HEAL(Permission.CHECK_FASTHEAL),
|
||||
FORCEFIELD(Permission.CHECK_FORCEFIELD),
|
||||
XRAY(Permission.CHECK_XRAY),
|
||||
LONG_REACH(Permission.CHECK_LONGREACH),
|
||||
FAST_PROJECTILE(Permission.CHECK_FASTPROJECTILE),
|
||||
ITEM_SPAM(Permission.CHECK_ITEMSPAM);
|
||||
|
||||
private final Permission permission;
|
||||
private final Map<String, Integer> level = new HashMap<String, Integer>();
|
||||
|
||||
private CheckType(Permission perm)
|
||||
{
|
||||
this.permission = perm;
|
||||
}
|
||||
|
||||
public boolean checkPermission(Player player)
|
||||
{
|
||||
return permission.get(player);
|
||||
}
|
||||
|
||||
public void logUse(Player player)
|
||||
{
|
||||
String name = player.getName();
|
||||
if (level.get(name) == null)
|
||||
{
|
||||
level.put(name, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
int amount = level.get(name) + 1;
|
||||
level.put(name, amount);
|
||||
}
|
||||
}
|
||||
|
||||
public void clearUse(Player player)
|
||||
{
|
||||
level.put(player.getName(), 0);
|
||||
}
|
||||
|
||||
public int getUses(Player player)
|
||||
{
|
||||
int use = 0;
|
||||
if (level.get(player.getName()) != null)
|
||||
{
|
||||
use = level.get(player.getName());
|
||||
}
|
||||
return use;
|
||||
}
|
||||
|
||||
public static String getName(CheckType type)
|
||||
{
|
||||
char[] chars = type.toString().replaceAll("_", " ").toLowerCase().toCharArray();
|
||||
chars[0] = Character.toUpperCase(chars[0]);
|
||||
return new String(chars);
|
||||
}
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
/*
|
||||
* AntiCheat for Bukkit.
|
||||
* Copyright (C) 2012 AntiCheat Team | http://h31ix.net
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.h31ix.anticheat.manage;
|
||||
|
||||
import org.bukkit.Location;
|
||||
|
||||
public class Distance
|
||||
{
|
||||
private final Location l1, l2;
|
||||
|
||||
public Distance(Location from, Location to)
|
||||
{
|
||||
l1 = to;
|
||||
l2 = from;
|
||||
}
|
||||
|
||||
public double fromY()
|
||||
{
|
||||
return l2.getY();
|
||||
}
|
||||
|
||||
public double toY()
|
||||
{
|
||||
return l1.getY();
|
||||
}
|
||||
|
||||
public double getXDifference()
|
||||
{
|
||||
return Math.abs(l1.getX() - l2.getX());
|
||||
}
|
||||
|
||||
public double getZDifference()
|
||||
{
|
||||
return Math.abs(l1.getZ() - l2.getZ());
|
||||
}
|
||||
|
||||
public double getYDifference()
|
||||
{
|
||||
return Math.abs(l1.getY() - l2.getY());
|
||||
}
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
/*
|
||||
* AntiCheat for Bukkit.
|
||||
* Copyright (C) 2012 AntiCheat Team | http://h31ix.net
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.h31ix.anticheat.manage;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
public enum Permission
|
||||
{
|
||||
/* Check Nodes */
|
||||
CHECK_ZOMBE_FLY,
|
||||
CHECK_ZOMBE_NOCLIP,
|
||||
CHECK_ZOMBE_CHEAT,
|
||||
CHECK_FLY,
|
||||
CHECK_WATERWALK,
|
||||
CHECK_NOSWING,
|
||||
CHECK_FASTBREAK,
|
||||
CHECK_FASTPLACE,
|
||||
CHECK_SPAM,
|
||||
CHECK_SPRINT,
|
||||
CHECK_SNEAK,
|
||||
CHECK_SPEED,
|
||||
CHECK_SPIDER,
|
||||
CHECK_NOFALL,
|
||||
CHECK_FASTBOW,
|
||||
CHECK_FASTEAT,
|
||||
CHECK_FASTHEAL,
|
||||
CHECK_FORCEFIELD,
|
||||
CHECK_XRAY,
|
||||
CHECK_LONGREACH,
|
||||
CHECK_FASTPROJECTILE,
|
||||
CHECK_ITEMSPAM,
|
||||
CHECK_VISUAL,
|
||||
|
||||
/* System Nodes */
|
||||
SYSTEM_LOG,
|
||||
SYSTEM_XRAY,
|
||||
SYSTEM_RESET,
|
||||
SYSTEM_SPY,
|
||||
SYSTEM_HELP,
|
||||
SYSTEM_UPDATE,
|
||||
SYSTEM_REPORT,
|
||||
SYSTEM_RELOAD;
|
||||
|
||||
public boolean get(CommandSender cs)
|
||||
{
|
||||
return cs.hasPermission(toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return "anticheat." + this.name().toLowerCase().replace("_", ".");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -18,10 +18,11 @@
|
||||
|
||||
package net.h31ix.anticheat.manage;
|
||||
|
||||
import net.h31ix.anticheat.util.CheckType;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import net.h31ix.anticheat.Configuration;
|
||||
import net.h31ix.anticheat.Language;
|
||||
import net.h31ix.anticheat.util.Configuration;
|
||||
import net.h31ix.anticheat.util.Language;
|
||||
import net.h31ix.anticheat.util.Utilities;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
Reference in new issue
Block a user