From dd0c22fae2c98dbf26a221f67b69f395965b3084 Mon Sep 17 00:00:00 2001 From: asofold Date: Mon, 6 Aug 2012 03:35:45 +0200 Subject: [PATCH] Quick adaption: back to NoCheatPlus --- CompatNoCheatPlus/cncp_lists.txt | 9 +++ CompatNoCheatPlus/plugin.yml | 4 +- .../asofold/bpl/cncp/CompatNoCheatPlus.java | 59 +++++++++++++++++-- .../src/me/asofold/bpl/cncp/hooks/Hook.java | 4 +- .../cncp/hooks/generic/HookPlayerClass.java | 8 +-- .../bpl/cncp/hooks/mcmmo/HookmcMMO.java | 15 ++--- .../asofold/bpl/cncp/setttings/Settings.java | 2 +- 7 files changed, 79 insertions(+), 22 deletions(-) diff --git a/CompatNoCheatPlus/cncp_lists.txt b/CompatNoCheatPlus/cncp_lists.txt index 34eda6a..d6b852d 100644 --- a/CompatNoCheatPlus/cncp_lists.txt +++ b/CompatNoCheatPlus/cncp_lists.txt @@ -22,6 +22,15 @@ STACK VERSION HISTORY --------------------------- +(3.0.0) +- (BIG CHANGE) Back to NoCheatPlus ! + This is a quick adaption only for a few check types, + it would probably not work with all thinkable external hooks. + Supported mappings: + (all) + fight: speed, angle + moving: survivalfly, creativefly, nofall + blockbreak: fastbreak, noswing, direction (2.0.1) - (bugfix?) Re release with corrected class name (something went wrong). diff --git a/CompatNoCheatPlus/plugin.yml b/CompatNoCheatPlus/plugin.yml index 5f7528a..696fca3 100644 --- a/CompatNoCheatPlus/plugin.yml +++ b/CompatNoCheatPlus/plugin.yml @@ -1,7 +1,7 @@ name: CompatNoCheatPlus main: me.asofold.bpl.cncp.CompatNoCheatPlus -version: 2.0.1 +version: 3.0.0 depend: -- DeadNoCheat +- NoCheatPlus softdepend: - mcMMO \ No newline at end of file diff --git a/CompatNoCheatPlus/src/me/asofold/bpl/cncp/CompatNoCheatPlus.java b/CompatNoCheatPlus/src/me/asofold/bpl/cncp/CompatNoCheatPlus.java index 844fbc1..03b6dd6 100644 --- a/CompatNoCheatPlus/src/me/asofold/bpl/cncp/CompatNoCheatPlus.java +++ b/CompatNoCheatPlus/src/me/asofold/bpl/cncp/CompatNoCheatPlus.java @@ -15,8 +15,6 @@ import me.asofold.bpl.cncp.hooks.generic.HookPlayerClass; import me.asofold.bpl.cncp.setttings.GroupHooks; import me.asofold.bpl.cncp.setttings.Settings; import me.asofold.bpl.cncp.utils.Utils; -import me.asofold.bpl.dead.nocheat.checks.Check; -import me.asofold.bpl.dead.nocheat.checks.CheckEvent; import org.bukkit.Bukkit; import org.bukkit.Server; @@ -28,8 +26,18 @@ import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.scheduler.BukkitScheduler; +import fr.neatmonster.nocheatplus.checks.CheckEvent; +import fr.neatmonster.nocheatplus.checks.blockbreak.Direction.DirectionEvent; +import fr.neatmonster.nocheatplus.checks.blockbreak.FastBreak.FastBreakEvent; +import fr.neatmonster.nocheatplus.checks.blockbreak.NoSwing.NoSwingEvent; +import fr.neatmonster.nocheatplus.checks.fight.Angle.AngleEvent; +import fr.neatmonster.nocheatplus.checks.fight.Speed.SpeedEvent; +import fr.neatmonster.nocheatplus.checks.moving.CreativeFly.CreativeFlyEvent; +import fr.neatmonster.nocheatplus.checks.moving.NoFall.NoFallEvent; +import fr.neatmonster.nocheatplus.checks.moving.SurvivalFly.SurvivalFlyEvent; + /** - * Quick attempt to provide compatibility to DeadNoCheat (former NoCheatPlus by NeatMonster) for some other plugins that change the vanilla game mechanichs, for instance by fast block breaking. + * Quick attempt to provide compatibility to NoCheatPlus (by NeatMonster) for some other plugins that change the vanilla game mechanichs, for instance by fast block breaking. * @author mc_dev * */ @@ -243,9 +251,48 @@ public class CompatNoCheatPlus extends JavaPlugin implements Listener { @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled=true) final void onCheckFail(final CheckEvent event){ // Check hooks, most specific first: - final Check check = event.getCheck(); - final String gn = check.getGroup(); - final String cn = check.getName(); + final String gn; + final String cn; + + + if (event instanceof SurvivalFlyEvent){ + gn = "moving"; + cn = "survivalfly"; + } + else if (event instanceof CreativeFlyEvent){ + gn = "moving"; + cn = "creativefly"; + } + else if (event instanceof NoFallEvent){ + gn = "moving"; + cn = "nofall"; + } + else if (event instanceof FastBreakEvent){ + gn = "blockbreak"; + cn = "fastbreak"; + } + else if (event instanceof NoSwingEvent){ + gn = "blockbreak"; + cn = "noswing"; + } + else if (event instanceof DirectionEvent){ + gn = "blockbreak"; + cn = "direction"; + } + else if (event instanceof SpeedEvent){ + gn = "fight"; + cn = "speed"; + } + else if (event instanceof AngleEvent){ + gn = "fight"; + cn = "angle"; + } + else{ + // TODO: ... + gn = ""; + cn = ""; + } + final GroupHooks gh = hooksGroups.get(gn.trim().toLowerCase()); if (gh != null){ final ArrayList hooks = gh.byCheck.get(cn.trim().toLowerCase()); diff --git a/CompatNoCheatPlus/src/me/asofold/bpl/cncp/hooks/Hook.java b/CompatNoCheatPlus/src/me/asofold/bpl/cncp/hooks/Hook.java index dd9e6f6..0fae9f0 100644 --- a/CompatNoCheatPlus/src/me/asofold/bpl/cncp/hooks/Hook.java +++ b/CompatNoCheatPlus/src/me/asofold/bpl/cncp/hooks/Hook.java @@ -1,9 +1,9 @@ package me.asofold.bpl.cncp.hooks; -import me.asofold.bpl.dead.nocheat.checks.CheckEvent; - import org.bukkit.event.Listener; +import fr.neatmonster.nocheatplus.checks.CheckEvent; + /** * Interface for hooking into another plugin.
* diff --git a/CompatNoCheatPlus/src/me/asofold/bpl/cncp/hooks/generic/HookPlayerClass.java b/CompatNoCheatPlus/src/me/asofold/bpl/cncp/hooks/generic/HookPlayerClass.java index 6cb5f8a..daed8cf 100644 --- a/CompatNoCheatPlus/src/me/asofold/bpl/cncp/hooks/generic/HookPlayerClass.java +++ b/CompatNoCheatPlus/src/me/asofold/bpl/cncp/hooks/generic/HookPlayerClass.java @@ -5,7 +5,7 @@ import java.util.HashSet; import java.util.Set; import me.asofold.bpl.cncp.hooks.AbstractHook; -import me.asofold.bpl.dead.nocheat.checks.CheckEvent; +import fr.neatmonster.nocheatplus.checks.CheckEvent; public final class HookPlayerClass extends AbstractHook { @@ -48,15 +48,15 @@ public final class HookPlayerClass extends AbstractHook { @Override public final String getHookVersion() { - return "0.0"; + return "0.1"; } @Override public final void processEvent(final String group, final String check, final CheckEvent event) { - if (exemptAll && !event.getPlayer().getBukkitPlayer().getClass().getSimpleName().equals(playerClassName)) event.setCancelled(true); + if (exemptAll && !event.getPlayer().getClass().getSimpleName().equals(playerClassName)) event.setCancelled(true); else { if (classNames.isEmpty()) return; - final Class clazz = event.getPlayer().getBukkitPlayer().getClass(); + final Class clazz = event.getPlayer().getClass(); final String name = clazz.getSimpleName(); if (classNames.contains(name)) event.setCancelled(true); else if (checkSuperClass){ diff --git a/CompatNoCheatPlus/src/me/asofold/bpl/cncp/hooks/mcmmo/HookmcMMO.java b/CompatNoCheatPlus/src/me/asofold/bpl/cncp/hooks/mcmmo/HookmcMMO.java index ea76441..e8fa063 100644 --- a/CompatNoCheatPlus/src/me/asofold/bpl/cncp/hooks/mcmmo/HookmcMMO.java +++ b/CompatNoCheatPlus/src/me/asofold/bpl/cncp/hooks/mcmmo/HookmcMMO.java @@ -5,8 +5,6 @@ import java.util.Map; import me.asofold.bpl.cncp.hooks.AbstractHook; import me.asofold.bpl.cncp.utils.PluginGetter; -import me.asofold.bpl.dead.nocheat.checks.CheckEvent; -import me.asofold.bpl.dead.nocheat.players.DNCPlayer; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; @@ -19,6 +17,8 @@ import com.gmail.nossr50.events.fake.FakeBlockBreakEvent; import com.gmail.nossr50.events.fake.FakeBlockDamageEvent; import com.gmail.nossr50.events.fake.FakeEntityDamageByEntityEvent; +import fr.neatmonster.nocheatplus.checks.CheckEvent; + public final class HookmcMMO extends AbstractHook implements Listener { private static final Map cancelChecksBlockBreak = new HashMap(); @@ -54,7 +54,7 @@ public final class HookmcMMO extends AbstractHook implements Listener { @Override public String getHookVersion() { - return "0.0"; + return "0.1"; } @Override @@ -62,7 +62,7 @@ public final class HookmcMMO extends AbstractHook implements Listener { return new String[][]{ {"blockbreak", "fastbreak", "noswing"}, {"fight", "angle", "speed"}, - }; + }; } @Override @@ -126,11 +126,12 @@ public final class HookmcMMO extends AbstractHook implements Listener { // System.out.println("[cncp] Return on cancel == null: "+event.getPlayer().getName()); return; } - final DNCPlayer ncpPlayer = event.getPlayer(); + + final Player player = event.getPlayer(); - final String name = ncpPlayer.getName(); + final String name = player.getName(); if (cancel.equals(name)){ - final Player player = ncpPlayer.getBukkitPlayer(); + if (player == null || player.getTicksLived() != cancelTicks){ // System.out.println("[cncp] No cancel (ticks/player): "+event.getPlayer().getName()); cancel = null; diff --git a/CompatNoCheatPlus/src/me/asofold/bpl/cncp/setttings/Settings.java b/CompatNoCheatPlus/src/me/asofold/bpl/cncp/setttings/Settings.java index d7f08df..3212e4f 100644 --- a/CompatNoCheatPlus/src/me/asofold/bpl/cncp/setttings/Settings.java +++ b/CompatNoCheatPlus/src/me/asofold/bpl/cncp/setttings/Settings.java @@ -25,7 +25,7 @@ public class Settings { public static CompatConfig getDefaultConfig(){ CompatConfig cfg = new NewConfig(null); Settings ref = new Settings(); - cfg.set("plugins.force-enable-later", ConfigUtil.asList(new String[]{ "DeadNoCheat" })); + cfg.set("plugins.force-enable-later", ConfigUtil.asList(new String[]{ "NoCheatPlus" })); cfg.set("plugins.ensure-enable", ConfigUtil.asList(new String[]{ "WorldGuard" })); cfg.set("hooks.player-class.exempt-names", new LinkedList()); cfg.set("hooks.player-class.exempt-all", ref.exemptAllPlayerClassNames);