mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-01 14:38:56 +00:00
Added Visual check (via @SuperSpyTX), fixes issue #26
This commit is contained in:
1 parent
77c8b57afb
commit
bb7b43afdb
7 files changed
+23
-26
No files matched your search
@@ -18,6 +18,7 @@
|
||||
|
||||
package net.h31ix.anticheat;
|
||||
|
||||
import net.h31ix.anticheat.manage.Permission;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
@@ -177,19 +177,18 @@ public class PlayerListener extends EventListener
|
||||
}
|
||||
|
||||
/* Interactions Check */
|
||||
//TODO: Extend this into block place/break and if working, change to visuals check.
|
||||
|
||||
Block block = event.getClickedBlock();
|
||||
if(block != null) {
|
||||
if(checkManager.willCheck(player, CheckType.INTERACTION) && Utilities.isInteractable(block.getType()))
|
||||
{
|
||||
// save load and actually call the backend check here.
|
||||
if(backend.checkInteraction(player, block))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
log("tried to interact with an object that couldn't see", player, CheckType.INTERACTION); //boring description though.
|
||||
}
|
||||
}
|
||||
if(block != null)
|
||||
{
|
||||
if(checkManager.willCheck(player, CheckType.VISUAL) && Utilities.isInteractable(block.getType()))
|
||||
{
|
||||
if(backend.checkInteraction(player, block))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
log("tried to interact with an object that they couldn't see", player, CheckType.VISUAL); //boring description though.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -274,26 +274,21 @@ public class Backend
|
||||
|
||||
public boolean checkInteraction(Player player, Block block)
|
||||
{
|
||||
// The most complicated check in the world...approaching nirvana.
|
||||
int strikes = 0;
|
||||
|
||||
// now let's swing the bat.
|
||||
|
||||
// First Line of Defense
|
||||
Block imple = player.getTargetBlock(null, 5);
|
||||
if(imple.getTypeId() != block.getTypeId())
|
||||
{
|
||||
strikes++;
|
||||
strikes++;
|
||||
}
|
||||
|
||||
// Second line of defense.
|
||||
if(!imple.getLocation().equals(block.getLocation()))
|
||||
{
|
||||
strikes++;
|
||||
strikes++;
|
||||
}
|
||||
|
||||
// ShamWow! That check was extremely easy!
|
||||
|
||||
|
||||
return strikes > 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@ package net.h31ix.anticheat.manage;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import net.h31ix.anticheat.Permission;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
@@ -42,7 +41,7 @@ public enum CheckType
|
||||
SPRINT(Permission.CHECK_SPRINT),
|
||||
SNEAK(Permission.CHECK_SNEAK),
|
||||
SPEED(Permission.CHECK_SPEED),
|
||||
INTERACTION(Permission.CHECK_INTERACTION),
|
||||
VISUAL(Permission.CHECK_VISUAL),
|
||||
SPIDER(Permission.CHECK_SPIDER),
|
||||
NOFALL(Permission.CHECK_NOFALL),
|
||||
FAST_BOW(Permission.CHECK_FASTBOW),
|
||||
|
||||
+2
-2
@@ -16,7 +16,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.h31ix.anticheat;
|
||||
package net.h31ix.anticheat.manage;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
@@ -45,7 +45,7 @@ public enum Permission
|
||||
CHECK_LONGREACH,
|
||||
CHECK_FASTPROJECTILE,
|
||||
CHECK_ITEMSPAM,
|
||||
CHECK_INTERACTION,
|
||||
CHECK_VISUAL,
|
||||
|
||||
/* System Nodes */
|
||||
SYSTEM_LOG,
|
||||
Reference in new issue
Block a user