Re-implementing mod functionality in a new way
This commit is contained in:
parent
f31369ab95
commit
55ba42864c
@ -87,6 +87,8 @@ dependencies {
|
||||
|
||||
modImplementation "ModMenu:ModMenu:${project.mod_menu_version}"
|
||||
|
||||
|
||||
|
||||
implementation "org.slf4j:slf4j-api:1.8.0-beta4"
|
||||
implementation "org.apache.logging.log4j:log4j-slf4j18-impl:2.16.0"
|
||||
|
||||
@ -98,6 +100,7 @@ dependencies {
|
||||
implementation("org.apache.logging.log4j:log4j-1.2-api:${log4jVersion}")
|
||||
|
||||
include(implementation("org.apache.commons:commons-lang3:3.12.0"))
|
||||
include(implementation("org.nanohttpd:nanohttpd:2.3.1"))
|
||||
}
|
||||
|
||||
java {
|
||||
|
@ -11,6 +11,6 @@ mod_menu_version=2.0.5
|
||||
halplibe_version=3.5.4
|
||||
|
||||
# Mod
|
||||
mod_version=1.0.0
|
||||
mod_version=1.0.1
|
||||
mod_group=alterdekim
|
||||
mod_name=offlineskin
|
||||
|
@ -1,5 +1,6 @@
|
||||
package alterwain.offlineskin;
|
||||
|
||||
import alterwain.offlineskin.http.WebServer;
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
import net.minecraft.core.Global;
|
||||
import org.slf4j.Logger;
|
||||
@ -39,6 +40,13 @@ public class OfflineSkinMod implements ModInitializer, GameStartEntrypoint, Reci
|
||||
@Override
|
||||
public void onInitialize() {
|
||||
LOGGER.info("OfflineSkins initialized.");
|
||||
new Thread(() -> {
|
||||
try {
|
||||
new WebServer();
|
||||
} catch (IOException e) {
|
||||
LOGGER.error(e.getMessage());
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
26
src/main/java/alterwain/offlineskin/http/WebServer.java
Normal file
26
src/main/java/alterwain/offlineskin/http/WebServer.java
Normal file
@ -0,0 +1,26 @@
|
||||
package alterwain.offlineskin.http;
|
||||
|
||||
import fi.iki.elonen.NanoHTTPD;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
public class WebServer extends NanoHTTPD {
|
||||
public WebServer() throws IOException {
|
||||
super(8080);
|
||||
start(NanoHTTPD.SOCKET_READ_TIMEOUT, false);
|
||||
System.out.println("\nRunning! Point your browsers to http://localhost:8080/ \n");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Response serve(IHTTPSession session) {
|
||||
String msg = "<html><body><h1>Hello server</h1>\n";
|
||||
Map<String, String> parms = session.getParms();
|
||||
if (parms.get("username") == null) {
|
||||
msg += "<form action='?' method='get'>\n <p>Your name: <input type='text' name='username'></p>\n" + "</form>\n";
|
||||
} else {
|
||||
msg += "<p>Hello, " + parms.get("username") + "!</p>";
|
||||
}
|
||||
return newFixedLengthResponse(msg + "</body></html>\n");
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user