mirror of
https://github.com/plexusorg/Module-BukkitTelnet.git
synced 2024-12-22 07:45:03 +00:00
Account for non-Plex versions of BukkitTelnet
This commit is contained in:
parent
46ad9c7c8c
commit
44469d91ec
1 changed files with 31 additions and 4 deletions
|
@ -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.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue