From c269b90cbffd579be82ca7c21277feb811d8ca43 Mon Sep 17 00:00:00 2001 From: Super_ Date: Sat, 27 Jun 2020 18:17:07 -0400 Subject: [PATCH] admins no get stop --- pom.xml | 13 +++++- .../java/me/hockey/captchafy/Captchafy.java | 3 ++ .../java/me/hockey/captchafy/Listeners.java | 9 ++-- .../java/me/hockey/captchafy/TFMHandler.java | 42 +++++++++++++++++++ 4 files changed, 63 insertions(+), 4 deletions(-) create mode 100644 src/main/java/me/hockey/captchafy/TFMHandler.java diff --git a/pom.xml b/pom.xml index aef1705..800d255 100644 --- a/pom.xml +++ b/pom.xml @@ -66,7 +66,18 @@ org.spigotmc spigot-api - 1.12.2-R0.1-SNAPSHOT + 1.16.1-R0.1-SNAPSHOT + provided + + + com.github.TFPatches + TotalFreedomMod + 5.5 + + + com.github.Pravian + Aero + 5f82926 provided diff --git a/src/main/java/me/hockey/captchafy/Captchafy.java b/src/main/java/me/hockey/captchafy/Captchafy.java index d182f63..9e80b75 100644 --- a/src/main/java/me/hockey/captchafy/Captchafy.java +++ b/src/main/java/me/hockey/captchafy/Captchafy.java @@ -35,6 +35,8 @@ public class Captchafy extends JavaPlugin public HttpServer server; public static boolean error = false; + + public TFMHandler tfh; @Override public void onEnable() @@ -43,6 +45,7 @@ public class Captchafy extends JavaPlugin configs = new Configuration(); listeners = new Listeners(); listeners.setThrottleSettings(); + tfh = new TFMHandler(); Bukkit.getPluginManager().registerEvents(listeners, this); getCommand("captchafy").setExecutor(new CaptchafyCommand()); try diff --git a/src/main/java/me/hockey/captchafy/Listeners.java b/src/main/java/me/hockey/captchafy/Listeners.java index c95b6a0..70974e3 100644 --- a/src/main/java/me/hockey/captchafy/Listeners.java +++ b/src/main/java/me/hockey/captchafy/Listeners.java @@ -62,9 +62,12 @@ public class Listeners implements Listener { setURLMessage(); } - event.disallow(PlayerLoginEvent.Result.KICK_OTHER, ChatColor.RED + "" + ChatColor.BOLD + "Yikes, we're under attack! Please solve the captcha.\n" + - ChatColor.WHITE + "Please go to " + ChatColor.GOLD + url + ChatColor.WHITE + " in your web browser and solve the captcha.\n" + - "Once solved successfully, you will be able to join."); + if (!Captchafy.plugin.tfh.isAdmin(event.getPlayer())) + { + event.disallow(PlayerLoginEvent.Result.KICK_OTHER, ChatColor.RED + "" + ChatColor.BOLD + "Yikes, we're under attack! Please solve the captcha.\n" + + ChatColor.WHITE + "Please go to " + ChatColor.GOLD + url + ChatColor.WHITE + " in your web browser and solve the captcha.\n" + + "Once solved successfully, you will be able to join."); + } return; } if (Captchafy.securityLevel == 3) diff --git a/src/main/java/me/hockey/captchafy/TFMHandler.java b/src/main/java/me/hockey/captchafy/TFMHandler.java new file mode 100644 index 0000000..4a1323d --- /dev/null +++ b/src/main/java/me/hockey/captchafy/TFMHandler.java @@ -0,0 +1,42 @@ +package me.hockey.captchafy; + +import me.totalfreedom.totalfreedommod.TotalFreedomMod; +import org.bukkit.entity.Player; +import org.bukkit.plugin.Plugin; + +public class TFMHandler +{ + private Captchafy plugin; + private TotalFreedomMod tfmPlugin; + + public TFMHandler() + { + this.plugin = Captchafy.plugin; + this.tfmPlugin = null; + } + + public TotalFreedomMod getTFM() + { + if (tfmPlugin == null) + { + try + { + final Plugin tfm = plugin.getServer().getPluginManager().getPlugin("TotalFreedomMod"); + if (tfm != null && tfm instanceof TotalFreedomMod) + { + tfmPlugin = (TotalFreedomMod) tfm; + } + } + catch (Exception ex) + { + ex.printStackTrace(); + } + } + return tfmPlugin; + } + + public boolean isAdmin(Player player) + { + return getTFM().al.isAdmin(player); + } +} \ No newline at end of file