1
0
Fork 0
This commit is contained in:
HoosierTransfer 2024-04-21 11:40:21 -04:00
parent ece80e88ac
commit 37f2ac12ba
6 changed files with 37901 additions and 37810 deletions

File diff suppressed because it is too large Load Diff

View File

@ -12,12 +12,32 @@
<meta property="og:description" content="test directory HTML page" />
<link type="image/png" rel="shortcut icon" href="favicon.png" />
<script type="text/javascript" src="classes.js"></script>
<script type="text/javascript">
<script type="text/javascript">
"use strict";
function setCookie(name, data) {
document.cookie = name + '=' + encodeURIComponent(data) + '; expires=Fri, 31 Dec 9999 23:59:59 GMT';
}
function getCookie(name) {
var cookies = document.cookie.split(';');
for(var i = 0; i < cookies.length; i++) {
var c = cookies[i];
while(c.charAt(0) == ' ') c = c.substring(1);
if(c.indexOf(name + '=') == 0) return decodeURIComponent(c.substring(name.length + 1, c.length));
}
return null;
}
window.addEventListener("load", () => {
if(document.location.href.startsWith("file:")) {
alert("HTTP please, do not open this file locally, run a local HTTP server and load it via HTTP");
}else {
if (localStorage.getItem("username") === null && getCookie("username") !== null) {
localStorage.setItem("username", getCookie("username"));
}
if (getCookie("username") === null && localStorage.getItem("username") !== null) {
setCookie("username", localStorage.getItem("username"));
}
const isHttps = document.location.protocol === "https:";
var serverURL = isHttps ? "wss://" : "ws://";
serverURL += document.location.host + "/";

View File

@ -155,6 +155,27 @@ public class EaglerProfile {
@JSBody(params = { "name", "data" }, script = "document.cookie = name + '=' + encodeURIComponent(data) + '; expires=Fri, 31 Dec 9999 23:59:59 GMT';")
public static native void setCookie(String name, String data);
@JSBody(params = { "name" }, script = "var value = '; ' + document.cookie; var parts = value.split('; ' + name + '='); if (parts.length == 2) return decodeURIComponent(parts.pop().split(';').shift()); return '';")
public static native String getCookie(String name);
@JSBody(params = { "name", "data" }, script = "localStorage.setItem(name, data);")
public static native void setLocalStorage(String name, String data);
@JSBody(params = { "name" }, script = "return localStorage.getItem(name);")
public static native String getLocalStorage(String name);
public static void updateUsernameCookies() {
setCookie("username", username);
setLocalStorage("username", username);
}
public static void updateUsernameCookieFromLocalStorage() {
String name = getLocalStorage("username");
if(name != null && !name.isEmpty()) {
username = name;
}
}
public static void read(byte[] profileStorage) {
if (profileStorage == null) {
return;
@ -178,7 +199,7 @@ public class EaglerProfile {
if(!loadUsername.isEmpty()) {
username = loadUsername.replaceAll("[^A-Za-z0-9]", "_");
setCookie("username", username);
updateUsernameCookies();
}
clearCustomSkins();

View File

@ -5,6 +5,8 @@ import java.io.DataOutputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import org.teavm.jso.JSBody;
import net.lax1dude.eaglercraft.v1_8.ArrayUtils;
import net.lax1dude.eaglercraft.v1_8.EaglerInputStream;
import net.lax1dude.eaglercraft.v1_8.EaglerOutputStream;
@ -377,6 +379,9 @@ public class ConnectionHandshake {
}
return b;
}
@JSBody(params = {}, script = "window.onbeforeunload = null; location.reload();")
public static native void reloadPage();
private static void showError(Minecraft mc, GuiConnecting connecting, GuiScreen scr, DataInputStream err, boolean v2) throws IOException {
int errorCode = err.read();
@ -392,6 +397,14 @@ public class ConnectionHandshake {
RateLimitTracker.registerLockOut(PlatformNetworking.getCurrentURI());
mc.displayGuiScreen(GuiDisconnected.createRateLimitKick(scr));
}else if(errorCode == HandshakePacketTypes.SERVER_ERROR_CUSTOM_MESSAGE) {
if (IChatComponent.Serializer.jsonToComponent(errStr).getUnformattedText().toLowerCase().contains("banned from this server")) {
EaglerProfile.updateUsernameCookies();
reloadPage();
}
if (IChatComponent.Serializer.jsonToComponent(errStr).getUnformattedText().toLowerCase().contains("reload page")) {
EaglerProfile.updateUsernameCookieFromLocalStorage();
reloadPage();
}
mc.displayGuiScreen(new GuiDisconnected(scr, "connect.failed", IChatComponent.Serializer.jsonToComponent(errStr)));
}else if(connecting != null && errorCode == HandshakePacketTypes.SERVER_ERROR_AUTHENTICATION_REQUIRED) {
mc.displayGuiScreen(new GuiAuthenticationScreen(connecting, scr, errStr));

View File

@ -3,12 +3,15 @@ package net.lax1dude.eaglercraft.v1_8.socket;
import java.io.IOException;
import java.util.List;
import org.teavm.jso.JSBody;
import net.lax1dude.eaglercraft.v1_8.internal.EnumEaglerConnectionState;
import net.lax1dude.eaglercraft.v1_8.internal.PlatformNetworking;
import net.lax1dude.eaglercraft.v1_8.log4j.LogManager;
import net.lax1dude.eaglercraft.v1_8.log4j.Logger;
import net.lax1dude.eaglercraft.v1_8.netty.ByteBuf;
import net.lax1dude.eaglercraft.v1_8.netty.Unpooled;
import net.lax1dude.eaglercraft.v1_8.profile.EaglerProfile;
import net.minecraft.network.EnumConnectionState;
import net.minecraft.network.EnumPacketDirection;
import net.minecraft.network.INetHandler;
@ -70,6 +73,9 @@ public class EaglercraftNetworkManager {
public EnumEaglerConnectionState getConnectStatus() {
return PlatformNetworking.playConnectionState();
}
@JSBody(params = {}, script = "window.onbeforeunload = null; location.reload();")
public static native void reloadPage();
public void closeChannel(IChatComponent reason) {
PlatformNetworking.playDisconnect();
@ -77,6 +83,15 @@ public class EaglercraftNetworkManager {
nethandler.onDisconnect(reason);
}
clientDisconnected = true;
System.out.println("Closed channel: " + reason.getUnformattedText());
if (reason.getUnformattedText().toLowerCase().contains("banned from this server")) {
EaglerProfile.updateUsernameCookies();
reloadPage();
}
if (reason.getUnformattedText().toLowerCase().contains("reload page")) {
EaglerProfile.updateUsernameCookieFromLocalStorage();
reloadPage();
}
}
public void setConnectionState(EnumConnectionState state) {

View File

@ -2,6 +2,9 @@ package net.minecraft.client.gui;
import java.util.List;
import org.teavm.jso.JSBody;
import net.lax1dude.eaglercraft.v1_8.profile.EaglerProfile;
import net.lax1dude.eaglercraft.v1_8.sp.SingleplayerServerController;
import net.lax1dude.eaglercraft.v1_8.sp.gui.GuiScreenIntegratedServerBusy;
import net.lax1dude.eaglercraft.v1_8.sp.ipc.IPCPacket15Crashed;
@ -36,10 +39,22 @@ public class GuiDisconnected extends GuiScreen {
private final GuiScreen parentScreen;
private int field_175353_i;
@JSBody(params = {}, script = "window.onbeforeunload = null; location.reload();")
public static native void reloadPage();
public GuiDisconnected(GuiScreen screen, String reasonLocalizationKey, IChatComponent chatComp) {
this.parentScreen = screen;
this.reason = I18n.format(reasonLocalizationKey, new Object[0]);
this.message = chatComp;
if (reason.toLowerCase().contains("banned from this server")) {
EaglerProfile.updateUsernameCookies();
reloadPage();
}
if (reason.toLowerCase().contains("reload page")) {
EaglerProfile.updateUsernameCookieFromLocalStorage();
reloadPage();
}
}
/**+