Permalink
Browse files

Added a web request handler for MDX's integrated web server. (Hive co…

…unt)
  • Loading branch information...
Ri5ux committed Dec 30, 2018
1 parent 2013ff6 commit d47f83f606c56479e1a6b90faebfb21d35526449
Showing with 36 additions and 0 deletions.
  1. +6 −0 src/main/java/org/avp/AliensVsPredator.java
  2. +30 −0 src/main/java/org/avp/WebRequestHandler.java
@@ -52,6 +52,7 @@ public void pre(FMLPreInitializationEvent event)
{
console().pre(event);
settings().pre(event);
webRequests().pre(event);
capabilities().pre(event);
}

@@ -115,6 +116,11 @@ public static AliensVsPredator instance()
{
return AliensVsPredator.instance;
}

public static WebRequestHandler webRequests()
{
return WebRequestHandler.instance;
}

public static Console console()
{
@@ -0,0 +1,30 @@
package org.avp;

import org.avp.world.hives.HiveHandler;

import com.arisux.mdx.web.RequestHandler;
import com.arisux.mdx.web.WebModule;
import com.arisux.mdx.web.RequestHandler.StandardRequestHandler;

import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;

public class WebRequestHandler
{
public static final WebRequestHandler instance = new WebRequestHandler();

public void pre(FMLPreInitializationEvent event)
{
WebModule.REQUESTS().add(new StandardRequestHandler("/avp/hives/count", new RequestHandler.IDataHandler() {
@Override
public Object getData()
{
if (HiveHandler.instance != null && HiveHandler.instance.getHives() != null)
{
return String.valueOf(HiveHandler.instance.getHives().size());
}

return null;
}
}));
}
}

0 comments on commit d47f83f

Please sign in to comment.