Add new client protocol classes
This commit is contained in:
parent
a8f11defc7
commit
bc5346f2c8
|
@ -0,0 +1,44 @@
|
|||
package net.lax1dude.eaglercraft.v1_8.socket.protocol;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2024 lax1dude. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public interface GamePacketInputBuffer extends DataInput {
|
||||
|
||||
void skipAllBytes(int n) throws IOException;
|
||||
|
||||
int readVarInt() throws IOException;
|
||||
|
||||
long readVarLong() throws IOException;
|
||||
|
||||
String readStringMC(int maxLen) throws IOException;
|
||||
|
||||
String readStringEaglerASCII8() throws IOException;
|
||||
|
||||
String readStringEaglerASCII16() throws IOException;
|
||||
|
||||
byte[] readByteArrayMC() throws IOException;
|
||||
|
||||
int available() throws IOException;
|
||||
|
||||
InputStream stream();
|
||||
|
||||
byte[] toByteArray() throws IOException;
|
||||
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
package net.lax1dude.eaglercraft.v1_8.socket.protocol;
|
||||
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2024 lax1dude. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public interface GamePacketOutputBuffer extends DataOutput {
|
||||
|
||||
void writeVarInt(int i) throws IOException;
|
||||
|
||||
void writeVarLong(long i) throws IOException;
|
||||
|
||||
void writeStringMC(String str) throws IOException;
|
||||
|
||||
void writeStringEaglerASCII8(String str) throws IOException;
|
||||
|
||||
void writeStringEaglerASCII16(String str) throws IOException;
|
||||
|
||||
void writeByteArrayMC(byte[] bytes) throws IOException;
|
||||
|
||||
OutputStream stream();
|
||||
|
||||
public static int getVarIntSize(int input) {
|
||||
for (int i = 1; i < 5; ++i) {
|
||||
if ((input & -1 << i * 7) == 0) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return 5;
|
||||
}
|
||||
|
||||
public static int getVarLongSize(long input) {
|
||||
for (int i = 1; i < 9; ++i) {
|
||||
if ((input & -1 << i * 7) == 0) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return 9;
|
||||
}
|
||||
|
||||
public static int getArrayMCSize(int len) {
|
||||
return getVarIntSize(len) + len;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
package net.lax1dude.eaglercraft.v1_8.socket.protocol;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2024 lax1dude. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public class GamePluginMessageConstants {
|
||||
|
||||
public static final String V3_SKIN_CHANNEL = "EAG|Skins-1.8";
|
||||
public static final String V3_CAPE_CHANNEL = "EAG|Capes-1.8";
|
||||
public static final String V3_VOICE_CHANNEL = "EAG|Voice-1.8";
|
||||
public static final String V3_UPDATE_CHANNEL = "EAG|UpdateCert-1.8";
|
||||
public static final String V3_FNAW_EN_CHANNEL = "EAG|FNAWSEn-1.8";
|
||||
|
||||
public static final String V4_CHANNEL = "EAG|1.8";
|
||||
|
||||
public static final int CLIENT_TO_SERVER = 0;
|
||||
public static final int SERVER_TO_CLIENT = 1;
|
||||
|
||||
public static String getDirectionString(int dir) {
|
||||
switch(dir) {
|
||||
case CLIENT_TO_SERVER:
|
||||
return "CLIENT_TO_SERVER";
|
||||
case SERVER_TO_CLIENT:
|
||||
return "SERVER_TO_CLIENT";
|
||||
default:
|
||||
return "UNKNOWN";
|
||||
}
|
||||
}
|
||||
|
||||
public static int oppositeDirection(int dir) {
|
||||
switch(dir) {
|
||||
case CLIENT_TO_SERVER:
|
||||
return SERVER_TO_CLIENT;
|
||||
case SERVER_TO_CLIENT:
|
||||
return CLIENT_TO_SERVER;
|
||||
default:
|
||||
throw new IllegalArgumentException("Invalid direction: " + dir);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,230 @@
|
|||
package net.lax1dude.eaglercraft.v1_8.socket.protocol;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.GameMessagePacket;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.client.*;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.server.*;
|
||||
|
||||
import static net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePluginMessageConstants.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2024 lax1dude. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public enum GamePluginMessageProtocol {
|
||||
V3(3,
|
||||
define(V3_SKIN_CHANNEL, 0x03, CLIENT_TO_SERVER, CPacketGetOtherSkinEAG.class),
|
||||
define(V3_SKIN_CHANNEL, 0x04, SERVER_TO_CLIENT, SPacketOtherSkinPresetEAG.class),
|
||||
define(V3_SKIN_CHANNEL, 0x05, SERVER_TO_CLIENT, SPacketOtherSkinCustomV3EAG.class),
|
||||
define(V3_SKIN_CHANNEL, 0x06, CLIENT_TO_SERVER, CPacketGetSkinByURLEAG.class),
|
||||
define(V3_SKIN_CHANNEL, 0x07, CLIENT_TO_SERVER, CPacketInstallSkinSPEAG.class),
|
||||
define(V3_CAPE_CHANNEL, 0x03, CLIENT_TO_SERVER, CPacketGetOtherCapeEAG.class),
|
||||
define(V3_CAPE_CHANNEL, 0x04, SERVER_TO_CLIENT, SPacketOtherCapePresetEAG.class),
|
||||
define(V3_CAPE_CHANNEL, 0x05, SERVER_TO_CLIENT, SPacketOtherCapeCustomEAG.class),
|
||||
define(V3_VOICE_CHANNEL, 0x00, SERVER_TO_CLIENT, SPacketVoiceSignalAllowedEAG.class),
|
||||
define(V3_VOICE_CHANNEL, 0x00, CLIENT_TO_SERVER, CPacketVoiceSignalRequestEAG.class),
|
||||
define(V3_VOICE_CHANNEL, 0x01, CLIENT_TO_SERVER, CPacketVoiceSignalConnectEAG.class),
|
||||
define(V3_VOICE_CHANNEL, 0x01, SERVER_TO_CLIENT, SPacketVoiceSignalConnectV3EAG.class),
|
||||
define(V3_VOICE_CHANNEL, 0x02, CLIENT_TO_SERVER, CPacketVoiceSignalDisconnectV3EAG.class),
|
||||
define(V3_VOICE_CHANNEL, 0x02, SERVER_TO_CLIENT, SPacketVoiceSignalDisconnectPeerEAG.class),
|
||||
define(V3_VOICE_CHANNEL, 0x03, CLIENT_TO_SERVER, CPacketVoiceSignalICEEAG.class),
|
||||
define(V3_VOICE_CHANNEL, 0x03, SERVER_TO_CLIENT, SPacketVoiceSignalICEEAG.class),
|
||||
define(V3_VOICE_CHANNEL, 0x04, CLIENT_TO_SERVER, CPacketVoiceSignalDescEAG.class),
|
||||
define(V3_VOICE_CHANNEL, 0x04, SERVER_TO_CLIENT, SPacketVoiceSignalDescEAG.class),
|
||||
define(V3_VOICE_CHANNEL, 0x05, SERVER_TO_CLIENT, SPacketVoiceSignalGlobalEAG.class),
|
||||
define(V3_UPDATE_CHANNEL, -1, SERVER_TO_CLIENT, SPacketUpdateCertEAG.class),
|
||||
define(V3_FNAW_EN_CHANNEL, -1, SERVER_TO_CLIENT, SPacketEnableFNAWSkinsEAG.class)
|
||||
), V4(4,
|
||||
define(V4_CHANNEL, 0x01, CLIENT_TO_SERVER, CPacketGetOtherSkinEAG.class),
|
||||
define(V4_CHANNEL, 0x02, SERVER_TO_CLIENT, SPacketOtherSkinPresetEAG.class),
|
||||
define(V4_CHANNEL, 0x03, SERVER_TO_CLIENT, SPacketOtherSkinCustomV4EAG.class),
|
||||
define(V4_CHANNEL, 0x04, CLIENT_TO_SERVER, CPacketGetSkinByURLEAG.class),
|
||||
define(V4_CHANNEL, 0x05, CLIENT_TO_SERVER, CPacketInstallSkinSPEAG.class),
|
||||
define(V4_CHANNEL, 0x06, CLIENT_TO_SERVER, CPacketGetOtherCapeEAG.class),
|
||||
define(V4_CHANNEL, 0x07, SERVER_TO_CLIENT, SPacketOtherCapePresetEAG.class),
|
||||
define(V4_CHANNEL, 0x08, SERVER_TO_CLIENT, SPacketOtherCapeCustomEAG.class),
|
||||
define(V4_CHANNEL, 0x09, SERVER_TO_CLIENT, SPacketVoiceSignalAllowedEAG.class),
|
||||
define(V4_CHANNEL, 0x0A, CLIENT_TO_SERVER, CPacketVoiceSignalRequestEAG.class),
|
||||
define(V4_CHANNEL, 0x0B, CLIENT_TO_SERVER, CPacketVoiceSignalConnectEAG.class),
|
||||
define(V4_CHANNEL, 0x0C, SERVER_TO_CLIENT, SPacketVoiceSignalConnectV4EAG.class),
|
||||
define(V4_CHANNEL, 0x0D, SERVER_TO_CLIENT, SPacketVoiceSignalConnectAnnounceV4EAG.class),
|
||||
define(V4_CHANNEL, 0x0E, CLIENT_TO_SERVER, CPacketVoiceSignalDisconnectV4EAG.class),
|
||||
define(V4_CHANNEL, 0x0F, CLIENT_TO_SERVER, CPacketVoiceSignalDisconnectPeerV4EAG.class),
|
||||
define(V4_CHANNEL, 0x10, SERVER_TO_CLIENT, SPacketVoiceSignalDisconnectPeerEAG.class),
|
||||
define(V4_CHANNEL, 0x11, CLIENT_TO_SERVER, CPacketVoiceSignalICEEAG.class),
|
||||
define(V4_CHANNEL, 0x12, SERVER_TO_CLIENT, SPacketVoiceSignalICEEAG.class),
|
||||
define(V4_CHANNEL, 0x13, CLIENT_TO_SERVER, CPacketVoiceSignalDescEAG.class),
|
||||
define(V4_CHANNEL, 0x14, SERVER_TO_CLIENT, SPacketVoiceSignalDescEAG.class),
|
||||
define(V4_CHANNEL, 0x15, SERVER_TO_CLIENT, SPacketVoiceSignalGlobalEAG.class),
|
||||
define(V4_CHANNEL, 0x16, SERVER_TO_CLIENT, SPacketUpdateCertEAG.class),
|
||||
define(V4_CHANNEL, 0x17, SERVER_TO_CLIENT, SPacketEnableFNAWSkinsEAG.class),
|
||||
define(V4_CHANNEL, 0x18, SERVER_TO_CLIENT, SPacketForceClientSkinPresetV4EAG.class),
|
||||
define(V4_CHANNEL, 0x19, SERVER_TO_CLIENT, SPacketForceClientSkinCustomV4EAG.class),
|
||||
define(V4_CHANNEL, 0x1A, SERVER_TO_CLIENT, SPacketSetServerCookieV4EAG.class),
|
||||
define(V4_CHANNEL, 0x1B, SERVER_TO_CLIENT, SPacketRedirectClientV4EAG.class),
|
||||
define(V4_CHANNEL, 0x1C, CLIENT_TO_SERVER, CPacketGetOtherClientUUIDV4EAG.class),
|
||||
define(V4_CHANNEL, 0x1D, SERVER_TO_CLIENT, SPacketOtherPlayerClientUUIDV4EAG.class),
|
||||
define(V4_CHANNEL, 0x1E, SERVER_TO_CLIENT, SPacketForceClientCapePresetV4EAG.class),
|
||||
define(V4_CHANNEL, 0x1F, SERVER_TO_CLIENT, SPacketForceClientCapeCustomV4EAG.class),
|
||||
define(V4_CHANNEL, 0x20, SERVER_TO_CLIENT, SPacketInvalidatePlayerCacheV4EAG.class),
|
||||
define(V4_CHANNEL, 0x21, SERVER_TO_CLIENT, SPacketUnforceClientV4EAG.class),
|
||||
define(V4_CHANNEL, 0x22, SERVER_TO_CLIENT, SPacketCustomizePauseMenuV4EAG.class),
|
||||
define(V4_CHANNEL, 0x23, CLIENT_TO_SERVER, CPacketRequestServerInfoV4EAG.class),
|
||||
define(V4_CHANNEL, 0x24, SERVER_TO_CLIENT, SPacketServerInfoDataChunkV4EAG.class),
|
||||
define(V4_CHANNEL, 0x25, CLIENT_TO_SERVER, CPacketWebViewMessageEnV4EAG.class),
|
||||
define(V4_CHANNEL, 0x26, CLIENT_TO_SERVER, CPacketWebViewMessageV4EAG.class),
|
||||
define(V4_CHANNEL, 0x27, SERVER_TO_CLIENT, SPacketWebViewMessageV4EAG.class),
|
||||
define(V4_CHANNEL, 0x28, SERVER_TO_CLIENT, SPacketNotifIconsRegisterV4EAG.class),
|
||||
define(V4_CHANNEL, 0x29, SERVER_TO_CLIENT, SPacketNotifIconsReleaseV4EAG.class),
|
||||
define(V4_CHANNEL, 0x2A, SERVER_TO_CLIENT, SPacketNotifBadgeShowV4EAG.class),
|
||||
define(V4_CHANNEL, 0x2B, SERVER_TO_CLIENT, SPacketNotifBadgeHideV4EAG.class)
|
||||
);
|
||||
|
||||
public final int ver;
|
||||
|
||||
private final Map<String, Object>[] channelMap;
|
||||
private final Map<Class<? extends GameMessagePacket>, PacketDef>[] classMap;
|
||||
private final Set<String> notChannelMap = new HashSet<>(); // populated in clinit
|
||||
|
||||
private static final GamePluginMessageProtocol[] PROTOCOLS_MAP = new GamePluginMessageProtocol[5];
|
||||
private static final Set<String> allChannels = new HashSet<>();
|
||||
|
||||
private GamePluginMessageProtocol(int versionInt, PacketDef... packets) {
|
||||
ver = versionInt;
|
||||
channelMap = new Map[] { new HashMap<>(), new HashMap<>() };
|
||||
classMap = new Map[] { new HashMap<>(), new HashMap<>() };
|
||||
for(int i = 0; i < packets.length; ++i) {
|
||||
PacketDef pkt = packets[i];
|
||||
classMap[pkt.dir].put(pkt.clazz, pkt);
|
||||
if(pkt.id == -1) {
|
||||
channelMap[pkt.dir].put(pkt.channel, pkt);
|
||||
}else {
|
||||
PacketDef[] map = (PacketDef[])channelMap[pkt.dir].get(pkt.channel);
|
||||
if(map == null || map.length <= pkt.id) {
|
||||
PacketDef[] newMap = new PacketDef[((pkt.id + 1) & 0xF0) + 0x0F];
|
||||
if(map != null) {
|
||||
System.arraycopy(map, 0, newMap, 0, map.length);
|
||||
}
|
||||
map = newMap;
|
||||
channelMap[pkt.dir].put(pkt.channel, map);
|
||||
}
|
||||
map[pkt.id] = pkt;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static PacketDef define(String channel, int id, int dir, Class<? extends GameMessagePacket> clazz) {
|
||||
return new PacketDef(channel, id, dir, clazz);
|
||||
}
|
||||
|
||||
private static class PacketDef {
|
||||
|
||||
private final String channel;
|
||||
private final int id;
|
||||
private final int dir;
|
||||
private final Class<? extends GameMessagePacket> clazz;
|
||||
|
||||
private PacketDef(String channel, int id, int dir, Class<? extends GameMessagePacket> clazz) {
|
||||
this.channel = channel;
|
||||
this.id = id;
|
||||
this.dir = dir;
|
||||
this.clazz = clazz;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public GameMessagePacket readPacket(String channel, int direction, GamePacketInputBuffer buffer) throws IOException {
|
||||
Object obj = channelMap[direction].get(channel);
|
||||
if(obj == null) {
|
||||
return null;
|
||||
}
|
||||
PacketDef toRead;
|
||||
if(obj instanceof PacketDef) {
|
||||
toRead = (PacketDef)obj;
|
||||
}else {
|
||||
int pktId = buffer.readUnsignedByte();
|
||||
PacketDef[] pkts = (PacketDef[])obj;
|
||||
if(pktId < 0 || pktId >= pkts.length || (toRead = pkts[pktId]) == null) {
|
||||
throw new IOException("[" + channel + "] Unknown packet ID: " + pktId);
|
||||
}
|
||||
}
|
||||
GameMessagePacket ret;
|
||||
try {
|
||||
ret = toRead.clazz.newInstance();
|
||||
}catch(Throwable t) {
|
||||
throw new RuntimeException("Reflection failed to call packet constructor! (Is it defined?)", t);
|
||||
}
|
||||
ret.readPacket(buffer);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public String writePacket(int direction, GamePacketOutputBuffer stream, GameMessagePacket packet) throws IOException {
|
||||
Class<? extends GameMessagePacket> clazz = packet.getClass();
|
||||
PacketDef def = classMap[direction].get(clazz);
|
||||
if(def == null) {
|
||||
throw new IOException("Unknown packet type or wrong direction: " + clazz);
|
||||
}
|
||||
if(def.id != -1) {
|
||||
stream.writeByte(def.id);
|
||||
}
|
||||
packet.writePacket(stream);
|
||||
return def.channel;
|
||||
}
|
||||
|
||||
public List<String> filterProtocols(Collection<String> data) {
|
||||
List<String> ret = new ArrayList<>(data.size());
|
||||
for(String str : data) {
|
||||
if(!notChannelMap.contains(str)) {
|
||||
ret.add(str);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static GamePluginMessageProtocol getByVersion(int ver) {
|
||||
if(ver < 0 || ver > PROTOCOLS_MAP.length) {
|
||||
return null;
|
||||
}
|
||||
return PROTOCOLS_MAP[ver];
|
||||
}
|
||||
|
||||
public static Set<String> getAllChannels() {
|
||||
return allChannels;
|
||||
}
|
||||
|
||||
static {
|
||||
GamePluginMessageProtocol[] _values = values();
|
||||
PROTOCOLS_MAP[2] = V3;
|
||||
for(int i = 0; i < _values.length; ++i) {
|
||||
GamePluginMessageProtocol protocol = _values[i];
|
||||
PROTOCOLS_MAP[protocol.ver] = protocol;
|
||||
allChannels.addAll(protocol.channelMap[CLIENT_TO_SERVER].keySet());
|
||||
allChannels.addAll(protocol.channelMap[SERVER_TO_CLIENT].keySet());
|
||||
}
|
||||
for(int i = 0; i < _values.length; ++i) {
|
||||
GamePluginMessageProtocol protocol = _values[i];
|
||||
protocol.notChannelMap.addAll(allChannels);
|
||||
protocol.notChannelMap.removeAll(protocol.channelMap[CLIENT_TO_SERVER].keySet());
|
||||
protocol.notChannelMap.removeAll(protocol.channelMap[SERVER_TO_CLIENT].keySet());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,207 @@
|
|||
package net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.client.*;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.server.*;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2024 lax1dude. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public interface GameMessageHandler {
|
||||
|
||||
default void handleClient(CPacketGetOtherCapeEAG packet) {
|
||||
throw new WrongPacketException();
|
||||
}
|
||||
|
||||
default void handleClient(CPacketGetOtherSkinEAG packet) {
|
||||
throw new WrongPacketException();
|
||||
}
|
||||
|
||||
default void handleClient(CPacketGetSkinByURLEAG packet) {
|
||||
throw new WrongPacketException();
|
||||
}
|
||||
|
||||
default void handleClient(CPacketInstallSkinSPEAG packet) {
|
||||
throw new WrongPacketException();
|
||||
}
|
||||
|
||||
default void handleClient(CPacketVoiceSignalConnectEAG packet) {
|
||||
throw new WrongPacketException();
|
||||
}
|
||||
|
||||
default void handleClient(CPacketVoiceSignalDescEAG packet) {
|
||||
throw new WrongPacketException();
|
||||
}
|
||||
|
||||
default void handleClient(CPacketVoiceSignalDisconnectV3EAG packet) {
|
||||
throw new WrongPacketException();
|
||||
}
|
||||
|
||||
default void handleClient(CPacketVoiceSignalDisconnectV4EAG packet) {
|
||||
throw new WrongPacketException();
|
||||
}
|
||||
|
||||
default void handleClient(CPacketVoiceSignalDisconnectPeerV4EAG packet) {
|
||||
throw new WrongPacketException();
|
||||
}
|
||||
|
||||
default void handleClient(CPacketVoiceSignalICEEAG packet) {
|
||||
throw new WrongPacketException();
|
||||
}
|
||||
|
||||
default void handleClient(CPacketVoiceSignalRequestEAG packet) {
|
||||
throw new WrongPacketException();
|
||||
}
|
||||
|
||||
default void handleClient(CPacketGetOtherClientUUIDV4EAG packet) {
|
||||
throw new WrongPacketException();
|
||||
}
|
||||
|
||||
default void handleClient(CPacketRequestServerInfoV4EAG packet) {
|
||||
throw new WrongPacketException();
|
||||
}
|
||||
|
||||
default void handleClient(CPacketWebViewMessageV4EAG packet) {
|
||||
throw new WrongPacketException();
|
||||
}
|
||||
|
||||
default void handleClient(CPacketWebViewMessageEnV4EAG packet) {
|
||||
throw new WrongPacketException();
|
||||
}
|
||||
|
||||
default void handleServer(SPacketEnableFNAWSkinsEAG packet) {
|
||||
throw new WrongPacketException();
|
||||
}
|
||||
|
||||
default void handleServer(SPacketOtherCapeCustomEAG packet) {
|
||||
throw new WrongPacketException();
|
||||
}
|
||||
|
||||
default void handleServer(SPacketOtherCapePresetEAG packet) {
|
||||
throw new WrongPacketException();
|
||||
}
|
||||
|
||||
default void handleServer(SPacketOtherSkinCustomV3EAG packet) {
|
||||
throw new WrongPacketException();
|
||||
}
|
||||
|
||||
default void handleServer(SPacketOtherSkinCustomV4EAG packet) {
|
||||
throw new WrongPacketException();
|
||||
}
|
||||
|
||||
default void handleServer(SPacketOtherSkinPresetEAG packet) {
|
||||
throw new WrongPacketException();
|
||||
}
|
||||
|
||||
default void handleServer(SPacketUpdateCertEAG packet) {
|
||||
throw new WrongPacketException();
|
||||
}
|
||||
|
||||
default void handleServer(SPacketVoiceSignalAllowedEAG packet) {
|
||||
throw new WrongPacketException();
|
||||
}
|
||||
|
||||
default void handleServer(SPacketVoiceSignalConnectV3EAG packet) {
|
||||
throw new WrongPacketException();
|
||||
}
|
||||
|
||||
default void handleServer(SPacketVoiceSignalConnectV4EAG packet) {
|
||||
throw new WrongPacketException();
|
||||
}
|
||||
|
||||
default void handleServer(SPacketVoiceSignalConnectAnnounceV4EAG packet) {
|
||||
throw new WrongPacketException();
|
||||
}
|
||||
|
||||
default void handleServer(SPacketVoiceSignalDescEAG packet) {
|
||||
throw new WrongPacketException();
|
||||
}
|
||||
|
||||
default void handleServer(SPacketVoiceSignalDisconnectPeerEAG packet) {
|
||||
throw new WrongPacketException();
|
||||
}
|
||||
|
||||
default void handleServer(SPacketVoiceSignalGlobalEAG packet) {
|
||||
throw new WrongPacketException();
|
||||
}
|
||||
|
||||
default void handleServer(SPacketVoiceSignalICEEAG packet) {
|
||||
throw new WrongPacketException();
|
||||
}
|
||||
|
||||
default void handleServer(SPacketForceClientSkinPresetV4EAG packet) {
|
||||
throw new WrongPacketException();
|
||||
}
|
||||
|
||||
default void handleServer(SPacketForceClientSkinCustomV4EAG packet) {
|
||||
throw new WrongPacketException();
|
||||
}
|
||||
|
||||
default void handleServer(SPacketSetServerCookieV4EAG packet) {
|
||||
throw new WrongPacketException();
|
||||
}
|
||||
|
||||
default void handleServer(SPacketRedirectClientV4EAG packet) {
|
||||
throw new WrongPacketException();
|
||||
}
|
||||
|
||||
default void handleServer(SPacketOtherPlayerClientUUIDV4EAG packet) {
|
||||
throw new WrongPacketException();
|
||||
}
|
||||
|
||||
default void handleServer(SPacketForceClientCapePresetV4EAG packet) {
|
||||
throw new WrongPacketException();
|
||||
}
|
||||
|
||||
default void handleServer(SPacketForceClientCapeCustomV4EAG packet) {
|
||||
throw new WrongPacketException();
|
||||
}
|
||||
|
||||
default void handleServer(SPacketInvalidatePlayerCacheV4EAG packet) {
|
||||
throw new WrongPacketException();
|
||||
}
|
||||
|
||||
default void handleServer(SPacketUnforceClientV4EAG packet) {
|
||||
throw new WrongPacketException();
|
||||
}
|
||||
|
||||
default void handleServer(SPacketCustomizePauseMenuV4EAG packet) {
|
||||
throw new WrongPacketException();
|
||||
}
|
||||
|
||||
default void handleServer(SPacketServerInfoDataChunkV4EAG packet) {
|
||||
throw new WrongPacketException();
|
||||
}
|
||||
|
||||
default void handleServer(SPacketWebViewMessageV4EAG packet) {
|
||||
throw new WrongPacketException();
|
||||
}
|
||||
|
||||
default void handleServer(SPacketNotifIconsRegisterV4EAG packet) {
|
||||
throw new WrongPacketException();
|
||||
}
|
||||
|
||||
default void handleServer(SPacketNotifIconsReleaseV4EAG packet) {
|
||||
throw new WrongPacketException();
|
||||
}
|
||||
|
||||
default void handleServer(SPacketNotifBadgeShowV4EAG packet) {
|
||||
throw new WrongPacketException();
|
||||
}
|
||||
|
||||
default void handleServer(SPacketNotifBadgeHideV4EAG packet) {
|
||||
throw new WrongPacketException();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
package net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePacketInputBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePacketOutputBuffer;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2024 lax1dude. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public interface GameMessagePacket {
|
||||
|
||||
void readPacket(GamePacketInputBuffer buffer) throws IOException;
|
||||
|
||||
void writePacket(GamePacketOutputBuffer buffer) throws IOException;
|
||||
|
||||
void handlePacket(GameMessageHandler handler);
|
||||
|
||||
int length();
|
||||
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2024 lax1dude. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public class WrongPacketException extends RuntimeException {
|
||||
|
||||
public WrongPacketException() {
|
||||
super("Wrong packet type recieved for the current handler!");
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
package net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.client;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePacketInputBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePacketOutputBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.GameMessageHandler;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.GameMessagePacket;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2024 lax1dude. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public class CPacketGetOtherCapeEAG implements GameMessagePacket {
|
||||
|
||||
public long uuidMost;
|
||||
public long uuidLeast;
|
||||
|
||||
public CPacketGetOtherCapeEAG() {
|
||||
}
|
||||
|
||||
public CPacketGetOtherCapeEAG(long uuidMost, long uuidLeast) {
|
||||
this.uuidMost = uuidMost;
|
||||
this.uuidLeast = uuidLeast;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readPacket(GamePacketInputBuffer buffer) throws IOException {
|
||||
uuidMost = buffer.readLong();
|
||||
uuidLeast = buffer.readLong();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writePacket(GamePacketOutputBuffer buffer) throws IOException {
|
||||
buffer.writeLong(uuidMost);
|
||||
buffer.writeLong(uuidLeast);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePacket(GameMessageHandler handler) {
|
||||
handler.handleClient(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int length() {
|
||||
return 16;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
package net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.client;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePacketInputBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePacketOutputBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.GameMessageHandler;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.GameMessagePacket;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2024 lax1dude. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public class CPacketGetOtherClientUUIDV4EAG implements GameMessagePacket {
|
||||
|
||||
public int requestId;
|
||||
public long playerUUIDMost;
|
||||
public long playerUUIDLeast;
|
||||
|
||||
public CPacketGetOtherClientUUIDV4EAG() {
|
||||
}
|
||||
|
||||
public CPacketGetOtherClientUUIDV4EAG(int requestId, long playerUUIDMost, long playerUUIDLeast) {
|
||||
this.requestId = requestId;
|
||||
this.playerUUIDMost = playerUUIDMost;
|
||||
this.playerUUIDLeast = playerUUIDLeast;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readPacket(GamePacketInputBuffer buffer) throws IOException {
|
||||
requestId = buffer.readVarInt();
|
||||
playerUUIDMost = buffer.readLong();
|
||||
playerUUIDLeast = buffer.readLong();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writePacket(GamePacketOutputBuffer buffer) throws IOException {
|
||||
buffer.writeVarInt(requestId);
|
||||
buffer.writeLong(playerUUIDMost);
|
||||
buffer.writeLong(playerUUIDLeast);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePacket(GameMessageHandler handler) {
|
||||
handler.handleClient(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int length() {
|
||||
return GamePacketOutputBuffer.getVarIntSize(requestId) + 16;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
package net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.client;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePacketInputBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePacketOutputBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.GameMessageHandler;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.GameMessagePacket;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2024 lax1dude. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public class CPacketGetOtherSkinEAG implements GameMessagePacket {
|
||||
|
||||
public long uuidMost;
|
||||
public long uuidLeast;
|
||||
|
||||
public CPacketGetOtherSkinEAG() {
|
||||
}
|
||||
|
||||
public CPacketGetOtherSkinEAG(long uuidMost, long uuidLeast) {
|
||||
this.uuidMost = uuidMost;
|
||||
this.uuidLeast = uuidLeast;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readPacket(GamePacketInputBuffer buffer) throws IOException {
|
||||
uuidMost = buffer.readLong();
|
||||
uuidLeast = buffer.readLong();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writePacket(GamePacketOutputBuffer buffer) throws IOException {
|
||||
buffer.writeLong(uuidMost);
|
||||
buffer.writeLong(uuidLeast);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePacket(GameMessageHandler handler) {
|
||||
handler.handleClient(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int length() {
|
||||
return 16;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
package net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.client;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePacketInputBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePacketOutputBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.GameMessageHandler;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.GameMessagePacket;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2024 lax1dude. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public class CPacketGetSkinByURLEAG implements GameMessagePacket {
|
||||
|
||||
public long uuidMost;
|
||||
public long uuidLeast;
|
||||
public String url;
|
||||
|
||||
public CPacketGetSkinByURLEAG() {
|
||||
}
|
||||
|
||||
public CPacketGetSkinByURLEAG(long uuidMost, long uuidLeast, String url) {
|
||||
this.uuidMost = uuidMost;
|
||||
this.uuidLeast = uuidLeast;
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readPacket(GamePacketInputBuffer buffer) throws IOException {
|
||||
uuidMost = buffer.readLong();
|
||||
uuidLeast = buffer.readLong();
|
||||
url = buffer.readStringEaglerASCII16();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writePacket(GamePacketOutputBuffer buffer) throws IOException {
|
||||
buffer.writeLong(uuidMost);
|
||||
buffer.writeLong(uuidLeast);
|
||||
buffer.writeStringEaglerASCII16(url);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePacket(GameMessageHandler handler) {
|
||||
handler.handleClient(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int length() {
|
||||
return 18 + url.length();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
package net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.client;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePacketInputBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePacketOutputBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.GameMessageHandler;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.GameMessagePacket;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2024 lax1dude. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public class CPacketInstallSkinSPEAG implements GameMessagePacket {
|
||||
|
||||
public byte[] customSkin;
|
||||
|
||||
public CPacketInstallSkinSPEAG() {
|
||||
}
|
||||
|
||||
public CPacketInstallSkinSPEAG(byte[] customSkin) {
|
||||
this.customSkin = customSkin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readPacket(GamePacketInputBuffer buffer) throws IOException {
|
||||
customSkin = new byte[buffer.readUnsignedShort()];
|
||||
buffer.readFully(customSkin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writePacket(GamePacketOutputBuffer buffer) throws IOException {
|
||||
buffer.writeShort(customSkin.length);
|
||||
buffer.write(customSkin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePacket(GameMessageHandler handler) {
|
||||
handler.handleClient(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int length() {
|
||||
return 2 + customSkin.length;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
package net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.client;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePacketInputBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePacketOutputBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.GameMessageHandler;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.GameMessagePacket;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2024 lax1dude. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public class CPacketRequestServerInfoV4EAG implements GameMessagePacket {
|
||||
|
||||
public byte[] requestHash;
|
||||
|
||||
public CPacketRequestServerInfoV4EAG() {
|
||||
}
|
||||
|
||||
public CPacketRequestServerInfoV4EAG(byte[] requestHash) {
|
||||
this.requestHash = requestHash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readPacket(GamePacketInputBuffer buffer) throws IOException {
|
||||
requestHash = new byte[20];
|
||||
buffer.readFully(requestHash);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writePacket(GamePacketOutputBuffer buffer) throws IOException {
|
||||
if(requestHash.length != 20) {
|
||||
throw new IOException("Hash must be 20 bytes! (" + requestHash.length + " given)");
|
||||
}
|
||||
buffer.write(requestHash);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePacket(GameMessageHandler handler) {
|
||||
handler.handleClient(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int length() {
|
||||
return 20;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
package net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.client;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePacketInputBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePacketOutputBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.GameMessageHandler;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.GameMessagePacket;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2024 lax1dude. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public class CPacketVoiceSignalConnectEAG implements GameMessagePacket {
|
||||
|
||||
public CPacketVoiceSignalConnectEAG() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readPacket(GamePacketInputBuffer buffer) throws IOException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writePacket(GamePacketOutputBuffer buffer) throws IOException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePacket(GameMessageHandler handler) {
|
||||
handler.handleClient(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int length() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,80 @@
|
|||
package net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.client;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePacketInputBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePacketOutputBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.GameMessageHandler;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.GameMessagePacket;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2024 lax1dude. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public class CPacketVoiceSignalDescEAG implements GameMessagePacket {
|
||||
|
||||
public long uuidMost;
|
||||
public long uuidLeast;
|
||||
public byte[] desc;
|
||||
|
||||
public CPacketVoiceSignalDescEAG() {
|
||||
}
|
||||
|
||||
public CPacketVoiceSignalDescEAG(long uuidMost, long uuidLeast, byte[] desc) {
|
||||
this.uuidMost = uuidMost;
|
||||
this.uuidLeast = uuidLeast;
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
public CPacketVoiceSignalDescEAG(long uuidMost, long uuidLeast, String desc) {
|
||||
this.uuidMost = uuidMost;
|
||||
this.uuidLeast = uuidLeast;
|
||||
this.desc = desc.getBytes(StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readPacket(GamePacketInputBuffer buffer) throws IOException {
|
||||
uuidMost = buffer.readLong();
|
||||
uuidLeast = buffer.readLong();
|
||||
int descLen = buffer.readVarInt();
|
||||
if(descLen > 32750) {
|
||||
throw new IOException("Voice signal packet DESC too long!");
|
||||
}
|
||||
desc = new byte[descLen];
|
||||
buffer.readFully(desc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writePacket(GamePacketOutputBuffer buffer) throws IOException {
|
||||
if(desc.length > 32750) {
|
||||
throw new IOException("Voice signal packet DESC too long!");
|
||||
}
|
||||
buffer.writeLong(uuidMost);
|
||||
buffer.writeLong(uuidLeast);
|
||||
buffer.writeVarInt(desc.length);
|
||||
buffer.write(desc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePacket(GameMessageHandler handler) {
|
||||
handler.handleClient(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int length() {
|
||||
return 16 + GamePacketOutputBuffer.getArrayMCSize(desc.length);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
package net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.client;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePacketInputBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePacketOutputBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.GameMessageHandler;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.GameMessagePacket;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2024 lax1dude. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public class CPacketVoiceSignalDisconnectPeerV4EAG implements GameMessagePacket {
|
||||
|
||||
public long uuidMost;
|
||||
public long uuidLeast;
|
||||
|
||||
public CPacketVoiceSignalDisconnectPeerV4EAG() {
|
||||
}
|
||||
|
||||
public CPacketVoiceSignalDisconnectPeerV4EAG(long uuidMost, long uuidLeast) {
|
||||
this.uuidMost = uuidMost;
|
||||
this.uuidLeast = uuidLeast;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readPacket(GamePacketInputBuffer buffer) throws IOException {
|
||||
uuidMost = buffer.readLong();
|
||||
uuidLeast = buffer.readLong();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writePacket(GamePacketOutputBuffer buffer) throws IOException {
|
||||
buffer.writeLong(uuidMost);
|
||||
buffer.writeLong(uuidLeast);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePacket(GameMessageHandler handler) {
|
||||
handler.handleClient(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int length() {
|
||||
return 16;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
package net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.client;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePacketInputBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePacketOutputBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.GameMessageHandler;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.GameMessagePacket;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2024 lax1dude. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public class CPacketVoiceSignalDisconnectV3EAG implements GameMessagePacket {
|
||||
|
||||
public boolean isPeerType;
|
||||
public long uuidMost;
|
||||
public long uuidLeast;
|
||||
|
||||
public CPacketVoiceSignalDisconnectV3EAG() {
|
||||
}
|
||||
|
||||
public CPacketVoiceSignalDisconnectV3EAG(boolean isPeerType, long uuidMost, long uuidLeast) {
|
||||
this.isPeerType = isPeerType;
|
||||
this.uuidMost = uuidMost;
|
||||
this.uuidLeast = uuidLeast;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readPacket(GamePacketInputBuffer buffer) throws IOException {
|
||||
if(buffer.available() > 0) {
|
||||
isPeerType = true;
|
||||
uuidMost = buffer.readLong();
|
||||
uuidLeast = buffer.readLong();
|
||||
}else {
|
||||
isPeerType = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writePacket(GamePacketOutputBuffer buffer) throws IOException {
|
||||
if(isPeerType) {
|
||||
buffer.writeLong(uuidMost);
|
||||
buffer.writeLong(uuidLeast);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePacket(GameMessageHandler handler) {
|
||||
handler.handleClient(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int length() {
|
||||
return isPeerType ? 16 : 0;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
package net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.client;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePacketInputBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePacketOutputBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.GameMessageHandler;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.GameMessagePacket;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2024 lax1dude. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public class CPacketVoiceSignalDisconnectV4EAG implements GameMessagePacket {
|
||||
|
||||
public CPacketVoiceSignalDisconnectV4EAG() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readPacket(GamePacketInputBuffer buffer) throws IOException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writePacket(GamePacketOutputBuffer buffer) throws IOException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePacket(GameMessageHandler handler) {
|
||||
handler.handleClient(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int length() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,80 @@
|
|||
package net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.client;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePacketInputBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePacketOutputBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.GameMessageHandler;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.GameMessagePacket;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2024 lax1dude. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public class CPacketVoiceSignalICEEAG implements GameMessagePacket {
|
||||
|
||||
public long uuidMost;
|
||||
public long uuidLeast;
|
||||
public byte[] ice;
|
||||
|
||||
public CPacketVoiceSignalICEEAG() {
|
||||
}
|
||||
|
||||
public CPacketVoiceSignalICEEAG(long uuidMost, long uuidLeast, byte[] ice) {
|
||||
this.uuidMost = uuidMost;
|
||||
this.uuidLeast = uuidLeast;
|
||||
this.ice = ice;
|
||||
}
|
||||
|
||||
public CPacketVoiceSignalICEEAG(long uuidMost, long uuidLeast, String ice) {
|
||||
this.uuidMost = uuidMost;
|
||||
this.uuidLeast = uuidLeast;
|
||||
this.ice = ice.getBytes(StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readPacket(GamePacketInputBuffer buffer) throws IOException {
|
||||
uuidMost = buffer.readLong();
|
||||
uuidLeast = buffer.readLong();
|
||||
int iceLen = buffer.readVarInt();
|
||||
if(iceLen > 32750) {
|
||||
throw new IOException("Voice signal packet ICE too long!");
|
||||
}
|
||||
ice = new byte[iceLen];
|
||||
buffer.readFully(ice);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writePacket(GamePacketOutputBuffer buffer) throws IOException {
|
||||
if(ice.length > 32750) {
|
||||
throw new IOException("Voice signal packet ICE too long!");
|
||||
}
|
||||
buffer.writeLong(uuidMost);
|
||||
buffer.writeLong(uuidLeast);
|
||||
buffer.writeVarInt(ice.length);
|
||||
buffer.write(ice);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePacket(GameMessageHandler handler) {
|
||||
handler.handleClient(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int length() {
|
||||
return 16 + GamePacketOutputBuffer.getArrayMCSize(ice.length);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
package net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.client;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePacketInputBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePacketOutputBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.GameMessageHandler;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.GameMessagePacket;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2024 lax1dude. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public class CPacketVoiceSignalRequestEAG implements GameMessagePacket {
|
||||
|
||||
public long uuidMost;
|
||||
public long uuidLeast;
|
||||
|
||||
public CPacketVoiceSignalRequestEAG() {
|
||||
}
|
||||
|
||||
public CPacketVoiceSignalRequestEAG(long uuidMost, long uuidLeast) {
|
||||
this.uuidMost = uuidMost;
|
||||
this.uuidLeast = uuidLeast;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readPacket(GamePacketInputBuffer buffer) throws IOException {
|
||||
uuidMost = buffer.readLong();
|
||||
uuidLeast = buffer.readLong();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writePacket(GamePacketOutputBuffer buffer) throws IOException {
|
||||
buffer.writeLong(uuidMost);
|
||||
buffer.writeLong(uuidLeast);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePacket(GameMessageHandler handler) {
|
||||
handler.handleClient(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int length() {
|
||||
return 16;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
package net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.client;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePacketInputBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePacketOutputBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.GameMessageHandler;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.GameMessagePacket;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2024 lax1dude. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public class CPacketWebViewMessageEnV4EAG implements GameMessagePacket {
|
||||
|
||||
public boolean messageChannelOpen;
|
||||
public String channelName;
|
||||
|
||||
public CPacketWebViewMessageEnV4EAG() {
|
||||
}
|
||||
|
||||
public CPacketWebViewMessageEnV4EAG(boolean messageChannelOpen, String channelName) {
|
||||
this.messageChannelOpen = messageChannelOpen;
|
||||
this.channelName = channelName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readPacket(GamePacketInputBuffer buffer) throws IOException {
|
||||
messageChannelOpen = buffer.readBoolean();
|
||||
if(messageChannelOpen) {
|
||||
channelName = buffer.readStringEaglerASCII8();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writePacket(GamePacketOutputBuffer buffer) throws IOException {
|
||||
buffer.writeBoolean(messageChannelOpen);
|
||||
if(messageChannelOpen) {
|
||||
if(channelName != null) {
|
||||
if(channelName.length() > 255) {
|
||||
throw new IOException("Channel name too long! (255 max, " + channelName.length() + " given)");
|
||||
}
|
||||
buffer.writeStringEaglerASCII8(channelName);
|
||||
}else {
|
||||
buffer.writeByte(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePacket(GameMessageHandler handler) {
|
||||
handler.handleClient(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int length() {
|
||||
return messageChannelOpen ? 2 + (channelName != null ? channelName.length() : 0) : 1;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,74 @@
|
|||
package net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.client;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePacketInputBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePacketOutputBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.GameMessageHandler;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.GameMessagePacket;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2024 lax1dude. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public class CPacketWebViewMessageV4EAG implements GameMessagePacket {
|
||||
|
||||
public static final int TYPE_STRING = 0;
|
||||
public static final int TYPE_BINARY = 1;
|
||||
|
||||
public int type;
|
||||
public byte[] data;
|
||||
|
||||
public CPacketWebViewMessageV4EAG() {
|
||||
}
|
||||
|
||||
public CPacketWebViewMessageV4EAG(int type, byte[] data) {
|
||||
this.type = type;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public CPacketWebViewMessageV4EAG(String str) {
|
||||
this.type = TYPE_STRING;
|
||||
this.data = str.getBytes(StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
public CPacketWebViewMessageV4EAG(byte[] data) {
|
||||
this.type = TYPE_BINARY;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readPacket(GamePacketInputBuffer buffer) throws IOException {
|
||||
type = buffer.readUnsignedByte();
|
||||
data = buffer.readByteArrayMC();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writePacket(GamePacketOutputBuffer buffer) throws IOException {
|
||||
buffer.writeByte(type);
|
||||
buffer.writeByteArrayMC(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePacket(GameMessageHandler handler) {
|
||||
handler.handleClient(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int length() {
|
||||
return 1 + GamePacketOutputBuffer.getVarIntSize(data.length) + data.length;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,193 @@
|
|||
package net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.server;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePacketInputBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePacketOutputBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.GameMessageHandler;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.GameMessagePacket;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.util.PacketImageData;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2024 lax1dude. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public class SPacketCustomizePauseMenuV4EAG implements GameMessagePacket {
|
||||
|
||||
public static final int SERVER_INFO_MODE_NONE = 0;
|
||||
public static final int SERVER_INFO_MODE_EXTERNAL_URL = 1;
|
||||
public static final int SERVER_INFO_MODE_SHOW_EMBED_OVER_HTTP = 2;
|
||||
public static final int SERVER_INFO_MODE_SHOW_EMBED_OVER_WS = 3;
|
||||
|
||||
public static final int SERVER_INFO_EMBED_PERMS_JAVASCRIPT = 1;
|
||||
public static final int SERVER_INFO_EMBED_PERMS_MESSAGE_API = 2;
|
||||
public static final int SERVER_INFO_EMBED_PERMS_STRICT_CSP = 4;
|
||||
|
||||
public static final int DISCORD_MODE_NONE = 0;
|
||||
public static final int DISCORD_MODE_INVITE_URL = 1;
|
||||
|
||||
public int serverInfoMode;
|
||||
public String serverInfoButtonText;
|
||||
public String serverInfoURL;
|
||||
public byte[] serverInfoHash;
|
||||
public int serverInfoEmbedPerms;
|
||||
public String serverInfoEmbedTitle;
|
||||
public int discordButtonMode;
|
||||
public String discordButtonText;
|
||||
public String discordInviteURL;
|
||||
|
||||
public Map<String,Integer> imageMappings;
|
||||
public List<PacketImageData> imageData;
|
||||
|
||||
public SPacketCustomizePauseMenuV4EAG() {
|
||||
}
|
||||
|
||||
public SPacketCustomizePauseMenuV4EAG(int serverInfoMode, String serverInfoButtonText, String serverInfoURL,
|
||||
byte[] serverInfoHash, int serverInfoEmbedPerms, String serverInfoEmbedTitle, int discordButtonMode,
|
||||
String discordButtonText, String discordInviteURL, Map<String, Integer> imageMappings,
|
||||
List<PacketImageData> imageData) {
|
||||
this.serverInfoMode = serverInfoMode;
|
||||
this.serverInfoButtonText = serverInfoButtonText;
|
||||
this.serverInfoURL = serverInfoURL;
|
||||
this.serverInfoHash = serverInfoHash;
|
||||
this.serverInfoEmbedPerms = serverInfoEmbedPerms;
|
||||
this.serverInfoEmbedTitle = serverInfoEmbedTitle;
|
||||
this.discordButtonMode = discordButtonMode;
|
||||
this.discordButtonText = discordButtonText;
|
||||
this.discordInviteURL = discordInviteURL;
|
||||
this.imageMappings = imageMappings;
|
||||
this.imageData = imageData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readPacket(GamePacketInputBuffer buffer) throws IOException {
|
||||
imageMappings = null;
|
||||
imageData = null;
|
||||
int flags = buffer.readUnsignedByte();
|
||||
serverInfoMode = (flags & 15);
|
||||
discordButtonMode = ((flags >> 4) & 15);
|
||||
switch(serverInfoMode) {
|
||||
case SERVER_INFO_MODE_EXTERNAL_URL:
|
||||
serverInfoButtonText = buffer.readStringMC(127);
|
||||
serverInfoURL = buffer.readStringEaglerASCII16();
|
||||
serverInfoEmbedPerms = 0;
|
||||
serverInfoHash = null;
|
||||
break;
|
||||
case SERVER_INFO_MODE_SHOW_EMBED_OVER_HTTP:
|
||||
serverInfoButtonText = buffer.readStringMC(127);
|
||||
serverInfoURL = buffer.readStringEaglerASCII16();
|
||||
serverInfoEmbedPerms = buffer.readUnsignedByte();
|
||||
serverInfoHash = null;
|
||||
serverInfoEmbedTitle = buffer.readStringMC(127);
|
||||
break;
|
||||
case SERVER_INFO_MODE_SHOW_EMBED_OVER_WS:
|
||||
serverInfoButtonText = buffer.readStringMC(127);
|
||||
serverInfoURL = null;
|
||||
serverInfoEmbedPerms = buffer.readUnsignedByte();
|
||||
serverInfoHash = new byte[20];
|
||||
serverInfoEmbedTitle = buffer.readStringMC(127);
|
||||
buffer.readFully(serverInfoHash);
|
||||
break;
|
||||
default:
|
||||
serverInfoButtonText = null;
|
||||
serverInfoURL = null;
|
||||
serverInfoEmbedPerms = 0;
|
||||
serverInfoHash = null;
|
||||
break;
|
||||
}
|
||||
if(discordButtonMode == DISCORD_MODE_INVITE_URL) {
|
||||
discordButtonText = buffer.readStringMC(127);
|
||||
discordInviteURL = buffer.readStringEaglerASCII16();
|
||||
}else {
|
||||
discordButtonText = null;
|
||||
discordInviteURL = null;
|
||||
}
|
||||
int mappingsCount = buffer.readVarInt();
|
||||
if(mappingsCount > 0) {
|
||||
imageMappings = new HashMap<>();
|
||||
imageData = new ArrayList<>();
|
||||
for(int i = 0; i < mappingsCount; ++i) {
|
||||
imageMappings.put(buffer.readStringEaglerASCII8(), buffer.readVarInt());
|
||||
}
|
||||
int imageDataCount = buffer.readVarInt();
|
||||
for(int i = 0; i < imageDataCount; ++i) {
|
||||
imageData.add(PacketImageData.readRGB16(buffer));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writePacket(GamePacketOutputBuffer buffer) throws IOException {
|
||||
buffer.writeByte(serverInfoMode | (discordButtonMode << 4));
|
||||
switch(serverInfoMode) {
|
||||
case SERVER_INFO_MODE_EXTERNAL_URL:
|
||||
buffer.writeStringMC(serverInfoButtonText);
|
||||
buffer.writeStringEaglerASCII16(serverInfoURL);
|
||||
break;
|
||||
case SERVER_INFO_MODE_SHOW_EMBED_OVER_HTTP:
|
||||
buffer.writeStringMC(serverInfoButtonText);
|
||||
buffer.writeStringEaglerASCII16(serverInfoURL);
|
||||
buffer.writeByte(serverInfoEmbedPerms);
|
||||
buffer.writeStringMC(serverInfoEmbedTitle);
|
||||
break;
|
||||
case SERVER_INFO_MODE_SHOW_EMBED_OVER_WS:
|
||||
buffer.writeStringMC(serverInfoButtonText);
|
||||
buffer.writeByte(serverInfoEmbedPerms);
|
||||
buffer.writeStringMC(serverInfoEmbedTitle);
|
||||
if(serverInfoHash.length != 20) {
|
||||
throw new IOException("Hash must be 20 bytes! (" + serverInfoHash.length + " given)");
|
||||
}
|
||||
buffer.write(serverInfoHash);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if(discordButtonMode == DISCORD_MODE_INVITE_URL) {
|
||||
buffer.writeStringMC(discordButtonText);
|
||||
buffer.writeStringEaglerASCII16(discordInviteURL);
|
||||
}
|
||||
if(imageMappings != null && !imageMappings.isEmpty()) {
|
||||
buffer.writeVarInt(imageMappings.size());
|
||||
for(Entry<String,Integer> etr : imageMappings.entrySet()) {
|
||||
buffer.writeStringEaglerASCII8(etr.getKey());
|
||||
buffer.writeVarInt(etr.getValue().intValue());
|
||||
}
|
||||
buffer.writeVarInt(imageData.size());
|
||||
for(PacketImageData etr : imageData) {
|
||||
if(etr.width < 1 || etr.width > 64 || etr.height < 1 || etr.height > 64) {
|
||||
throw new IOException("Invalid image dimensions in packet, must be between 1x1 and 64x64, got " + etr.width + "x" + etr.height);
|
||||
}
|
||||
PacketImageData.writeRGB16(buffer, etr);
|
||||
}
|
||||
}else {
|
||||
buffer.writeByte(0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePacket(GameMessageHandler handler) {
|
||||
handler.handleServer(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int length() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
package net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.server;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePacketInputBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePacketOutputBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.GameMessageHandler;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.GameMessagePacket;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2024 lax1dude. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public class SPacketEnableFNAWSkinsEAG implements GameMessagePacket {
|
||||
|
||||
public boolean enableSkins;
|
||||
public boolean force;
|
||||
|
||||
public SPacketEnableFNAWSkinsEAG() {
|
||||
}
|
||||
|
||||
public SPacketEnableFNAWSkinsEAG(boolean enableSkins, boolean force) {
|
||||
this.enableSkins = enableSkins;
|
||||
this.force = force;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readPacket(GamePacketInputBuffer buffer) throws IOException {
|
||||
int i = buffer.readUnsignedByte();
|
||||
enableSkins = (i & 1) != 0;
|
||||
force = (i & 2) != 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writePacket(GamePacketOutputBuffer buffer) throws IOException {
|
||||
buffer.writeByte((enableSkins ? 1 : 0) | (force ? 2 : 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePacket(GameMessageHandler handler) {
|
||||
handler.handleServer(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int length() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
package net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.server;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePacketInputBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePacketOutputBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.GameMessageHandler;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.GameMessagePacket;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2024 lax1dude. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public class SPacketForceClientCapeCustomV4EAG implements GameMessagePacket {
|
||||
|
||||
public byte[] customCape;
|
||||
|
||||
public SPacketForceClientCapeCustomV4EAG() {
|
||||
}
|
||||
|
||||
public SPacketForceClientCapeCustomV4EAG(byte[] customCape) {
|
||||
this.customCape = customCape;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readPacket(GamePacketInputBuffer buffer) throws IOException {
|
||||
customCape = new byte[1173];
|
||||
buffer.readFully(customCape);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writePacket(GamePacketOutputBuffer buffer) throws IOException {
|
||||
if(customCape.length != 1173) {
|
||||
throw new IOException("Custom cape data length is not 1173 bytes! (" + customCape.length + ")");
|
||||
}
|
||||
buffer.write(customCape);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePacket(GameMessageHandler handler) {
|
||||
handler.handleServer(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int length() {
|
||||
return 1173;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
package net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.server;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePacketInputBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePacketOutputBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.GameMessageHandler;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.GameMessagePacket;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2024 lax1dude. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public class SPacketForceClientCapePresetV4EAG implements GameMessagePacket {
|
||||
|
||||
public int presetCape;
|
||||
|
||||
public SPacketForceClientCapePresetV4EAG() {
|
||||
}
|
||||
|
||||
public SPacketForceClientCapePresetV4EAG(int presetCape) {
|
||||
this.presetCape = presetCape;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readPacket(GamePacketInputBuffer buffer) throws IOException {
|
||||
presetCape = buffer.readInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writePacket(GamePacketOutputBuffer buffer) throws IOException {
|
||||
buffer.writeInt(presetCape);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePacket(GameMessageHandler handler) {
|
||||
handler.handleServer(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int length() {
|
||||
return 4;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
package net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.server;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePacketInputBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePacketOutputBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.GameMessageHandler;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.GameMessagePacket;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2024 lax1dude. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public class SPacketForceClientSkinCustomV4EAG implements GameMessagePacket {
|
||||
|
||||
public int modelID;
|
||||
public byte[] customSkin;
|
||||
|
||||
public SPacketForceClientSkinCustomV4EAG() {
|
||||
}
|
||||
|
||||
public SPacketForceClientSkinCustomV4EAG(int modelID, byte[] customSkin) {
|
||||
this.modelID = modelID;
|
||||
this.customSkin = customSkin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readPacket(GamePacketInputBuffer buffer) throws IOException {
|
||||
modelID = buffer.readUnsignedByte();
|
||||
customSkin = new byte[12288];
|
||||
buffer.readFully(customSkin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writePacket(GamePacketOutputBuffer buffer) throws IOException {
|
||||
if(customSkin.length != 12288) {
|
||||
throw new IOException("Custom skin data length is not 12288 bytes! (" + customSkin.length + ")");
|
||||
}
|
||||
buffer.write(modelID);
|
||||
buffer.write(customSkin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePacket(GameMessageHandler handler) {
|
||||
handler.handleServer(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int length() {
|
||||
return 12289;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
package net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.server;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePacketInputBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePacketOutputBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.GameMessageHandler;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.GameMessagePacket;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2024 lax1dude. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public class SPacketForceClientSkinPresetV4EAG implements GameMessagePacket {
|
||||
|
||||
public int presetSkin;
|
||||
|
||||
public SPacketForceClientSkinPresetV4EAG() {
|
||||
}
|
||||
|
||||
public SPacketForceClientSkinPresetV4EAG(int presetSkin) {
|
||||
this.presetSkin = presetSkin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readPacket(GamePacketInputBuffer buffer) throws IOException {
|
||||
presetSkin = buffer.readInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writePacket(GamePacketOutputBuffer buffer) throws IOException {
|
||||
buffer.writeInt(presetSkin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePacket(GameMessageHandler handler) {
|
||||
handler.handleServer(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int length() {
|
||||
return 4;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,114 @@
|
|||
package net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.server;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.RandomAccess;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePacketInputBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePacketOutputBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.GameMessageHandler;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.GameMessagePacket;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2024 lax1dude. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public class SPacketInvalidatePlayerCacheV4EAG implements GameMessagePacket {
|
||||
|
||||
public Collection<InvalidateRequest> players;
|
||||
|
||||
public static class InvalidateRequest {
|
||||
|
||||
public final boolean invalidateSkin;
|
||||
public final boolean invalidateCape;
|
||||
public final long uuidMost;
|
||||
public final long uuidLeast;
|
||||
|
||||
public InvalidateRequest(boolean invalidateSkin, boolean invalidateCape, long uuidMost, long uuidLeast) {
|
||||
this.invalidateSkin = invalidateSkin;
|
||||
this.invalidateCape = invalidateCape;
|
||||
this.uuidMost = uuidMost;
|
||||
this.uuidLeast = uuidLeast;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public SPacketInvalidatePlayerCacheV4EAG() {
|
||||
}
|
||||
|
||||
public SPacketInvalidatePlayerCacheV4EAG(Collection<InvalidateRequest> players) {
|
||||
this.players = players;
|
||||
}
|
||||
|
||||
public SPacketInvalidatePlayerCacheV4EAG(InvalidateRequest... players) {
|
||||
this.players = Arrays.asList(players);
|
||||
}
|
||||
|
||||
public SPacketInvalidatePlayerCacheV4EAG(boolean invalidateSkin, boolean invalidateCape, long uuidMost, long uuidLeast) {
|
||||
this.players = Arrays.asList(new InvalidateRequest(invalidateSkin, invalidateCape, uuidMost, uuidLeast));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readPacket(GamePacketInputBuffer buffer) throws IOException {
|
||||
int cnt = buffer.readVarInt();
|
||||
List<InvalidateRequest> userList = (List<InvalidateRequest>)(players = new ArrayList<>(cnt));
|
||||
if(cnt > 0) {
|
||||
for(int i = 0; i < cnt; ++i) {
|
||||
int flags = buffer.readUnsignedByte();
|
||||
userList.add(new InvalidateRequest((flags & 1) != 0, (flags & 2) != 0, buffer.readLong(), buffer.readLong()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writePacket(GamePacketOutputBuffer buffer) throws IOException {
|
||||
if(players == null || players.size() == 0) {
|
||||
buffer.write(0);
|
||||
}else {
|
||||
if(players instanceof RandomAccess) {
|
||||
List<InvalidateRequest> userList = (List<InvalidateRequest>)players;
|
||||
int cnt = userList.size();
|
||||
buffer.writeVarInt(cnt);
|
||||
for(int i = 0; i < cnt; ++i) {
|
||||
InvalidateRequest dt = userList.get(i);
|
||||
buffer.writeByte((dt.invalidateSkin ? 1 : 0) | (dt.invalidateCape ? 2 : 0));
|
||||
buffer.writeLong(dt.uuidMost);
|
||||
buffer.writeLong(dt.uuidLeast);
|
||||
}
|
||||
}else {
|
||||
buffer.writeVarInt(players.size());
|
||||
for(InvalidateRequest dt : players) {
|
||||
buffer.writeByte((dt.invalidateSkin ? 1 : 0) | (dt.invalidateCape ? 2 : 0));
|
||||
buffer.writeLong(dt.uuidMost);
|
||||
buffer.writeLong(dt.uuidLeast);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePacket(GameMessageHandler handler) {
|
||||
handler.handleServer(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int length() {
|
||||
int cnt = players.size();
|
||||
return GamePacketOutputBuffer.getVarIntSize(cnt) + 17 * cnt;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
package net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.server;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePacketInputBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePacketOutputBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.GameMessageHandler;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.GameMessagePacket;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2024 lax1dude. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public class SPacketNotifBadgeHideV4EAG implements GameMessagePacket {
|
||||
|
||||
public long badgeUUIDMost;
|
||||
public long badgeUUIDLeast;
|
||||
|
||||
public SPacketNotifBadgeHideV4EAG() {
|
||||
}
|
||||
|
||||
public SPacketNotifBadgeHideV4EAG(long badgeUUIDMost, long badgeUUIDLeast) {
|
||||
this.badgeUUIDMost = badgeUUIDMost;
|
||||
this.badgeUUIDLeast = badgeUUIDLeast;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readPacket(GamePacketInputBuffer buffer) throws IOException {
|
||||
badgeUUIDMost = buffer.readLong();
|
||||
badgeUUIDLeast = buffer.readLong();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writePacket(GamePacketOutputBuffer buffer) throws IOException {
|
||||
buffer.writeLong(badgeUUIDMost);
|
||||
buffer.writeLong(badgeUUIDLeast);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePacket(GameMessageHandler handler) {
|
||||
handler.handleServer(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int length() {
|
||||
return 16;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,172 @@
|
|||
package net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.server;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePacketInputBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePacketOutputBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.GameMessageHandler;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.GameMessagePacket;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2024 lax1dude. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public class SPacketNotifBadgeShowV4EAG implements GameMessagePacket {
|
||||
|
||||
public static enum EnumBadgePriority {
|
||||
LOW(0), NORMAL(1), HIGHER(2), HIGHEST(3);
|
||||
|
||||
public final int priority;
|
||||
|
||||
private EnumBadgePriority(int priority) {
|
||||
this.priority = priority;
|
||||
}
|
||||
|
||||
private static final EnumBadgePriority[] lookup = new EnumBadgePriority[4];
|
||||
|
||||
public static EnumBadgePriority getByID(int id) {
|
||||
if(id >= 0 && id < lookup.length) {
|
||||
return lookup[id];
|
||||
}else {
|
||||
return NORMAL;
|
||||
}
|
||||
}
|
||||
|
||||
static {
|
||||
EnumBadgePriority[] _values = values();
|
||||
for(int i = 0; i < _values.length; ++i) {
|
||||
lookup[_values[i].priority] = _values[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public long badgeUUIDMost;
|
||||
public long badgeUUIDLeast;
|
||||
public String bodyComponent;
|
||||
public String titleComponent;
|
||||
public String sourceComponent;
|
||||
public long originalTimestampSec;
|
||||
public boolean silent;
|
||||
public EnumBadgePriority priority;
|
||||
public long mainIconUUIDMost;
|
||||
public long mainIconUUIDLeast;
|
||||
public long titleIconUUIDMost;
|
||||
public long titleIconUUIDLeast;
|
||||
public int hideAfterSec;
|
||||
public int expireAfterSec;
|
||||
public int backgroundColor;
|
||||
public int bodyTxtColor;
|
||||
public int titleTxtColor;
|
||||
public int sourceTxtColor;
|
||||
|
||||
public SPacketNotifBadgeShowV4EAG() {
|
||||
}
|
||||
|
||||
public SPacketNotifBadgeShowV4EAG(long badgeUUIDMost, long badgeUUIDLeast, String bodyComponent,
|
||||
String titleComponent, String sourceComponent, long originalTimestampSec, boolean silent,
|
||||
EnumBadgePriority priority, long mainIconUUIDMost, long mainIconUUIDLeast, long titleIconUUIDMost,
|
||||
long titleIconUUIDLeast, int hideAfterSec, int expireAfterSec, int backgroundColor, int bodyTxtColor,
|
||||
int titleTxtColor, int sourceTxtColor) {
|
||||
this.badgeUUIDMost = badgeUUIDMost;
|
||||
this.badgeUUIDLeast = badgeUUIDLeast;
|
||||
this.bodyComponent = bodyComponent;
|
||||
this.titleComponent = titleComponent;
|
||||
this.sourceComponent = sourceComponent;
|
||||
this.originalTimestampSec = originalTimestampSec;
|
||||
this.silent = silent;
|
||||
this.priority = priority;
|
||||
this.mainIconUUIDMost = mainIconUUIDMost;
|
||||
this.mainIconUUIDLeast = mainIconUUIDLeast;
|
||||
this.titleIconUUIDMost = titleIconUUIDMost;
|
||||
this.titleIconUUIDLeast = titleIconUUIDLeast;
|
||||
this.hideAfterSec = hideAfterSec;
|
||||
this.expireAfterSec = expireAfterSec;
|
||||
this.backgroundColor = backgroundColor;
|
||||
this.bodyTxtColor = bodyTxtColor;
|
||||
this.titleTxtColor = titleTxtColor;
|
||||
this.sourceTxtColor = sourceTxtColor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readPacket(GamePacketInputBuffer buffer) throws IOException {
|
||||
badgeUUIDMost = buffer.readLong();
|
||||
badgeUUIDLeast = buffer.readLong();
|
||||
bodyComponent = buffer.readStringMC(32767);
|
||||
titleComponent = buffer.readStringMC(255);
|
||||
sourceComponent = buffer.readStringMC(255);
|
||||
originalTimestampSec = ((long)buffer.readUnsignedShort() << 32l) | ((long)buffer.readInt() & 0xFFFFFFFFl);
|
||||
int flags = buffer.readUnsignedByte();
|
||||
silent = (flags & 1) != 0;
|
||||
priority = EnumBadgePriority.getByID((flags >>> 1) & 3);
|
||||
hideAfterSec = buffer.readUnsignedByte();
|
||||
expireAfterSec = buffer.readUnsignedShort();
|
||||
mainIconUUIDMost = (flags & 8) != 0 ? buffer.readLong() : 0l;
|
||||
mainIconUUIDLeast = (flags & 8) != 0 ? buffer.readLong() : 0l;
|
||||
titleIconUUIDMost = (flags & 16) != 0 ? buffer.readLong() : 0l;
|
||||
titleIconUUIDLeast = (flags & 16) != 0 ? buffer.readLong() : 0l;
|
||||
backgroundColor = (buffer.readUnsignedByte() << 16) | (buffer.readUnsignedByte() << 8) | buffer.readUnsignedByte();
|
||||
bodyTxtColor = (buffer.readUnsignedByte() << 16) | (buffer.readUnsignedByte() << 8) | buffer.readUnsignedByte();
|
||||
titleTxtColor = (buffer.readUnsignedByte() << 16) | (buffer.readUnsignedByte() << 8) | buffer.readUnsignedByte();
|
||||
sourceTxtColor = (buffer.readUnsignedByte() << 16) | (buffer.readUnsignedByte() << 8) | buffer.readUnsignedByte();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writePacket(GamePacketOutputBuffer buffer) throws IOException {
|
||||
buffer.writeLong(badgeUUIDMost);
|
||||
buffer.writeLong(badgeUUIDLeast);
|
||||
buffer.writeStringMC(bodyComponent);
|
||||
buffer.writeStringMC(titleComponent);
|
||||
buffer.writeStringMC(sourceComponent);
|
||||
buffer.writeShort((int)((originalTimestampSec >>> 32l) & 0xFFFFl));
|
||||
buffer.writeInt((int)(originalTimestampSec & 0xFFFFFFFFl));
|
||||
int flags = (silent ? 1 : 0);
|
||||
flags |= ((priority != null ? priority.priority : 1) << 1);
|
||||
flags |= ((mainIconUUIDMost != 0l || mainIconUUIDLeast != 0l) ? 8 : 0);
|
||||
flags |= ((titleIconUUIDMost != 0l || titleIconUUIDLeast != 0l) ? 16 : 0);
|
||||
buffer.writeByte(flags);
|
||||
buffer.writeByte(hideAfterSec);
|
||||
buffer.writeShort(expireAfterSec);
|
||||
if((flags & 8) != 0) {
|
||||
buffer.writeLong(mainIconUUIDMost);
|
||||
buffer.writeLong(mainIconUUIDLeast);
|
||||
}
|
||||
if((flags & 16) != 0) {
|
||||
buffer.writeLong(titleIconUUIDMost);
|
||||
buffer.writeLong(titleIconUUIDLeast);
|
||||
}
|
||||
buffer.writeByte((backgroundColor >>> 16) & 0xFF);
|
||||
buffer.writeByte((backgroundColor >>> 8) & 0xFF);
|
||||
buffer.writeByte(backgroundColor & 0xFF);
|
||||
buffer.writeByte((bodyTxtColor >>> 16) & 0xFF);
|
||||
buffer.writeByte((bodyTxtColor >>> 8) & 0xFF);
|
||||
buffer.writeByte(bodyTxtColor & 0xFF);
|
||||
buffer.writeByte((titleTxtColor >>> 16) & 0xFF);
|
||||
buffer.writeByte((titleTxtColor >>> 8) & 0xFF);
|
||||
buffer.writeByte(titleTxtColor & 0xFF);
|
||||
buffer.writeByte((sourceTxtColor >>> 16) & 0xFF);
|
||||
buffer.writeByte((sourceTxtColor >>> 8) & 0xFF);
|
||||
buffer.writeByte(sourceTxtColor & 0xFF);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePacket(GameMessageHandler handler) {
|
||||
handler.handleServer(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int length() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,111 @@
|
|||
package net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.server;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.RandomAccess;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePacketInputBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePacketOutputBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.GameMessageHandler;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.GameMessagePacket;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.util.PacketImageData;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2024 lax1dude. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public class SPacketNotifIconsRegisterV4EAG implements GameMessagePacket {
|
||||
|
||||
public static class CreateIcon {
|
||||
|
||||
public long uuidMost;
|
||||
public long uuidLeast;
|
||||
public PacketImageData imageData;
|
||||
|
||||
public CreateIcon(long uuidMost, long uuidLeast, PacketImageData imageData) {
|
||||
this.uuidMost = uuidMost;
|
||||
this.uuidLeast = uuidLeast;
|
||||
this.imageData = imageData;
|
||||
}
|
||||
|
||||
public int length() {
|
||||
return 16 + imageData.getByteLengthRGB16();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public Collection<CreateIcon> iconsToCreate = null;
|
||||
|
||||
public SPacketNotifIconsRegisterV4EAG() {
|
||||
}
|
||||
|
||||
public SPacketNotifIconsRegisterV4EAG(Collection<CreateIcon> iconsToCreate) {
|
||||
this.iconsToCreate = iconsToCreate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readPacket(GamePacketInputBuffer buffer) throws IOException {
|
||||
int len = buffer.readVarInt();
|
||||
iconsToCreate = new ArrayList<>(len);
|
||||
for(int i = 0; i < len; ++i) {
|
||||
iconsToCreate.add(new CreateIcon(buffer.readLong(), buffer.readLong(), PacketImageData.readRGB16(buffer)));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writePacket(GamePacketOutputBuffer buffer) throws IOException {
|
||||
if(iconsToCreate instanceof RandomAccess) {
|
||||
int len = iconsToCreate.size();
|
||||
buffer.writeVarInt(len);
|
||||
List<CreateIcon> vigg = (List<CreateIcon>)iconsToCreate;
|
||||
for(int i = 0, l = vigg.size(); i < l; ++i) {
|
||||
CreateIcon icn = vigg.get(i);
|
||||
buffer.writeLong(icn.uuidMost);
|
||||
buffer.writeLong(icn.uuidLeast);
|
||||
PacketImageData.writeRGB16(buffer, icn.imageData);
|
||||
}
|
||||
}else {
|
||||
buffer.writeVarInt(iconsToCreate.size());
|
||||
for(CreateIcon icn : iconsToCreate) {
|
||||
buffer.writeLong(icn.uuidMost);
|
||||
buffer.writeLong(icn.uuidLeast);
|
||||
PacketImageData.writeRGB16(buffer, icn.imageData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePacket(GameMessageHandler handler) {
|
||||
handler.handleServer(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int length() {
|
||||
int len = GamePacketOutputBuffer.getVarIntSize(iconsToCreate.size());
|
||||
if(iconsToCreate instanceof RandomAccess) {
|
||||
List<CreateIcon> vigg = (List<CreateIcon>)iconsToCreate;
|
||||
for(int i = 0, l = vigg.size(); i < l; ++i) {
|
||||
len += vigg.get(i).length();
|
||||
}
|
||||
}else {
|
||||
for(CreateIcon icn : iconsToCreate) {
|
||||
len += icn.length();
|
||||
}
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,92 @@
|
|||
package net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.server;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.RandomAccess;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePacketInputBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePacketOutputBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.GameMessageHandler;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.GameMessagePacket;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2024 lax1dude. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public class SPacketNotifIconsReleaseV4EAG implements GameMessagePacket {
|
||||
|
||||
public static class DestroyIcon {
|
||||
|
||||
public long uuidMost;
|
||||
public long uuidLeast;
|
||||
|
||||
public DestroyIcon(long uuidMost, long uuidLeast) {
|
||||
this.uuidMost = uuidMost;
|
||||
this.uuidLeast = uuidLeast;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public Collection<DestroyIcon> iconsToDestroy = null;
|
||||
|
||||
public SPacketNotifIconsReleaseV4EAG() {
|
||||
}
|
||||
|
||||
public SPacketNotifIconsReleaseV4EAG(Collection<DestroyIcon> iconsToDestroy) {
|
||||
this.iconsToDestroy = iconsToDestroy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readPacket(GamePacketInputBuffer buffer) throws IOException {
|
||||
int len = buffer.readVarInt();
|
||||
iconsToDestroy = new ArrayList<>(len);
|
||||
for(int i = 0; i < len; ++i) {
|
||||
iconsToDestroy.add(new DestroyIcon(buffer.readLong(), buffer.readLong()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writePacket(GamePacketOutputBuffer buffer) throws IOException {
|
||||
if(iconsToDestroy instanceof RandomAccess) {
|
||||
int len = iconsToDestroy.size();
|
||||
buffer.writeVarInt(len);
|
||||
List<DestroyIcon> vigg = (List<DestroyIcon>)iconsToDestroy;
|
||||
for(int i = 0; i < len; ++i) {
|
||||
DestroyIcon icn = vigg.get(i);
|
||||
buffer.writeLong(icn.uuidMost);
|
||||
buffer.writeLong(icn.uuidLeast);
|
||||
}
|
||||
}else {
|
||||
buffer.writeVarInt(iconsToDestroy.size());
|
||||
for(DestroyIcon icn : iconsToDestroy) {
|
||||
buffer.writeLong(icn.uuidMost);
|
||||
buffer.writeLong(icn.uuidLeast);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePacket(GameMessageHandler handler) {
|
||||
handler.handleServer(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int length() {
|
||||
int len = iconsToDestroy.size();
|
||||
return GamePacketOutputBuffer.getVarIntSize(len) + (len << 4);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
package net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.server;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePacketInputBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePacketOutputBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.GameMessageHandler;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.GameMessagePacket;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2024 lax1dude. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public class SPacketOtherCapeCustomEAG implements GameMessagePacket {
|
||||
|
||||
public long uuidMost;
|
||||
public long uuidLeast;
|
||||
public byte[] customCape;
|
||||
|
||||
public SPacketOtherCapeCustomEAG() {
|
||||
}
|
||||
|
||||
public SPacketOtherCapeCustomEAG(long uuidMost, long uuidLeast, byte[] customCape) {
|
||||
this.uuidMost = uuidMost;
|
||||
this.uuidLeast = uuidLeast;
|
||||
this.customCape = customCape;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readPacket(GamePacketInputBuffer buffer) throws IOException {
|
||||
uuidMost = buffer.readLong();
|
||||
uuidLeast = buffer.readLong();
|
||||
customCape = new byte[1173];
|
||||
buffer.readFully(customCape);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writePacket(GamePacketOutputBuffer buffer) throws IOException {
|
||||
if(customCape.length != 1173) {
|
||||
throw new IOException("Custom cape data length is not 1173 bytes! (" + customCape.length + ")");
|
||||
}
|
||||
buffer.writeLong(uuidMost);
|
||||
buffer.writeLong(uuidLeast);
|
||||
buffer.write(customCape);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePacket(GameMessageHandler handler) {
|
||||
handler.handleServer(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int length() {
|
||||
return 1189;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
package net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.server;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePacketInputBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePacketOutputBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.GameMessageHandler;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.GameMessagePacket;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2024 lax1dude. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public class SPacketOtherCapePresetEAG implements GameMessagePacket {
|
||||
|
||||
public long uuidMost;
|
||||
public long uuidLeast;
|
||||
public int presetCape;
|
||||
|
||||
public SPacketOtherCapePresetEAG() {
|
||||
}
|
||||
|
||||
public SPacketOtherCapePresetEAG(long uuidMost, long uuidLeast, int presetCape) {
|
||||
this.uuidMost = uuidMost;
|
||||
this.uuidLeast = uuidLeast;
|
||||
this.presetCape = presetCape;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readPacket(GamePacketInputBuffer buffer) throws IOException {
|
||||
uuidMost = buffer.readLong();
|
||||
uuidLeast = buffer.readLong();
|
||||
presetCape = buffer.readInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writePacket(GamePacketOutputBuffer buffer) throws IOException {
|
||||
buffer.writeLong(uuidMost);
|
||||
buffer.writeLong(uuidLeast);
|
||||
buffer.writeInt(presetCape);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePacket(GameMessageHandler handler) {
|
||||
handler.handleServer(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int length() {
|
||||
return 20;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
package net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.server;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePacketInputBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePacketOutputBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.GameMessageHandler;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.GameMessagePacket;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2024 lax1dude. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public class SPacketOtherPlayerClientUUIDV4EAG implements GameMessagePacket {
|
||||
|
||||
public int requestId;
|
||||
public long clientUUIDMost;
|
||||
public long clientUUIDLeast;
|
||||
|
||||
public SPacketOtherPlayerClientUUIDV4EAG() {
|
||||
}
|
||||
|
||||
public SPacketOtherPlayerClientUUIDV4EAG(int requestId, long playerUUIDMost, long playerUUIDLeast) {
|
||||
this.requestId = requestId;
|
||||
this.clientUUIDMost = playerUUIDMost;
|
||||
this.clientUUIDLeast = playerUUIDLeast;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readPacket(GamePacketInputBuffer buffer) throws IOException {
|
||||
requestId = buffer.readVarInt();
|
||||
clientUUIDMost = buffer.readLong();
|
||||
clientUUIDLeast = buffer.readLong();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writePacket(GamePacketOutputBuffer buffer) throws IOException {
|
||||
buffer.writeVarInt(requestId);
|
||||
buffer.writeLong(clientUUIDMost);
|
||||
buffer.writeLong(clientUUIDLeast);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePacket(GameMessageHandler handler) {
|
||||
handler.handleServer(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int length() {
|
||||
return GamePacketOutputBuffer.getVarIntSize(requestId) + 16;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,72 @@
|
|||
package net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.server;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePacketInputBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePacketOutputBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.GameMessageHandler;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.GameMessagePacket;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2024 lax1dude. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public class SPacketOtherSkinCustomV3EAG implements GameMessagePacket {
|
||||
|
||||
public long uuidMost;
|
||||
public long uuidLeast;
|
||||
public int modelID;
|
||||
public byte[] customSkin;
|
||||
|
||||
public SPacketOtherSkinCustomV3EAG() {
|
||||
}
|
||||
|
||||
public SPacketOtherSkinCustomV3EAG(long uuidMost, long uuidLeast, int modelID, byte[] customSkin) {
|
||||
this.uuidMost = uuidMost;
|
||||
this.uuidLeast = uuidLeast;
|
||||
this.modelID = modelID;
|
||||
this.customSkin = customSkin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readPacket(GamePacketInputBuffer buffer) throws IOException {
|
||||
uuidMost = buffer.readLong();
|
||||
uuidLeast = buffer.readLong();
|
||||
modelID = buffer.readUnsignedByte();
|
||||
customSkin = new byte[16384];
|
||||
buffer.readFully(customSkin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writePacket(GamePacketOutputBuffer buffer) throws IOException {
|
||||
if(customSkin.length != 16384) {
|
||||
throw new IOException("Custom skin data length is not 16384 bytes! (" + customSkin.length + ")");
|
||||
}
|
||||
buffer.writeLong(uuidMost);
|
||||
buffer.writeLong(uuidLeast);
|
||||
buffer.writeByte(modelID);
|
||||
buffer.write(customSkin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePacket(GameMessageHandler handler) {
|
||||
handler.handleServer(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int length() {
|
||||
return 16401;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,72 @@
|
|||
package net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.server;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePacketInputBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePacketOutputBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.GameMessageHandler;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.GameMessagePacket;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2024 lax1dude. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public class SPacketOtherSkinCustomV4EAG implements GameMessagePacket {
|
||||
|
||||
public long uuidMost;
|
||||
public long uuidLeast;
|
||||
public int modelID;
|
||||
public byte[] customSkin;
|
||||
|
||||
public SPacketOtherSkinCustomV4EAG() {
|
||||
}
|
||||
|
||||
public SPacketOtherSkinCustomV4EAG(long uuidMost, long uuidLeast, int modelID, byte[] customSkin) {
|
||||
this.uuidMost = uuidMost;
|
||||
this.uuidLeast = uuidLeast;
|
||||
this.modelID = modelID;
|
||||
this.customSkin = customSkin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readPacket(GamePacketInputBuffer buffer) throws IOException {
|
||||
uuidMost = buffer.readLong();
|
||||
uuidLeast = buffer.readLong();
|
||||
modelID = buffer.readUnsignedByte();
|
||||
customSkin = new byte[12288];
|
||||
buffer.readFully(customSkin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writePacket(GamePacketOutputBuffer buffer) throws IOException {
|
||||
if(customSkin.length != 12288) {
|
||||
throw new IOException("Custom skin data length is not 12288 bytes! (" + customSkin.length + ")");
|
||||
}
|
||||
buffer.writeLong(uuidMost);
|
||||
buffer.writeLong(uuidLeast);
|
||||
buffer.write(modelID);
|
||||
buffer.write(customSkin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePacket(GameMessageHandler handler) {
|
||||
handler.handleServer(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int length() {
|
||||
return 12305;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
package net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.server;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePacketInputBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePacketOutputBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.GameMessageHandler;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.GameMessagePacket;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2024 lax1dude. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public class SPacketOtherSkinPresetEAG implements GameMessagePacket {
|
||||
|
||||
public long uuidMost;
|
||||
public long uuidLeast;
|
||||
public int presetSkin;
|
||||
|
||||
public SPacketOtherSkinPresetEAG() {
|
||||
}
|
||||
|
||||
public SPacketOtherSkinPresetEAG(long uuidMost, long uuidLeast, int presetSkin) {
|
||||
this.uuidMost = uuidMost;
|
||||
this.uuidLeast = uuidLeast;
|
||||
this.presetSkin = presetSkin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readPacket(GamePacketInputBuffer buffer) throws IOException {
|
||||
uuidMost = buffer.readLong();
|
||||
uuidLeast = buffer.readLong();
|
||||
presetSkin = buffer.readInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writePacket(GamePacketOutputBuffer buffer) throws IOException {
|
||||
buffer.writeLong(uuidMost);
|
||||
buffer.writeLong(uuidLeast);
|
||||
buffer.writeInt(presetSkin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePacket(GameMessageHandler handler) {
|
||||
handler.handleServer(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int length() {
|
||||
return 20;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
package net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.server;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePacketInputBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePacketOutputBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.GameMessageHandler;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.GameMessagePacket;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2024 lax1dude. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public class SPacketRedirectClientV4EAG implements GameMessagePacket {
|
||||
|
||||
public String redirectURI;
|
||||
|
||||
public SPacketRedirectClientV4EAG() {
|
||||
}
|
||||
|
||||
public SPacketRedirectClientV4EAG(String redirectURI) {
|
||||
this.redirectURI = redirectURI;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readPacket(GamePacketInputBuffer buffer) throws IOException {
|
||||
redirectURI = buffer.readStringEaglerASCII16();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writePacket(GamePacketOutputBuffer buffer) throws IOException {
|
||||
buffer.writeStringEaglerASCII16(redirectURI);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePacket(GameMessageHandler handler) {
|
||||
handler.handleServer(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int length() {
|
||||
return 2 + redirectURI.length();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,79 @@
|
|||
package net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.server;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePacketInputBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePacketOutputBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.GameMessageHandler;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.GameMessagePacket;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2024 lax1dude. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public class SPacketServerInfoDataChunkV4EAG implements GameMessagePacket {
|
||||
|
||||
public boolean lastChunk;
|
||||
public int seqId;
|
||||
public int finalSize;
|
||||
public byte[] finalHash;
|
||||
public byte[] data;
|
||||
|
||||
public SPacketServerInfoDataChunkV4EAG() {
|
||||
}
|
||||
|
||||
public SPacketServerInfoDataChunkV4EAG(boolean lastChunk, int seqId, byte[] finalHash, int finalSize, byte[] data) {
|
||||
this.lastChunk = lastChunk;
|
||||
this.seqId = seqId;
|
||||
this.finalHash = finalHash;
|
||||
this.finalSize = finalSize;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readPacket(GamePacketInputBuffer buffer) throws IOException {
|
||||
lastChunk = buffer.readBoolean();
|
||||
seqId = buffer.readVarInt();
|
||||
finalSize = buffer.readVarInt();
|
||||
finalHash = new byte[20];
|
||||
buffer.readFully(finalHash);
|
||||
data = new byte[buffer.readVarInt()];
|
||||
buffer.readFully(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writePacket(GamePacketOutputBuffer buffer) throws IOException {
|
||||
if(finalHash.length != 20) {
|
||||
throw new IOException("Hash must be 20 bytes! (" + finalHash.length + " given)");
|
||||
}
|
||||
buffer.writeBoolean(lastChunk);
|
||||
buffer.writeVarInt(seqId);
|
||||
buffer.writeVarInt(finalSize);
|
||||
buffer.write(finalHash);
|
||||
buffer.writeVarInt(data.length);
|
||||
buffer.write(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePacket(GameMessageHandler handler) {
|
||||
handler.handleServer(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int length() {
|
||||
return 21 + GamePacketOutputBuffer.getVarIntSize(finalSize) + GamePacketOutputBuffer.getVarIntSize(seqId)
|
||||
+ GamePacketOutputBuffer.getVarIntSize(data.length) + data.length;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,85 @@
|
|||
package net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.server;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePacketInputBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePacketOutputBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.GameMessageHandler;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.GameMessagePacket;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2024 lax1dude. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public class SPacketSetServerCookieV4EAG implements GameMessagePacket {
|
||||
|
||||
public boolean revokeQuerySupported;
|
||||
public boolean saveCookieToDisk;
|
||||
public long expires;
|
||||
public byte[] data;
|
||||
|
||||
public SPacketSetServerCookieV4EAG() {
|
||||
}
|
||||
|
||||
public SPacketSetServerCookieV4EAG(byte[] data, long expires, boolean revokeQuerySupported, boolean saveCookieToDisk) {
|
||||
if(data.length > 255) {
|
||||
throw new IllegalArgumentException("Cookie is too large! (Max 255 bytes)");
|
||||
}
|
||||
this.data = data;
|
||||
this.expires = expires;
|
||||
this.revokeQuerySupported = revokeQuerySupported;
|
||||
this.saveCookieToDisk = saveCookieToDisk;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readPacket(GamePacketInputBuffer buffer) throws IOException {
|
||||
byte b = buffer.readByte();
|
||||
revokeQuerySupported = (b & 1) != 0;
|
||||
saveCookieToDisk = (b & 2) != 0;
|
||||
expires = buffer.readVarLong();
|
||||
int len = buffer.readUnsignedByte();
|
||||
if(len > 0) {
|
||||
data = new byte[len];
|
||||
buffer.readFully(data);
|
||||
}else {
|
||||
data = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writePacket(GamePacketOutputBuffer buffer) throws IOException {
|
||||
if(data != null && data.length > 255) {
|
||||
throw new IOException("Cookie is too large! (Max 255 bytes)");
|
||||
}
|
||||
buffer.writeByte((revokeQuerySupported ? 1 : 0) | (saveCookieToDisk ? 2 : 0));
|
||||
buffer.writeVarLong(expires);
|
||||
if(data != null) {
|
||||
buffer.writeByte(data.length);
|
||||
buffer.write(data);
|
||||
}else {
|
||||
buffer.writeByte(0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePacket(GameMessageHandler handler) {
|
||||
handler.handleServer(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int length() {
|
||||
return GamePacketOutputBuffer.getVarLongSize(expires) + 2 + data.length;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
package net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.server;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePacketInputBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePacketOutputBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.GameMessageHandler;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.GameMessagePacket;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2024 lax1dude. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public class SPacketUnforceClientV4EAG implements GameMessagePacket {
|
||||
|
||||
public boolean resetSkin;
|
||||
public boolean resetCape;
|
||||
public boolean resetFNAW;
|
||||
|
||||
public SPacketUnforceClientV4EAG() {
|
||||
}
|
||||
|
||||
public SPacketUnforceClientV4EAG(boolean resetSkin, boolean resetCape, boolean resetFNAW) {
|
||||
this.resetSkin = resetSkin;
|
||||
this.resetCape = resetCape;
|
||||
this.resetFNAW = resetFNAW;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readPacket(GamePacketInputBuffer buffer) throws IOException {
|
||||
int i = buffer.readUnsignedByte();
|
||||
resetSkin = (i & 1) != 0;
|
||||
resetCape = (i & 2) != 0;
|
||||
resetFNAW = (i & 4) != 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writePacket(GamePacketOutputBuffer buffer) throws IOException {
|
||||
buffer.writeByte((resetSkin ? 1 : 0) | (resetCape ? 2 : 0) | (resetFNAW ? 4 : 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePacket(GameMessageHandler handler) {
|
||||
handler.handleServer(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int length() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
package net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.server;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePacketInputBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePacketOutputBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.GameMessageHandler;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.GameMessagePacket;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2024 lax1dude. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public class SPacketUpdateCertEAG implements GameMessagePacket {
|
||||
|
||||
public byte[] updateCert;
|
||||
|
||||
public SPacketUpdateCertEAG() {
|
||||
}
|
||||
|
||||
public SPacketUpdateCertEAG(byte[] updateCert) {
|
||||
this.updateCert = updateCert;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readPacket(GamePacketInputBuffer buffer) throws IOException {
|
||||
updateCert = buffer.toByteArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writePacket(GamePacketOutputBuffer buffer) throws IOException {
|
||||
// note: its better to send the raw bytes directly instead of
|
||||
// using this class when programming a backend (for efficiency)
|
||||
buffer.write(updateCert);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePacket(GameMessageHandler handler) {
|
||||
handler.handleServer(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int length() {
|
||||
return updateCert.length;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,79 @@
|
|||
package net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.server;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePacketInputBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePacketOutputBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.GameMessageHandler;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.GameMessagePacket;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2024 lax1dude. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public class SPacketVoiceSignalAllowedEAG implements GameMessagePacket {
|
||||
|
||||
public boolean allowed;
|
||||
public String[] iceServers;
|
||||
|
||||
public SPacketVoiceSignalAllowedEAG() {
|
||||
}
|
||||
|
||||
public SPacketVoiceSignalAllowedEAG(boolean allowed, String[] iceServers) {
|
||||
this.allowed = allowed;
|
||||
this.iceServers = iceServers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readPacket(GamePacketInputBuffer buffer) throws IOException {
|
||||
allowed = buffer.readBoolean();
|
||||
if(allowed) {
|
||||
int numIce = buffer.readVarInt();
|
||||
if(numIce > 64) {
|
||||
throw new IOException("Too many STUN/TURN servers recieved! (" + numIce + ", max is 64!)");
|
||||
}
|
||||
iceServers = new String[numIce];
|
||||
for(int i = 0; i < iceServers.length; ++i) {
|
||||
iceServers[i] = buffer.readStringMC(1024);
|
||||
}
|
||||
}else {
|
||||
iceServers = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writePacket(GamePacketOutputBuffer buffer) throws IOException {
|
||||
if(allowed && iceServers.length > 64) {
|
||||
throw new IOException("Too many STUN/TURN servers to send! (" + iceServers.length + ", max is 64!)");
|
||||
}
|
||||
buffer.writeBoolean(allowed);
|
||||
if(allowed) {
|
||||
buffer.writeVarInt(iceServers.length);
|
||||
for(int i = 0; i < iceServers.length; ++i) {
|
||||
buffer.writeStringMC(iceServers[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePacket(GameMessageHandler handler) {
|
||||
handler.handleServer(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int length() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
package net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.server;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePacketInputBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePacketOutputBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.GameMessageHandler;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.GameMessagePacket;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2024 lax1dude. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public class SPacketVoiceSignalConnectAnnounceV4EAG implements GameMessagePacket {
|
||||
|
||||
public long uuidMost;
|
||||
public long uuidLeast;
|
||||
|
||||
public SPacketVoiceSignalConnectAnnounceV4EAG() {
|
||||
}
|
||||
|
||||
public SPacketVoiceSignalConnectAnnounceV4EAG(long uuidMost, long uuidLeast) {
|
||||
this.uuidMost = uuidMost;
|
||||
this.uuidLeast = uuidLeast;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readPacket(GamePacketInputBuffer buffer) throws IOException {
|
||||
uuidMost = buffer.readLong();
|
||||
uuidLeast = buffer.readLong();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writePacket(GamePacketOutputBuffer buffer) throws IOException {
|
||||
buffer.writeLong(uuidMost);
|
||||
buffer.writeLong(uuidLeast);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePacket(GameMessageHandler handler) {
|
||||
handler.handleServer(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int length() {
|
||||
return 16;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,73 @@
|
|||
package net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.server;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePacketInputBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePacketOutputBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.GameMessageHandler;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.GameMessagePacket;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2024 lax1dude. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public class SPacketVoiceSignalConnectV3EAG implements GameMessagePacket {
|
||||
|
||||
public long uuidMost;
|
||||
public long uuidLeast;
|
||||
public boolean isAnnounceType;
|
||||
public boolean offer;
|
||||
|
||||
public SPacketVoiceSignalConnectV3EAG() {
|
||||
}
|
||||
|
||||
public SPacketVoiceSignalConnectV3EAG(long uuidMost, long uuidLeast, boolean isAnnounceType, boolean offer) {
|
||||
this.uuidMost = uuidMost;
|
||||
this.uuidLeast = uuidLeast;
|
||||
this.isAnnounceType = isAnnounceType;
|
||||
this.offer = offer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readPacket(GamePacketInputBuffer buffer) throws IOException {
|
||||
uuidMost = buffer.readLong();
|
||||
uuidLeast = buffer.readLong();
|
||||
if(buffer.available() > 0) {
|
||||
isAnnounceType = false;
|
||||
offer = buffer.readBoolean();
|
||||
}else {
|
||||
isAnnounceType = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writePacket(GamePacketOutputBuffer buffer) throws IOException {
|
||||
buffer.writeLong(uuidMost);
|
||||
buffer.writeLong(uuidLeast);
|
||||
if(!isAnnounceType) {
|
||||
buffer.writeBoolean(offer);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePacket(GameMessageHandler handler) {
|
||||
handler.handleServer(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int length() {
|
||||
return isAnnounceType ? 16 : 17;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
package net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.server;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePacketInputBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePacketOutputBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.GameMessageHandler;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.GameMessagePacket;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2024 lax1dude. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public class SPacketVoiceSignalConnectV4EAG implements GameMessagePacket {
|
||||
|
||||
public long uuidMost;
|
||||
public long uuidLeast;
|
||||
public boolean offer;
|
||||
|
||||
public SPacketVoiceSignalConnectV4EAG() {
|
||||
}
|
||||
|
||||
public SPacketVoiceSignalConnectV4EAG(long uuidMost, long uuidLeast, boolean offer) {
|
||||
this.uuidMost = uuidMost;
|
||||
this.uuidLeast = uuidLeast;
|
||||
this.offer = offer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readPacket(GamePacketInputBuffer buffer) throws IOException {
|
||||
uuidMost = buffer.readLong();
|
||||
uuidLeast = buffer.readLong();
|
||||
offer = buffer.readBoolean();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writePacket(GamePacketOutputBuffer buffer) throws IOException {
|
||||
buffer.writeLong(uuidMost);
|
||||
buffer.writeLong(uuidLeast);
|
||||
buffer.writeBoolean(offer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePacket(GameMessageHandler handler) {
|
||||
handler.handleServer(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int length() {
|
||||
return 17;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,73 @@
|
|||
package net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.server;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePacketInputBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePacketOutputBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.GameMessageHandler;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.GameMessagePacket;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2024 lax1dude. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public class SPacketVoiceSignalDescEAG implements GameMessagePacket {
|
||||
|
||||
public long uuidMost;
|
||||
public long uuidLeast;
|
||||
public byte[] desc;
|
||||
|
||||
public SPacketVoiceSignalDescEAG() {
|
||||
}
|
||||
|
||||
public SPacketVoiceSignalDescEAG(long uuidMost, long uuidLeast, byte[] desc) {
|
||||
this.uuidMost = uuidMost;
|
||||
this.uuidLeast = uuidLeast;
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readPacket(GamePacketInputBuffer buffer) throws IOException {
|
||||
uuidMost = buffer.readLong();
|
||||
uuidLeast = buffer.readLong();
|
||||
int descLen = buffer.readVarInt();
|
||||
if(descLen > 32750) {
|
||||
throw new IOException("Voice signal packet DESC too long!");
|
||||
}
|
||||
desc = new byte[descLen];
|
||||
buffer.readFully(desc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writePacket(GamePacketOutputBuffer buffer) throws IOException {
|
||||
if(desc.length > 32750) {
|
||||
throw new IOException("Voice signal packet DESC too long!");
|
||||
}
|
||||
buffer.writeLong(uuidMost);
|
||||
buffer.writeLong(uuidLeast);
|
||||
buffer.writeVarInt(desc.length);
|
||||
buffer.write(desc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePacket(GameMessageHandler handler) {
|
||||
handler.handleServer(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int length() {
|
||||
return 16 + GamePacketOutputBuffer.getArrayMCSize(desc.length);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
package net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.server;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePacketInputBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePacketOutputBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.GameMessageHandler;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.GameMessagePacket;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2024 lax1dude. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public class SPacketVoiceSignalDisconnectPeerEAG implements GameMessagePacket {
|
||||
|
||||
public long uuidMost;
|
||||
public long uuidLeast;
|
||||
|
||||
public SPacketVoiceSignalDisconnectPeerEAG() {
|
||||
}
|
||||
|
||||
public SPacketVoiceSignalDisconnectPeerEAG(long uuidMost, long uuidLeast) {
|
||||
this.uuidMost = uuidMost;
|
||||
this.uuidLeast = uuidLeast;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readPacket(GamePacketInputBuffer buffer) throws IOException {
|
||||
uuidMost = buffer.readLong();
|
||||
uuidLeast = buffer.readLong();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writePacket(GamePacketOutputBuffer buffer) throws IOException {
|
||||
buffer.writeLong(uuidMost);
|
||||
buffer.writeLong(uuidLeast);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePacket(GameMessageHandler handler) {
|
||||
handler.handleServer(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int length() {
|
||||
return 16;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,110 @@
|
|||
package net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.server;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.RandomAccess;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePacketInputBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePacketOutputBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.GameMessageHandler;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.GameMessagePacket;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2024 lax1dude. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public class SPacketVoiceSignalGlobalEAG implements GameMessagePacket {
|
||||
|
||||
public Collection<UserData> users;
|
||||
|
||||
public static class UserData {
|
||||
|
||||
public long uuidMost;
|
||||
public long uuidLeast;
|
||||
public String username;
|
||||
|
||||
public UserData(long uuidMost, long uuidLeast, String username) {
|
||||
this.uuidMost = uuidMost;
|
||||
this.uuidLeast = uuidLeast;
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public SPacketVoiceSignalGlobalEAG() {
|
||||
}
|
||||
|
||||
public SPacketVoiceSignalGlobalEAG(Collection<UserData> users) {
|
||||
this.users = users;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readPacket(GamePacketInputBuffer buffer) throws IOException {
|
||||
int cnt = buffer.readVarInt();
|
||||
List<UserData> userList = (List<UserData>)(users = new ArrayList<>(cnt));
|
||||
if(cnt > 0) {
|
||||
for(int i = 0; i < cnt; ++i) {
|
||||
userList.add(new UserData(buffer.readLong(), buffer.readLong(), null));
|
||||
}
|
||||
if(buffer.available() > 0) {
|
||||
for(int i = 0; i < cnt; ++i) {
|
||||
userList.get(i).username = buffer.readStringMC(16);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writePacket(GamePacketOutputBuffer buffer) throws IOException {
|
||||
if(users == null || users.size() == 0) {
|
||||
buffer.write(0);
|
||||
}else {
|
||||
if(users instanceof RandomAccess) {
|
||||
List<UserData> userList = (List<UserData>)users;
|
||||
int cnt = userList.size();
|
||||
buffer.writeVarInt(cnt);
|
||||
for(int i = 0; i < cnt; ++i) {
|
||||
UserData dt = userList.get(i);
|
||||
buffer.writeLong(dt.uuidMost);
|
||||
buffer.writeLong(dt.uuidLeast);
|
||||
}
|
||||
for(int i = 0; i < cnt; ++i) {
|
||||
buffer.writeStringMC(userList.get(i).username);
|
||||
}
|
||||
}else {
|
||||
buffer.writeVarInt(users.size());
|
||||
for(UserData dt : users) {
|
||||
buffer.writeLong(dt.uuidMost);
|
||||
buffer.writeLong(dt.uuidLeast);
|
||||
}
|
||||
for(UserData dt : users) {
|
||||
buffer.writeStringMC(dt.username);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePacket(GameMessageHandler handler) {
|
||||
handler.handleServer(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int length() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,73 @@
|
|||
package net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.server;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePacketInputBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePacketOutputBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.GameMessageHandler;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.GameMessagePacket;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2024 lax1dude. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public class SPacketVoiceSignalICEEAG implements GameMessagePacket {
|
||||
|
||||
public long uuidMost;
|
||||
public long uuidLeast;
|
||||
public byte[] ice;
|
||||
|
||||
public SPacketVoiceSignalICEEAG() {
|
||||
}
|
||||
|
||||
public SPacketVoiceSignalICEEAG(long uuidMost, long uuidLeast, byte[] ice) {
|
||||
this.uuidMost = uuidMost;
|
||||
this.uuidLeast = uuidLeast;
|
||||
this.ice = ice;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readPacket(GamePacketInputBuffer buffer) throws IOException {
|
||||
uuidMost = buffer.readLong();
|
||||
uuidLeast = buffer.readLong();
|
||||
int iceLen = buffer.readVarInt();
|
||||
if(iceLen > 32750) {
|
||||
throw new IOException("Voice signal packet ICE too long!");
|
||||
}
|
||||
ice = new byte[iceLen];
|
||||
buffer.readFully(ice);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writePacket(GamePacketOutputBuffer buffer) throws IOException {
|
||||
if(ice.length > 32750) {
|
||||
throw new IOException("Voice signal packet ICE too long!");
|
||||
}
|
||||
buffer.writeLong(uuidMost);
|
||||
buffer.writeLong(uuidLeast);
|
||||
buffer.writeVarInt(ice.length);
|
||||
buffer.write(ice);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePacket(GameMessageHandler handler) {
|
||||
handler.handleServer(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int length() {
|
||||
return 16 + GamePacketOutputBuffer.getArrayMCSize(ice.length);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,74 @@
|
|||
package net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.server;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePacketInputBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePacketOutputBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.GameMessageHandler;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.GameMessagePacket;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2024 lax1dude. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public class SPacketWebViewMessageV4EAG implements GameMessagePacket {
|
||||
|
||||
public static final int TYPE_STRING = 0;
|
||||
public static final int TYPE_BINARY = 1;
|
||||
|
||||
public int type;
|
||||
public byte[] data;
|
||||
|
||||
public SPacketWebViewMessageV4EAG() {
|
||||
}
|
||||
|
||||
public SPacketWebViewMessageV4EAG(int type, byte[] data) {
|
||||
this.type = type;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public SPacketWebViewMessageV4EAG(String str) {
|
||||
this.type = TYPE_STRING;
|
||||
this.data = str.getBytes(StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
public SPacketWebViewMessageV4EAG(byte[] data) {
|
||||
this.type = TYPE_BINARY;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readPacket(GamePacketInputBuffer buffer) throws IOException {
|
||||
type = buffer.readUnsignedByte();
|
||||
data = buffer.readByteArrayMC();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writePacket(GamePacketOutputBuffer buffer) throws IOException {
|
||||
buffer.writeByte(type);
|
||||
buffer.writeByteArrayMC(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePacket(GameMessageHandler handler) {
|
||||
handler.handleServer(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int length() {
|
||||
return 1 + GamePacketOutputBuffer.getVarIntSize(data.length) + data.length;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,79 @@
|
|||
package net.lax1dude.eaglercraft.v1_8.socket.protocol.util;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePacketInputBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePacketOutputBuffer;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2024 lax1dude. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public class PacketImageData {
|
||||
|
||||
public final int width;
|
||||
public final int height;
|
||||
public final int[] rgba;
|
||||
|
||||
public PacketImageData(int width, int height, int[] rgba) {
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
this.rgba = rgba;
|
||||
}
|
||||
|
||||
public int getByteLengthRGB16() {
|
||||
return 2 + (rgba.length << 1);
|
||||
}
|
||||
|
||||
public static PacketImageData readRGB16(GamePacketInputBuffer buffer) throws IOException {
|
||||
int w = buffer.readUnsignedByte();
|
||||
int h = buffer.readUnsignedByte();
|
||||
int pixelCount = w * h;
|
||||
int[] pixels = new int[pixelCount];
|
||||
for(int j = 0, p, pR, pG, pB; j < pixelCount; ++j) {
|
||||
p = buffer.readUnsignedShort();
|
||||
pR = (p >>> 11) & 0x1F;
|
||||
pG = (p >>> 5) & 0x3F;
|
||||
pB = p & 0x1F;
|
||||
if(pR + pG + pB > 0) {
|
||||
pB = (int)((pB - 1) * 8.5f);
|
||||
pixels[j] = 0xFF000000 | (pR << 19) | (pG << 10) | pB;
|
||||
}else {
|
||||
pixels[j] = 0;
|
||||
}
|
||||
}
|
||||
return new PacketImageData(w, h, pixels);
|
||||
}
|
||||
|
||||
public static void writeRGB16(GamePacketOutputBuffer buffer, PacketImageData imageData) throws IOException {
|
||||
if(imageData.width < 1 || imageData.width > 255 || imageData.height < 1 || imageData.height > 255) {
|
||||
throw new IOException("Invalid image dimensions in packet, must be between 1x1 and 255x255, got " + imageData.width + "x" + imageData.height);
|
||||
}
|
||||
buffer.writeByte(imageData.width);
|
||||
buffer.writeByte(imageData.height);
|
||||
int pixelCount = imageData.width * imageData.height;
|
||||
for(int j = 0, p, pR, pG, pB; j < pixelCount; ++j) {
|
||||
p = imageData.rgba[j];
|
||||
if((p >>> 24) > 0x7F) {
|
||||
pR = (p >>> 19) & 0x1F;
|
||||
pG = (p >>> 10) & 0x3F;
|
||||
pB = (int)((p & 0xFF) * 0.1176471f) + 1;
|
||||
buffer.writeShort((pR << 11) | (pG << 5) | pB);
|
||||
}else {
|
||||
buffer.writeShort(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,80 @@
|
|||
package net.lax1dude.eaglercraft.v1_8.socket.protocol.util;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2024 lax1dude. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public class ReusableByteArrayInputStream extends InputStream {
|
||||
|
||||
private volatile byte[] currentBuffer = null;
|
||||
private int idx = 0;
|
||||
private int markIDX = 0;
|
||||
|
||||
public void feedBuffer(byte[] b) {
|
||||
currentBuffer = b;
|
||||
idx = 0;
|
||||
markIDX = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int read() throws IOException {
|
||||
if(currentBuffer.length <= idx) throw new IOException("ReusableByteArrayInputStream buffer underflow, no bytes remaining");
|
||||
return (int)currentBuffer[idx++] & 0xFF;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int read(byte b[], int off, int len) throws IOException {
|
||||
if(idx + len > currentBuffer.length) {
|
||||
throw new IOException(
|
||||
"ReusableByteArrayInputStream buffer underflow, 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 mark() {
|
||||
markIDX = idx;
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
idx = markIDX;
|
||||
}
|
||||
|
||||
public int getReaderIndex() {
|
||||
return idx;
|
||||
}
|
||||
|
||||
public int available() {
|
||||
return Math.max(currentBuffer.length - idx, 0);
|
||||
}
|
||||
|
||||
public void setReaderIndex(int i) {
|
||||
idx = i;
|
||||
markIDX = idx;
|
||||
}
|
||||
|
||||
public boolean markSupported() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,81 @@
|
|||
package net.lax1dude.eaglercraft.v1_8.socket.protocol.util;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2024 lax1dude. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public class ReusableByteArrayOutputStream extends OutputStream {
|
||||
|
||||
private volatile byte[] currentBuffer = null;
|
||||
private int idx = 0;
|
||||
private int originalSize = 0;
|
||||
|
||||
public void feedBuffer(byte[] buf) {
|
||||
currentBuffer = buf;
|
||||
idx = 0;
|
||||
originalSize = buf == null ? 0 : buf.length;
|
||||
}
|
||||
|
||||
public boolean hasGrown() {
|
||||
return currentBuffer.length != originalSize;
|
||||
}
|
||||
|
||||
public byte[] returnBuffer() {
|
||||
return currentBuffer.length == idx ? currentBuffer : Arrays.copyOf(currentBuffer, idx);
|
||||
}
|
||||
|
||||
private void growBuffer(int i) {
|
||||
int ii = currentBuffer.length;
|
||||
int iii = i - ii;
|
||||
if(iii > 0) {
|
||||
int j = ii + (ii >> 1);
|
||||
while(j < i) {
|
||||
j += (j >> 1);
|
||||
}
|
||||
byte[] n = new byte[j];
|
||||
System.arraycopy(currentBuffer, 0, n, 0, ii);
|
||||
currentBuffer = n;
|
||||
}
|
||||
}
|
||||
|
||||
public int getWriterIndex() {
|
||||
return idx;
|
||||
}
|
||||
|
||||
public void setWriterIndex(int i) {
|
||||
idx = i;
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,209 @@
|
|||
package net.lax1dude.eaglercraft.v1_8.socket.protocol.util;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.EOFException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePacketInputBuffer;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2024 lax1dude. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public class SimpleInputBufferImpl extends DataInputStream implements GamePacketInputBuffer {
|
||||
|
||||
protected byte[] toByteArrayReturns;
|
||||
|
||||
public SimpleInputBufferImpl(InputStream in) {
|
||||
super(in);
|
||||
this.toByteArrayReturns = null;
|
||||
}
|
||||
|
||||
public SimpleInputBufferImpl(InputStream in, byte[] toByteArrayReturns) {
|
||||
super(in);
|
||||
this.toByteArrayReturns = toByteArrayReturns;
|
||||
}
|
||||
|
||||
public void setStream(InputStream parent) {
|
||||
in = parent;
|
||||
toByteArrayReturns = null;
|
||||
}
|
||||
|
||||
public void setToByteArrayReturns(byte[] toByteArrayReturns) {
|
||||
this.toByteArrayReturns = toByteArrayReturns;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void skipAllBytes(int n) throws IOException {
|
||||
if(skipBytes(n) != n) {
|
||||
throw new EOFException();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int readVarInt() throws IOException {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
|
||||
while (true) {
|
||||
int b0 = in.read();
|
||||
if(b0 < 0) {
|
||||
throw new EOFException();
|
||||
}
|
||||
i |= (b0 & 127) << j++ * 7;
|
||||
if (j > 5) {
|
||||
throw new IOException("VarInt too big");
|
||||
}
|
||||
|
||||
if ((b0 & 128) != 128) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long readVarLong() throws IOException {
|
||||
long i = 0L;
|
||||
int j = 0;
|
||||
|
||||
while (true) {
|
||||
int b0 = in.read();
|
||||
if(b0 < 0) {
|
||||
throw new EOFException();
|
||||
}
|
||||
i |= (long) (b0 & 127) << j++ * 7;
|
||||
if (j > 10) {
|
||||
throw new IOException("VarLong too big");
|
||||
}
|
||||
|
||||
if ((b0 & 128) != 128) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String readStringMC(int maxLen) throws IOException {
|
||||
int i = this.readVarInt();
|
||||
if (i > (maxLen << 2)) {
|
||||
throw new IOException("The received encoded string buffer length is longer than maximum allowed (" + i
|
||||
+ " > " + (maxLen << 2) + ")");
|
||||
} else if (i < 0) {
|
||||
throw new IOException("The received encoded string buffer length is less than zero! Weird string!");
|
||||
} else {
|
||||
byte[] toRead = new byte[i];
|
||||
this.readFully(toRead);
|
||||
String s = new String(toRead, StandardCharsets.UTF_8);
|
||||
if (s.length() > maxLen) {
|
||||
throw new IOException(
|
||||
"The received string length is longer than maximum allowed (" + i + " > " + maxLen + ")");
|
||||
} else {
|
||||
return s;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String readStringEaglerASCII8() throws IOException {
|
||||
int len = in.read();
|
||||
if(len < 0) {
|
||||
throw new EOFException();
|
||||
}
|
||||
char[] ret = new char[len];
|
||||
for(int i = 0, j; i < len; ++i) {
|
||||
j = in.read();
|
||||
if(j < 0) {
|
||||
throw new EOFException();
|
||||
}
|
||||
ret[i] = (char)j;
|
||||
}
|
||||
return new String(ret);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String readStringEaglerASCII16() throws IOException {
|
||||
int len = readUnsignedShort();
|
||||
char[] ret = new char[len];
|
||||
for(int i = 0, j; i < len; ++i) {
|
||||
j = in.read();
|
||||
if(j < 0) {
|
||||
throw new EOFException();
|
||||
}
|
||||
ret[i] = (char)j;
|
||||
}
|
||||
return new String(ret);
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] readByteArrayMC() throws IOException {
|
||||
byte[] abyte = new byte[this.readVarInt()];
|
||||
this.readFully(abyte);
|
||||
return abyte;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream stream() {
|
||||
return in;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] toByteArray() throws IOException {
|
||||
if(toByteArrayReturns != null) {
|
||||
return toByteArrayReturns;
|
||||
}else if(in instanceof ByteArrayInputStream) {
|
||||
ByteArrayInputStream bis = (ByteArrayInputStream)in;
|
||||
byte[] ret = new byte[bis.available()];
|
||||
bis.read(ret);
|
||||
return ret;
|
||||
}else {
|
||||
ByteArrayOutputStream bao = null;
|
||||
byte[] copyBuffer = new byte[in.available()];
|
||||
int i = in.read(copyBuffer);
|
||||
if(i == copyBuffer.length) {
|
||||
int j = in.read();
|
||||
if(j == -1) {
|
||||
return copyBuffer;
|
||||
}else {
|
||||
int k = Math.max(copyBuffer.length, 64);
|
||||
bao = new ByteArrayOutputStream(k + 1);
|
||||
bao.write(copyBuffer);
|
||||
bao.write(j);
|
||||
if(k != copyBuffer.length) {
|
||||
copyBuffer = new byte[k];
|
||||
}
|
||||
}
|
||||
}else {
|
||||
int j = Math.max(copyBuffer.length, 64);
|
||||
bao = new ByteArrayOutputStream(j);
|
||||
bao.write(copyBuffer);
|
||||
if(j != copyBuffer.length) {
|
||||
copyBuffer = new byte[j];
|
||||
}
|
||||
}
|
||||
while((i = in.read(copyBuffer)) != -1) {
|
||||
bao.write(copyBuffer, 0, i);
|
||||
}
|
||||
return bao.toByteArray();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,107 @@
|
|||
package net.lax1dude.eaglercraft.v1_8.socket.protocol.util;
|
||||
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePacketOutputBuffer;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2024 lax1dude. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public class SimpleOutputBufferImpl extends DataOutputStream implements GamePacketOutputBuffer {
|
||||
|
||||
public SimpleOutputBufferImpl(OutputStream out) {
|
||||
super(out);
|
||||
}
|
||||
|
||||
public void setStream(OutputStream parent) {
|
||||
out = parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeVarInt(int i) throws IOException {
|
||||
while ((i & -128) != 0) {
|
||||
out.write(i & 127 | 128);
|
||||
i >>>= 7;
|
||||
}
|
||||
out.write(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeVarLong(long i) throws IOException {
|
||||
while ((i & -128L) != 0L) {
|
||||
out.write((int) (i & 127L) | 128);
|
||||
i >>>= 7;
|
||||
}
|
||||
out.write((int) i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeStringMC(String str) throws IOException {
|
||||
byte[] abyte = str.getBytes(StandardCharsets.UTF_8);
|
||||
if (abyte.length > 32767) {
|
||||
throw new IOException("String too big (was " + str.length() + " bytes encoded, max " + 32767 + ")");
|
||||
} else {
|
||||
this.writeVarInt(abyte.length);
|
||||
this.write(abyte);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeStringEaglerASCII8(String str) throws IOException {
|
||||
int len = str.length();
|
||||
if(len > 255) {
|
||||
throw new IOException("String is longer than 255 chars! (" + len + ")");
|
||||
}
|
||||
out.write(len);
|
||||
for(int i = 0, j; i < len; ++i) {
|
||||
j = (int)str.charAt(i);
|
||||
if(j > 255) {
|
||||
j = (int)'?';
|
||||
}
|
||||
out.write(j);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeStringEaglerASCII16(String str) throws IOException {
|
||||
int len = str.length();
|
||||
if(len > 65535) {
|
||||
throw new IOException("String is longer than 65535 chars! (" + len + ")");
|
||||
}
|
||||
writeShort(len);
|
||||
for(int i = 0, j; i < len; ++i) {
|
||||
j = (int)str.charAt(i);
|
||||
if(j > 255) {
|
||||
j = (int)'?';
|
||||
}
|
||||
out.write(j);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeByteArrayMC(byte[] bytes) throws IOException {
|
||||
this.writeVarInt(bytes.length);
|
||||
this.write(bytes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public OutputStream stream() {
|
||||
return out;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,360 @@
|
|||
package net.lax1dude.eaglercraft.v1_8.socket.protocol.util;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.GamePluginMessageProtocol;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.GameMessagePacket;
|
||||
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.server.*;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2024 lax1dude. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public class SkinPacketVersionCache {
|
||||
|
||||
public GameMessagePacket skinPacketV3;
|
||||
public GameMessagePacket skinPacketV4;
|
||||
|
||||
public SkinPacketVersionCache(GameMessagePacket skinPacketV3, GameMessagePacket skinPacketV4) {
|
||||
this.skinPacketV3 = skinPacketV3;
|
||||
this.skinPacketV4 = skinPacketV4;
|
||||
}
|
||||
|
||||
public static SkinPacketVersionCache createPreset(long uuidMost, long uuidLeast) {
|
||||
long hilo = uuidMost ^ uuidLeast;
|
||||
GameMessagePacket pkt = new SPacketOtherSkinPresetEAG(uuidMost, uuidLeast,
|
||||
((((int) (hilo >> 32)) ^ (int) hilo) & 1) != 0 ? 1 : 0);
|
||||
return new SkinPacketVersionCache(pkt, pkt);
|
||||
}
|
||||
|
||||
public static SkinPacketVersionCache createPreset(long uuidMost, long uuidLeast, int presetID) {
|
||||
GameMessagePacket pkt = new SPacketOtherSkinPresetEAG(uuidMost, uuidLeast, presetID);
|
||||
return new SkinPacketVersionCache(pkt, pkt);
|
||||
}
|
||||
|
||||
public static SkinPacketVersionCache createCustomV3(long uuidMost, long uuidLeast, int modelID, byte[] texture) {
|
||||
return new SkinPacketVersionCache(new SPacketOtherSkinCustomV3EAG(uuidMost, uuidLeast, modelID, texture), null);
|
||||
}
|
||||
|
||||
public static SkinPacketVersionCache createCustomV4(long uuidMost, long uuidLeast, int modelID, byte[] texture) {
|
||||
return new SkinPacketVersionCache(null, new SPacketOtherSkinCustomV4EAG(uuidMost, uuidLeast, modelID, texture));
|
||||
}
|
||||
|
||||
public GameMessagePacket get(GamePluginMessageProtocol vers) {
|
||||
switch(vers) {
|
||||
case V3:
|
||||
return getV3();
|
||||
case V4:
|
||||
return getV4();
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public GameMessagePacket get(GamePluginMessageProtocol vers, long rewriteUUIDMost, long rewriteUUIDLeast) {
|
||||
switch(vers) {
|
||||
case V3:
|
||||
return getV3(rewriteUUIDMost, rewriteUUIDLeast);
|
||||
case V4:
|
||||
return getV4(rewriteUUIDMost, rewriteUUIDLeast);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public GameMessagePacket get(GamePluginMessageProtocol vers, long rewriteUUIDMost, long rewriteUUIDLeast, int rewriteModel) {
|
||||
switch(vers) {
|
||||
case V3:
|
||||
return getV3(rewriteUUIDMost, rewriteUUIDLeast, rewriteModel);
|
||||
case V4:
|
||||
return getV4(rewriteUUIDMost, rewriteUUIDLeast, rewriteModel);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public GameMessagePacket getV3() {
|
||||
if(skinPacketV3 != null) {
|
||||
return skinPacketV3;
|
||||
}else {
|
||||
if(skinPacketV4 == null) {
|
||||
return null;
|
||||
}
|
||||
return skinPacketV3 = convertToV3(skinPacketV4);
|
||||
}
|
||||
}
|
||||
|
||||
public GameMessagePacket getV4() {
|
||||
if(skinPacketV4 != null) {
|
||||
return skinPacketV4;
|
||||
}else {
|
||||
if(skinPacketV3 == null) {
|
||||
return null;
|
||||
}
|
||||
return skinPacketV4 = convertToV4(skinPacketV3);
|
||||
}
|
||||
}
|
||||
|
||||
public GameMessagePacket getV3(long rewriteUUIDMost, long rewriteUUIDLeast) {
|
||||
if(skinPacketV3 != null) {
|
||||
return rewriteUUID(skinPacketV3, rewriteUUIDMost, rewriteUUIDLeast);
|
||||
}else {
|
||||
if(skinPacketV4 == null) {
|
||||
return null;
|
||||
}
|
||||
return skinPacketV3 = convertToV3RewriteUUID(skinPacketV4, rewriteUUIDMost, rewriteUUIDLeast);
|
||||
}
|
||||
}
|
||||
|
||||
public GameMessagePacket getV4(long rewriteUUIDMost, long rewriteUUIDLeast) {
|
||||
if(skinPacketV4 != null) {
|
||||
return rewriteUUID(skinPacketV4, rewriteUUIDMost, rewriteUUIDLeast);
|
||||
}else {
|
||||
if(skinPacketV3 == null) {
|
||||
return null;
|
||||
}
|
||||
return skinPacketV4 = convertToV4RewriteUUID(skinPacketV3, rewriteUUIDMost, rewriteUUIDLeast);
|
||||
}
|
||||
}
|
||||
|
||||
public GameMessagePacket getV3(long rewriteUUIDMost, long rewriteUUIDLeast, int rewriteModel) {
|
||||
if(skinPacketV3 != null) {
|
||||
return rewriteUUIDModel(skinPacketV3, rewriteUUIDMost, rewriteUUIDLeast, rewriteModel);
|
||||
}else {
|
||||
if(skinPacketV4 == null) {
|
||||
return null;
|
||||
}
|
||||
return skinPacketV3 = convertToV3RewriteUUIDModel(skinPacketV4, rewriteUUIDMost, rewriteUUIDLeast, rewriteModel);
|
||||
}
|
||||
}
|
||||
|
||||
public GameMessagePacket getV4(long rewriteUUIDMost, long rewriteUUIDLeast, int rewriteModel) {
|
||||
if(skinPacketV4 != null) {
|
||||
return rewriteUUIDModel(skinPacketV4, rewriteUUIDMost, rewriteUUIDLeast, rewriteModel);
|
||||
}else {
|
||||
if(skinPacketV3 == null) {
|
||||
return null;
|
||||
}
|
||||
return skinPacketV4 = convertToV4RewriteUUIDModel(skinPacketV3, rewriteUUIDMost, rewriteUUIDLeast, rewriteModel);
|
||||
}
|
||||
}
|
||||
|
||||
public GameMessagePacket getForceClientV4() {
|
||||
if(skinPacketV4 != null) {
|
||||
return convertToForceV4(skinPacketV4);
|
||||
}else {
|
||||
if(skinPacketV3 == null) {
|
||||
return null;
|
||||
}
|
||||
return convertToForceV4(skinPacketV4 = convertToV4(skinPacketV3));
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] getV3HandshakeData() {
|
||||
GameMessagePacket packetV3 = getV3();
|
||||
if(packetV3 instanceof SPacketOtherSkinCustomV3EAG) {
|
||||
SPacketOtherSkinCustomV3EAG pkt = (SPacketOtherSkinCustomV3EAG)packetV3;
|
||||
byte[] tex = pkt.customSkin;
|
||||
byte[] ret = new byte[2 + tex.length];
|
||||
ret[0] = (byte)2;
|
||||
ret[1] = (byte)pkt.modelID;
|
||||
System.arraycopy(tex, 0, ret, 2, tex.length);
|
||||
return ret;
|
||||
}else {
|
||||
SPacketOtherSkinPresetEAG pkt = (SPacketOtherSkinPresetEAG)packetV3;
|
||||
int p = pkt.presetSkin;
|
||||
byte[] ret = new byte[5];
|
||||
ret[0] = (byte)1;
|
||||
ret[1] = (byte)(p >>> 24);
|
||||
ret[2] = (byte)(p >>> 16);
|
||||
ret[3] = (byte)(p >>> 8);
|
||||
ret[4] = (byte)(p & 0xFF);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
public int getModelId() {
|
||||
if(skinPacketV4 != null) {
|
||||
if(skinPacketV4 instanceof SPacketOtherSkinCustomV4EAG) {
|
||||
return ((SPacketOtherSkinCustomV4EAG)skinPacketV4).modelID;
|
||||
}
|
||||
}else if(skinPacketV3 != null) {
|
||||
if(skinPacketV3 instanceof SPacketOtherSkinCustomV3EAG) {
|
||||
return ((SPacketOtherSkinCustomV3EAG)skinPacketV3).modelID;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static GameMessagePacket rewriteUUID(GameMessagePacket pkt, long uuidMost, long uuidLeast) {
|
||||
if(pkt instanceof SPacketOtherSkinPresetEAG) {
|
||||
return new SPacketOtherSkinPresetEAG(uuidMost, uuidLeast, ((SPacketOtherSkinPresetEAG)pkt).presetSkin);
|
||||
}else if(pkt instanceof SPacketOtherSkinCustomV4EAG) {
|
||||
SPacketOtherSkinCustomV4EAG pkt2 = (SPacketOtherSkinCustomV4EAG)pkt;
|
||||
return new SPacketOtherSkinCustomV4EAG(uuidMost, uuidLeast, pkt2.modelID, pkt2.customSkin);
|
||||
}else if(pkt instanceof SPacketOtherSkinCustomV3EAG) {
|
||||
SPacketOtherSkinCustomV3EAG pkt2 = (SPacketOtherSkinCustomV3EAG)pkt;
|
||||
return new SPacketOtherSkinCustomV3EAG(uuidMost, uuidLeast, pkt2.modelID, pkt2.customSkin);
|
||||
}else {
|
||||
return pkt;
|
||||
}
|
||||
}
|
||||
|
||||
public static GameMessagePacket rewriteUUIDModel(GameMessagePacket pkt, long uuidMost, long uuidLeast, int modelID) {
|
||||
if(pkt instanceof SPacketOtherSkinPresetEAG) {
|
||||
return new SPacketOtherSkinPresetEAG(uuidMost, uuidLeast, ((SPacketOtherSkinPresetEAG)pkt).presetSkin);
|
||||
}else if(pkt instanceof SPacketOtherSkinCustomV4EAG) {
|
||||
SPacketOtherSkinCustomV4EAG pkt2 = (SPacketOtherSkinCustomV4EAG)pkt;
|
||||
return new SPacketOtherSkinCustomV4EAG(uuidMost, uuidLeast, modelID, pkt2.customSkin);
|
||||
}else if(pkt instanceof SPacketOtherSkinCustomV3EAG) {
|
||||
SPacketOtherSkinCustomV3EAG pkt2 = (SPacketOtherSkinCustomV3EAG)pkt;
|
||||
return new SPacketOtherSkinCustomV3EAG(uuidMost, uuidLeast, modelID, pkt2.customSkin);
|
||||
}else {
|
||||
return pkt;
|
||||
}
|
||||
}
|
||||
|
||||
public static byte[] convertToV3Raw(byte[] v4data) {
|
||||
byte[] v3data = new byte[16384];
|
||||
for(int i = 0, j, k; i < 4096; ++i) {
|
||||
j = i * 3;
|
||||
k = i << 2;
|
||||
v3data[k + 1] = v4data[j];
|
||||
v3data[k + 2] = v4data[j + 1];
|
||||
v3data[k + 3] = (byte)(v4data[j + 2] << 1);
|
||||
v3data[k] = (v4data[j + 2] & 0x80) != 0 ? (byte)0xFF : (byte)0;
|
||||
}
|
||||
return v3data;
|
||||
}
|
||||
|
||||
public static byte[] convertToV4Raw(byte[] v3data) {
|
||||
byte[] v4data = new byte[12288];
|
||||
for(int i = 0, j, k; i < 4096; ++i) {
|
||||
j = i << 2;
|
||||
k = i * 3;
|
||||
v4data[k] = v3data[j + 1];
|
||||
v4data[k + 1] = v3data[j + 2];
|
||||
v4data[k + 2] = (byte)((v3data[j + 3] >>> 1) | (v3data[j] & 0x80));
|
||||
}
|
||||
return v4data;
|
||||
}
|
||||
|
||||
public static GameMessagePacket convertToV3(GameMessagePacket v4pkt) {
|
||||
if(v4pkt instanceof SPacketOtherSkinCustomV4EAG) {
|
||||
SPacketOtherSkinCustomV4EAG pkt = (SPacketOtherSkinCustomV4EAG)v4pkt;
|
||||
return new SPacketOtherSkinCustomV3EAG(pkt.uuidMost, pkt.uuidLeast, pkt.modelID, convertToV3Raw(pkt.customSkin));
|
||||
}else {
|
||||
return v4pkt;
|
||||
}
|
||||
}
|
||||
|
||||
public static GameMessagePacket convertToV4(GameMessagePacket v3pkt) {
|
||||
if(v3pkt instanceof SPacketOtherSkinCustomV3EAG) {
|
||||
SPacketOtherSkinCustomV3EAG pkt = (SPacketOtherSkinCustomV3EAG)v3pkt;
|
||||
return new SPacketOtherSkinCustomV4EAG(pkt.uuidMost, pkt.uuidLeast, pkt.modelID, convertToV4Raw(pkt.customSkin));
|
||||
}else {
|
||||
return v3pkt;
|
||||
}
|
||||
}
|
||||
|
||||
public static GameMessagePacket convertToV3RewriteUUID(GameMessagePacket v4pkt, long uuidMost, long uuidLeast) {
|
||||
if(v4pkt instanceof SPacketOtherSkinCustomV4EAG) {
|
||||
SPacketOtherSkinCustomV4EAG pkt = (SPacketOtherSkinCustomV4EAG)v4pkt;
|
||||
return new SPacketOtherSkinCustomV3EAG(uuidMost, uuidLeast, pkt.modelID, convertToV3Raw(pkt.customSkin));
|
||||
}else {
|
||||
return v4pkt;
|
||||
}
|
||||
}
|
||||
|
||||
public static GameMessagePacket convertToV4RewriteUUID(GameMessagePacket v3pkt, long uuidMost, long uuidLeast) {
|
||||
if(v3pkt instanceof SPacketOtherSkinCustomV3EAG) {
|
||||
SPacketOtherSkinCustomV3EAG pkt = (SPacketOtherSkinCustomV3EAG)v3pkt;
|
||||
return new SPacketOtherSkinCustomV4EAG(uuidMost, uuidLeast, pkt.modelID, convertToV4Raw(pkt.customSkin));
|
||||
}else {
|
||||
return v3pkt;
|
||||
}
|
||||
}
|
||||
|
||||
public static GameMessagePacket convertToV3RewriteUUIDModel(GameMessagePacket v4pkt, long uuidMost, long uuidLeast, int modelID) {
|
||||
if(v4pkt instanceof SPacketOtherSkinCustomV4EAG) {
|
||||
SPacketOtherSkinCustomV4EAG pkt = (SPacketOtherSkinCustomV4EAG)v4pkt;
|
||||
return new SPacketOtherSkinCustomV3EAG(uuidMost, uuidLeast, modelID, convertToV3Raw(pkt.customSkin));
|
||||
}else {
|
||||
return v4pkt;
|
||||
}
|
||||
}
|
||||
|
||||
public static GameMessagePacket convertToV4RewriteUUIDModel(GameMessagePacket v3pkt, long uuidMost, long uuidLeast, int modelID) {
|
||||
if(v3pkt instanceof SPacketOtherSkinCustomV3EAG) {
|
||||
SPacketOtherSkinCustomV3EAG pkt = (SPacketOtherSkinCustomV3EAG)v3pkt;
|
||||
return new SPacketOtherSkinCustomV4EAG(uuidMost, uuidLeast, modelID, convertToV4Raw(pkt.customSkin));
|
||||
}else {
|
||||
return v3pkt;
|
||||
}
|
||||
}
|
||||
|
||||
public static SkinPacketVersionCache rewriteUUID(SkinPacketVersionCache pkt, long uuidMost, long uuidLeast) {
|
||||
GameMessagePacket rv3 = null;
|
||||
GameMessagePacket rv4 = null;
|
||||
if(pkt.skinPacketV3 != null) {
|
||||
if(pkt.skinPacketV3 instanceof SPacketOtherSkinCustomV3EAG) {
|
||||
SPacketOtherSkinCustomV3EAG pkt2 = (SPacketOtherSkinCustomV3EAG)pkt.skinPacketV3;
|
||||
rv3 = new SPacketOtherSkinCustomV3EAG(uuidMost, uuidLeast, pkt2.modelID, pkt2.customSkin);
|
||||
}else {
|
||||
rv3 = pkt.skinPacketV3;
|
||||
}
|
||||
}
|
||||
if(pkt.skinPacketV4 != null) {
|
||||
if(pkt.skinPacketV4 instanceof SPacketOtherSkinCustomV4EAG) {
|
||||
SPacketOtherSkinCustomV4EAG pkt2 = (SPacketOtherSkinCustomV4EAG)pkt.skinPacketV4;
|
||||
rv4 = new SPacketOtherSkinCustomV4EAG(uuidMost, uuidLeast, pkt2.modelID, pkt2.customSkin);
|
||||
}else {
|
||||
rv4 = pkt.skinPacketV4;
|
||||
}
|
||||
}
|
||||
return new SkinPacketVersionCache(rv3, rv4);
|
||||
}
|
||||
|
||||
public static SkinPacketVersionCache rewriteUUIDModel(SkinPacketVersionCache pkt, long uuidMost, long uuidLeast, int model) {
|
||||
GameMessagePacket rv3 = null;
|
||||
GameMessagePacket rv4 = null;
|
||||
if(pkt.skinPacketV3 != null) {
|
||||
if(pkt.skinPacketV3 instanceof SPacketOtherSkinCustomV3EAG) {
|
||||
SPacketOtherSkinCustomV3EAG pkt2 = (SPacketOtherSkinCustomV3EAG)pkt.skinPacketV3;
|
||||
rv3 = new SPacketOtherSkinCustomV3EAG(uuidMost, uuidLeast, model, pkt2.customSkin);
|
||||
}else {
|
||||
rv3 = pkt.skinPacketV3;
|
||||
}
|
||||
}
|
||||
if(pkt.skinPacketV4 != null) {
|
||||
if(pkt.skinPacketV4 instanceof SPacketOtherSkinCustomV4EAG) {
|
||||
SPacketOtherSkinCustomV4EAG pkt2 = (SPacketOtherSkinCustomV4EAG)pkt.skinPacketV4;
|
||||
rv4 = new SPacketOtherSkinCustomV4EAG(uuidMost, uuidLeast, model, pkt2.customSkin);
|
||||
}else {
|
||||
rv4 = pkt.skinPacketV4;
|
||||
}
|
||||
}
|
||||
return new SkinPacketVersionCache(rv3, rv4);
|
||||
}
|
||||
|
||||
public static GameMessagePacket convertToForceV4(GameMessagePacket v4pkt) {
|
||||
if(v4pkt instanceof SPacketOtherSkinCustomV4EAG) {
|
||||
SPacketOtherSkinCustomV4EAG pkt = (SPacketOtherSkinCustomV4EAG)v4pkt;
|
||||
return new SPacketForceClientSkinCustomV4EAG(pkt.modelID, pkt.customSkin);
|
||||
}else if(v4pkt instanceof SPacketOtherSkinPresetEAG) {
|
||||
return new SPacketForceClientSkinPresetV4EAG(((SPacketOtherSkinPresetEAG)v4pkt).presetSkin);
|
||||
}else {
|
||||
return v4pkt;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user