This commit is contained in:
Paldiu
2021-01-07 13:29:47 -06:00
parent 323fd1a031
commit 260368585e
14 changed files with 35 additions and 42 deletions

View File

@ -15,28 +15,6 @@ public abstract class ModuleExecutable
this.async = async;
}
public NanoHTTPD.Response execute(final NanoHTTPD.HTTPSession session)
{
try
{
if (async)
{
return getResponse(session);
}
// Sync to server thread
return Bukkit.getScheduler().callSyncMethod(TotalFreedomMod.getPlugin(), () -> getResponse(session)).get();
}
catch (Exception ex)
{
FLog.severe(ex);
}
return null;
}
public abstract NanoHTTPD.Response getResponse(NanoHTTPD.HTTPSession session);
public static ModuleExecutable forClass(final TotalFreedomMod plugin, Class<? extends HTTPDModule> clazz, boolean async)
{
final Constructor<? extends HTTPDModule> cons;
@ -67,6 +45,28 @@ public abstract class ModuleExecutable
};
}
public NanoHTTPD.Response execute(final NanoHTTPD.HTTPSession session)
{
try
{
if (async)
{
return getResponse(session);
}
// Sync to server thread
return Bukkit.getScheduler().callSyncMethod(TotalFreedomMod.getPlugin(), () -> getResponse(session)).get();
}
catch (Exception ex)
{
FLog.severe(ex);
}
return null;
}
public abstract NanoHTTPD.Response getResponse(NanoHTTPD.HTTPSession session);
public boolean isAsync()
{
return async;