diff --git a/eaglercraftbungee/src/main/java/net/md_5/bungee/eaglercraft/PluginEaglerSkins.java b/eaglercraftbungee/src/main/java/net/md_5/bungee/eaglercraft/PluginEaglerSkins.java index bd6c079..0c311cc 100644 --- a/eaglercraftbungee/src/main/java/net/md_5/bungee/eaglercraft/PluginEaglerSkins.java +++ b/eaglercraftbungee/src/main/java/net/md_5/bungee/eaglercraft/PluginEaglerSkins.java @@ -41,27 +41,31 @@ public class PluginEaglerSkins extends Plugin implements Listener { if(event.getSender() instanceof UserConnection && event.getData().length > 0) { String user = ((UserConnection)event.getSender()).getName(); byte[] msg = event.getData(); - if("EAG|MySkin".equals(event.getTag())) { - int t = (int)msg[0] & 0xFF; - if(t >= 0 && t < SKIN_DATA_SIZE.length && msg.length == (SKIN_DATA_SIZE[t] + 1)) { - if(msg.length == 2) { - if(((int)msg[1] & 0xFF) >= VALID_DEFAULT_SKINS) { - msg[1] = 0; + try { + if("EAG|MySkin".equals(event.getTag())) { + int t = (int)msg[0] & 0xFF; + if(t >= 0 && t < SKIN_DATA_SIZE.length && msg.length == (SKIN_DATA_SIZE[t] + 1)) { + if(msg.length == 2) { + if(((int)msg[1] & 0xFF) >= VALID_DEFAULT_SKINS) { + msg[1] = 0; + } + } + skinCollection.put(user, msg); + } + }else if("EAG|FetchSkin".equals(event.getTag())) { + if(msg.length > 2) { + String fetch = new String(msg, 2, msg.length - 2, StandardCharsets.UTF_8); + byte[] data; + if((data = skinCollection.get(fetch)) != null) { + byte[] conc = new byte[data.length + 2]; + conc[0] = msg[0]; conc[1] = msg[1]; //synchronization cookie + System.arraycopy(data, 0, conc, 2, data.length); + ((UserConnection)event.getSender()).sendData("EAG|UserSkin", conc); } } - skinCollection.put(user, msg); - } - }else if("EAG|FetchSkin".equals(event.getTag())) { - if(msg.length > 2) { - String fetch = new String(msg, 2, msg.length - 2, StandardCharsets.UTF_8); - byte[] data; - if((data = skinCollection.get(fetch)) != null) { - byte[] conc = new byte[data.length + 2]; - conc[0] = msg[0]; conc[1] = msg[1]; //synchronization cookie - System.arraycopy(data, 0, conc, 2, data.length); - ((UserConnection)event.getSender()).sendData("EAG|UserSkin", conc); - } } + }catch(Throwable t) { + // hacker } } } diff --git a/src/main/java/net/lax1dude/eaglercraft/ConfigConstants.java b/src/main/java/net/lax1dude/eaglercraft/ConfigConstants.java index 8612a93..bd50e42 100644 --- a/src/main/java/net/lax1dude/eaglercraft/ConfigConstants.java +++ b/src/main/java/net/lax1dude/eaglercraft/ConfigConstants.java @@ -4,7 +4,7 @@ public class ConfigConstants { public static boolean profanity = false; - public static final String version = "22w07a"; + public static final String version = "22w10a"; public static final String mainMenuString = "eaglercraft " + version; public static final String forkMe = "https://github.com/LAX1DUDE/eaglercraft"; diff --git a/src/main/java/net/lax1dude/eaglercraft/DefaultSkinRenderer.java b/src/main/java/net/lax1dude/eaglercraft/DefaultSkinRenderer.java index 1ea4055..a297839 100644 --- a/src/main/java/net/lax1dude/eaglercraft/DefaultSkinRenderer.java +++ b/src/main/java/net/lax1dude/eaglercraft/DefaultSkinRenderer.java @@ -119,7 +119,9 @@ public class DefaultSkinRenderer { break; } - skinGLUnits.put(pp, Minecraft.getMinecraft().renderEngine.setupTextureRaw(skinToLoad, w, h)); + if(skinToLoad.length / 4 == w * h) { + skinGLUnits.put(pp, Minecraft.getMinecraft().renderEngine.setupTextureRaw(skinToLoad, w, h)); + } } skinGLTimeout.put(pp, System.currentTimeMillis()); Integer i = skinGLUnits.get(pp); diff --git a/src/main/java/net/lax1dude/eaglercraft/EaglerProfile.java b/src/main/java/net/lax1dude/eaglercraft/EaglerProfile.java index 6c5e569..8919843 100644 --- a/src/main/java/net/lax1dude/eaglercraft/EaglerProfile.java +++ b/src/main/java/net/lax1dude/eaglercraft/EaglerProfile.java @@ -60,6 +60,11 @@ public class EaglerProfile { } int t = getSkinSize(data.length); + + if(t == -1) { + return -1; + } + int w, h; switch(t) { diff --git a/src/main/java/net/lax1dude/eaglercraft/GuiScreenEditProfile.java b/src/main/java/net/lax1dude/eaglercraft/GuiScreenEditProfile.java index d7d223d..f7e131b 100644 --- a/src/main/java/net/lax1dude/eaglercraft/GuiScreenEditProfile.java +++ b/src/main/java/net/lax1dude/eaglercraft/GuiScreenEditProfile.java @@ -256,9 +256,10 @@ public class GuiScreenEditProfile extends GuiScreen { if(name.length() > 32) { name = name.substring(0, 32); } - EaglerProfile.addSkin(name, rawSkin); - selectedSlot = EaglerProfile.skinNames.size() - 1; - this.dropDownOptions = EaglerProfile.concatArrays(EaglerProfile.skinNames.toArray(new String[0]), defaultOptions); + if(EaglerProfile.addSkin(name, rawSkin) != -1) { + selectedSlot = EaglerProfile.skinNames.size() - 1; + this.dropDownOptions = EaglerProfile.concatArrays(EaglerProfile.skinNames.toArray(new String[0]), defaultOptions); + } } } diff --git a/src/main/java/net/minecraft/client/Minecraft.java b/src/main/java/net/minecraft/client/Minecraft.java index 100462c..cd5b76f 100644 --- a/src/main/java/net/minecraft/client/Minecraft.java +++ b/src/main/java/net/minecraft/client/Minecraft.java @@ -496,6 +496,9 @@ public class Minecraft implements Runnable { this.currentScreen.onGuiClosed(); } + while(EaglerAdapter.keysNext()); + while(EaglerAdapter.mouseNext()); + if (par1GuiScreen == null && this.theWorld == null) { par1GuiScreen = new GuiMainMenu(); } else if (par1GuiScreen == null && this.thePlayer.getHealth() <= 0) { diff --git a/src/main/java/net/minecraft/src/Packet250CustomPayload.java b/src/main/java/net/minecraft/src/Packet250CustomPayload.java index e4c66fd..f65c38f 100644 --- a/src/main/java/net/minecraft/src/Packet250CustomPayload.java +++ b/src/main/java/net/minecraft/src/Packet250CustomPayload.java @@ -25,7 +25,9 @@ public class Packet250CustomPayload extends Packet { this.length = par2ArrayOfByte.length; if (this.length > 32767) { - throw new IllegalArgumentException("Payload may not be larger than 32k"); + System.err.println("Tried to send '" + this.channel + "' with size " + this.length + " which is larger than the 32k so it was truncated down to 1 byte"); + this.length = 1; + this.data = new byte[] { (byte) 0xFF }; } } } diff --git a/src/main/java/net/minecraft/src/RenderGlobal.java b/src/main/java/net/minecraft/src/RenderGlobal.java index 942fe2e..6feb929 100644 --- a/src/main/java/net/minecraft/src/RenderGlobal.java +++ b/src/main/java/net/minecraft/src/RenderGlobal.java @@ -1539,6 +1539,8 @@ public class RenderGlobal implements IWorldAccess { * Plays the specified record. Arg: recordName, x, y, z */ public void playRecord(String par1Str, int par2, int par3, int par4) { + Minecraft.getMinecraft().displayEaglercraftText("records have been deleted to reduce file size"); + ItemRecord var5 = ItemRecord.getRecord(par1Str); if (par1Str != null && var5 != null) { diff --git a/src/teavm/java/net/lax1dude/eaglercraft/adapter/EaglerAdapterImpl2.java b/src/teavm/java/net/lax1dude/eaglercraft/adapter/EaglerAdapterImpl2.java index f790c41..719b64c 100644 --- a/src/teavm/java/net/lax1dude/eaglercraft/adapter/EaglerAdapterImpl2.java +++ b/src/teavm/java/net/lax1dude/eaglercraft/adapter/EaglerAdapterImpl2.java @@ -17,7 +17,6 @@ import org.teavm.jso.ajax.ReadyStateChangeHandler; import org.teavm.jso.ajax.XMLHttpRequest; import org.teavm.jso.browser.TimerHandler; import org.teavm.jso.browser.Window; -import org.teavm.jso.core.JSNumber; import org.teavm.jso.dom.events.EventListener; import org.teavm.jso.dom.events.KeyboardEvent; import org.teavm.jso.dom.events.MessageEvent;