Fix TFMExtras not working if SWM isn't enabled

This commit is contained in:
2024-01-10 19:14:35 -06:00
parent fb724fb104
commit a4c0c1c003
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;
}
}

View File

@ -183,6 +183,10 @@ public class SlimeWorldHook implements IHook<SlimePlugin>
{
PlexLog.error(STORAGE_FAILURE);
}
catch (WorldLockedException | UnknownWorldException e)
{
throw new RuntimeException(e);
}
final World world = Bukkit.getWorld(uuid.toString());
if (world == null)