Account for non-Plex versions of BukkitTelnet

This commit is contained in:
Telesphoreo 2022-05-12 22:01:16 -05:00
parent 46ad9c7c8c
commit 44469d91ec
No known key found for this signature in database
GPG key ID: 5ACFFC4682CF849B

View file

@ -2,6 +2,8 @@ package dev.plex;
import dev.plex.listener.BukkitTelnetListener;
import dev.plex.module.PlexModule;
import dev.plex.util.PlexLog;
import java.lang.reflect.Method;
import lombok.Getter;
import me.totalfreedom.bukkittelnet.BukkitTelnet;
import org.bukkit.Bukkit;
@ -13,6 +15,8 @@ public class BukkitTelnetModule extends PlexModule
private BukkitTelnet bukkitTelnet;
boolean failed = false;
@Override
public void load()
{
@ -22,14 +26,33 @@ public class BukkitTelnetModule extends PlexModule
@Override
public void enable()
{
/*if (getPlex().getSystem().equalsIgnoreCase("permissions") && !Bukkit.getPluginManager().isPluginEnabled("Vault"))
if (getPlex().getSystem().equalsIgnoreCase("permissions") && !Bukkit.getPluginManager().isPluginEnabled("Vault"))
{
throw new RuntimeException("Plex-BukkitTelnet requires the 'Vault' plugin as well as a Permissions plugin that hooks into 'Vault.' We recommend LuckPerms!");
}*/
failed = true;
PlexLog.error("Plex-BukkitTelnet requires the 'Vault' plugin as well as a Permissions plugin that hooks into 'Vault.' We recommend LuckPerms!");
module.disable();
return;
}
if (!Bukkit.getPluginManager().isPluginEnabled("BukkitTelnet"))
{
throw new RuntimeException("The Plex-BukkitTelnet module requires the BukkitTelnet plugin to work. Please download it from: https://github.com/plexusorg/BukkitTelnet/releases");
failed = true;
PlexLog.error("The Plex-BukkitTelnet module requires the BukkitTelnet plugin to work. Please download it from: https://github.com/plexusorg/BukkitTelnet/releases");
module.disable();
return;
}
try
{
failed = true;
Class<?> clazz = Class.forName("me.totalfreedom.bukkittelnet.BukkitTelnet");
Method method = clazz.getDeclaredMethod("getPlugin");
}
catch (ClassNotFoundException | NoSuchMethodException ignored)
{
PlexLog.error("You are using an older version of BukkitTelnet that does not support Plex. Please download a version that does from: https://ci.plex.us.org/job/Plex-BukkitTelnet");
module.disable();
return;
}
this.registerListener(new BukkitTelnetListener());
@ -39,5 +62,9 @@ public class BukkitTelnetModule extends PlexModule
@Override
public void disable()
{
if (failed)
{
PlexLog.error("Disabling Module-BukkitTelnet. Please resolve the above error.");
}
}
}