Fix Daemon Error

Reflection issue when initializing the daemon; trying to call a constructor with one argument using two arguments.

Removed an unused constructor.
This commit is contained in:
Paldiu 2021-01-08 17:32:54 -06:00
parent 9688827a39
commit 830daab8f4
2 changed files with 5 additions and 10 deletions

View File

@ -137,7 +137,7 @@ public class HTTPDaemon extends FreedomService
private void module(String name, Class<? extends HTTPDModule> clazz, boolean async) private void module(String name, Class<? extends HTTPDModule> clazz, boolean async)
{ {
modules.put(name, ModuleExecutable.forClass(plugin, clazz, async)); modules.put(name, ModuleExecutable.forClass(clazz, async));
} }
private class HTTPD extends NanoHTTPD private class HTTPD extends NanoHTTPD
@ -147,11 +147,6 @@ public class HTTPDaemon extends FreedomService
super(port); super(port);
} }
private HTTPD(String hostname, int port)
{
super(hostname, port);
}
@Override @Override
public Response serve(HTTPSession session) public Response serve(HTTPSession session)
{ {

View File

@ -15,12 +15,12 @@ public abstract class ModuleExecutable
this.async = async; this.async = async;
} }
public static ModuleExecutable forClass(final TotalFreedomMod plugin, Class<? extends HTTPDModule> clazz, boolean async) public static ModuleExecutable forClass(Class<? extends HTTPDModule> clazz, boolean async)
{ {
final Constructor<? extends HTTPDModule> cons; final Constructor<? extends HTTPDModule> cons;
try try
{ {
cons = clazz.getConstructor(TotalFreedomMod.class, NanoHTTPD.HTTPSession.class); cons = clazz.getConstructor(NanoHTTPD.HTTPSession.class);
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -34,7 +34,7 @@ public abstract class ModuleExecutable
{ {
try try
{ {
return cons.newInstance(plugin, session).getResponse(); return cons.newInstance(session).getResponse();
} }
catch (Exception ex) catch (Exception ex)
{ {