admins no get stop

This commit is contained in:
Super_ 2020-06-27 18:17:07 -04:00
parent 9a1cbbe3a8
commit c269b90cbf
4 changed files with 63 additions and 4 deletions

13
pom.xml
View File

@ -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>

View File

@ -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

View File

@ -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)

View File

@ -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);
}
}