reformatted some singleplayer classes
This commit is contained in:
parent
7d0bf17586
commit
efcf5f8e77
|
@ -1,41 +1,39 @@
|
||||||
package net.lax1dude.eaglercraft.sp;
|
package net.lax1dude.eaglercraft.sp;
|
||||||
|
|
||||||
import org.teavm.classlib.java.util.zip.TChecksum;
|
|
||||||
|
|
||||||
import java.util.zip.Checksum;
|
import java.util.zip.Checksum;
|
||||||
|
|
||||||
public class CRC32 implements Checksum {
|
public class CRC32 implements Checksum {
|
||||||
private com.jcraft.jzlib.CRC32 impl = new com.jcraft.jzlib.CRC32();
|
private com.jcraft.jzlib.CRC32 impl = new com.jcraft.jzlib.CRC32();
|
||||||
long tbytes;
|
long tbytes;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getValue() {
|
public long getValue() {
|
||||||
return impl.getValue();
|
return impl.getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void reset() {
|
public void reset() {
|
||||||
impl.reset();
|
impl.reset();
|
||||||
tbytes = 0;
|
tbytes = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(int val) {
|
public void update(int val) {
|
||||||
impl.update(new byte[] { (byte) val }, 0, 1);
|
impl.update(new byte[] { (byte) val }, 0, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update(byte[] buf) {
|
public void update(byte[] buf) {
|
||||||
update(buf, 0, buf.length);
|
update(buf, 0, buf.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(byte[] buf, int off, int nbytes) {
|
public void update(byte[] buf, int off, int nbytes) {
|
||||||
// avoid int overflow, check null buf
|
// avoid int overflow, check null buf
|
||||||
if (off <= buf.length && nbytes >= 0 && off >= 0 && buf.length - off >= nbytes) {
|
if (off <= buf.length && nbytes >= 0 && off >= 0 && buf.length - off >= nbytes) {
|
||||||
impl.update(buf, off, nbytes);
|
impl.update(buf, off, nbytes);
|
||||||
tbytes += nbytes;
|
tbytes += nbytes;
|
||||||
} else {
|
} else {
|
||||||
throw new ArrayIndexOutOfBoundsException();
|
throw new ArrayIndexOutOfBoundsException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,16 +12,39 @@ import java.util.Map;
|
||||||
import java.util.zip.ZipEntry;
|
import java.util.zip.ZipEntry;
|
||||||
import java.util.zip.ZipInputStream;
|
import java.util.zip.ZipInputStream;
|
||||||
|
|
||||||
import net.minecraft.src.ChunkCoordIntPair;
|
|
||||||
import org.teavm.jso.JSBody;
|
import org.teavm.jso.JSBody;
|
||||||
import org.teavm.jso.JSFunctor;
|
import org.teavm.jso.JSFunctor;
|
||||||
import org.teavm.jso.JSObject;
|
import org.teavm.jso.JSObject;
|
||||||
import org.teavm.jso.typedarrays.ArrayBuffer;
|
import org.teavm.jso.typedarrays.ArrayBuffer;
|
||||||
import org.teavm.jso.typedarrays.Uint8Array;
|
import org.teavm.jso.typedarrays.Uint8Array;
|
||||||
|
|
||||||
import net.lax1dude.eaglercraft.sp.ipc.*;
|
import net.lax1dude.eaglercraft.sp.ipc.IPCPacket00StartServer;
|
||||||
|
import net.lax1dude.eaglercraft.sp.ipc.IPCPacket01StopServer;
|
||||||
|
import net.lax1dude.eaglercraft.sp.ipc.IPCPacket02InitWorld;
|
||||||
|
import net.lax1dude.eaglercraft.sp.ipc.IPCPacket03DeleteWorld;
|
||||||
|
import net.lax1dude.eaglercraft.sp.ipc.IPCPacket04RenameWorld;
|
||||||
|
import net.lax1dude.eaglercraft.sp.ipc.IPCPacket05RequestData;
|
||||||
|
import net.lax1dude.eaglercraft.sp.ipc.IPCPacket06RenameWorldNBT;
|
||||||
|
import net.lax1dude.eaglercraft.sp.ipc.IPCPacket07ImportWorld;
|
||||||
|
import net.lax1dude.eaglercraft.sp.ipc.IPCPacket09RequestResponse;
|
||||||
|
import net.lax1dude.eaglercraft.sp.ipc.IPCPacket0ASetWorldDifficulty;
|
||||||
|
import net.lax1dude.eaglercraft.sp.ipc.IPCPacket0BPause;
|
||||||
|
import net.lax1dude.eaglercraft.sp.ipc.IPCPacket0CPlayerChannel;
|
||||||
|
import net.lax1dude.eaglercraft.sp.ipc.IPCPacket0DProgressUpdate;
|
||||||
|
import net.lax1dude.eaglercraft.sp.ipc.IPCPacket0EListWorlds;
|
||||||
|
import net.lax1dude.eaglercraft.sp.ipc.IPCPacket0FListFiles;
|
||||||
|
import net.lax1dude.eaglercraft.sp.ipc.IPCPacket10FileRead;
|
||||||
|
import net.lax1dude.eaglercraft.sp.ipc.IPCPacket12FileWrite;
|
||||||
|
import net.lax1dude.eaglercraft.sp.ipc.IPCPacket13FileCopyMove;
|
||||||
|
import net.lax1dude.eaglercraft.sp.ipc.IPCPacket14StringList;
|
||||||
|
import net.lax1dude.eaglercraft.sp.ipc.IPCPacket15ThrowException;
|
||||||
|
import net.lax1dude.eaglercraft.sp.ipc.IPCPacket16NBTList;
|
||||||
|
import net.lax1dude.eaglercraft.sp.ipc.IPCPacketBase;
|
||||||
|
import net.lax1dude.eaglercraft.sp.ipc.IPCPacketFFProcessKeepAlive;
|
||||||
|
import net.lax1dude.eaglercraft.sp.ipc.IPCPacketManager;
|
||||||
import net.minecraft.src.AchievementList;
|
import net.minecraft.src.AchievementList;
|
||||||
import net.minecraft.src.AchievementMap;
|
import net.minecraft.src.AchievementMap;
|
||||||
|
import net.minecraft.src.ChunkCoordIntPair;
|
||||||
import net.minecraft.src.CompressedStreamTools;
|
import net.minecraft.src.CompressedStreamTools;
|
||||||
import net.minecraft.src.EnumGameType;
|
import net.minecraft.src.EnumGameType;
|
||||||
import net.minecraft.src.ILogAgent;
|
import net.minecraft.src.ILogAgent;
|
||||||
|
|
|
@ -5,165 +5,179 @@ import java.io.ByteArrayOutputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
|
|
||||||
import com.jcraft.jzlib.DeflaterOutputStream;
|
|
||||||
import com.jcraft.jzlib.GZIPInputStream;
|
|
||||||
import com.jcraft.jzlib.GZIPOutputStream;
|
|
||||||
import net.minecraft.src.ChunkCoordIntPair;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.zip.InflaterInputStream;
|
import java.util.zip.InflaterInputStream;
|
||||||
|
|
||||||
|
import com.jcraft.jzlib.DeflaterOutputStream;
|
||||||
|
import com.jcraft.jzlib.GZIPInputStream;
|
||||||
|
import com.jcraft.jzlib.GZIPOutputStream;
|
||||||
|
|
||||||
|
import net.minecraft.src.ChunkCoordIntPair;
|
||||||
|
|
||||||
public class MCAConverter {
|
public class MCAConverter {
|
||||||
public static void convertFromMCA(VFile dir, byte[] file, String fileName) {
|
public static void convertFromMCA(VFile dir, byte[] file, String fileName) {
|
||||||
VFile levelDir = new VFile(dir, "level" + (fileName.startsWith("region/") ? "0" : fileName.substring(3, fileName.indexOf('/'))));
|
VFile levelDir = new VFile(dir,
|
||||||
|
"level" + (fileName.startsWith("region/") ? "0" : fileName.substring(3, fileName.indexOf('/'))));
|
||||||
|
|
||||||
String[] xz = fileName.substring(fileName.lastIndexOf('r') + 2, fileName.length() - 4).split("\\.");
|
String[] xz = fileName.substring(fileName.lastIndexOf('r') + 2, fileName.length() - 4).split("\\.");
|
||||||
int gx = Integer.parseInt(xz[0]);
|
int gx = Integer.parseInt(xz[0]);
|
||||||
int gz = Integer.parseInt(xz[1]);
|
int gz = Integer.parseInt(xz[1]);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
byte[] buffer = new byte[16000];
|
byte[] buffer = new byte[16000];
|
||||||
for (int x = 0; x < 32; ++x) {
|
for (int x = 0; x < 32; ++x) {
|
||||||
for (int z = 0; z < 32; ++z) {
|
for (int z = 0; z < 32; ++z) {
|
||||||
int i = ((x % 32) + (z % 32) * 32) * 4;
|
int i = ((x % 32) + (z % 32) * 32) * 4;
|
||||||
int offset = (((file[i] & 0xff) << 16) | ((file[i + 1] & 0xff) << 8) | (file[i + 2] & 0xff)) * 4096;
|
int offset = (((file[i] & 0xff) << 16) | ((file[i + 1] & 0xff) << 8) | (file[i + 2] & 0xff)) * 4096;
|
||||||
if (offset == 0 && file[i + 3] == 0) {
|
if (offset == 0 && file[i + 3] == 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
int chunkLen = (((file[offset] & 0xff) << 24) | ((file[offset + 1] & 0xff) << 16) | ((file[offset + 2] & 0xff) << 8) | (file[offset + 3] & 0xff));
|
int chunkLen = (((file[offset] & 0xff) << 24) | ((file[offset + 1] & 0xff) << 16)
|
||||||
if (chunkLen == 0) continue;
|
| ((file[offset + 2] & 0xff) << 8) | (file[offset + 3] & 0xff));
|
||||||
byte compression = file[offset + 4];
|
if (chunkLen == 0)
|
||||||
byte[] data = new byte[chunkLen - 1];
|
continue;
|
||||||
System.arraycopy(file, offset + 5, data, 0, chunkLen - 1);
|
byte compression = file[offset + 4];
|
||||||
if (compression == 0) {
|
byte[] data = new byte[chunkLen - 1];
|
||||||
OutputStream os = new VFile(levelDir, VFSChunkLoader.getChunkPath(gx * 32 + x, gz * 32 + z) + ".dat").getOutputStream();
|
System.arraycopy(file, offset + 5, data, 0, chunkLen - 1);
|
||||||
GZIPOutputStream gos = new GZIPOutputStream(os);
|
if (compression == 0) {
|
||||||
ByteArrayInputStream bais = new ByteArrayInputStream(data);
|
OutputStream os = new VFile(levelDir,
|
||||||
int len;
|
VFSChunkLoader.getChunkPath(gx * 32 + x, gz * 32 + z) + ".dat").getOutputStream();
|
||||||
while ((len = bais.read(buffer)) > 0) {
|
GZIPOutputStream gos = new GZIPOutputStream(os);
|
||||||
gos.write(buffer, 0, len);
|
ByteArrayInputStream bais = new ByteArrayInputStream(data);
|
||||||
}
|
int len;
|
||||||
gos.close();
|
while ((len = bais.read(buffer)) > 0) {
|
||||||
os.close();
|
gos.write(buffer, 0, len);
|
||||||
bais.close();
|
}
|
||||||
} else if (compression == 2) {
|
gos.close();
|
||||||
OutputStream os = new VFile(levelDir, VFSChunkLoader.getChunkPath(gx * 32 + x, gz * 32 + z) + ".dat").getOutputStream();
|
os.close();
|
||||||
GZIPOutputStream gos = new GZIPOutputStream(os);
|
bais.close();
|
||||||
InflaterInputStream iis = new InflaterInputStream(new ByteArrayInputStream(data));
|
} else if (compression == 2) {
|
||||||
int len;
|
OutputStream os = new VFile(levelDir,
|
||||||
while ((len = iis.read(buffer)) > 0) {
|
VFSChunkLoader.getChunkPath(gx * 32 + x, gz * 32 + z) + ".dat").getOutputStream();
|
||||||
gos.write(buffer, 0, len);
|
GZIPOutputStream gos = new GZIPOutputStream(os);
|
||||||
}
|
InflaterInputStream iis = new InflaterInputStream(new ByteArrayInputStream(data));
|
||||||
gos.close();
|
int len;
|
||||||
os.close();
|
while ((len = iis.read(buffer)) > 0) {
|
||||||
iis.close();
|
gos.write(buffer, 0, len);
|
||||||
} else if (compression == 1) {
|
}
|
||||||
new VFile(levelDir, VFSChunkLoader.getChunkPath(gx * 32 + x, gz * 32 + z) + ".dat").setAllBytes(data);
|
gos.close();
|
||||||
}
|
os.close();
|
||||||
}
|
iis.close();
|
||||||
}
|
} else if (compression == 1) {
|
||||||
} catch (Throwable e) {
|
new VFile(levelDir, VFSChunkLoader.getChunkPath(gx * 32 + x, gz * 32 + z) + ".dat")
|
||||||
e.printStackTrace();
|
.setAllBytes(data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
} catch (Throwable e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static Map<String, byte[]> convertToMCA(Map<ChunkCoordIntPair, byte[]> regions) {
|
public static Map<String, byte[]> convertToMCA(Map<ChunkCoordIntPair, byte[]> regions) {
|
||||||
Map<String, byte[]> regionsOut = new HashMap<>();
|
Map<String, byte[]> regionsOut = new HashMap<>();
|
||||||
|
|
||||||
if (regions.size() == 0) return regionsOut;
|
if (regions.size() == 0)
|
||||||
|
return regionsOut;
|
||||||
|
|
||||||
byte[] readBuffer = new byte[16000];
|
byte[] readBuffer = new byte[16000];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
int timestamp = (int) System.currentTimeMillis();
|
int timestamp = (int) System.currentTimeMillis();
|
||||||
|
|
||||||
int maxX = Integer.MIN_VALUE;
|
int maxX = Integer.MIN_VALUE;
|
||||||
int maxZ = Integer.MIN_VALUE;
|
int maxZ = Integer.MIN_VALUE;
|
||||||
int minX = Integer.MAX_VALUE;
|
int minX = Integer.MAX_VALUE;
|
||||||
int minZ = Integer.MAX_VALUE;
|
int minZ = Integer.MAX_VALUE;
|
||||||
|
|
||||||
for (ChunkCoordIntPair coords : regions.keySet()) {
|
for (ChunkCoordIntPair coords : regions.keySet()) {
|
||||||
if (maxX < coords.chunkXPos) maxX = coords.chunkXPos;
|
if (maxX < coords.chunkXPos)
|
||||||
if (maxZ < coords.chunkZPos) maxZ = coords.chunkZPos;
|
maxX = coords.chunkXPos;
|
||||||
if (minX > coords.chunkXPos) minX = coords.chunkXPos;
|
if (maxZ < coords.chunkZPos)
|
||||||
if (minZ > coords.chunkZPos) minZ = coords.chunkZPos;
|
maxZ = coords.chunkZPos;
|
||||||
}
|
if (minX > coords.chunkXPos)
|
||||||
|
minX = coords.chunkXPos;
|
||||||
|
if (minZ > coords.chunkZPos)
|
||||||
|
minZ = coords.chunkZPos;
|
||||||
|
}
|
||||||
|
|
||||||
for (int z = minZ - (32 + (minZ % 32)); z <= maxZ + (32 + (maxZ % 32)); z += 32) {
|
for (int z = minZ - (32 + (minZ % 32)); z <= maxZ + (32 + (maxZ % 32)); z += 32) {
|
||||||
for (int x = minX - (32 + (minX % 32)); x <= maxX + (32 + (maxX % 32)); x += 32) {
|
for (int x = minX - (32 + (minX % 32)); x <= maxX + (32 + (maxX % 32)); x += 32) {
|
||||||
ByteArrayOutputStream offsets = new ByteArrayOutputStream();
|
ByteArrayOutputStream offsets = new ByteArrayOutputStream();
|
||||||
DataOutputStream offsetsDos = new DataOutputStream(offsets);
|
DataOutputStream offsetsDos = new DataOutputStream(offsets);
|
||||||
ByteArrayOutputStream timestamps = new ByteArrayOutputStream();
|
ByteArrayOutputStream timestamps = new ByteArrayOutputStream();
|
||||||
DataOutputStream timestampsDos = new DataOutputStream(timestamps);
|
DataOutputStream timestampsDos = new DataOutputStream(timestamps);
|
||||||
ByteArrayOutputStream chunks = new ByteArrayOutputStream();
|
ByteArrayOutputStream chunks = new ByteArrayOutputStream();
|
||||||
DataOutputStream chunksDos = new DataOutputStream(chunks);
|
DataOutputStream chunksDos = new DataOutputStream(chunks);
|
||||||
boolean anyChunks = false;
|
boolean anyChunks = false;
|
||||||
for (int cz = 0; cz < 32; cz++) {
|
for (int cz = 0; cz < 32; cz++) {
|
||||||
for (int cx = 0; cx < 32; cx++) {
|
for (int cx = 0; cx < 32; cx++) {
|
||||||
int tx = x + cx;
|
int tx = x + cx;
|
||||||
int tz = z + cz;
|
int tz = z + cz;
|
||||||
|
|
||||||
byte[] region = regions.get(new ChunkCoordIntPair(tx, tz));
|
byte[] region = regions.get(new ChunkCoordIntPair(tx, tz));
|
||||||
if (region == null) {
|
if (region == null) {
|
||||||
offsetsDos.writeInt(0);
|
offsetsDos.writeInt(0);
|
||||||
timestampsDos.writeInt(0);
|
timestampsDos.writeInt(0);
|
||||||
} else {
|
} else {
|
||||||
anyChunks = true;
|
anyChunks = true;
|
||||||
|
|
||||||
ByteArrayInputStream bais = new ByteArrayInputStream(region);
|
ByteArrayInputStream bais = new ByteArrayInputStream(region);
|
||||||
GZIPInputStream gis = new GZIPInputStream(bais);
|
GZIPInputStream gis = new GZIPInputStream(bais);
|
||||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
DeflaterOutputStream dos = new DeflaterOutputStream(baos);
|
DeflaterOutputStream dos = new DeflaterOutputStream(baos);
|
||||||
int len;
|
int len;
|
||||||
while ((len = gis.read(readBuffer)) > 0) {
|
while ((len = gis.read(readBuffer)) > 0) {
|
||||||
dos.write(readBuffer, 0, len);
|
dos.write(readBuffer, 0, len);
|
||||||
}
|
}
|
||||||
dos.close();
|
dos.close();
|
||||||
baos.close();
|
baos.close();
|
||||||
bais.close();
|
bais.close();
|
||||||
gis.close();
|
gis.close();
|
||||||
byte[] zlibbed = baos.toByteArray();
|
byte[] zlibbed = baos.toByteArray();
|
||||||
|
|
||||||
int offset = 2 + (chunksDos.size() / 4096);
|
int offset = 2 + (chunksDos.size() / 4096);
|
||||||
offsetsDos.write((offset >> 16) & 0xff);
|
offsetsDos.write((offset >> 16) & 0xff);
|
||||||
offsetsDos.write((offset >> 8) & 0xff);
|
offsetsDos.write((offset >> 8) & 0xff);
|
||||||
offsetsDos.write(offset & 0xff);
|
offsetsDos.write(offset & 0xff);
|
||||||
offsetsDos.write((int) Math.ceil((5 + zlibbed.length) / 4096.0));
|
offsetsDos.write((int) Math.ceil((5 + zlibbed.length) / 4096.0));
|
||||||
|
|
||||||
timestampsDos.writeInt(timestamp);
|
timestampsDos.writeInt(timestamp);
|
||||||
|
|
||||||
chunksDos.writeInt(region.length);
|
chunksDos.writeInt(region.length);
|
||||||
chunksDos.write(2);
|
chunksDos.write(2);
|
||||||
chunksDos.write(zlibbed);
|
chunksDos.write(zlibbed);
|
||||||
|
|
||||||
int chunksSizeOff = chunksDos.size() % 4096;
|
int chunksSizeOff = chunksDos.size() % 4096;
|
||||||
if (chunksSizeOff != 0) chunksDos.write(new byte[4096 - chunksSizeOff]);
|
if (chunksSizeOff != 0)
|
||||||
}
|
chunksDos.write(new byte[4096 - chunksSizeOff]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
offsetsDos.close();
|
offsetsDos.close();
|
||||||
timestampsDos.close();
|
timestampsDos.close();
|
||||||
chunksDos.close();
|
chunksDos.close();
|
||||||
|
|
||||||
if (!anyChunks) continue;
|
if (!anyChunks)
|
||||||
|
continue;
|
||||||
|
|
||||||
byte[] offsetsOut = offsets.toByteArray();
|
byte[] offsetsOut = offsets.toByteArray();
|
||||||
byte[] timestampsOut = timestamps.toByteArray();
|
byte[] timestampsOut = timestamps.toByteArray();
|
||||||
byte[] chunksOut = chunks.toByteArray();
|
byte[] chunksOut = chunks.toByteArray();
|
||||||
|
|
||||||
byte[] regionFile = new byte[offsetsOut.length + timestampsOut.length + chunksOut.length];
|
byte[] regionFile = new byte[offsetsOut.length + timestampsOut.length + chunksOut.length];
|
||||||
System.arraycopy(offsetsOut, 0, regionFile, 0, offsetsOut.length);
|
System.arraycopy(offsetsOut, 0, regionFile, 0, offsetsOut.length);
|
||||||
System.arraycopy(timestampsOut, 0, regionFile, offsetsOut.length, timestampsOut.length);
|
System.arraycopy(timestampsOut, 0, regionFile, offsetsOut.length, timestampsOut.length);
|
||||||
System.arraycopy(chunksOut, 0, regionFile, offsetsOut.length + timestampsOut.length, chunksOut.length);
|
System.arraycopy(chunksOut, 0, regionFile, offsetsOut.length + timestampsOut.length,
|
||||||
regionsOut.put("r." + (x / 32) + "." + (z / 32), regionFile);
|
chunksOut.length);
|
||||||
}
|
regionsOut.put("r." + (x / 32) + "." + (z / 32), regionFile);
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
}
|
||||||
e.printStackTrace();
|
} catch (IOException e) {
|
||||||
}
|
e.printStackTrace();
|
||||||
return regionsOut;
|
}
|
||||||
}
|
return regionsOut;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,6 @@ import org.teavm.interop.Async;
|
||||||
import org.teavm.interop.AsyncCallback;
|
import org.teavm.interop.AsyncCallback;
|
||||||
import org.teavm.jso.JSBody;
|
import org.teavm.jso.JSBody;
|
||||||
import org.teavm.jso.JSObject;
|
import org.teavm.jso.JSObject;
|
||||||
import org.teavm.jso.dom.events.Event;
|
|
||||||
import org.teavm.jso.dom.events.EventListener;
|
import org.teavm.jso.dom.events.EventListener;
|
||||||
import org.teavm.jso.indexeddb.EventHandler;
|
import org.teavm.jso.indexeddb.EventHandler;
|
||||||
import org.teavm.jso.indexeddb.IDBCountRequest;
|
import org.teavm.jso.indexeddb.IDBCountRequest;
|
||||||
|
|
|
@ -5,6 +5,7 @@ import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
import net.minecraft.src.NetHandler;
|
import net.minecraft.src.NetHandler;
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package net.lax1dude.eaglercraft.sp;
|
package net.lax1dude.eaglercraft.sp;
|
||||||
|
|
||||||
import com.jcraft.jzlib.Deflater;
|
import static java.util.zip.Deflater.BEST_COMPRESSION;
|
||||||
import com.jcraft.jzlib.DeflaterOutputStream;
|
import static java.util.zip.Deflater.DEFAULT_COMPRESSION;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -11,320 +11,317 @@ import java.util.List;
|
||||||
import java.util.zip.ZipEntry;
|
import java.util.zip.ZipEntry;
|
||||||
import java.util.zip.ZipException;
|
import java.util.zip.ZipException;
|
||||||
|
|
||||||
import static java.util.zip.Deflater.BEST_COMPRESSION;
|
import com.jcraft.jzlib.Deflater;
|
||||||
import static java.util.zip.Deflater.DEFAULT_COMPRESSION;
|
import com.jcraft.jzlib.DeflaterOutputStream;
|
||||||
|
|
||||||
public class ZipOutputStream extends DeflaterOutputStream {
|
public class ZipOutputStream extends DeflaterOutputStream {
|
||||||
long LOCSIG = 0x4034b50;
|
long LOCSIG = 0x4034b50;
|
||||||
long EXTSIG = 0x8074b50;
|
long EXTSIG = 0x8074b50;
|
||||||
long CENSIG = 0x2014b50;
|
long CENSIG = 0x2014b50;
|
||||||
long ENDSIG = 0x6054b50;
|
long ENDSIG = 0x6054b50;
|
||||||
|
|
||||||
int LOCHDR = 30;
|
int LOCHDR = 30;
|
||||||
int EXTHDR = 16;
|
int EXTHDR = 16;
|
||||||
|
|
||||||
public static final int DEFLATED = 8;
|
public static final int DEFLATED = 8;
|
||||||
public static final int STORED = 0;
|
public static final int STORED = 0;
|
||||||
|
|
||||||
static final int ZIPDataDescriptorFlag = 8;
|
static final int ZIPDataDescriptorFlag = 8;
|
||||||
static final int ZIPLocalHeaderVersionNeeded = 20;
|
static final int ZIPLocalHeaderVersionNeeded = 20;
|
||||||
private String comment;
|
private String comment;
|
||||||
private final List<String> entries = new ArrayList<>();
|
private final List<String> entries = new ArrayList<>();
|
||||||
private int compressMethod = DEFLATED;
|
private int compressMethod = DEFLATED;
|
||||||
private int compressLevel = -1;
|
private int compressLevel = -1;
|
||||||
private ByteArrayOutputStream cDir = new ByteArrayOutputStream();
|
private ByteArrayOutputStream cDir = new ByteArrayOutputStream();
|
||||||
private ZipEntry currentEntry;
|
private ZipEntry currentEntry;
|
||||||
private final CRC32 crc = new CRC32();
|
private final CRC32 crc = new CRC32();
|
||||||
private int offset;
|
private int offset;
|
||||||
private int curOffset;
|
private int curOffset;
|
||||||
private int nameLength;
|
private int nameLength;
|
||||||
private byte[] nameBytes;
|
private byte[] nameBytes;
|
||||||
|
|
||||||
public ZipOutputStream(OutputStream p1) throws IOException {
|
public ZipOutputStream(OutputStream p1) throws IOException {
|
||||||
super(p1, new Deflater(-1, true));
|
super(p1, new Deflater(-1, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void close() throws IOException {
|
public void close() throws IOException {
|
||||||
if (out != null) {
|
if (out != null) {
|
||||||
finish();
|
finish();
|
||||||
out.close();
|
out.close();
|
||||||
out = null;
|
out = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void closeEntry() throws IOException {
|
public void closeEntry() throws IOException {
|
||||||
if (cDir == null) {
|
if (cDir == null) {
|
||||||
throw new IOException();
|
throw new IOException();
|
||||||
}
|
}
|
||||||
if (currentEntry == null) {
|
if (currentEntry == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (currentEntry.getMethod() == DEFLATED) {
|
if (currentEntry.getMethod() == DEFLATED) {
|
||||||
super.finish();
|
super.finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify values for STORED types
|
// Verify values for STORED types
|
||||||
if (currentEntry.getMethod() == STORED) {
|
if (currentEntry.getMethod() == STORED) {
|
||||||
if (crc.getValue() != currentEntry.getCrc()) {
|
if (crc.getValue() != currentEntry.getCrc()) {
|
||||||
throw new ZipException();
|
throw new ZipException();
|
||||||
}
|
}
|
||||||
if (currentEntry.getSize() != crc.tbytes) {
|
if (currentEntry.getSize() != crc.tbytes) {
|
||||||
throw new ZipException();
|
throw new ZipException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
curOffset = LOCHDR;
|
curOffset = LOCHDR;
|
||||||
|
|
||||||
// Write the DataDescriptor
|
// Write the DataDescriptor
|
||||||
if (currentEntry.getMethod() != STORED) {
|
if (currentEntry.getMethod() != STORED) {
|
||||||
curOffset += EXTHDR;
|
curOffset += EXTHDR;
|
||||||
writeLong(out, EXTSIG);
|
writeLong(out, EXTSIG);
|
||||||
currentEntry.setCrc(crc.getValue());
|
currentEntry.setCrc(crc.getValue());
|
||||||
writeLong(out, currentEntry.getCrc());
|
writeLong(out, currentEntry.getCrc());
|
||||||
currentEntry.setCompressedSize(deflater.getTotalOut());
|
currentEntry.setCompressedSize(deflater.getTotalOut());
|
||||||
writeLong(out, currentEntry.getCompressedSize());
|
writeLong(out, currentEntry.getCompressedSize());
|
||||||
currentEntry.setSize(deflater.getTotalIn());
|
currentEntry.setSize(deflater.getTotalIn());
|
||||||
writeLong(out, currentEntry.getSize());
|
writeLong(out, currentEntry.getSize());
|
||||||
}
|
}
|
||||||
// Update the CentralDirectory
|
// Update the CentralDirectory
|
||||||
writeLong(cDir, CENSIG);
|
writeLong(cDir, CENSIG);
|
||||||
writeShort(cDir, ZIPLocalHeaderVersionNeeded); // Version created
|
writeShort(cDir, ZIPLocalHeaderVersionNeeded); // Version created
|
||||||
writeShort(cDir, ZIPLocalHeaderVersionNeeded); // Version to extract
|
writeShort(cDir, ZIPLocalHeaderVersionNeeded); // Version to extract
|
||||||
writeShort(cDir, currentEntry.getMethod() == STORED ? 0 : ZIPDataDescriptorFlag);
|
writeShort(cDir, currentEntry.getMethod() == STORED ? 0 : ZIPDataDescriptorFlag);
|
||||||
writeShort(cDir, currentEntry.getMethod());
|
writeShort(cDir, currentEntry.getMethod());
|
||||||
writeShort(cDir, (int) currentEntry.getTime());
|
writeShort(cDir, (int) currentEntry.getTime());
|
||||||
writeShort(cDir, 0);
|
writeShort(cDir, 0);
|
||||||
writeLong(cDir, crc.getValue());
|
writeLong(cDir, crc.getValue());
|
||||||
if (currentEntry.getMethod() == DEFLATED) {
|
if (currentEntry.getMethod() == DEFLATED) {
|
||||||
curOffset += writeLong(cDir, deflater.getTotalOut());
|
curOffset += writeLong(cDir, deflater.getTotalOut());
|
||||||
writeLong(cDir, deflater.getTotalIn());
|
writeLong(cDir, deflater.getTotalIn());
|
||||||
} else {
|
} else {
|
||||||
curOffset += writeLong(cDir, crc.tbytes);
|
curOffset += writeLong(cDir, crc.tbytes);
|
||||||
writeLong(cDir, crc.tbytes);
|
writeLong(cDir, crc.tbytes);
|
||||||
}
|
}
|
||||||
curOffset += writeShort(cDir, nameLength);
|
curOffset += writeShort(cDir, nameLength);
|
||||||
if (currentEntry.getExtra() != null) {
|
if (currentEntry.getExtra() != null) {
|
||||||
curOffset += writeShort(cDir, currentEntry.getExtra().length);
|
curOffset += writeShort(cDir, currentEntry.getExtra().length);
|
||||||
} else {
|
} else {
|
||||||
writeShort(cDir, 0);
|
writeShort(cDir, 0);
|
||||||
}
|
}
|
||||||
String c = currentEntry.getComment();
|
String c = currentEntry.getComment();
|
||||||
writeShort(cDir, c != null ? c.length() : 0);
|
writeShort(cDir, c != null ? c.length() : 0);
|
||||||
writeShort(cDir, 0); // Disk Start
|
writeShort(cDir, 0); // Disk Start
|
||||||
writeShort(cDir, 0); // Internal File Attributes
|
writeShort(cDir, 0); // Internal File Attributes
|
||||||
writeLong(cDir, 0); // External File Attributes
|
writeLong(cDir, 0); // External File Attributes
|
||||||
writeLong(cDir, offset);
|
writeLong(cDir, offset);
|
||||||
cDir.write(nameBytes);
|
cDir.write(nameBytes);
|
||||||
nameBytes = null;
|
nameBytes = null;
|
||||||
if (currentEntry.getExtra() != null) {
|
if (currentEntry.getExtra() != null) {
|
||||||
cDir.write(currentEntry.getExtra());
|
cDir.write(currentEntry.getExtra());
|
||||||
}
|
}
|
||||||
offset += curOffset;
|
offset += curOffset;
|
||||||
if (c != null) {
|
if (c != null) {
|
||||||
cDir.write(c.getBytes());
|
cDir.write(c.getBytes());
|
||||||
}
|
}
|
||||||
currentEntry = null;
|
currentEntry = null;
|
||||||
crc.reset();
|
crc.reset();
|
||||||
deflater.end();
|
deflater.end();
|
||||||
deflater.init(-1, true);
|
deflater.init(-1, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void finish() throws IOException {
|
public void finish() throws IOException {
|
||||||
if (out == null) {
|
if (out == null) {
|
||||||
throw new IOException();
|
throw new IOException();
|
||||||
}
|
}
|
||||||
if (cDir == null) {
|
if (cDir == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (entries.size() == 0) {
|
if (entries.size() == 0) {
|
||||||
throw new ZipException();
|
throw new ZipException();
|
||||||
}
|
}
|
||||||
if (currentEntry != null) {
|
if (currentEntry != null) {
|
||||||
closeEntry();
|
closeEntry();
|
||||||
}
|
}
|
||||||
int cdirSize = cDir.size();
|
int cdirSize = cDir.size();
|
||||||
// Write Central Dir End
|
// Write Central Dir End
|
||||||
writeLong(cDir, ENDSIG);
|
writeLong(cDir, ENDSIG);
|
||||||
writeShort(cDir, 0); // Disk Number
|
writeShort(cDir, 0); // Disk Number
|
||||||
writeShort(cDir, 0); // Start Disk
|
writeShort(cDir, 0); // Start Disk
|
||||||
writeShort(cDir, entries.size()); // Number of entries
|
writeShort(cDir, entries.size()); // Number of entries
|
||||||
writeShort(cDir, entries.size()); // Number of entries
|
writeShort(cDir, entries.size()); // Number of entries
|
||||||
writeLong(cDir, cdirSize); // Size of central dir
|
writeLong(cDir, cdirSize); // Size of central dir
|
||||||
writeLong(cDir, offset); // Offset of central dir
|
writeLong(cDir, offset); // Offset of central dir
|
||||||
if (comment != null) {
|
if (comment != null) {
|
||||||
writeShort(cDir, comment.length());
|
writeShort(cDir, comment.length());
|
||||||
cDir.write(comment.getBytes());
|
cDir.write(comment.getBytes());
|
||||||
} else {
|
} else {
|
||||||
writeShort(cDir, 0);
|
writeShort(cDir, 0);
|
||||||
}
|
}
|
||||||
// Write the central dir
|
// Write the central dir
|
||||||
out.write(cDir.toByteArray());
|
out.write(cDir.toByteArray());
|
||||||
cDir = null;
|
cDir = null;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void putNextEntry(ZipEntry ze) throws IOException {
|
public void putNextEntry(ZipEntry ze) throws IOException {
|
||||||
if (currentEntry != null) {
|
if (currentEntry != null) {
|
||||||
closeEntry();
|
closeEntry();
|
||||||
}
|
}
|
||||||
if (ze.getMethod() == STORED
|
if (ze.getMethod() == STORED || (compressMethod == STORED && ze.getMethod() == -1)) {
|
||||||
|| (compressMethod == STORED && ze.getMethod() == -1)) {
|
if (ze.getCrc() == -1) {
|
||||||
if (ze.getCrc() == -1) {
|
throw new ZipException("Crc mismatch");
|
||||||
throw new ZipException("Crc mismatch");
|
}
|
||||||
}
|
if (ze.getSize() == -1 && ze.getCompressedSize() == -1) {
|
||||||
if (ze.getSize() == -1 && ze.getCompressedSize() == -1) {
|
throw new ZipException("Size mismatch");
|
||||||
throw new ZipException("Size mismatch");
|
}
|
||||||
}
|
if (ze.getSize() != ze.getCompressedSize() && ze.getCompressedSize() != -1 && ze.getSize() != -1) {
|
||||||
if (ze.getSize() != ze.getCompressedSize() && ze.getCompressedSize() != -1 && ze.getSize() != -1) {
|
throw new ZipException("Size mismatch");
|
||||||
throw new ZipException("Size mismatch");
|
}
|
||||||
}
|
}
|
||||||
}
|
if (cDir == null) {
|
||||||
if (cDir == null) {
|
throw new IOException("Stream is closed");
|
||||||
throw new IOException("Stream is closed");
|
}
|
||||||
}
|
if (entries.contains(ze.getName())) {
|
||||||
if (entries.contains(ze.getName())) {
|
throw new ZipException("Entry already exists: " + ze.getName());
|
||||||
throw new ZipException("Entry already exists: " + ze.getName());
|
}
|
||||||
}
|
nameLength = utf8Count(ze.getName());
|
||||||
nameLength = utf8Count(ze.getName());
|
if (nameLength > 0xffff) {
|
||||||
if (nameLength > 0xffff) {
|
throw new IllegalArgumentException("Name too long: " + ze.getName());
|
||||||
throw new IllegalArgumentException("Name too long: " + ze.getName());
|
}
|
||||||
}
|
|
||||||
|
|
||||||
deflater.params(compressLevel, 0);
|
deflater.params(compressLevel, 0);
|
||||||
currentEntry = ze;
|
currentEntry = ze;
|
||||||
entries.add(currentEntry.getName());
|
entries.add(currentEntry.getName());
|
||||||
if (currentEntry.getMethod() == -1) {
|
if (currentEntry.getMethod() == -1) {
|
||||||
currentEntry.setMethod(compressMethod);
|
currentEntry.setMethod(compressMethod);
|
||||||
}
|
}
|
||||||
writeLong(out, LOCSIG); // Entry header
|
writeLong(out, LOCSIG); // Entry header
|
||||||
writeShort(out, ZIPLocalHeaderVersionNeeded); // Extraction version
|
writeShort(out, ZIPLocalHeaderVersionNeeded); // Extraction version
|
||||||
writeShort(out, currentEntry.getMethod() == STORED ? 0 : ZIPDataDescriptorFlag);
|
writeShort(out, currentEntry.getMethod() == STORED ? 0 : ZIPDataDescriptorFlag);
|
||||||
writeShort(out, currentEntry.getMethod());
|
writeShort(out, currentEntry.getMethod());
|
||||||
if (currentEntry.getTime() == -1) {
|
if (currentEntry.getTime() == -1) {
|
||||||
currentEntry.setTime(System.currentTimeMillis());
|
currentEntry.setTime(System.currentTimeMillis());
|
||||||
}
|
}
|
||||||
writeShort(out, (int) currentEntry.getTime());
|
writeShort(out, (int) currentEntry.getTime());
|
||||||
writeShort(out, 0);
|
writeShort(out, 0);
|
||||||
|
|
||||||
if (currentEntry.getMethod() == STORED) {
|
if (currentEntry.getMethod() == STORED) {
|
||||||
if (currentEntry.getSize() == -1) {
|
if (currentEntry.getSize() == -1) {
|
||||||
currentEntry.setSize(currentEntry.getCompressedSize());
|
currentEntry.setSize(currentEntry.getCompressedSize());
|
||||||
} else if (currentEntry.getCompressedSize() == -1) {
|
} else if (currentEntry.getCompressedSize() == -1) {
|
||||||
currentEntry.setCompressedSize(currentEntry.getSize());
|
currentEntry.setCompressedSize(currentEntry.getSize());
|
||||||
}
|
}
|
||||||
writeLong(out, currentEntry.getCrc());
|
writeLong(out, currentEntry.getCrc());
|
||||||
writeLong(out, currentEntry.getSize());
|
writeLong(out, currentEntry.getSize());
|
||||||
writeLong(out, currentEntry.getSize());
|
writeLong(out, currentEntry.getSize());
|
||||||
} else {
|
} else {
|
||||||
writeLong(out, 0);
|
writeLong(out, 0);
|
||||||
writeLong(out, 0);
|
writeLong(out, 0);
|
||||||
writeLong(out, 0);
|
writeLong(out, 0);
|
||||||
}
|
}
|
||||||
writeShort(out, nameLength);
|
writeShort(out, nameLength);
|
||||||
writeShort(out, currentEntry.getExtra() != null ? currentEntry.getExtra().length : 0);
|
writeShort(out, currentEntry.getExtra() != null ? currentEntry.getExtra().length : 0);
|
||||||
nameBytes = toUTF8Bytes(currentEntry.getName(), nameLength);
|
nameBytes = toUTF8Bytes(currentEntry.getName(), nameLength);
|
||||||
out.write(nameBytes);
|
out.write(nameBytes);
|
||||||
if (currentEntry.getExtra() != null) {
|
if (currentEntry.getExtra() != null) {
|
||||||
out.write(currentEntry.getExtra());
|
out.write(currentEntry.getExtra());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setComment(String comment) {
|
public void setComment(String comment) {
|
||||||
if (comment.length() > 0xFFFF) {
|
if (comment.length() > 0xFFFF) {
|
||||||
throw new IllegalArgumentException();
|
throw new IllegalArgumentException();
|
||||||
}
|
}
|
||||||
this.comment = comment;
|
this.comment = comment;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLevel(int level) {
|
public void setLevel(int level) {
|
||||||
if (level < DEFAULT_COMPRESSION || level > BEST_COMPRESSION) {
|
if (level < DEFAULT_COMPRESSION || level > BEST_COMPRESSION) {
|
||||||
throw new IllegalArgumentException();
|
throw new IllegalArgumentException();
|
||||||
}
|
}
|
||||||
compressLevel = level;
|
compressLevel = level;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMethod(int method) {
|
public void setMethod(int method) {
|
||||||
if (method != STORED && method != DEFLATED) {
|
if (method != STORED && method != DEFLATED) {
|
||||||
throw new IllegalArgumentException();
|
throw new IllegalArgumentException();
|
||||||
}
|
}
|
||||||
compressMethod = method;
|
compressMethod = method;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private long writeLong(OutputStream os, long i) throws IOException {
|
private long writeLong(OutputStream os, long i) throws IOException {
|
||||||
// Write out the long value as an unsigned int
|
// Write out the long value as an unsigned int
|
||||||
os.write((int) (i & 0xFF));
|
os.write((int) (i & 0xFF));
|
||||||
os.write((int) (i >> 8) & 0xFF);
|
os.write((int) (i >> 8) & 0xFF);
|
||||||
os.write((int) (i >> 16) & 0xFF);
|
os.write((int) (i >> 16) & 0xFF);
|
||||||
os.write((int) (i >> 24) & 0xFF);
|
os.write((int) (i >> 24) & 0xFF);
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int writeShort(OutputStream os, int i) throws IOException {
|
private int writeShort(OutputStream os, int i) throws IOException {
|
||||||
os.write(i & 0xFF);
|
os.write(i & 0xFF);
|
||||||
os.write((i >> 8) & 0xFF);
|
os.write((i >> 8) & 0xFF);
|
||||||
return i;
|
return i;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Writes data for the current entry to the underlying stream.
|
* Writes data for the current entry to the underlying stream.
|
||||||
*
|
*
|
||||||
* @exception IOException
|
* @exception IOException If an error occurs writing to the stream
|
||||||
* If an error occurs writing to the stream
|
*/
|
||||||
*/
|
@Override
|
||||||
@Override
|
public void write(byte[] buffer, int off, int nbytes) throws IOException {
|
||||||
public void write(byte[] buffer, int off, int nbytes)
|
// avoid int overflow, check null buf
|
||||||
throws IOException {
|
if ((off < 0 || (nbytes < 0) || off > buffer.length) || (buffer.length - off < nbytes)) {
|
||||||
// avoid int overflow, check null buf
|
throw new IndexOutOfBoundsException();
|
||||||
if ((off < 0 || (nbytes < 0) || off > buffer.length) || (buffer.length - off < nbytes)) {
|
}
|
||||||
throw new IndexOutOfBoundsException();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (currentEntry == null) {
|
if (currentEntry == null) {
|
||||||
throw new ZipException("No active entry");
|
throw new ZipException("No active entry");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentEntry.getMethod() == STORED) {
|
if (currentEntry.getMethod() == STORED) {
|
||||||
out.write(buffer, off, nbytes);
|
out.write(buffer, off, nbytes);
|
||||||
} else {
|
} else {
|
||||||
super.write(buffer, off, nbytes);
|
super.write(buffer, off, nbytes);
|
||||||
}
|
}
|
||||||
crc.update(buffer, off, nbytes);
|
crc.update(buffer, off, nbytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int utf8Count(String value) {
|
static int utf8Count(String value) {
|
||||||
int total = 0;
|
int total = 0;
|
||||||
for (int i = value.length(); --i >= 0;) {
|
for (int i = value.length(); --i >= 0;) {
|
||||||
char ch = value.charAt(i);
|
char ch = value.charAt(i);
|
||||||
if (ch < 0x80) {
|
if (ch < 0x80) {
|
||||||
total++;
|
total++;
|
||||||
} else if (ch < 0x800) {
|
} else if (ch < 0x800) {
|
||||||
total += 2;
|
total += 2;
|
||||||
} else {
|
} else {
|
||||||
total += 3;
|
total += 3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return total;
|
return total;
|
||||||
}
|
}
|
||||||
|
|
||||||
static byte[] toUTF8Bytes(String value, int length) {
|
static byte[] toUTF8Bytes(String value, int length) {
|
||||||
byte[] result = new byte[length];
|
byte[] result = new byte[length];
|
||||||
int pos = result.length;
|
int pos = result.length;
|
||||||
for (int i = value.length(); --i >= 0;) {
|
for (int i = value.length(); --i >= 0;) {
|
||||||
char ch = value.charAt(i);
|
char ch = value.charAt(i);
|
||||||
if (ch < 0x80) {
|
if (ch < 0x80) {
|
||||||
result[--pos] = (byte) ch;
|
result[--pos] = (byte) ch;
|
||||||
} else if (ch < 0x800) {
|
} else if (ch < 0x800) {
|
||||||
result[--pos] = (byte) (0x80 | (ch & 0x3f));
|
result[--pos] = (byte) (0x80 | (ch & 0x3f));
|
||||||
result[--pos] = (byte) (0xc0 | (ch >> 6));
|
result[--pos] = (byte) (0xc0 | (ch >> 6));
|
||||||
} else {
|
} else {
|
||||||
result[--pos] = (byte) (0x80 | (ch & 0x3f));
|
result[--pos] = (byte) (0x80 | (ch & 0x3f));
|
||||||
result[--pos] = (byte) (0x80 | ((ch >> 6) & 0x3f));
|
result[--pos] = (byte) (0x80 | ((ch >> 6) & 0x3f));
|
||||||
result[--pos] = (byte) (0xe0 | (ch >> 12));
|
result[--pos] = (byte) (0xe0 | (ch >> 12));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,9 +8,9 @@ import java.util.List;
|
||||||
|
|
||||||
import net.lax1dude.eaglercraft.sp.IntegratedServer;
|
import net.lax1dude.eaglercraft.sp.IntegratedServer;
|
||||||
import net.lax1dude.eaglercraft.sp.SYS;
|
import net.lax1dude.eaglercraft.sp.SYS;
|
||||||
import net.lax1dude.eaglercraft.sp.WorkerListenThread;
|
|
||||||
import net.lax1dude.eaglercraft.sp.VFSSaveHandler;
|
import net.lax1dude.eaglercraft.sp.VFSSaveHandler;
|
||||||
import net.lax1dude.eaglercraft.sp.VFile;
|
import net.lax1dude.eaglercraft.sp.VFile;
|
||||||
|
import net.lax1dude.eaglercraft.sp.WorkerListenThread;
|
||||||
import net.lax1dude.eaglercraft.sp.ipc.IPCPacket0DProgressUpdate;
|
import net.lax1dude.eaglercraft.sp.ipc.IPCPacket0DProgressUpdate;
|
||||||
import net.lax1dude.eaglercraft.sp.ipc.IPCPacket14StringList;
|
import net.lax1dude.eaglercraft.sp.ipc.IPCPacket14StringList;
|
||||||
import net.minecraft.src.AxisAlignedBB;
|
import net.minecraft.src.AxisAlignedBB;
|
||||||
|
@ -24,7 +24,6 @@ import net.minecraft.src.ICommandManager;
|
||||||
import net.minecraft.src.ICommandSender;
|
import net.minecraft.src.ICommandSender;
|
||||||
import net.minecraft.src.ILogAgent;
|
import net.minecraft.src.ILogAgent;
|
||||||
import net.minecraft.src.IProgressUpdate;
|
import net.minecraft.src.IProgressUpdate;
|
||||||
import net.minecraft.src.ISaveFormat;
|
|
||||||
import net.minecraft.src.ISaveHandler;
|
import net.minecraft.src.ISaveHandler;
|
||||||
import net.minecraft.src.IUpdatePlayerListBox;
|
import net.minecraft.src.IUpdatePlayerListBox;
|
||||||
import net.minecraft.src.MinecraftException;
|
import net.minecraft.src.MinecraftException;
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package net.minecraft.src;
|
package net.minecraft.src;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
import net.lax1dude.eaglercraft.sp.EaglercraftRandom;
|
import net.lax1dude.eaglercraft.sp.EaglercraftRandom;
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
|
|
||||||
public abstract class CommandBase implements ICommand {
|
public abstract class CommandBase implements ICommand {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package net.minecraft.src;
|
package net.minecraft.src;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
|
|
||||||
public class CommandClearInventory extends CommandBase {
|
public class CommandClearInventory extends CommandBase {
|
||||||
|
|
|
@ -1,10 +1,7 @@
|
||||||
package net.minecraft.src;
|
package net.minecraft.src;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileWriter;
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
|
|
||||||
public class CommandDebug extends CommandBase {
|
public class CommandDebug extends CommandBase {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package net.minecraft.src;
|
package net.minecraft.src;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
|
|
||||||
public class CommandDifficulty extends CommandBase {
|
public class CommandDifficulty extends CommandBase {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package net.minecraft.src;
|
package net.minecraft.src;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
|
|
||||||
public class CommandEffect extends CommandBase {
|
public class CommandEffect extends CommandBase {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package net.minecraft.src;
|
package net.minecraft.src;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
|
|
||||||
public class CommandEnchant extends CommandBase {
|
public class CommandEnchant extends CommandBase {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package net.minecraft.src;
|
package net.minecraft.src;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
|
|
||||||
public class CommandGameMode extends CommandBase {
|
public class CommandGameMode extends CommandBase {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package net.minecraft.src;
|
package net.minecraft.src;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
|
|
||||||
public class CommandGameRule extends CommandBase {
|
public class CommandGameRule extends CommandBase {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package net.minecraft.src;
|
package net.minecraft.src;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
|
|
||||||
public class CommandGive extends CommandBase {
|
public class CommandGive extends CommandBase {
|
||||||
|
|
|
@ -6,8 +6,8 @@ import java.util.HashSet;
|
||||||
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.Set;
|
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
public class CommandHandler implements ICommandManager {
|
public class CommandHandler implements ICommandManager {
|
||||||
/** Map of Strings to the ICommand objects they represent */
|
/** Map of Strings to the ICommand objects they represent */
|
||||||
|
|
|
@ -4,6 +4,7 @@ import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
|
|
||||||
public class CommandHelp extends CommandBase {
|
public class CommandHelp extends CommandBase {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package net.minecraft.src;
|
package net.minecraft.src;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
|
|
||||||
public class CommandServerEmote extends CommandBase {
|
public class CommandServerEmote extends CommandBase {
|
||||||
|
|
|
@ -2,6 +2,7 @@ package net.minecraft.src;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
|
|
||||||
public class CommandServerMessage extends CommandBase {
|
public class CommandServerMessage extends CommandBase {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package net.minecraft.src;
|
package net.minecraft.src;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
|
|
||||||
public class CommandServerSay extends CommandBase {
|
public class CommandServerSay extends CommandBase {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package net.minecraft.src;
|
package net.minecraft.src;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
|
|
||||||
public class CommandServerTp extends CommandBase {
|
public class CommandServerTp extends CommandBase {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package net.minecraft.src;
|
package net.minecraft.src;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
|
|
||||||
public class CommandSetSpawnpoint extends CommandBase {
|
public class CommandSetSpawnpoint extends CommandBase {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package net.minecraft.src;
|
package net.minecraft.src;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
|
|
||||||
public class CommandTime extends CommandBase {
|
public class CommandTime extends CommandBase {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package net.minecraft.src;
|
package net.minecraft.src;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
|
|
||||||
public class CommandXP extends CommandBase {
|
public class CommandXP extends CommandBase {
|
||||||
|
|
|
@ -10,7 +10,6 @@ import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.util.Collection;
|
|
||||||
|
|
||||||
import com.jcraft.jzlib.Deflater;
|
import com.jcraft.jzlib.Deflater;
|
||||||
import com.jcraft.jzlib.GZIPInputStream;
|
import com.jcraft.jzlib.GZIPInputStream;
|
||||||
|
|
|
@ -8,8 +8,6 @@ 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.concurrent.locks.ReadWriteLock;
|
|
||||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
|
||||||
|
|
||||||
public class DataWatcher {
|
public class DataWatcher {
|
||||||
/** When isBlank is true the DataWatcher is not watching any objects */
|
/** When isBlank is true the DataWatcher is not watching any objects */
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package net.minecraft.src;
|
package net.minecraft.src;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
|
|
||||||
public abstract class EntityMinecart extends Entity {
|
public abstract class EntityMinecart extends Entity {
|
||||||
|
|
|
@ -9,6 +9,7 @@ import java.util.Collection;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
|
|
||||||
public class EntityPlayerMP extends EntityPlayer implements ICrafting {
|
public class EntityPlayerMP extends EntityPlayer implements ICrafting {
|
||||||
|
|
|
@ -5,7 +5,6 @@ import java.util.Iterator;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.Map.Entry;
|
|
||||||
|
|
||||||
public class LowerStringMap implements Map {
|
public class LowerStringMap implements Map {
|
||||||
private final Map internalMap = new LinkedHashMap();
|
private final Map internalMap = new LinkedHashMap();
|
||||||
|
|
|
@ -3,9 +3,6 @@ package net.minecraft.src;
|
||||||
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.zip.DataFormatException;
|
|
||||||
import java.util.zip.Deflater;
|
|
||||||
import java.util.zip.Inflater;
|
|
||||||
|
|
||||||
public class Packet51MapChunk extends Packet {
|
public class Packet51MapChunk extends Packet {
|
||||||
/** The x-position of the transmitted chunk, in chunk coordinates. */
|
/** The x-position of the transmitted chunk, in chunk coordinates. */
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
package net.minecraft.src;
|
package net.minecraft.src;
|
||||||
|
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
|
||||||
import javax.swing.JList;
|
import javax.swing.JList;
|
||||||
|
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
|
|
||||||
public class PlayerListBox extends JList implements IUpdatePlayerListBox {
|
public class PlayerListBox extends JList implements IUpdatePlayerListBox {
|
||||||
|
|
|
@ -2,7 +2,6 @@ package net.minecraft.src;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UnknownFormatConversionException;
|
|
||||||
|
|
||||||
public class PlayerManager {
|
public class PlayerManager {
|
||||||
private final WorldServer theWorldServer;
|
private final WorldServer theWorldServer;
|
||||||
|
|
|
@ -7,6 +7,7 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
|
|
||||||
public class PlayerSelector {
|
public class PlayerSelector {
|
||||||
|
|
|
@ -2,6 +2,7 @@ package net.minecraft.src;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
|
|
||||||
public class ScoreboardSaveData extends WorldSavedData {
|
public class ScoreboardSaveData extends WorldSavedData {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package net.minecraft.src;
|
package net.minecraft.src;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
|
|
||||||
public class ServerCommandManager extends CommandHandler implements IAdminCommand {
|
public class ServerCommandManager extends CommandHandler implements IAdminCommand {
|
||||||
|
|
|
@ -7,6 +7,7 @@ import java.util.HashSet;
|
||||||
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 net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
|
|
||||||
public class ServerCommandScoreboard extends CommandBase {
|
public class ServerCommandScoreboard extends CommandBase {
|
||||||
|
|
|
@ -7,8 +7,9 @@ import java.util.HashSet;
|
||||||
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.Set;
|
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
|
|
||||||
public class ServerConfigurationManager {
|
public class ServerConfigurationManager {
|
||||||
|
|
|
@ -6,6 +6,7 @@ import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
|
|
||||||
public class ServerScoreboard extends Scoreboard {
|
public class ServerScoreboard extends Scoreboard {
|
||||||
|
|
|
@ -2,6 +2,7 @@ package net.minecraft.src;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
|
|
||||||
public class TileEntity {
|
public class TileEntity {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package net.minecraft.src;
|
package net.minecraft.src;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
|
|
||||||
public class WorldManager implements IWorldAccess {
|
public class WorldManager implements IWorldAccess {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user