Compare commits
No commits in common. "7.1" and "1.0.0" have entirely different histories.
@ -87,8 +87,6 @@ dependencies {
|
|||||||
|
|
||||||
modImplementation "ModMenu:ModMenu:${project.mod_menu_version}"
|
modImplementation "ModMenu:ModMenu:${project.mod_menu_version}"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
implementation "org.slf4j:slf4j-api:1.8.0-beta4"
|
implementation "org.slf4j:slf4j-api:1.8.0-beta4"
|
||||||
implementation "org.apache.logging.log4j:log4j-slf4j18-impl:2.16.0"
|
implementation "org.apache.logging.log4j:log4j-slf4j18-impl:2.16.0"
|
||||||
|
|
||||||
@ -100,7 +98,6 @@ dependencies {
|
|||||||
implementation("org.apache.logging.log4j:log4j-1.2-api:${log4jVersion}")
|
implementation("org.apache.logging.log4j:log4j-1.2-api:${log4jVersion}")
|
||||||
|
|
||||||
include(implementation("org.apache.commons:commons-lang3:3.12.0"))
|
include(implementation("org.apache.commons:commons-lang3:3.12.0"))
|
||||||
include(implementation("org.nanohttpd:nanohttpd:2.3.1"))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
java {
|
java {
|
||||||
|
@ -11,6 +11,6 @@ mod_menu_version=2.0.5
|
|||||||
halplibe_version=3.5.4
|
halplibe_version=3.5.4
|
||||||
|
|
||||||
# Mod
|
# Mod
|
||||||
mod_version=1.0.1
|
mod_version=1.0.0
|
||||||
mod_group=alterdekim
|
mod_group=alterdekim
|
||||||
mod_name=offlineskin
|
mod_name=offlineskin
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package alterwain.offlineskin;
|
package alterwain.offlineskin;
|
||||||
|
|
||||||
import alterwain.offlineskin.http.WebServer;
|
|
||||||
import net.fabricmc.api.ModInitializer;
|
import net.fabricmc.api.ModInitializer;
|
||||||
import net.minecraft.core.Global;
|
import net.minecraft.core.Global;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
@ -40,13 +39,6 @@ public class OfflineSkinMod implements ModInitializer, GameStartEntrypoint, Reci
|
|||||||
@Override
|
@Override
|
||||||
public void onInitialize() {
|
public void onInitialize() {
|
||||||
LOGGER.info("OfflineSkins initialized.");
|
LOGGER.info("OfflineSkins initialized.");
|
||||||
new Thread(() -> {
|
|
||||||
try {
|
|
||||||
new WebServer();
|
|
||||||
} catch (IOException e) {
|
|
||||||
LOGGER.error(e.getMessage());
|
|
||||||
}
|
|
||||||
}).start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -8,20 +8,14 @@ public class SendSet extends Thread {
|
|||||||
private final String username;
|
private final String username;
|
||||||
private final boolean isCape;
|
private final boolean isCape;
|
||||||
|
|
||||||
private boolean isRunning = true;
|
|
||||||
|
|
||||||
public SendSet(String username, boolean isCape) {
|
public SendSet(String username, boolean isCape) {
|
||||||
this.username = username;
|
this.username = username;
|
||||||
this.isCape = isCape;
|
this.isCape = isCape;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRunning(boolean isRunning) {
|
|
||||||
this.isRunning = isRunning;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
while(isRunning) {
|
while(true) {
|
||||||
try {
|
try {
|
||||||
Thread.sleep(4000);
|
Thread.sleep(4000);
|
||||||
if (isCape) {
|
if (isCape) {
|
||||||
|
@ -1,26 +0,0 @@
|
|||||||
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");
|
|
||||||
}
|
|
||||||
}
|
|
@ -14,13 +14,9 @@ import java.awt.image.BufferedImage;
|
|||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class Packet246SkinSet extends Packet {
|
public class Packet246SkinSet extends Packet {
|
||||||
|
|
||||||
private static final Map<String, SendSet> skinThread = new HashMap<>();
|
|
||||||
private static final Map<String, SendSet> capeThread = new HashMap<>();
|
|
||||||
private String username;
|
private String username;
|
||||||
private byte[] skin;
|
private byte[] skin;
|
||||||
private byte[] cape;
|
private byte[] cape;
|
||||||
@ -71,18 +67,8 @@ public class Packet246SkinSet extends Packet {
|
|||||||
BufferedImage skin1 = OfflineSkinMod.bytesToImage(this.skin);
|
BufferedImage skin1 = OfflineSkinMod.bytesToImage(this.skin);
|
||||||
BufferedImage cape1 = OfflineSkinMod.bytesToImage(this.cape);
|
BufferedImage cape1 = OfflineSkinMod.bytesToImage(this.cape);
|
||||||
OfflineSkinMod.skins.put(this.username, new SkinConfig(skin1, cape1, this.modelType));
|
OfflineSkinMod.skins.put(this.username, new SkinConfig(skin1, cape1, this.modelType));
|
||||||
if( Packet246SkinSet.skinThread.containsKey(this.username) ) {
|
new SendSet(this.username, false).start();
|
||||||
Packet246SkinSet.skinThread.get(this.username).setRunning(false);
|
new SendSet(this.username, true).start();
|
||||||
}
|
|
||||||
SendSet ss = new SendSet(this.username, false);
|
|
||||||
Packet246SkinSet.skinThread.put(this.username, ss);
|
|
||||||
ss.start();
|
|
||||||
if( Packet246SkinSet.capeThread.containsKey(this.username) ) {
|
|
||||||
Packet246SkinSet.capeThread.get(this.username).setRunning(false);
|
|
||||||
}
|
|
||||||
SendSet cs = new SendSet(this.username, true);
|
|
||||||
Packet246SkinSet.capeThread.put(this.username, cs);
|
|
||||||
cs.start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
x
Reference in New Issue
Block a user