Added Visual check (via @SuperSpyTX), fixes issue #26

This commit is contained in:
H31IX committed 2012-06-12 14:11:47 -04:00
1 parent 77c8b57afb
commit bb7b43afdb
7 files changed
+20 -23

No files matched your search

-1
View File
@@ -39,7 +39,6 @@
</resources> </resources>
</build> </build>
<dependencies> <dependencies>
<!-- mbaxter is a dependency. -->
<dependency> <dependency>
<groupId>org.bukkit</groupId> <groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId> <artifactId>bukkit</artifactId>
@@ -18,6 +18,7 @@
package net.h31ix.anticheat; package net.h31ix.anticheat;
import net.h31ix.anticheat.manage.Permission;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@@ -177,19 +177,18 @@ public class PlayerListener extends EventListener
} }
/* Interactions Check */ /* Interactions Check */
//TODO: Extend this into block place/break and if working, change to visuals check.
Block block = event.getClickedBlock(); Block block = event.getClickedBlock();
if(block != null) { if(block != null)
if(checkManager.willCheck(player, CheckType.INTERACTION) && Utilities.isInteractable(block.getType())) {
{ if(checkManager.willCheck(player, CheckType.VISUAL) && Utilities.isInteractable(block.getType()))
// save load and actually call the backend check here. {
if(backend.checkInteraction(player, block)) if(backend.checkInteraction(player, block))
{ {
event.setCancelled(true); event.setCancelled(true);
log("tried to interact with an object that couldn't see", player, CheckType.INTERACTION); //boring description though. 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) public boolean checkInteraction(Player player, Block block)
{ {
// The most complicated check in the world...approaching nirvana.
int strikes = 0; int strikes = 0;
// now let's swing the bat.
// First Line of Defense // First Line of Defense
Block imple = player.getTargetBlock(null, 5); Block imple = player.getTargetBlock(null, 5);
if(imple.getTypeId() != block.getTypeId()) if(imple.getTypeId() != block.getTypeId())
{ {
strikes++; strikes++;
} }
// Second line of defense. // Second line of defense.
if(!imple.getLocation().equals(block.getLocation())) if(!imple.getLocation().equals(block.getLocation()))
{ {
strikes++; strikes++;
} }
// ShamWow! That check was extremely easy!
return strikes > 0; return strikes > 0;
} }
@@ -20,7 +20,6 @@ package net.h31ix.anticheat.manage;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import net.h31ix.anticheat.Permission;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
/** /**
@@ -42,7 +41,7 @@ public enum CheckType
SPRINT(Permission.CHECK_SPRINT), SPRINT(Permission.CHECK_SPRINT),
SNEAK(Permission.CHECK_SNEAK), SNEAK(Permission.CHECK_SNEAK),
SPEED(Permission.CHECK_SPEED), SPEED(Permission.CHECK_SPEED),
INTERACTION(Permission.CHECK_INTERACTION), VISUAL(Permission.CHECK_VISUAL),
SPIDER(Permission.CHECK_SPIDER), SPIDER(Permission.CHECK_SPIDER),
NOFALL(Permission.CHECK_NOFALL), NOFALL(Permission.CHECK_NOFALL),
FAST_BOW(Permission.CHECK_FASTBOW), FAST_BOW(Permission.CHECK_FASTBOW),
@@ -16,7 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * 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; import org.bukkit.command.CommandSender;
@@ -45,7 +45,7 @@ public enum Permission
CHECK_LONGREACH, CHECK_LONGREACH,
CHECK_FASTPROJECTILE, CHECK_FASTPROJECTILE,
CHECK_ITEMSPAM, CHECK_ITEMSPAM,
CHECK_INTERACTION, CHECK_VISUAL,
/* System Nodes */ /* System Nodes */
SYSTEM_LOG, SYSTEM_LOG,
+4
View File
@@ -113,6 +113,9 @@ permissions:
anticheat.check.itemspam: anticheat.check.itemspam:
description: Allow players to use inventory drop spam hacks description: Allow players to use inventory drop spam hacks
default: false default: false
anticheat.check.visual:
description: Allow players to interact with objects out of their view
default: false
anticheat.check.exempt: anticheat.check.exempt:
description: Total exemption from checks description: Total exemption from checks
default: false default: false
@@ -139,3 +142,4 @@ permissions:
anticheat.check.longreach: true anticheat.check.longreach: true
anticheat.check.projectile: true anticheat.check.projectile: true
anticheat.check.itemspam: true anticheat.check.itemspam: true
anticheat.check.visual: true