diff options
author | md_5 <md_5@bigpond.com> | 2012-03-12 10:39:36 +1100 |
---|---|---|
committer | md_5 <md_5@bigpond.com> | 2012-03-12 10:39:36 +1100 |
commit | 78f4820876f42f7b50bf88f64afd45bee939e4e4 (patch) | |
tree | 317cd3bcc63fc9e86a6efbcb5e13a50ed9efbaaf /EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/checks/WorkaroundsListener.java | |
parent | 26409058467e9f34aa65a08df3c68a58129d22ba (diff) | |
download | Essentials-78f4820876f42f7b50bf88f64afd45bee939e4e4.tar Essentials-78f4820876f42f7b50bf88f64afd45bee939e4e4.tar.gz Essentials-78f4820876f42f7b50bf88f64afd45bee939e4e4.tar.lz Essentials-78f4820876f42f7b50bf88f64afd45bee939e4e4.tar.xz Essentials-78f4820876f42f7b50bf88f64afd45bee939e4e4.zip |
Initial formatted and slightly tweaked version of @evenprime 's NoCheat. Will be intergrated into the main Essentials as soon as possible
Diffstat (limited to 'EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/checks/WorkaroundsListener.java')
-rw-r--r-- | EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/checks/WorkaroundsListener.java | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/checks/WorkaroundsListener.java b/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/checks/WorkaroundsListener.java new file mode 100644 index 000000000..7191c0c23 --- /dev/null +++ b/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/checks/WorkaroundsListener.java @@ -0,0 +1,55 @@ +package com.earth2me.essentials.anticheat.checks; + +import com.earth2me.essentials.anticheat.EventManager; +import com.earth2me.essentials.anticheat.config.ConfigurationCacheStore; +import java.util.Collections; +import java.util.List; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerMoveEvent; +import org.bukkit.event.player.PlayerToggleSprintEvent; + + +/** + * Only place that listens to Player-teleport related events and dispatches them to relevant checks + * + */ +public class WorkaroundsListener implements Listener, EventManager +{ + public WorkaroundsListener() + { + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void playerMove(final PlayerMoveEvent event) + { + // No typo here. I really only handle cancelled events and ignore others + if (!event.isCancelled()) + { + return; + } + + // Fix a common mistake that other developers make (cancelling move + // events is crazy, rather set the target location to the from location) + event.setCancelled(false); + event.setTo(event.getFrom().clone()); + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void toggleSprint(final PlayerToggleSprintEvent event) + { + // Some plugins cancel "sprinting", which makes no sense at all because + // it doesn't stop people from sprinting and rewards them by reducing + // their hunger bar as if they were walking instead of sprinting + if (event.isCancelled() && event.isSprinting()) + { + event.setCancelled(false); + } + } + + public List<String> getActiveChecks(ConfigurationCacheStore cc) + { + return Collections.emptyList(); + } +} |