Fix TFMExtras not working if SWM isn't enabled

This commit is contained in:
Telesphoreo 2024-01-10 19:14:35 -06:00
parent fb724fb104
commit a4c0c1c003
No known key found for this signature in database
GPG key ID: 9D1991811E093C02
5 changed files with 33 additions and 13 deletions

View file

@ -34,7 +34,7 @@ public class TFMExtras extends PlexModule
private ModuleConfig config;
@Getter
private final SlimeWorldHook slimeWorldHook = new SlimeWorldHook();
private SlimeWorldHook slimeWorldHook;
@Override
public void load()
@ -43,6 +43,10 @@ public class TFMExtras extends PlexModule
config = new ModuleConfig(this, "tfmextras/config.yml", "config.yml");
config.load();
jumpPads = new JumpPads();
if (swmEnabled())
{
slimeWorldHook = new SlimeWorldHook();
}
// PlexLog.debug(String.valueOf(config.getInt("server.jumppad_strength")));
// PlexLog.log("Test map: {0}", StringUtils.join(SQLUtil.createTable(Lists.newArrayList(), PlayerWorld.class), "\n"));
}
@ -50,14 +54,13 @@ public class TFMExtras extends PlexModule
@Override
public void enable()
{
if (slimeWorldHook.plugin() != null)
if (swmEnabled())
{
slimeWorldHook.onEnable(this);
registerCommand(new SlimeManagerCommand());
registerCommand(new MyWorldCommand());
}
getClassesFrom("dev.plex.extras.command").forEach(aClass ->
{
if (PlexCommand.class.isAssignableFrom(aClass) && aClass.isAnnotationPresent(CommandParameters.class) && aClass.isAnnotationPresent(CommandPermissions.class))
@ -152,4 +155,17 @@ public class TFMExtras extends PlexModule
return Collections.unmodifiableSet(classes);
}
private boolean swmEnabled()
{
try
{
Class.forName("com.infernalsuite.aswm.api.exceptions.UnknownWorldException");
}
catch (Exception ignored)
{
return false;
}
return true;
}
}