mirror of
https://git.zelz.net/catfoolyou/Project164.git
synced 2025-12-14 08:47:40 +00:00
Integrated server works
This commit is contained in:
@@ -1,69 +0,0 @@
|
||||
package net.lax1dude.eaglercraft.sp.ipc;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
public class IPCInputStream extends InputStream {
|
||||
|
||||
private byte[] currentBuffer = null;
|
||||
private int idx = 0;
|
||||
private int markIDX = 0;
|
||||
private String errorName = null;
|
||||
|
||||
public void feedBuffer(byte[] b) {
|
||||
currentBuffer = b;
|
||||
idx = 0;
|
||||
errorName = null;
|
||||
markIDX = 0;
|
||||
}
|
||||
|
||||
public void nameBuffer(String str) {
|
||||
errorName = str;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int read() throws IOException {
|
||||
try {
|
||||
return ((int)currentBuffer[idx++]) & 0xFF;
|
||||
}catch(ArrayIndexOutOfBoundsException a) {
|
||||
throw new IOException("IPCInputStream buffer underflow" + (errorName == null ? "," : (" (while deserializing '" + errorName + "')")) + " no bytes remaining", a);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int read(byte b[], int off, int len) throws IOException {
|
||||
if(idx + len > currentBuffer.length) {
|
||||
throw new IOException("IPCInputStream buffer underflow" + (errorName == null ? "," : (" (while deserializing '" + errorName + "')")) + " tried to read " + len + " when there are only " + (currentBuffer.length - idx) + " bytes remaining", new ArrayIndexOutOfBoundsException(idx + len - 1));
|
||||
}
|
||||
if(off + len > b.length) {
|
||||
throw new ArrayIndexOutOfBoundsException(off + len - 1);
|
||||
}
|
||||
System.arraycopy(currentBuffer, idx, b, off, len);
|
||||
idx += len;
|
||||
return len;
|
||||
}
|
||||
|
||||
public void markIndex() {
|
||||
markIDX = idx;
|
||||
}
|
||||
|
||||
public void rewindIndex() {
|
||||
idx = markIDX;
|
||||
}
|
||||
|
||||
public byte[] getLeftover() {
|
||||
if(currentBuffer.length - idx <= 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
byte[] buf = new byte[currentBuffer.length - idx];
|
||||
System.arraycopy(currentBuffer, idx, buf, 0, currentBuffer.length - idx);
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
public int getLeftoverCount() {
|
||||
return currentBuffer.length - idx;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
package net.lax1dude.eaglercraft.sp.ipc;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
public class IPCOutputStream extends OutputStream {
|
||||
|
||||
private String className = null;
|
||||
private byte[] currentBuffer = null;
|
||||
private int idx = 0;
|
||||
private int originalSize = 0;
|
||||
|
||||
public void feedBuffer(byte[] buf, String clazzName) {
|
||||
currentBuffer = buf;
|
||||
idx = 0;
|
||||
originalSize = buf.length;
|
||||
className = clazzName;
|
||||
}
|
||||
|
||||
public byte[] returnBuffer() {
|
||||
if(className != null && currentBuffer.length != originalSize) {
|
||||
System.err.println("WARNING: Packet '" + className + "' was supposed to be " + originalSize + " bytes but buffer has grown by " + (currentBuffer.length - originalSize) + " to " + currentBuffer.length + " bytes");
|
||||
}
|
||||
return currentBuffer;
|
||||
}
|
||||
|
||||
void growBuffer(int i) {
|
||||
int ii = currentBuffer.length;
|
||||
int iii = i - ii;
|
||||
if(iii > 0) {
|
||||
byte[] n = new byte[i];
|
||||
System.arraycopy(currentBuffer, 0, n, 0, ii);
|
||||
currentBuffer = n;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(int b) throws IOException {
|
||||
if(idx >= currentBuffer.length) {
|
||||
growBuffer(idx + 1);
|
||||
}
|
||||
currentBuffer[idx++] = (byte) b;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(byte b[], int off, int len) throws IOException {
|
||||
if(idx + len > currentBuffer.length) {
|
||||
growBuffer(idx + len);
|
||||
}
|
||||
System.arraycopy(b, off, currentBuffer, idx, len);
|
||||
idx += len;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
package net.lax1dude.eaglercraft.sp.ipc;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
|
||||
public class IPCPacket00StartServer implements IPCPacketBase {
|
||||
|
||||
public static final int ID = 0x00;
|
||||
|
||||
public String worldName;
|
||||
public String ownerName;
|
||||
public int initialDifficulty;
|
||||
|
||||
public IPCPacket00StartServer() {
|
||||
}
|
||||
|
||||
public IPCPacket00StartServer(String worldName, String ownerName, int initialDifficulty) {
|
||||
this.worldName = worldName;
|
||||
this.ownerName = ownerName;
|
||||
this.initialDifficulty = initialDifficulty;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(DataInput bin) throws IOException {
|
||||
worldName = bin.readUTF();
|
||||
ownerName = bin.readUTF();
|
||||
initialDifficulty = bin.readByte();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(DataOutput bin) throws IOException {
|
||||
bin.writeUTF(worldName);
|
||||
bin.writeUTF(ownerName);
|
||||
bin.writeByte(initialDifficulty);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int id() {
|
||||
return ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return IPCPacketBase.strLen(worldName) + IPCPacketBase.strLen(ownerName) + 1;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
package net.lax1dude.eaglercraft.sp.ipc;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
|
||||
public class IPCPacket01StopServer implements IPCPacketBase {
|
||||
|
||||
public static final int ID = 0x01;
|
||||
|
||||
public IPCPacket01StopServer() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(DataInput bin) throws IOException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(DataOutput bin) throws IOException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int id() {
|
||||
return ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
package net.lax1dude.eaglercraft.sp.ipc;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
|
||||
public class IPCPacket02InitWorld implements IPCPacketBase {
|
||||
|
||||
public static final int ID = 0x02;
|
||||
|
||||
public String worldName;
|
||||
public byte gamemode;
|
||||
public byte worldType;
|
||||
public String worldArgs;
|
||||
public long seed;
|
||||
public boolean cheats;
|
||||
public boolean structures;
|
||||
public boolean bonusChest;
|
||||
|
||||
public IPCPacket02InitWorld() {
|
||||
}
|
||||
|
||||
public IPCPacket02InitWorld(String worldName, int gamemode, int worldType, String worldArgs, long seed, boolean cheats, boolean structures, boolean bonusChest) {
|
||||
this.worldName = worldName;
|
||||
this.gamemode = (byte)gamemode;
|
||||
this.worldType = (byte)worldType;
|
||||
this.worldArgs = worldArgs;
|
||||
this.seed = seed;
|
||||
this.cheats = cheats;
|
||||
this.structures = structures;
|
||||
this.bonusChest = bonusChest;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(DataInput bin) throws IOException {
|
||||
worldName = bin.readUTF();
|
||||
gamemode = bin.readByte();
|
||||
worldType = bin.readByte();
|
||||
worldArgs = bin.readUTF();
|
||||
seed = bin.readLong();
|
||||
cheats = bin.readBoolean();
|
||||
structures = bin.readBoolean();
|
||||
bonusChest = bin.readBoolean();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(DataOutput bin) throws IOException {
|
||||
bin.writeUTF(worldName);
|
||||
bin.writeByte(gamemode);
|
||||
bin.writeByte(worldType);
|
||||
bin.writeUTF(worldArgs);
|
||||
bin.writeLong(seed);
|
||||
bin.writeBoolean(cheats);
|
||||
bin.writeBoolean(structures);
|
||||
bin.writeBoolean(bonusChest);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int id() {
|
||||
return ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return IPCPacketBase.strLen(worldName) + 1 + 1 + IPCPacketBase.strLen(worldArgs) + 8 + 1 + 1 + 1;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
package net.lax1dude.eaglercraft.sp.ipc;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
|
||||
public class IPCPacket03DeleteWorld implements IPCPacketBase {
|
||||
|
||||
public static final int ID = 0x03;
|
||||
|
||||
public String worldName;
|
||||
|
||||
public IPCPacket03DeleteWorld() {
|
||||
}
|
||||
|
||||
public IPCPacket03DeleteWorld(String worldName) {
|
||||
this.worldName = worldName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(DataInput bin) throws IOException {
|
||||
worldName = bin.readUTF();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(DataOutput bin) throws IOException {
|
||||
bin.writeUTF(worldName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int id() {
|
||||
return ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return IPCPacketBase.strLen(worldName);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
package net.lax1dude.eaglercraft.sp.ipc;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
|
||||
public class IPCPacket04RenameWorld implements IPCPacketBase {
|
||||
|
||||
public static final int ID = 0x04;
|
||||
|
||||
public String worldOldName;
|
||||
public String worldNewName;
|
||||
public String displayName;
|
||||
public boolean copy;
|
||||
|
||||
public IPCPacket04RenameWorld() {
|
||||
}
|
||||
|
||||
public IPCPacket04RenameWorld(String worldOldName, String worldNewName, String displayName, boolean copy) {
|
||||
this.worldOldName = worldOldName;
|
||||
this.worldNewName = worldNewName;
|
||||
this.displayName = displayName;
|
||||
this.copy = copy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(DataInput bin) throws IOException {
|
||||
worldOldName = bin.readUTF();
|
||||
worldNewName = bin.readUTF();
|
||||
displayName = bin.readUTF();
|
||||
copy = bin.readBoolean();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(DataOutput bin) throws IOException {
|
||||
bin.writeUTF(worldOldName);
|
||||
bin.writeUTF(worldNewName);
|
||||
bin.writeUTF(displayName);
|
||||
bin.writeBoolean(copy);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int id() {
|
||||
return ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return IPCPacketBase.strLen(worldOldName) + IPCPacketBase.strLen(worldNewName) + IPCPacketBase.strLen(displayName) + 1;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
package net.lax1dude.eaglercraft.sp.ipc;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
|
||||
public class IPCPacket05RequestData implements IPCPacketBase {
|
||||
|
||||
public static final int ID = 0x05;
|
||||
|
||||
public static final byte REQUEST_LEVEL_DAT = 0x00;
|
||||
public static final byte REQUEST_LEVEL_EAG = 0x01;
|
||||
public static final byte REQUEST_LEVEL_MCA = 0x02;
|
||||
|
||||
public String worldName;
|
||||
public byte request;
|
||||
|
||||
public IPCPacket05RequestData() {
|
||||
}
|
||||
|
||||
public IPCPacket05RequestData(String worldName, byte request) {
|
||||
this.worldName = worldName;
|
||||
this.request = request;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(DataInput bin) throws IOException {
|
||||
worldName = bin.readUTF();
|
||||
request = bin.readByte();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(DataOutput bin) throws IOException {
|
||||
bin.writeUTF(worldName);
|
||||
bin.writeByte(request);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int id() {
|
||||
return ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return IPCPacketBase.strLen(worldName) + 1;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
package net.lax1dude.eaglercraft.sp.ipc;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
|
||||
public class IPCPacket06RenameWorldNBT implements IPCPacketBase {
|
||||
|
||||
public static final int ID = 0x06;
|
||||
|
||||
public String worldName;
|
||||
public String displayName;
|
||||
|
||||
public IPCPacket06RenameWorldNBT() {
|
||||
}
|
||||
|
||||
public IPCPacket06RenameWorldNBT(String worldName, String displayName) {
|
||||
this.worldName = worldName;
|
||||
this.displayName = displayName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(DataInput bin) throws IOException {
|
||||
this.worldName = bin.readUTF();
|
||||
this.displayName = bin.readUTF();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(DataOutput bin) throws IOException {
|
||||
bin.writeUTF(worldName);
|
||||
bin.writeUTF(displayName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int id() {
|
||||
return ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return IPCPacketBase.strLen(worldName) + IPCPacketBase.strLen(displayName);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
package net.lax1dude.eaglercraft.sp.ipc;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
|
||||
public class IPCPacket07ImportWorld implements IPCPacketBase {
|
||||
|
||||
public static final int ID = 0x07;
|
||||
|
||||
public String worldName;
|
||||
public byte[] worldData;
|
||||
public byte worldFormat;
|
||||
|
||||
public static final byte WORLD_FORMAT_EAG = 0x00;
|
||||
public static final byte WORLD_FORMAT_MCA = 0x01;
|
||||
|
||||
public IPCPacket07ImportWorld() {
|
||||
}
|
||||
|
||||
public IPCPacket07ImportWorld(String worldName, byte[] worldData, byte worldFormat) {
|
||||
this.worldName = worldName;
|
||||
this.worldData = worldData;
|
||||
this.worldFormat = worldFormat;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(DataInput bin) throws IOException {
|
||||
worldName = bin.readUTF();
|
||||
worldData = new byte[bin.readInt()];
|
||||
worldFormat = bin.readByte();
|
||||
bin.readFully(worldData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(DataOutput bin) throws IOException {
|
||||
bin.writeUTF(worldName);
|
||||
bin.writeInt(worldData.length);
|
||||
bin.writeByte(worldFormat);
|
||||
bin.write(worldData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int id() {
|
||||
return ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return IPCPacketBase.strLen(worldName) + worldData.length + 5;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
package net.lax1dude.eaglercraft.sp.ipc;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
|
||||
public class IPCPacket09RequestResponse implements IPCPacketBase {
|
||||
|
||||
public static final int ID = 0x09;
|
||||
|
||||
public byte[] response;
|
||||
|
||||
public IPCPacket09RequestResponse() {
|
||||
}
|
||||
|
||||
public IPCPacket09RequestResponse(byte[] dat) {
|
||||
this.response = dat;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(DataInput bin) throws IOException {
|
||||
response = new byte[bin.readInt()];
|
||||
bin.readFully(response);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(DataOutput bin) throws IOException {
|
||||
bin.writeInt(response.length);
|
||||
bin.write(response);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int id() {
|
||||
return ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return 4 + response.length;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
package net.lax1dude.eaglercraft.sp.ipc;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
|
||||
public class IPCPacket0ASetWorldDifficulty implements IPCPacketBase {
|
||||
|
||||
public static final int ID = 0x0A;
|
||||
|
||||
public byte difficulty;
|
||||
|
||||
public IPCPacket0ASetWorldDifficulty() {
|
||||
}
|
||||
|
||||
public IPCPacket0ASetWorldDifficulty(byte difficulty) {
|
||||
this.difficulty = difficulty;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(DataInput bin) throws IOException {
|
||||
difficulty = bin.readByte();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(DataOutput bin) throws IOException {
|
||||
bin.writeByte(difficulty);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int id() {
|
||||
return ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
package net.lax1dude.eaglercraft.sp.ipc;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
|
||||
public class IPCPacket0BPause implements IPCPacketBase {
|
||||
|
||||
public static final int ID = 0x0B;
|
||||
|
||||
public boolean pause;
|
||||
|
||||
public IPCPacket0BPause() {
|
||||
}
|
||||
|
||||
public IPCPacket0BPause(boolean pause) {
|
||||
this.pause = pause;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(DataInput bin) throws IOException {
|
||||
pause = bin.readBoolean();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(DataOutput bin) throws IOException {
|
||||
bin.writeBoolean(pause);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int id() {
|
||||
return ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
package net.lax1dude.eaglercraft.sp.ipc;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
|
||||
public class IPCPacket0CPlayerChannel implements IPCPacketBase {
|
||||
|
||||
public static final int ID = 0x0C;
|
||||
|
||||
public String channel;
|
||||
public boolean open;
|
||||
|
||||
public IPCPacket0CPlayerChannel() {
|
||||
}
|
||||
|
||||
public IPCPacket0CPlayerChannel(String channel, boolean open) {
|
||||
this.channel = channel;
|
||||
this.open = open;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(DataInput bin) throws IOException {
|
||||
channel = bin.readUTF();
|
||||
open = bin.readBoolean();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(DataOutput bin) throws IOException {
|
||||
bin.writeUTF(channel);
|
||||
bin.writeBoolean(open);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int id() {
|
||||
return ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return IPCPacketBase.strLen(channel) + 1;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
package net.lax1dude.eaglercraft.sp.ipc;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
|
||||
public class IPCPacket0DProgressUpdate implements IPCPacketBase {
|
||||
|
||||
public static final int ID = 0x0D;
|
||||
|
||||
public String updateMessage;
|
||||
public float updateProgress;
|
||||
|
||||
public IPCPacket0DProgressUpdate() {
|
||||
}
|
||||
|
||||
public IPCPacket0DProgressUpdate(String updateMessage, float updateProgress) {
|
||||
this.updateMessage = updateMessage == null ? "" : updateMessage;
|
||||
this.updateProgress = updateProgress;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(DataInput bin) throws IOException {
|
||||
updateMessage = bin.readUTF();
|
||||
updateProgress = bin.readFloat();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(DataOutput bin) throws IOException {
|
||||
bin.writeUTF(updateMessage);
|
||||
bin.writeFloat(updateProgress);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int id() {
|
||||
return ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return IPCPacketBase.strLen(updateMessage) + 4;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
package net.lax1dude.eaglercraft.sp.ipc;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
|
||||
public class IPCPacket0EListWorlds implements IPCPacketBase {
|
||||
|
||||
public static final int ID = 0x0E;
|
||||
|
||||
public IPCPacket0EListWorlds() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(DataInput bin) throws IOException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(DataOutput bin) throws IOException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int id() {
|
||||
return ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
package net.lax1dude.eaglercraft.sp.ipc;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
|
||||
public class IPCPacket0FListFiles implements IPCPacketBase {
|
||||
|
||||
public static final int ID = 0x0F;
|
||||
|
||||
public String path;
|
||||
|
||||
public IPCPacket0FListFiles() {
|
||||
}
|
||||
|
||||
public IPCPacket0FListFiles(String path) {
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(DataInput bin) throws IOException {
|
||||
this.path = bin.readUTF();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(DataOutput bin) throws IOException {
|
||||
bin.writeUTF(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int id() {
|
||||
return ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return IPCPacketBase.strLen(path);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
package net.lax1dude.eaglercraft.sp.ipc;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
|
||||
public class IPCPacket10FileRead implements IPCPacketBase {
|
||||
|
||||
public static final int ID = 0x10;
|
||||
|
||||
public String file;
|
||||
|
||||
public IPCPacket10FileRead() {
|
||||
}
|
||||
|
||||
public IPCPacket10FileRead(String file) {
|
||||
this.file = file;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(DataInput bin) throws IOException {
|
||||
file = bin.readUTF();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(DataOutput bin) throws IOException {
|
||||
bin.writeUTF(file);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int id() {
|
||||
return ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return IPCPacketBase.strLen(file);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
package net.lax1dude.eaglercraft.sp.ipc;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
|
||||
public class IPCPacket12FileWrite implements IPCPacketBase {
|
||||
|
||||
public static final int ID = 0x12;
|
||||
|
||||
public String path;
|
||||
public byte[] data;
|
||||
|
||||
public IPCPacket12FileWrite() {
|
||||
}
|
||||
|
||||
public IPCPacket12FileWrite(String path, byte[] data) {
|
||||
this.path = path;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(DataInput bin) throws IOException {
|
||||
path = bin.readUTF();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(DataOutput bin) throws IOException {
|
||||
bin.writeUTF(path);
|
||||
bin.writeInt(data.length);
|
||||
bin.write(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int id() {
|
||||
return ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return IPCPacketBase.strLen(path) + 4 + data.length;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
package net.lax1dude.eaglercraft.sp.ipc;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
|
||||
public class IPCPacket13FileCopyMove implements IPCPacketBase {
|
||||
|
||||
public static final int ID = 0x13;
|
||||
|
||||
public String fileOldName;
|
||||
public String fileNewName;
|
||||
public boolean copy;
|
||||
|
||||
public IPCPacket13FileCopyMove() {
|
||||
}
|
||||
|
||||
public IPCPacket13FileCopyMove(String fileOldName, String fileNewName, boolean copy) {
|
||||
this.fileOldName = fileOldName;
|
||||
this.fileNewName = fileNewName;
|
||||
this.copy = copy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(DataInput bin) throws IOException {
|
||||
fileOldName = bin.readUTF();
|
||||
fileNewName = bin.readUTF();
|
||||
copy = bin.readBoolean();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(DataOutput bin) throws IOException {
|
||||
bin.writeUTF(fileOldName);
|
||||
bin.writeUTF(fileNewName);
|
||||
bin.writeBoolean(copy);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int id() {
|
||||
return ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return IPCPacketBase.strLen(fileOldName) + IPCPacketBase.strLen(fileNewName) + 1;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,80 +0,0 @@
|
||||
package net.lax1dude.eaglercraft.sp.ipc;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class IPCPacket14StringList implements IPCPacketBase {
|
||||
|
||||
public static final int ID = 0x14;
|
||||
|
||||
public static final int FILE_LIST = 0x0;
|
||||
public static final int LOCALE = 0x1;
|
||||
public static final int STAT_GUID = 0x2;
|
||||
public static final int SERVER_TPS = 0x3;
|
||||
|
||||
public int opCode;
|
||||
public final List<String> stringList;
|
||||
|
||||
public IPCPacket14StringList() {
|
||||
stringList = new ArrayList<>();
|
||||
}
|
||||
|
||||
public IPCPacket14StringList(int opcode, String[] list) {
|
||||
stringList = new ArrayList<>();
|
||||
for(String s : list) {
|
||||
s = s.trim();
|
||||
if(s.length() > 0) {
|
||||
stringList.add(s);
|
||||
}
|
||||
}
|
||||
this.opCode = opcode;
|
||||
}
|
||||
|
||||
public IPCPacket14StringList(int opcode, List<String> list) {
|
||||
stringList = new ArrayList<>();
|
||||
for(String s : list) {
|
||||
s = s.trim();
|
||||
if(s.length() > 0) {
|
||||
stringList.add(s);
|
||||
}
|
||||
}
|
||||
this.opCode = opcode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(DataInput bin) throws IOException {
|
||||
stringList.clear();
|
||||
opCode = bin.readByte();
|
||||
int len = bin.readInt();
|
||||
for(int i = 0; i < len; ++i) {
|
||||
stringList.add(bin.readUTF());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(DataOutput bin) throws IOException {
|
||||
bin.writeByte(opCode);
|
||||
bin.writeInt(stringList.size());
|
||||
for(String str : stringList) {
|
||||
bin.writeUTF(str);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int id() {
|
||||
return ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
int len = 5;
|
||||
for(String str : stringList) {
|
||||
len += IPCPacketBase.strLen(str);
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
package net.lax1dude.eaglercraft.sp.ipc;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class IPCPacket15ThrowException implements IPCPacketBase {
|
||||
|
||||
public static final int ID = 0x15;
|
||||
|
||||
public String errorMessage;
|
||||
public final List<String> stackTrace;
|
||||
|
||||
public IPCPacket15ThrowException() {
|
||||
stackTrace = new ArrayList<>();
|
||||
}
|
||||
|
||||
public IPCPacket15ThrowException(String errorMessage, String[] list) {
|
||||
stackTrace = new ArrayList<>(Arrays.asList(list));
|
||||
this.errorMessage = errorMessage;
|
||||
}
|
||||
|
||||
public IPCPacket15ThrowException(String errorMessage, List<String> list) {
|
||||
stackTrace = list;
|
||||
this.errorMessage = errorMessage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(DataInput bin) throws IOException {
|
||||
stackTrace.clear();
|
||||
errorMessage = bin.readUTF();
|
||||
int len = bin.readInt();
|
||||
for(int i = 0; i < len; ++i) {
|
||||
stackTrace.add(bin.readUTF());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(DataOutput bin) throws IOException {
|
||||
bin.writeUTF(errorMessage);
|
||||
bin.writeInt(stackTrace.size());
|
||||
for(String str : stackTrace) {
|
||||
bin.writeUTF(str);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int id() {
|
||||
return ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
int len = 4 + IPCPacketBase.strLen(errorMessage);
|
||||
for(String str : stackTrace) {
|
||||
len += IPCPacketBase.strLen(str);
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
public void log() {
|
||||
System.err.println("Integrated server exception: " + errorMessage);
|
||||
for(String s : stackTrace) {
|
||||
System.err.println(" at " + s);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,95 +0,0 @@
|
||||
package net.lax1dude.eaglercraft.sp.ipc;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataInput;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutput;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.src.CompressedStreamTools;
|
||||
import net.minecraft.src.NBTTagCompound;
|
||||
|
||||
public class IPCPacket16NBTList implements IPCPacketBase {
|
||||
|
||||
public static final int ID = 0x16;
|
||||
|
||||
public static final int WORLD_LIST = 0x0;
|
||||
|
||||
public int opCode;
|
||||
public final List<byte[]> tagList;
|
||||
public final List<NBTTagCompound> nbtTagList;
|
||||
|
||||
public IPCPacket16NBTList() {
|
||||
tagList = new LinkedList<>();
|
||||
nbtTagList = new LinkedList<>();
|
||||
}
|
||||
|
||||
public IPCPacket16NBTList(int opcode, NBTTagCompound[] list) {
|
||||
this(opcode, Arrays.asList(list));
|
||||
}
|
||||
|
||||
public IPCPacket16NBTList(int opcode, List<NBTTagCompound> list) {
|
||||
tagList = new LinkedList<>();
|
||||
nbtTagList = list;
|
||||
for(int i = 0, size = list.size(); i < size; ++i) {
|
||||
NBTTagCompound tag = list.get(i);
|
||||
try {
|
||||
ByteArrayOutputStream bao = new ByteArrayOutputStream();
|
||||
CompressedStreamTools.write(tag, new DataOutputStream(bao));
|
||||
tagList.add(bao.toByteArray());
|
||||
}catch(IOException e) {
|
||||
System.err.println("Failed to write tag '" + tag.getName() + "' (#" + i + ") in IPCPacket16NBTList");
|
||||
}
|
||||
}
|
||||
opCode = opcode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(DataInput bin) throws IOException {
|
||||
tagList.clear();
|
||||
nbtTagList.clear();
|
||||
opCode = bin.readInt();
|
||||
int count = bin.readInt();
|
||||
for(int i = 0; i < count; ++i) {
|
||||
byte[] toRead = new byte[bin.readInt()];
|
||||
bin.readFully(toRead);
|
||||
tagList.add(toRead);
|
||||
try {
|
||||
nbtTagList.add(CompressedStreamTools.read(new DataInputStream(new ByteArrayInputStream(toRead))));
|
||||
}catch(IOException e) {
|
||||
System.err.println("Failed to read tag #" + i + " in IPCPacket16NBTList");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(DataOutput bin) throws IOException {
|
||||
bin.writeInt(opCode);
|
||||
bin.writeInt(tagList.size());
|
||||
for(byte[] str : tagList) {
|
||||
bin.writeInt(str.length);
|
||||
bin.write(str);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int id() {
|
||||
return ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
int len = 8;
|
||||
for(byte[] str : tagList) {
|
||||
len += 4;
|
||||
len += str.length;
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
package net.lax1dude.eaglercraft.sp.ipc;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class IPCPacket17ConfigureLAN implements IPCPacketBase {
|
||||
|
||||
public static final int ID = 0x17;
|
||||
|
||||
public int gamemode;
|
||||
public boolean cheats;
|
||||
public final List<String> iceServers;
|
||||
|
||||
public IPCPacket17ConfigureLAN() {
|
||||
iceServers = new ArrayList<>();
|
||||
}
|
||||
|
||||
public IPCPacket17ConfigureLAN(int gamemode, boolean cheats, List<String> iceServers) {
|
||||
this.gamemode = gamemode;
|
||||
this.cheats = cheats;
|
||||
this.iceServers = iceServers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(DataInput bin) throws IOException {
|
||||
gamemode = bin.readUnsignedByte();
|
||||
cheats = bin.readBoolean();
|
||||
iceServers.clear();
|
||||
int iceCount = bin.readUnsignedByte();
|
||||
for(int i = 0; i < iceCount; ++i) {
|
||||
iceServers.add(bin.readUTF());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(DataOutput bin) throws IOException {
|
||||
bin.writeByte(gamemode);
|
||||
bin.writeBoolean(cheats);
|
||||
bin.writeByte(iceServers.size());
|
||||
for(int i = 0, l = iceServers.size(); i < l; ++i) {
|
||||
bin.writeUTF(iceServers.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int id() {
|
||||
return ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
int s = 0;
|
||||
for(int i = 0, l = iceServers.size(); i < l; ++i) {
|
||||
s += 2;
|
||||
s += iceServers.get(i).length();
|
||||
}
|
||||
return 2 + 1 + s;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
package net.lax1dude.eaglercraft.sp.ipc;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
|
||||
public class IPCPacket18ClearPlayers implements IPCPacketBase {
|
||||
|
||||
public static final int ID = 0x18;
|
||||
|
||||
public String worldName = null;
|
||||
|
||||
public IPCPacket18ClearPlayers(String worldName) {
|
||||
this.worldName = worldName;
|
||||
}
|
||||
|
||||
public IPCPacket18ClearPlayers() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(DataInput bin) throws IOException {
|
||||
worldName = bin.readUTF();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(DataOutput bin) throws IOException {
|
||||
bin.writeUTF(worldName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int id() {
|
||||
return ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return IPCPacketBase.strLen(worldName);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
package net.lax1dude.eaglercraft.sp.ipc;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
|
||||
public interface IPCPacketBase {
|
||||
|
||||
public void deserialize(DataInput bin) throws IOException;
|
||||
public void serialize(DataOutput bin) throws IOException;
|
||||
public int id();
|
||||
public int size();
|
||||
|
||||
public static int strLen(String s) {
|
||||
int strlen = s.length();
|
||||
int utflen = 2;
|
||||
int c;
|
||||
|
||||
for (int i = 0; i < strlen; ++i) {
|
||||
c = s.charAt(i);
|
||||
if ((c >= 0x0001) && (c <= 0x007F)) {
|
||||
++utflen;
|
||||
} else if (c > 0x07FF) {
|
||||
utflen += 3;
|
||||
} else {
|
||||
utflen += 2;
|
||||
}
|
||||
}
|
||||
|
||||
return utflen;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
package net.lax1dude.eaglercraft.sp.ipc;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
|
||||
public class IPCPacketFFProcessKeepAlive implements IPCPacketBase {
|
||||
|
||||
public static final int ID = 0xFF;
|
||||
|
||||
public static final int KEEPALIVE = 0;
|
||||
public static final int FAILURE = 0xFE;
|
||||
|
||||
public int ack;
|
||||
|
||||
public IPCPacketFFProcessKeepAlive() {
|
||||
}
|
||||
|
||||
public IPCPacketFFProcessKeepAlive(int ack) {
|
||||
this.ack = ack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(DataInput bin) throws IOException {
|
||||
ack = bin.readUnsignedByte();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(DataOutput bin) throws IOException {
|
||||
bin.writeByte(ack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int id() {
|
||||
return ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,79 +0,0 @@
|
||||
package net.lax1dude.eaglercraft.sp.ipc;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class IPCPacketManager {
|
||||
|
||||
public static final HashMap<Integer, Supplier<IPCPacketBase>> mappings = new HashMap<>();
|
||||
|
||||
public static final IPCInputStream IPC_INPUT_STREAM = new IPCInputStream();
|
||||
public static final IPCOutputStream IPC_OUTPUT_STREAM = new IPCOutputStream();
|
||||
|
||||
public static final DataInputStream IPC_DATA_INPUT_STREAM = new DataInputStream(IPC_INPUT_STREAM);
|
||||
public static final DataOutputStream IPC_DATA_OUTPUT_STREAM = new DataOutputStream(IPC_OUTPUT_STREAM);
|
||||
|
||||
static {
|
||||
mappings.put(IPCPacket00StartServer.ID, () -> new IPCPacket00StartServer());
|
||||
mappings.put(IPCPacket01StopServer.ID, () -> new IPCPacket01StopServer());
|
||||
mappings.put(IPCPacket02InitWorld.ID, () -> new IPCPacket02InitWorld());
|
||||
mappings.put(IPCPacket03DeleteWorld.ID, () -> new IPCPacket03DeleteWorld());
|
||||
mappings.put(IPCPacket04RenameWorld.ID, () -> new IPCPacket04RenameWorld());
|
||||
mappings.put(IPCPacket05RequestData.ID, () -> new IPCPacket05RequestData());
|
||||
mappings.put(IPCPacket06RenameWorldNBT.ID, () -> new IPCPacket06RenameWorldNBT());
|
||||
mappings.put(IPCPacket07ImportWorld.ID, () -> new IPCPacket07ImportWorld());
|
||||
mappings.put(IPCPacket09RequestResponse.ID, () -> new IPCPacket09RequestResponse());
|
||||
mappings.put(IPCPacket0ASetWorldDifficulty.ID, () -> new IPCPacket0ASetWorldDifficulty());
|
||||
mappings.put(IPCPacket0BPause.ID, () -> new IPCPacket0BPause());
|
||||
mappings.put(IPCPacket0CPlayerChannel.ID, () -> new IPCPacket0CPlayerChannel());
|
||||
mappings.put(IPCPacket0DProgressUpdate.ID, () -> new IPCPacket0DProgressUpdate());
|
||||
mappings.put(IPCPacket0EListWorlds.ID, () -> new IPCPacket0EListWorlds());
|
||||
mappings.put(IPCPacket0FListFiles.ID, () -> new IPCPacket0FListFiles());
|
||||
mappings.put(IPCPacket10FileRead.ID, () -> new IPCPacket10FileRead());
|
||||
mappings.put(IPCPacket12FileWrite.ID, () -> new IPCPacket12FileWrite());
|
||||
mappings.put(IPCPacket13FileCopyMove.ID, () -> new IPCPacket13FileCopyMove());
|
||||
mappings.put(IPCPacket14StringList.ID, () -> new IPCPacket14StringList());
|
||||
mappings.put(IPCPacket15ThrowException.ID, () -> new IPCPacket15ThrowException());
|
||||
mappings.put(IPCPacket16NBTList.ID, () -> new IPCPacket16NBTList());
|
||||
mappings.put(IPCPacket17ConfigureLAN.ID, () -> new IPCPacket17ConfigureLAN());
|
||||
mappings.put(IPCPacket18ClearPlayers.ID, () -> new IPCPacket18ClearPlayers());
|
||||
mappings.put(IPCPacketFFProcessKeepAlive.ID, () -> new IPCPacketFFProcessKeepAlive());
|
||||
}
|
||||
|
||||
public static byte[] IPCSerialize(IPCPacketBase pkt) throws IOException {
|
||||
|
||||
IPC_OUTPUT_STREAM.feedBuffer(new byte[pkt.size() + 1], pkt.getClass().getSimpleName());
|
||||
IPC_OUTPUT_STREAM.write(pkt.id());
|
||||
pkt.serialize(IPC_DATA_OUTPUT_STREAM);
|
||||
|
||||
return IPC_OUTPUT_STREAM.returnBuffer();
|
||||
}
|
||||
|
||||
public static IPCPacketBase IPCDeserialize(byte[] pkt) throws IOException {
|
||||
|
||||
IPC_INPUT_STREAM.feedBuffer(pkt);
|
||||
int i = IPC_INPUT_STREAM.read();
|
||||
|
||||
Supplier<IPCPacketBase> pk = mappings.get(Integer.valueOf(i));
|
||||
if(pk == null) {
|
||||
throw new IOException("Packet type 0x" + Integer.toHexString(i) + " doesn't exist");
|
||||
}
|
||||
|
||||
IPCPacketBase p = pk.get();
|
||||
|
||||
IPC_INPUT_STREAM.nameBuffer(p.getClass().getSimpleName());
|
||||
|
||||
p.deserialize(IPC_DATA_INPUT_STREAM);
|
||||
|
||||
int lo = IPC_INPUT_STREAM.getLeftoverCount();
|
||||
if(lo > 0) {
|
||||
System.err.println("Packet type 0x" + Integer.toHexString(i) + " class '" + p.getClass().getSimpleName() + "' was size " + (pkt.length - 1) + " but only " + (pkt.length - 1 - lo) + " bytes were read");
|
||||
}
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
package net.minecraft.client;
|
||||
|
||||
public class ClientBrandRetriever
|
||||
{
|
||||
public static String getClientModName()
|
||||
{
|
||||
return "vanilla";
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,6 @@ package net.lax1dude.eaglercraft;
|
||||
|
||||
import static org.teavm.jso.webgl.WebGLRenderingContext.*;
|
||||
|
||||
import net.lax1dude.eaglercraft.sp.IntegratedServer;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.teavm.jso.JSBody;
|
||||
|
||||
@@ -22,6 +22,9 @@ import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user