Created
May 14, 2014 22:23
-
-
Save riking/6d2965debbffc5f3c857 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package eu.phiwa.dt.anticheatplugins; | |
import org.bukkit.entity.Player; | |
public interface AbstractHandler { | |
public void startExempting(Player player); | |
public void stopExempting(Player player); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package eu.phiwa.dt.anticheatplugins; | |
import net.h31ix.anticheat.api.AnticheatAPI; | |
import org.bukkit.entity.Player; | |
public class AntiCheatHandler implements AbstractHandler { | |
static { | |
// This throws an exception if the class isn't loaded | |
AnticheatAPI.getManager(); | |
} | |
@Override | |
public void startExempting(Player player) { | |
if (!AnticheatAPI.isExempt(player, net.h31ix.anticheat.manage.CheckType.FLY)) { | |
AnticheatAPI.exemptPlayer(player, net.h31ix.anticheat.manage.CheckType.FLY); | |
} | |
} | |
@Override | |
public void stopExempting(Player player) { | |
if (AnticheatAPI.isExempt(player, net.h31ix.anticheat.manage.CheckType.FLY)) { | |
AnticheatAPI.unexemptPlayer(player, net.h31ix.anticheat.manage.CheckType.FLY); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package eu.phiwa.dt.anticheatplugins; | |
import org.bukkit.entity.Player; | |
import eu.phiwa.dt.DragonTravelMain; | |
public class CheatProtectionHandler { | |
private static NoCheatPlusHandler ncpHandle = null; | |
private static AntiCheatHandler acHandle = null; | |
public static void setup() { | |
try { | |
acHandle = new AntiCheatHandler(); | |
} catch (Throwable t) { | |
acHandle = null; | |
} | |
if (acHandle != null) { | |
DragonTravelMain.plugin.getLogger().info("[DragonTravel] AntiCheat support enabled"); | |
} | |
try { | |
ncpHandle = new NoCheatPlusHandler(); | |
} catch (Throwable t) { | |
ncpHandle = null; | |
} | |
if (ncpHandle != null) { | |
DragonTravelMain.plugin.getLogger().info("[DragonTravel] NoCheatPlus support enabled"); | |
} | |
} | |
/** | |
* Exempts a player from the Cheat-check of AntiCheat-plugins | |
* | |
* @param player the player to exempt from the check | |
*/ | |
public static void exemptPlayerFromCheatChecks(Player player) { | |
// AntiCheat | |
if (acHandle != null) { | |
acHandle.startExempting(player); | |
} | |
// NoCheatPlus | |
if (ncpHandle != null) { | |
ncpHandle.startExempting(player); | |
} | |
} | |
/** | |
* Unexempts a player from the Cheat-check of AntiCheat-plugins | |
* | |
* @param player the player to unexempt from the check | |
*/ | |
public static void unexemptPlayerFromCheatChecks(Player player) { | |
// AntiCheat | |
if (acHandle != null) { | |
acHandle.stopExempting(player); | |
} | |
// NoCheatPlus | |
if (ncpHandle != null) { | |
ncpHandle.stopExempting(player); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package eu.phiwa.dt.anticheatplugins; | |
import org.bukkit.entity.Player; | |
import fr.neatmonster.nocheatplus.checks.CheckType; | |
import fr.neatmonster.nocheatplus.hooks.NCPExemptionManager; | |
public class NoCheatPlusHandler implements AbstractHandler { | |
static { | |
// This throws an exception if the class isn't loaded | |
NCPExemptionManager.getListener(); | |
} | |
@Override | |
public void startExempting(Player player) { | |
if (!NCPExemptionManager.isExempted(player, CheckType.MOVING_SURVIVALFLY) || !NCPExemptionManager.isExempted(player, CheckType.MOVING_CREATIVEFLY)) { | |
NCPExemptionManager.exemptPermanently(player, CheckType.MOVING_SURVIVALFLY); | |
NCPExemptionManager.exemptPermanently(player, CheckType.MOVING_CREATIVEFLY); | |
} | |
} | |
@Override | |
public void stopExempting(Player player) { | |
if (NCPExemptionManager.isExempted(player, CheckType.MOVING_SURVIVALFLY) || NCPExemptionManager.isExempted(player, CheckType.MOVING_CREATIVEFLY)) { | |
NCPExemptionManager.unexempt(player, CheckType.MOVING_SURVIVALFLY); | |
NCPExemptionManager.unexempt(player, CheckType.MOVING_CREATIVEFLY); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment