Merge branch 'main' of https://github.com/lax1dude/eaglercraft-nope-lol
This commit is contained in:
commit
5918b23f14
|
@ -2010,4 +2010,16 @@ public class EaglerAdapterImpl2 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static final boolean immediateContinueSupported() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final void immediateContinue() {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final List<LANPeerEvent> serverLANGetAllEvent(String clientId) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,80 @@
|
||||||
|
package net.lax1dude.eaglercraft.adapter.vfs;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
public class VFile extends File {
|
||||||
|
|
||||||
|
public VFile(String pathname) {
|
||||||
|
super(pathname);
|
||||||
|
}
|
||||||
|
|
||||||
|
public VFile(String parent, String child) {
|
||||||
|
super(parent, child);
|
||||||
|
}
|
||||||
|
|
||||||
|
public VFile(File parent, String child) {
|
||||||
|
super(parent, child);
|
||||||
|
}
|
||||||
|
|
||||||
|
public VFile(String parent, String child, String child2) {
|
||||||
|
super(new VFile(parent, child), child2);
|
||||||
|
}
|
||||||
|
|
||||||
|
public InputStream getInputStream() {
|
||||||
|
try {
|
||||||
|
return Files.newInputStream(this.toPath());
|
||||||
|
} catch (IOException e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String[] getAllLines() {
|
||||||
|
try {
|
||||||
|
return Files.readAllLines(this.toPath(), StandardCharsets.UTF_8).toArray(new String[0]);
|
||||||
|
} catch (IOException e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAllChars() {
|
||||||
|
try {
|
||||||
|
return Files.readString(this.toPath(), StandardCharsets.UTF_8);
|
||||||
|
} catch (IOException e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean setAllChars(String chars) {
|
||||||
|
return setAllBytes(chars.getBytes(StandardCharsets.UTF_8));
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean setAllBytes(byte[] bytes) {
|
||||||
|
try {
|
||||||
|
if (this.getParentFile() != null) {
|
||||||
|
this.getParentFile().mkdirs();
|
||||||
|
}
|
||||||
|
Files.write(this.toPath(), bytes);
|
||||||
|
return true;
|
||||||
|
} catch (IOException e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int deleteAll() {
|
||||||
|
try (Stream<Path> pathStream = Files.walk(this.toPath())) {
|
||||||
|
pathStream.sorted(Comparator.reverseOrder())
|
||||||
|
.map(Path::toFile)
|
||||||
|
.forEach(File::delete);
|
||||||
|
return 1;
|
||||||
|
} catch (IOException e) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -3,8 +3,7 @@ package net.minecraft.src;
|
||||||
import net.lax1dude.eaglercraft.EPKDecompiler;
|
import net.lax1dude.eaglercraft.EPKDecompiler;
|
||||||
import net.lax1dude.eaglercraft.EaglerAdapter;
|
import net.lax1dude.eaglercraft.EaglerAdapter;
|
||||||
import net.lax1dude.eaglercraft.EaglerInputStream;
|
import net.lax1dude.eaglercraft.EaglerInputStream;
|
||||||
import net.lax1dude.eaglercraft.EaglerMisc;
|
import net.lax1dude.eaglercraft.adapter.vfs.VFile;
|
||||||
import net.lax1dude.eaglercraft.adapter.teavm.vfs.VFile;
|
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -28,6 +27,8 @@ public class GuiTexturePacks extends GuiScreen {
|
||||||
private GuiTexturePackSlot guiTexturePackSlot;
|
private GuiTexturePackSlot guiTexturePackSlot;
|
||||||
private GameSettings field_96146_n;
|
private GameSettings field_96146_n;
|
||||||
|
|
||||||
|
protected static final VFile texturePackListFile = new VFile("__LIST__");
|
||||||
|
|
||||||
public GuiTexturePacks(GuiScreen par1, GameSettings par2) {
|
public GuiTexturePacks(GuiScreen par1, GameSettings par2) {
|
||||||
this.guiScreen = par1;
|
this.guiScreen = par1;
|
||||||
this.field_96146_n = par2;
|
this.field_96146_n = par2;
|
||||||
|
@ -107,6 +108,11 @@ public class GuiTexturePacks extends GuiScreen {
|
||||||
isSelectingPack = false;
|
isSelectingPack = false;
|
||||||
String name = EaglerAdapter.getFileChooserResultName();
|
String name = EaglerAdapter.getFileChooserResultName();
|
||||||
String safeName = name.replaceAll("[^A-Za-z0-9_]", "_");
|
String safeName = name.replaceAll("[^A-Za-z0-9_]", "_");
|
||||||
|
if (texturePackListFile.exists()) {
|
||||||
|
texturePackListFile.setAllChars(texturePackListFile.getAllChars() + "\n" + safeName);
|
||||||
|
} else {
|
||||||
|
texturePackListFile.setAllChars(safeName);
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
if (name.toLowerCase().endsWith(".zip")) {
|
if (name.toLowerCase().endsWith(".zip")) {
|
||||||
try(ZipInputStream zipInputStream = new ZipInputStream(new ByteArrayInputStream(EaglerAdapter.getFileChooserResult()))) {
|
try(ZipInputStream zipInputStream = new ZipInputStream(new ByteArrayInputStream(EaglerAdapter.getFileChooserResult()))) {
|
||||||
|
@ -138,10 +144,19 @@ public class GuiTexturePacks extends GuiScreen {
|
||||||
List var3 = this.mc.texturePackList.availableTexturePacks();
|
List var3 = this.mc.texturePackList.availableTexturePacks();
|
||||||
|
|
||||||
if (par1) {
|
if (par1) {
|
||||||
new VFile(fileLocation, ((ITexturePack) var3.get(par2)).getTexturePackFileName()).deleteAll();
|
|
||||||
this.mc.texturePackList.setTexturePack((ITexturePack) var3.get(0));
|
this.mc.texturePackList.setTexturePack((ITexturePack) var3.get(0));
|
||||||
this.mc.renderEngine.refreshTextures();
|
this.mc.renderEngine.refreshTextures();
|
||||||
this.mc.renderGlobal.loadRenderers();
|
this.mc.renderGlobal.loadRenderers();
|
||||||
|
String safeName = ((ITexturePack) var3.get(par2)).getTexturePackFileName();
|
||||||
|
new VFile(fileLocation, safeName).deleteAll();
|
||||||
|
if (texturePackListFile.exists()) {
|
||||||
|
String res = texturePackListFile.getAllChars().replaceFirst(safeName, "").replace("\n\n", "\n");
|
||||||
|
if (res.isEmpty()) {
|
||||||
|
texturePackListFile.delete();
|
||||||
|
} else {
|
||||||
|
texturePackListFile.setAllChars(res);
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
this.mc.texturePackList.setTexturePack((ITexturePack) var3.get(par2));
|
this.mc.texturePackList.setTexturePack((ITexturePack) var3.get(par2));
|
||||||
|
@ -152,7 +167,16 @@ public class GuiTexturePacks extends GuiScreen {
|
||||||
this.mc.texturePackList.setTexturePack((ITexturePack) var3.get(0));
|
this.mc.texturePackList.setTexturePack((ITexturePack) var3.get(0));
|
||||||
this.mc.renderEngine.refreshTextures();
|
this.mc.renderEngine.refreshTextures();
|
||||||
this.mc.renderGlobal.loadRenderers();
|
this.mc.renderGlobal.loadRenderers();
|
||||||
new VFile(fileLocation, ((ITexturePack) var3.get(par2)).getTexturePackFileName()).deleteAll();
|
String safeName = ((ITexturePack) var3.get(par2)).getTexturePackFileName();
|
||||||
|
new VFile(fileLocation, safeName).deleteAll();
|
||||||
|
if (texturePackListFile.exists()) {
|
||||||
|
String res = texturePackListFile.getAllChars().replaceFirst(safeName, "").replace("\n\n", "\n");
|
||||||
|
if (res.isEmpty()) {
|
||||||
|
texturePackListFile.delete();
|
||||||
|
} else {
|
||||||
|
texturePackListFile.setAllChars(res);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package net.minecraft.src;
|
package net.minecraft.src;
|
||||||
|
|
||||||
import net.lax1dude.eaglercraft.adapter.teavm.vfs.VFile;
|
import net.lax1dude.eaglercraft.adapter.vfs.VFile;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
|
|
@ -8,8 +8,7 @@ import java.io.InputStreamReader;
|
||||||
import net.lax1dude.eaglercraft.EaglerAdapter;
|
import net.lax1dude.eaglercraft.EaglerAdapter;
|
||||||
import net.lax1dude.eaglercraft.EaglerImage;
|
import net.lax1dude.eaglercraft.EaglerImage;
|
||||||
import net.lax1dude.eaglercraft.EaglerInputStream;
|
import net.lax1dude.eaglercraft.EaglerInputStream;
|
||||||
import net.lax1dude.eaglercraft.EaglerMisc;
|
import net.lax1dude.eaglercraft.adapter.vfs.VFile;
|
||||||
import net.lax1dude.eaglercraft.adapter.teavm.vfs.VFile;
|
|
||||||
|
|
||||||
public abstract class TexturePackImplementation implements ITexturePack
|
public abstract class TexturePackImplementation implements ITexturePack
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,14 +1,20 @@
|
||||||
package net.minecraft.src;
|
package net.minecraft.src;
|
||||||
|
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.zip.ZipEntry;
|
||||||
|
import java.util.zip.ZipInputStream;
|
||||||
|
|
||||||
import net.lax1dude.eaglercraft.EaglerProfile;
|
import net.lax1dude.eaglercraft.EPKDecompiler;
|
||||||
import net.lax1dude.eaglercraft.adapter.teavm.vfs.VFile;
|
import net.lax1dude.eaglercraft.EaglerAdapter;
|
||||||
|
import net.lax1dude.eaglercraft.EaglerInputStream;
|
||||||
|
import net.lax1dude.eaglercraft.adapter.vfs.VFile;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
|
|
||||||
public class TexturePackList
|
public class TexturePackList
|
||||||
|
@ -47,6 +53,7 @@ public class TexturePackList
|
||||||
this.mc = par2Minecraft;
|
this.mc = par2Minecraft;
|
||||||
this.texturePackDir = new VFile("texturepacks");
|
this.texturePackDir = new VFile("texturepacks");
|
||||||
this.mpTexturePackFolder = new VFile("texturepacks-mp-cache");
|
this.mpTexturePackFolder = new VFile("texturepacks-mp-cache");
|
||||||
|
this.mpTexturePackFolder.deleteAll();
|
||||||
this.updateAvaliableTexturePacks();
|
this.updateAvaliableTexturePacks();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,26 +88,41 @@ public class TexturePackList
|
||||||
var2 = var2.substring(0, var2.indexOf("?"));
|
var2 = var2.substring(0, var2.indexOf("?"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (var2.endsWith(".zip"))
|
if (var2.toLowerCase().endsWith(".zip") || var2.toLowerCase().endsWith(".epk"))
|
||||||
{
|
{
|
||||||
VFile var3 = new VFile(this.mpTexturePackFolder, var2);
|
VFile var3 = new VFile(this.mpTexturePackFolder, var2.replaceAll("[^A-Za-z0-9_]", "_"));
|
||||||
this.downloadTexture(par1Str, var3);
|
this.downloadTexture(par1Str, var3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void downloadTexture(String par1Str, VFile par2File)
|
private void downloadTexture(String par1Str, VFile par2File)
|
||||||
{
|
{
|
||||||
HashMap var3 = new HashMap();
|
|
||||||
GuiProgress var4 = new GuiProgress();
|
|
||||||
var3.put("X-Minecraft-Username", EaglerProfile.username);
|
|
||||||
var3.put("X-Minecraft-Version", "1.5.2");
|
|
||||||
var3.put("X-Minecraft-Supported-Resolutions", "16");
|
|
||||||
this.isDownloading = true;
|
this.isDownloading = true;
|
||||||
this.mc.displayGuiScreen(var4);
|
try {
|
||||||
// todo: extract epk/zip to VFS, activate, and signal success
|
byte[] data = EaglerAdapter.downloadURL(par1Str);
|
||||||
onDownloadFinished(); // temp
|
if (data == null) throw new IOException("Unable to download texture pack!");
|
||||||
// SimpleStorage.set(par2File.replaceAll("[^A-Za-z0-9_]", "_"), par2File.toLowerCase().endsWith(".zip") ? zipToEpk(EaglerAdapter.downloadURL(par1Str)) : EaglerAdapter.downloadURL(par1Str));
|
if (par2File.getName().toLowerCase().endsWith(".epk")) {
|
||||||
// HttpUtil.downloadTexturePack(par2File, par1Str, new TexturePackDownloadSuccess(this), var3, 10000000, var4);
|
EPKDecompiler epkDecompiler = new EPKDecompiler(data);
|
||||||
|
EPKDecompiler.FileEntry file;
|
||||||
|
while ((file = epkDecompiler.readFile()) != null) {
|
||||||
|
new VFile(par2File, file.name).setAllBytes(file.data);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
try(ZipInputStream zipInputStream = new ZipInputStream(new ByteArrayInputStream(data))) {
|
||||||
|
ZipEntry entry;
|
||||||
|
while ((entry = zipInputStream.getNextEntry()) != null) {
|
||||||
|
if (entry.isDirectory()) continue;
|
||||||
|
new VFile(par2File, entry.getName()).setAllBytes(EaglerInputStream.inputStreamToBytesNoClose(zipInputStream));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
if (this.isDownloading) {
|
||||||
|
setSelectedTexturePack(this, new TexturePackFolder(TexturePackList.generateTexturePackID(this, par2File), par2File, defaultTexturePack));
|
||||||
|
this.mc.scheduleTexturePackRefresh();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -183,20 +205,12 @@ public class TexturePackList
|
||||||
*/
|
*/
|
||||||
private List getTexturePackDirContents()
|
private List getTexturePackDirContents()
|
||||||
{
|
{
|
||||||
// TODO: MAKE THIS MORE EFFICIENT!! THIS IS A TEMPORARY FIX BC IM TIRED
|
if (!GuiTexturePacks.texturePackListFile.exists()) return Collections.emptyList();
|
||||||
List<String> strings = this.texturePackDir.list();
|
String[] lines = GuiTexturePacks.texturePackListFile.getAllLines();
|
||||||
List<String> strings2 = new ArrayList<>();
|
|
||||||
List<VFile> files = new ArrayList<>();
|
List<VFile> files = new ArrayList<>();
|
||||||
for (String name : strings) {
|
for (String line : lines) {
|
||||||
name = name.substring(this.texturePackDir.getPath().length() + 1);
|
files.add(new VFile(this.texturePackDir, line));
|
||||||
name = name.substring(0, name.indexOf('/'));
|
|
||||||
name = this.texturePackDir.getPath() + "/" + name;
|
|
||||||
if (strings2.contains(name)) continue;
|
|
||||||
strings2.add(name);
|
|
||||||
files.add(new VFile(name));
|
|
||||||
}
|
}
|
||||||
strings2.clear();
|
|
||||||
strings.clear();
|
|
||||||
return files;
|
return files;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package net.lax1dude.eaglercraft.adapter.teavm.vfs;
|
package net.lax1dude.eaglercraft.adapter.vfs;
|
||||||
|
|
||||||
public class BooleanResult {
|
public class BooleanResult {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package net.lax1dude.eaglercraft.adapter.teavm.vfs;
|
package net.lax1dude.eaglercraft.adapter.vfs;
|
||||||
|
|
||||||
public class SYS {
|
public class SYS {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package net.lax1dude.eaglercraft.adapter.teavm.vfs;
|
package net.lax1dude.eaglercraft.adapter.vfs;
|
||||||
|
|
||||||
public interface VFSIterator {
|
public interface VFSIterator {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package net.lax1dude.eaglercraft.adapter.teavm.vfs;
|
package net.lax1dude.eaglercraft.adapter.vfs;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
|
@ -1,4 +1,4 @@
|
||||||
package net.lax1dude.eaglercraft.adapter.teavm.vfs;
|
package net.lax1dude.eaglercraft.adapter.vfs;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
|
@ -1,6 +1,5 @@
|
||||||
package net.lax1dude.eaglercraft.adapter.teavm.vfs;
|
package net.lax1dude.eaglercraft.adapter.vfs;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
Loading…
Reference in New Issue
Block a user