thing
This commit is contained in:
parent
ece80e88ac
commit
37f2ac12ba
75623
javascript/classes.js
75623
javascript/classes.js
File diff suppressed because it is too large
Load Diff
|
@ -14,10 +14,30 @@
|
||||||
<script type="text/javascript" src="classes.js"></script>
|
<script type="text/javascript" src="classes.js"></script>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
"use strict";
|
"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", () => {
|
window.addEventListener("load", () => {
|
||||||
if(document.location.href.startsWith("file:")) {
|
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");
|
alert("HTTP please, do not open this file locally, run a local HTTP server and load it via HTTP");
|
||||||
}else {
|
}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:";
|
const isHttps = document.location.protocol === "https:";
|
||||||
var serverURL = isHttps ? "wss://" : "ws://";
|
var serverURL = isHttps ? "wss://" : "ws://";
|
||||||
serverURL += document.location.host + "/";
|
serverURL += document.location.host + "/";
|
||||||
|
|
|
@ -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';")
|
@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);
|
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) {
|
public static void read(byte[] profileStorage) {
|
||||||
if (profileStorage == null) {
|
if (profileStorage == null) {
|
||||||
return;
|
return;
|
||||||
|
@ -178,7 +199,7 @@ public class EaglerProfile {
|
||||||
|
|
||||||
if(!loadUsername.isEmpty()) {
|
if(!loadUsername.isEmpty()) {
|
||||||
username = loadUsername.replaceAll("[^A-Za-z0-9]", "_");
|
username = loadUsername.replaceAll("[^A-Za-z0-9]", "_");
|
||||||
setCookie("username", username);
|
updateUsernameCookies();
|
||||||
}
|
}
|
||||||
|
|
||||||
clearCustomSkins();
|
clearCustomSkins();
|
||||||
|
|
|
@ -5,6 +5,8 @@ import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
|
import org.teavm.jso.JSBody;
|
||||||
|
|
||||||
import net.lax1dude.eaglercraft.v1_8.ArrayUtils;
|
import net.lax1dude.eaglercraft.v1_8.ArrayUtils;
|
||||||
import net.lax1dude.eaglercraft.v1_8.EaglerInputStream;
|
import net.lax1dude.eaglercraft.v1_8.EaglerInputStream;
|
||||||
import net.lax1dude.eaglercraft.v1_8.EaglerOutputStream;
|
import net.lax1dude.eaglercraft.v1_8.EaglerOutputStream;
|
||||||
|
@ -378,6 +380,9 @@ public class ConnectionHandshake {
|
||||||
return b;
|
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 {
|
private static void showError(Minecraft mc, GuiConnecting connecting, GuiScreen scr, DataInputStream err, boolean v2) throws IOException {
|
||||||
int errorCode = err.read();
|
int errorCode = err.read();
|
||||||
int msgLen = v2 ? err.read() : err.readUnsignedShort();
|
int msgLen = v2 ? err.read() : err.readUnsignedShort();
|
||||||
|
@ -392,6 +397,14 @@ public class ConnectionHandshake {
|
||||||
RateLimitTracker.registerLockOut(PlatformNetworking.getCurrentURI());
|
RateLimitTracker.registerLockOut(PlatformNetworking.getCurrentURI());
|
||||||
mc.displayGuiScreen(GuiDisconnected.createRateLimitKick(scr));
|
mc.displayGuiScreen(GuiDisconnected.createRateLimitKick(scr));
|
||||||
}else if(errorCode == HandshakePacketTypes.SERVER_ERROR_CUSTOM_MESSAGE) {
|
}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)));
|
mc.displayGuiScreen(new GuiDisconnected(scr, "connect.failed", IChatComponent.Serializer.jsonToComponent(errStr)));
|
||||||
}else if(connecting != null && errorCode == HandshakePacketTypes.SERVER_ERROR_AUTHENTICATION_REQUIRED) {
|
}else if(connecting != null && errorCode == HandshakePacketTypes.SERVER_ERROR_AUTHENTICATION_REQUIRED) {
|
||||||
mc.displayGuiScreen(new GuiAuthenticationScreen(connecting, scr, errStr));
|
mc.displayGuiScreen(new GuiAuthenticationScreen(connecting, scr, errStr));
|
||||||
|
|
|
@ -3,12 +3,15 @@ package net.lax1dude.eaglercraft.v1_8.socket;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.teavm.jso.JSBody;
|
||||||
|
|
||||||
import net.lax1dude.eaglercraft.v1_8.internal.EnumEaglerConnectionState;
|
import net.lax1dude.eaglercraft.v1_8.internal.EnumEaglerConnectionState;
|
||||||
import net.lax1dude.eaglercraft.v1_8.internal.PlatformNetworking;
|
import net.lax1dude.eaglercraft.v1_8.internal.PlatformNetworking;
|
||||||
import net.lax1dude.eaglercraft.v1_8.log4j.LogManager;
|
import net.lax1dude.eaglercraft.v1_8.log4j.LogManager;
|
||||||
import net.lax1dude.eaglercraft.v1_8.log4j.Logger;
|
import net.lax1dude.eaglercraft.v1_8.log4j.Logger;
|
||||||
import net.lax1dude.eaglercraft.v1_8.netty.ByteBuf;
|
import net.lax1dude.eaglercraft.v1_8.netty.ByteBuf;
|
||||||
import net.lax1dude.eaglercraft.v1_8.netty.Unpooled;
|
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.EnumConnectionState;
|
||||||
import net.minecraft.network.EnumPacketDirection;
|
import net.minecraft.network.EnumPacketDirection;
|
||||||
import net.minecraft.network.INetHandler;
|
import net.minecraft.network.INetHandler;
|
||||||
|
@ -71,12 +74,24 @@ public class EaglercraftNetworkManager {
|
||||||
return PlatformNetworking.playConnectionState();
|
return PlatformNetworking.playConnectionState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JSBody(params = {}, script = "window.onbeforeunload = null; location.reload();")
|
||||||
|
public static native void reloadPage();
|
||||||
|
|
||||||
public void closeChannel(IChatComponent reason) {
|
public void closeChannel(IChatComponent reason) {
|
||||||
PlatformNetworking.playDisconnect();
|
PlatformNetworking.playDisconnect();
|
||||||
if(nethandler != null) {
|
if(nethandler != null) {
|
||||||
nethandler.onDisconnect(reason);
|
nethandler.onDisconnect(reason);
|
||||||
}
|
}
|
||||||
clientDisconnected = true;
|
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) {
|
public void setConnectionState(EnumConnectionState state) {
|
||||||
|
|
|
@ -2,6 +2,9 @@ package net.minecraft.client.gui;
|
||||||
|
|
||||||
import java.util.List;
|
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.SingleplayerServerController;
|
||||||
import net.lax1dude.eaglercraft.v1_8.sp.gui.GuiScreenIntegratedServerBusy;
|
import net.lax1dude.eaglercraft.v1_8.sp.gui.GuiScreenIntegratedServerBusy;
|
||||||
import net.lax1dude.eaglercraft.v1_8.sp.ipc.IPCPacket15Crashed;
|
import net.lax1dude.eaglercraft.v1_8.sp.ipc.IPCPacket15Crashed;
|
||||||
|
@ -36,10 +39,22 @@ public class GuiDisconnected extends GuiScreen {
|
||||||
private final GuiScreen parentScreen;
|
private final GuiScreen parentScreen;
|
||||||
private int field_175353_i;
|
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) {
|
public GuiDisconnected(GuiScreen screen, String reasonLocalizationKey, IChatComponent chatComp) {
|
||||||
this.parentScreen = screen;
|
this.parentScreen = screen;
|
||||||
this.reason = I18n.format(reasonLocalizationKey, new Object[0]);
|
this.reason = I18n.format(reasonLocalizationKey, new Object[0]);
|
||||||
this.message = chatComp;
|
this.message = chatComp;
|
||||||
|
if (reason.toLowerCase().contains("banned from this server")) {
|
||||||
|
EaglerProfile.updateUsernameCookies();
|
||||||
|
reloadPage();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (reason.toLowerCase().contains("reload page")) {
|
||||||
|
EaglerProfile.updateUsernameCookieFromLocalStorage();
|
||||||
|
reloadPage();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**+
|
/**+
|
||||||
|
|
Loading…
Reference in New Issue