diff --git a/pom.xml b/pom.xml index aef1705..800d255 100644 --- a/pom.xml +++ b/pom.xml @@ -66,7 +66,18 @@ <dependency> <groupId>org.spigotmc</groupId> <artifactId>spigot-api</artifactId> - <version>1.12.2-R0.1-SNAPSHOT</version> + <version>1.16.1-R0.1-SNAPSHOT</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>com.github.TFPatches</groupId> + <artifactId>TotalFreedomMod</artifactId> + <version>5.5</version> + </dependency> + <dependency> + <groupId>com.github.Pravian</groupId> + <artifactId>Aero</artifactId> + <version>5f82926</version> <scope>provided</scope> </dependency> </dependencies> 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