make player list and skins proxy sided

This commit is contained in:
Sen 2025-06-05 15:32:03 +02:00
parent bc997ea42d
commit fefdcc3612
Signed by: sen
GPG key ID: 3AC50A6F47D1B722
16 changed files with 425 additions and 419 deletions

View file

@ -59,12 +59,15 @@ import proxy.network.Decoder;
import proxy.network.Splitter;
import proxy.network.Encoder;
import proxy.network.EventLoopLoader;
import proxy.network.Packet;
import proxy.network.Prepender;
import proxy.command.*;
import proxy.handler.HandshakeHandler;
import proxy.handler.ProxyHandler;
import proxy.handler.Handler.ThreadQuickExitException;
import proxy.network.Connection;
import proxy.packet.S38PacketPlayerListItem;
import proxy.packet.S38PacketPlayerListItem.Action;
import proxy.packet.S40PacketDisconnect;
import proxy.packet.ServerInfo;
import proxy.util.Formatter;
@ -106,8 +109,12 @@ public class Proxy {
private int minPassLength = 8;
private int maxAttempts = 5;
private int maxPlayers = 64;
private int pingInterval = 5;
private String defaultSkinTexture = "ewogICJ0aW1lc3RhbXAiIDogMTc0OTEyOTgyODQ2MCwKICAicHJvZmlsZUlkIiA6ICJlYjcxMWNlYmNjMWM0ZGQwYTc5MmE3ZGM2Y2Q3NzcyZiIsCiAgInByb2ZpbGVOYW1lIiA6ICJTZW5qaXVuIiwKICAic2lnbmF0dXJlUmVxdWlyZWQiIDogdHJ1ZSwKICAidGV4dHVyZXMiIDogewogICAgIlNLSU4iIDogewogICAgICAidXJsIiA6ICJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzk5ZGMxYmU3ODQ1N2ViODk3Zjk3MTYxYzZjYTEyOTFlMjkxN2IzYzI4ZWIzMTc4OGY3MGEzYWY4ZGIwMGEyN2IiCiAgICB9CiAgfQp9";
private String defaultSkinSignature = "uX4TdWeMU7nQZp4ZZY5d4GUOg3e+KzgndM3UhcQHZuxpfJqg5l9vZ6KmHpYpUf5hZqEzTLxWefhxLpurm3nd2kzL51GVHMQuquiISqXXGBY33bfCJtl0iVijKhAuvVWrwvBZo5tI/zCz3OQBEdW+DkNAfX7ZXntrl+0JWqhxg2+suzL4pnW7ye45/p4rVhiZ4pU/n0jTF8q6Jv6Rx4L8AoemsQ4MWmC/J5rT24gUD6DuuAc06KjUJy9g1gHNwVJ5uUjzaJ/li6as22Io09B0MdyVe5ryO9WbRKriUComNDWp/YdQrpp/hZThSNTAeJphAS5+YslRod/ZJPknrgx1yLauYaYDoHaVfQx9ZZGvJFOO+tIPQGBIefO1W3QgBqz+hdgFwsevtcqsewcdT/1khAAA2nESahOX5OuVZZhphmbfcUXK4FPn2H4jqcquP5VcsEpq3+IgE/+Nt8qFi4uANB6of/bPDWP/oDzISvtFVj/Odh+kZ/Y+OEYxn9ALYiVz5QF5gww2mtwiOh5/P9kJNc88ZrLgtnf/PggLDr6rET6L2t9DN2biwbm8NlMEB0oMa3wF/E166HRgXsxvTGvYxod1L4c70uaiyU/FlA0fL+K03bxIKYRuH7yht2E2MnzxeuPDIU/26DUG56Ek00eYdHVk9NuyUEX/96uMCArjpZ0=";
private ServerInfo status;
private long lastPingSync;
private static String getIcon(File file) {
if(file.isFile()) {
@ -135,6 +142,7 @@ public class Proxy {
public static void main(String[] args) {
Thread.currentThread().setName("Proxy thread");
Log.info("Starting login proxy ...");
Proxy proxy = new Proxy();
proxy.run();
}
@ -145,7 +153,7 @@ public class Proxy {
this.registerCommands();
}
public void run() {
private void loadConfig() {
this.status = new ServerInfo("VLoginProxy 1.8.9", 47);
this.status.setCapacity(this.maxPlayers);
Collections.addAll(this.status.getMotds(), Formatter.DARK_RED + "Miau\n" + Formatter.YELLOW + "Test??", Formatter.AQUA + "Server\n" + Formatter.GREEN + "Test!!");
@ -156,7 +164,11 @@ public class Proxy {
if(icon != null)
this.status.getIcons().add(icon);
Collections.addAll(this.status.getList(), Formatter.DARK_GREEN + "TESTTTT", "Test 2!", Formatter.BLUE + "Test numbah 3!!!!!");
Log.info("Starting login proxy on %s:%d", this.proxyHost.isEmpty() ? "0.0.0.0" : this.proxyHost, this.proxyPort);
}
public void run() {
this.loadConfig();
Log.info("Hosting proxy on %s:%d", this.proxyHost.isEmpty() ? "0.0.0.0" : this.proxyHost, this.proxyPort);
try {
this.addLanEndpoint(this.proxyHost.isEmpty() ? null : InetAddress.getByName(IDN.toASCII(this.proxyHost)), this.proxyPort);
}
@ -214,7 +226,7 @@ public class Proxy {
}
}
}
this.networkTick();
this.update();
try {
Thread.sleep(50L);
}
@ -278,7 +290,13 @@ public class Proxy {
}
}
public void networkTick() {
public void update() {
long time = System.currentTimeMillis();
if(time - this.lastPingSync >= (long)this.pingInterval * 1000L) {
this.lastPingSync = time;
this.sendPacket(new S38PacketPlayerListItem(this.players.values(), true));
}
synchronized(this.networkManagers) {
Iterator<Connection> iterator = this.networkManagers.iterator();
@ -384,6 +402,14 @@ public class Proxy {
public int getOnlinePlayers() {
return this.players.size();
}
public String getDefaultSkinTexture() {
return this.defaultSkinTexture;
}
public String getDefaultSkinSignature() {
return this.defaultSkinSignature;
}
public User getUser(String user) {
return this.users.get(user.toLowerCase(Locale.US));
@ -393,11 +419,36 @@ public class Proxy {
this.users.put(usr.getUsername().toLowerCase(Locale.US), usr);
}
public void sendPacket(Packet packet) {
for(ProxyHandler player : this.players.values()) {
player.sendToClient(packet);
}
}
public void sendPacket(Packet packet, ProxyHandler except) {
for(ProxyHandler player : this.players.values()) {
if(player != except)
player.sendToClient(packet);
}
}
private void addPlayer(ProxyHandler handler) {
handler.sendToClient(new S38PacketPlayerListItem(this.players.values(), false));
this.sendPacket(new S38PacketPlayerListItem(handler, Action.ADD_PLAYER), handler);
this.status.setOnline(this.players.size());
}
private void removePlayer(ProxyHandler handler) {
this.sendPacket(new S38PacketPlayerListItem(handler, Action.REMOVE_PLAYER), handler);
this.status.setOnline(this.players.size());
}
public void deleteUser(String user) {
user = user.toLowerCase(Locale.US);
this.users.remove(user);
this.players.remove(user);
this.status.setOnline(this.players.size());
ProxyHandler handler = this.players.remove(user);
if(handler != null)
this.removePlayer(handler);
}
public void setLoggedIn(String user, ProxyHandler handler) {
@ -407,7 +458,7 @@ public class Proxy {
handler.copyFrom(usr);
this.users.put(user, handler);
this.players.put(user, handler);
this.status.setOnline(this.players.size());
this.addPlayer(handler);
}
public void setLoggedOut(String user) {
@ -417,8 +468,8 @@ public class Proxy {
User usr = new User(handler.getUsername());
usr.copyFrom(handler);
this.users.put(user, usr);
this.removePlayer(handler);
}
this.status.setOnline(this.players.size());
}
public boolean isLoggedIn(String user) {

View file

@ -21,6 +21,8 @@ import proxy.network.Packet;
import proxy.network.PacketBuffer;
import proxy.network.Protocol;
import proxy.packet.*;
import proxy.packet.C16PacketClientStatus.EnumState;
import proxy.packet.S38PacketPlayerListItem.Action;
import proxy.util.Formatter;
import proxy.util.User;
import proxy.util.Log;
@ -65,6 +67,8 @@ public class ProxyHandler extends User implements Handler {
private Connection server;
private int ping;
private int pingKey;
private int networkTickCount;
private long lastPingTime;
private long lastSentPingPacket;
@ -77,6 +81,8 @@ public class ProxyHandler extends User implements Handler {
private String completion;
private int spoofedId = -1;
private int realId = -1;
private int prevMode = -1;
private int mode = 0;
private static boolean isAllowedChar(char ch) {
return ch != 167 && ch >= 32 && ch != 127;
@ -110,6 +116,26 @@ public class ProxyHandler extends User implements Handler {
public String getUsername() {
return this.username;
}
public int getPing() {
return this.ping;
}
public int getMode() {
return this.mode;
}
public String getListDisplayName() {
return null;
}
public String getTextureData() {
return this.skinTexture == null ? this.proxy.getDefaultSkinTexture() : this.skinTexture;
}
public String getTextureSignature() {
return this.skinTexture == null ? this.proxy.getDefaultSkinSignature() : this.skinSignature;
}
public void setupPlayer(int id) {
this.spoofedId = id;
@ -131,19 +157,24 @@ public class ProxyHandler extends User implements Handler {
public void update(Connection connection) {
if(connection == this.server)
return;
++this.networkTickCount;
if((long)this.networkTickCount - this.lastSentPingPacket > 40L) {
this.lastSentPingPacket = (long)this.networkTickCount;
this.lastPingTime = System.nanoTime() / 1000000L;
this.pingKey = (int)this.lastPingTime;
this.sendToClient(new S00PacketKeepAlive(this.pingKey));
}
if(!this.connected) {
++this.networkTickCount;
if((long)this.networkTickCount - this.lastSentPingPacket > 40L) {
this.lastSentPingPacket = (long)this.networkTickCount;
this.lastPingTime = System.nanoTime() / 1000000L;
this.sendToClient(new S00PacketKeepAlive((int)this.lastPingTime));
}
if(this.hasMoved) {
this.hasMoved = false;
this.sendToClient(new S08PacketPlayerPosLook(0.5, 65.0, 0.5, 0.0f, 0.0f));
}
}
if(this.connecting || this.connected) {
if(this.mode != this.prevMode) {
this.prevMode = this.mode;
this.proxy.sendPacket(new S38PacketPlayerListItem(this, Action.UPDATE_GAME_MODE));
}
if(this.server.isChannelOpen()) {
try {
this.server.processReceivedPackets();
@ -221,6 +252,13 @@ public class ProxyHandler extends User implements Handler {
}, "Forward connector #" + CONN_COUNTER.incrementAndGet()).start();
}
public void processKeepAlive(C00PacketKeepAlive packetIn) {
if(packetIn.getKey() == this.pingKey) {
int passed = (int)(System.nanoTime() / 1000000L - this.lastPingTime);
this.ping = (this.ping * 3 + passed) / 4;
}
}
public void processInput(C0CPacketInput packetIn) {
if(this.connected)
this.sendToServer(packetIn);
@ -457,21 +495,11 @@ public class ProxyHandler extends User implements Handler {
this.sendToServer(packetIn);
}
public void handleResourcePackStatus(C19PacketResourcePackStatus packetIn) {
if(this.connected)
this.sendToServer(packetIn);
}
public void processHeldItemChange(C09PacketHeldItemChange packetIn) {
if(this.connected)
this.sendToServer(packetIn);
}
public void processKeepAlive(C00PacketKeepAlive packetIn) {
if(this.connected)
this.sendToServer(packetIn);
}
public void handleAnimation(C0APacketAnimation packetIn) {
if(this.connected)
this.sendToServer(packetIn);
@ -647,6 +675,7 @@ public class ProxyHandler extends User implements Handler {
public void handleJoinGame(S01PacketJoinGame packetIn) {
this.realId = packetIn.getEntityId();
this.mode = packetIn.getGameType();
this.sendToClient(new S07PacketRespawn(packetIn));
// this.sendToClient(new S2EPacketCloseWindow());
}
@ -656,7 +685,7 @@ public class ProxyHandler extends User implements Handler {
}
public void handleKeepAlive(S00PacketKeepAlive packetIn) {
this.sendToClient(packetIn);
this.sendToServer(new C00PacketKeepAlive(packetIn.func_149134_c()));
}
public void handleSpawnObject(S0EPacketSpawnObject packetIn) {
@ -768,6 +797,7 @@ public class ProxyHandler extends User implements Handler {
}
public void handleRespawn(S07PacketRespawn packetIn) {
this.mode = packetIn.getGameType();
this.sendToClient(packetIn);
}
@ -828,6 +858,13 @@ public class ProxyHandler extends User implements Handler {
}
public void handleChangeGameState(S2BPacketChangeGameState packetIn) {
if(packetIn.getType() == 3) {
this.mode = packetIn.getIntValue();
}
else if(packetIn.getType() == 4) {
this.sendToServer(new C16PacketClientStatus(EnumState.PERFORM_RESPAWN));
return;
}
this.sendToClient(packetIn);
}
@ -847,10 +884,6 @@ public class ProxyHandler extends User implements Handler {
this.sendToClient(packetIn.replaceEntityId(this.realId, this.spoofedId));
}
public void handleCombatEvent(S42PacketCombatEvent packetIn) {
// this.sendToClient(packetIn);
}
public void handleServerDifficulty(S41PacketServerDifficulty packetIn) {
this.sendToClient(packetIn);
}
@ -867,18 +900,10 @@ public class ProxyHandler extends User implements Handler {
this.sendToClient(packetIn);
}
public void handlePlayerListHeaderFooter(S47PacketPlayerListHeaderFooter packetIn) {
this.sendToClient(packetIn);
}
public void handleRemoveEntityEffect(S1EPacketRemoveEntityEffect packetIn) {
this.sendToClient(packetIn.replaceEntityId(this.realId, this.spoofedId));
}
public void handlePlayerListItem(S38PacketPlayerListItem packetIn) {
this.sendToClient(packetIn);
}
public void handlePlayerAbilities(S39PacketPlayerAbilities packetIn) {
this.sendToClient(packetIn);
}
@ -887,10 +912,6 @@ public class ProxyHandler extends User implements Handler {
this.sendToClient(packetIn);
}
public void handleResourcePack(S48PacketResourcePackSend packetIn) {
this.sendToClient(packetIn);
}
public void handleEntityNBT(S49PacketUpdateEntityNBT packetIn) {
this.sendToClient(packetIn.replaceEntityId(this.realId, this.spoofedId));
}
@ -899,22 +920,6 @@ public class ProxyHandler extends User implements Handler {
this.sendToClient(packetIn);
}
public void handleScoreboardObjective(S3BPacketScoreboardObjective packetIn) {
this.sendToClient(packetIn);
}
public void handleUpdateScore(S3CPacketUpdateScore packetIn) {
this.sendToClient(packetIn);
}
public void handleDisplayScoreboard(S3DPacketDisplayScoreboard packetIn) {
this.sendToClient(packetIn);
}
public void handleTeams(S3EPacketTeams packetIn) {
this.sendToClient(packetIn);
}
public void handleParticles(S2APacketParticles packetIn) {
this.sendToClient(packetIn);
}

View file

@ -9,6 +9,13 @@ import proxy.network.PacketBuffer;
public class C16PacketClientStatus implements Packet<ProxyHandler>
{
private C16PacketClientStatus.EnumState status;
public C16PacketClientStatus() {
}
public C16PacketClientStatus(EnumState status) {
this.status = status;
}
/**
* Reads the raw packet data from the data stream.

View file

@ -6,42 +6,24 @@ import proxy.handler.ProxyHandler;
import proxy.network.Packet;
import proxy.network.PacketBuffer;
public class C19PacketResourcePackStatus implements Packet<ProxyHandler>
{
private String hash;
private C19PacketResourcePackStatus.Action status;
public class C19PacketResourcePackStatus implements Packet<ProxyHandler> {
private static enum Action {
SUCCESSFULLY_LOADED, DECLINED, FAILED_DOWNLOAD, ACCEPTED;
}
/**
* Reads the raw packet data from the data stream.
*/
public void readPacketData(PacketBuffer buf) throws IOException
{
this.hash = buf.readStringFromBuffer(40);
this.status = (C19PacketResourcePackStatus.Action)buf.readEnumValue(C19PacketResourcePackStatus.Action.class);
}
private String hash;
private C19PacketResourcePackStatus.Action status;
/**
* Writes the raw packet data to the data stream.
*/
public void writePacketData(PacketBuffer buf) throws IOException
{
buf.writeString(this.hash);
buf.writeEnumValue(this.status);
}
public void readPacketData(PacketBuffer buf) throws IOException {
this.hash = buf.readStringFromBuffer(40);
this.status = buf.readEnumValue(Action.class);
}
/**
* Passes this Packet on to the NetHandler for processing.
*/
public void processPacket(ProxyHandler handler)
{
handler.handleResourcePackStatus(this);
}
public void writePacketData(PacketBuffer buf) throws IOException {
buf.writeString(this.hash);
buf.writeEnumValue(this.status);
}
public static enum Action
{
SUCCESSFULLY_LOADED,
DECLINED,
FAILED_DOWNLOAD,
ACCEPTED;
}
public void processPacket(ProxyHandler handler) {
}
}

View file

@ -1,58 +0,0 @@
package proxy.packet;
import java.util.UUID;
import com.google.common.collect.LinkedHashMultimap;
import com.google.common.collect.Multimap;
public class Profile {
public static class Property {
private final String name;
private final String value;
private final String signature;
public Property(String value, String name) {
this(value, name, null);
}
public Property(String name, String value, String signature) {
this.name = name;
this.value = value;
this.signature = signature;
}
public String getName() {
return this.name;
}
public String getValue() {
return this.value;
}
public String getSignature() {
return this.signature;
}
}
private final UUID id;
private final String name;
private final Multimap<String, Property> properties = LinkedHashMultimap.create();
private boolean legacy;
public Profile(UUID id, String name) {
this.id = id;
this.name = name;
}
public UUID getId() {
return this.id;
}
public String getName() {
return this.name;
}
public Multimap<String, Property> getProperties() {
return this.properties;
}
}

View file

@ -54,4 +54,9 @@ public class S07PacketRespawn implements Packet<ProxyHandler>
buf.writeByte(this.gameType);
buf.writeString(this.worldType);
}
public byte getGameType()
{
return this.gameType;
}
}

View file

@ -9,7 +9,7 @@ import proxy.network.PacketBuffer;
public class S2BPacketChangeGameState implements Packet<ProxyHandler>
{
private int state;
private float field_149141_c;
private float value;
public S2BPacketChangeGameState()
{
@ -18,7 +18,7 @@ public class S2BPacketChangeGameState implements Packet<ProxyHandler>
public S2BPacketChangeGameState(int stateIn, float p_i45194_2_)
{
this.state = stateIn;
this.field_149141_c = p_i45194_2_;
this.value = p_i45194_2_;
}
/**
@ -27,7 +27,7 @@ public class S2BPacketChangeGameState implements Packet<ProxyHandler>
public void readPacketData(PacketBuffer buf) throws IOException
{
this.state = buf.readUnsignedByte();
this.field_149141_c = buf.readFloat();
this.value = buf.readFloat();
}
/**
@ -36,7 +36,7 @@ public class S2BPacketChangeGameState implements Packet<ProxyHandler>
public void writePacketData(PacketBuffer buf) throws IOException
{
buf.writeByte(this.state);
buf.writeFloat(this.field_149141_c);
buf.writeFloat(this.value);
}
/**
@ -46,4 +46,18 @@ public class S2BPacketChangeGameState implements Packet<ProxyHandler>
{
handler.handleChangeGameState(this);
}
public int getType() {
return this.state;
}
public int getIntValue() {
float value = this.value + 0.5f;
int v = (int)value;
return value < (float)v ? v - 1 : v;
}
public float getFloatValue() {
return this.value;
}
}

View file

@ -1,240 +1,198 @@
package proxy.packet;
import com.google.common.base.Objects;
import com.google.common.collect.Lists;
import java.io.IOException;
import java.util.Collection;
import java.util.List;
import java.util.UUID;
import proxy.packet.Profile.Property;
import proxy.Proxy;
import proxy.handler.ProxyHandler;
import proxy.network.Packet;
import proxy.network.PacketBuffer;
public class S38PacketPlayerListItem implements Packet<ProxyHandler>
{
private S38PacketPlayerListItem.Action action;
private final List<S38PacketPlayerListItem.AddPlayerData> players = Lists.<S38PacketPlayerListItem.AddPlayerData>newArrayList();
public class S38PacketPlayerListItem implements Packet<ProxyHandler> {
public static enum Action {
ADD_PLAYER, UPDATE_GAME_MODE, UPDATE_LATENCY, UPDATE_DISPLAY_NAME, REMOVE_PLAYER;
}
/**
* Reads the raw packet data from the data stream.
*/
public void readPacketData(PacketBuffer buf) throws IOException
{
this.action = (S38PacketPlayerListItem.Action)buf.readEnumValue(S38PacketPlayerListItem.Action.class);
int i = buf.readVarIntFromBuffer();
private class PlayerInfo {
private final String name;
private final int ping;
private final int mode;
private final String displayName;
private final String textureData;
private final String textureSignature;
for (int j = 0; j < i; ++j)
{
Profile gameprofile = null;
int k = 0;
int worldsettings$gametype = 0;
String ichatcomponent = null;
public PlayerInfo(String name, int ping, int mode, String display, String texture, String signature) {
this.name = name;
this.ping = ping;
this.mode = mode;
this.displayName = display;
this.textureData = texture;
this.textureSignature = signature;
}
switch (this.action)
{
case ADD_PLAYER:
gameprofile = new Profile(buf.readUuid(), buf.readStringFromBuffer(16));
int l = buf.readVarIntFromBuffer();
int i1 = 0;
public String getName() {
return this.name;
}
for (; i1 < l; ++i1)
{
String s = buf.readStringFromBuffer(32767);
String s1 = buf.readStringFromBuffer(32767);
public int getPing() {
return this.ping;
}
if (buf.readBoolean())
{
gameprofile.getProperties().put(s, new Property(s, s1, buf.readStringFromBuffer(32767)));
}
else
{
gameprofile.getProperties().put(s, new Property(s, s1));
}
}
public int getMode() {
return this.mode;
}
worldsettings$gametype = buf.readVarIntFromBuffer();
k = buf.readVarIntFromBuffer();
public String getDisplayName() {
return this.displayName;
}
if (buf.readBoolean())
{
ichatcomponent = buf.readChatComponent();
}
public String getTextureData() {
return this.textureData;
}
break;
public String getTextureSignature() {
return this.textureSignature;
}
}
case UPDATE_GAME_MODE:
gameprofile = new Profile(buf.readUuid(), (String)null);
worldsettings$gametype = buf.readVarIntFromBuffer();
break;
private final List<PlayerInfo> players;
case UPDATE_LATENCY:
gameprofile = new Profile(buf.readUuid(), (String)null);
k = buf.readVarIntFromBuffer();
break;
private Action action;
case UPDATE_DISPLAY_NAME:
gameprofile = new Profile(buf.readUuid(), (String)null);
public S38PacketPlayerListItem() {
this.players = Lists.newArrayList();
}
if (buf.readBoolean())
{
ichatcomponent = buf.readChatComponent();
}
public S38PacketPlayerListItem(Collection<ProxyHandler> players, boolean pingOnly) {
this.players = Lists.newArrayListWithCapacity(players.size());
for(ProxyHandler player : players) {
this.players.add(new PlayerInfo(player.getUsername(), player.getPing(), player.getMode(), player.getListDisplayName(), player.getTextureData(), player.getTextureSignature()));
}
this.action = pingOnly ? Action.UPDATE_LATENCY : Action.ADD_PLAYER;
}
break;
public S38PacketPlayerListItem(ProxyHandler player, Action action) {
this.players = Lists.newArrayList(new PlayerInfo(player.getUsername(), player.getPing(), player.getMode(), player.getListDisplayName(), player.getTextureData(), player.getTextureSignature()));
this.action = action;
}
case REMOVE_PLAYER:
gameprofile = new Profile(buf.readUuid(), (String)null);
}
public void readPacketData(PacketBuffer buf) throws IOException {
this.action = buf.readEnumValue(Action.class);
int i = buf.readVarIntFromBuffer();
this.players.add(new S38PacketPlayerListItem.AddPlayerData(gameprofile, k, worldsettings$gametype, ichatcomponent));
}
}
for(int j = 0; j < i; ++j) {
switch(this.action) {
case ADD_PLAYER:
buf.readUuid();
buf.readStringFromBuffer(16);
int l = buf.readVarIntFromBuffer();
/**
* Writes the raw packet data to the data stream.
*/
public void writePacketData(PacketBuffer buf) throws IOException
{
buf.writeEnumValue(this.action);
buf.writeVarIntToBuffer(this.players.size());
for(int i1 = 0; i1 < l; ++i1) {
String s = buf.readStringFromBuffer(32767);
String s1 = buf.readStringFromBuffer(32767);
if(buf.readBoolean())
buf.readStringFromBuffer(32767);
}
for (S38PacketPlayerListItem.AddPlayerData s38packetplayerlistitem$addplayerdata : this.players)
{
switch (this.action)
{
case ADD_PLAYER:
buf.writeUuid(s38packetplayerlistitem$addplayerdata.getProfile().getId());
buf.writeString(s38packetplayerlistitem$addplayerdata.getProfile().getName());
buf.writeVarIntToBuffer(s38packetplayerlistitem$addplayerdata.getProfile().getProperties().size());
buf.readVarIntFromBuffer();
buf.readVarIntFromBuffer();
for (Property property : s38packetplayerlistitem$addplayerdata.getProfile().getProperties().values())
{
buf.writeString(property.getName());
buf.writeString(property.getValue());
if(buf.readBoolean())
buf.readChatComponent();
if (property.getSignature() != null)
{
buf.writeBoolean(true);
buf.writeString(property.getSignature());
}
else
{
buf.writeBoolean(false);
}
}
break;
buf.writeVarIntToBuffer(s38packetplayerlistitem$addplayerdata.getGameMode());
buf.writeVarIntToBuffer(s38packetplayerlistitem$addplayerdata.getPing());
case UPDATE_GAME_MODE:
buf.readUuid();
buf.readVarIntFromBuffer();
break;
if (s38packetplayerlistitem$addplayerdata.getDisplayName() == null)
{
buf.writeBoolean(false);
}
else
{
buf.writeBoolean(true);
buf.writeChatComponent(s38packetplayerlistitem$addplayerdata.getDisplayName());
}
case UPDATE_LATENCY:
buf.readUuid();
buf.readVarIntFromBuffer();
break;
break;
case UPDATE_DISPLAY_NAME:
buf.readUuid();
case UPDATE_GAME_MODE:
buf.writeUuid(s38packetplayerlistitem$addplayerdata.getProfile().getId());
buf.writeVarIntToBuffer(s38packetplayerlistitem$addplayerdata.getGameMode());
break;
if(buf.readBoolean())
buf.readChatComponent();
case UPDATE_LATENCY:
buf.writeUuid(s38packetplayerlistitem$addplayerdata.getProfile().getId());
buf.writeVarIntToBuffer(s38packetplayerlistitem$addplayerdata.getPing());
break;
break;
case UPDATE_DISPLAY_NAME:
buf.writeUuid(s38packetplayerlistitem$addplayerdata.getProfile().getId());
case REMOVE_PLAYER:
buf.readUuid();
}
}
}
if (s38packetplayerlistitem$addplayerdata.getDisplayName() == null)
{
buf.writeBoolean(false);
}
else
{
buf.writeBoolean(true);
buf.writeChatComponent(s38packetplayerlistitem$addplayerdata.getDisplayName());
}
public void writePacketData(PacketBuffer buf) throws IOException {
buf.writeEnumValue(this.action);
buf.writeVarIntToBuffer(this.players.size());
break;
for(PlayerInfo data : this.players) {
UUID id = Proxy.getOfflineUUID(data.getName());
switch(this.action) {
case ADD_PLAYER:
buf.writeUuid(id);
buf.writeString(data.getName());
if(data.getTextureData() == null || data.getTextureSignature() == null) {
buf.writeVarIntToBuffer(0);
}
else {
buf.writeVarIntToBuffer(1);
buf.writeString("textures");
buf.writeString(data.getTextureData());
buf.writeBoolean(true);
buf.writeString(data.getTextureSignature());
}
case REMOVE_PLAYER:
buf.writeUuid(s38packetplayerlistitem$addplayerdata.getProfile().getId());
}
}
}
buf.writeVarIntToBuffer(data.getMode());
buf.writeVarIntToBuffer(data.getPing());
/**
* Passes this Packet on to the NetHandler for processing.
*/
public void processPacket(ProxyHandler handler)
{
handler.handlePlayerListItem(this);
}
if(data.getDisplayName() == null) {
buf.writeBoolean(false);
}
else {
buf.writeBoolean(true);
buf.writeChatComponent(data.getDisplayName());
}
public List<S38PacketPlayerListItem.AddPlayerData> getEntries()
{
return this.players;
}
break;
public S38PacketPlayerListItem.Action getAction()
{
return this.action;
}
case UPDATE_GAME_MODE:
buf.writeUuid(id);
buf.writeVarIntToBuffer(data.getMode());
break;
public String toString()
{
return Objects.toStringHelper(this).add("action", this.action).add("entries", this.players).toString();
}
case UPDATE_LATENCY:
buf.writeUuid(id);
buf.writeVarIntToBuffer(data.getPing());
break;
public static enum Action
{
ADD_PLAYER,
UPDATE_GAME_MODE,
UPDATE_LATENCY,
UPDATE_DISPLAY_NAME,
REMOVE_PLAYER;
}
case UPDATE_DISPLAY_NAME:
buf.writeUuid(id);
public class AddPlayerData
{
private final int ping;
private final int gamemode;
private final Profile profile;
private final String displayName;
if(data.getDisplayName() == null) {
buf.writeBoolean(false);
}
else {
buf.writeBoolean(true);
buf.writeChatComponent(data.getDisplayName());
}
public AddPlayerData(Profile profile, int pingIn, int gamemodeIn, String displayNameIn)
{
this.profile = profile;
this.ping = pingIn;
this.gamemode = gamemodeIn;
this.displayName = displayNameIn;
}
break;
public Profile getProfile()
{
return this.profile;
}
case REMOVE_PLAYER:
buf.writeUuid(id);
}
}
}
public int getPing()
{
return this.ping;
}
public int getGameMode()
{
return this.gamemode;
}
public String getDisplayName()
{
return this.displayName;
}
}
public void processPacket(ProxyHandler handler) {
}
}

View file

@ -11,7 +11,17 @@ public class S3BPacketScoreboardObjective implements Packet<ProxyHandler>
private String objectiveName;
private String objectiveValue;
private String type;
private int field_149342_c;
private int mode;
public S3BPacketScoreboardObjective() {
}
public S3BPacketScoreboardObjective(String name, String value, String type, int mode) {
this.objectiveName = name;
this.objectiveValue = value;
this.type = type;
this.mode = mode;
}
/**
* Reads the raw packet data from the data stream.
@ -19,9 +29,9 @@ public class S3BPacketScoreboardObjective implements Packet<ProxyHandler>
public void readPacketData(PacketBuffer buf) throws IOException
{
this.objectiveName = buf.readStringFromBuffer(16);
this.field_149342_c = buf.readByte();
this.mode = buf.readByte();
if (this.field_149342_c == 0 || this.field_149342_c == 2)
if (this.mode == 0 || this.mode == 2)
{
this.objectiveValue = buf.readStringFromBuffer(32);
this.type = buf.readStringFromBuffer(16);
@ -34,9 +44,9 @@ public class S3BPacketScoreboardObjective implements Packet<ProxyHandler>
public void writePacketData(PacketBuffer buf) throws IOException
{
buf.writeString(this.objectiveName);
buf.writeByte(this.field_149342_c);
buf.writeByte(this.mode);
if (this.field_149342_c == 0 || this.field_149342_c == 2)
if (this.mode == 0 || this.mode == 2)
{
buf.writeString(this.objectiveValue);
buf.writeString(this.type);
@ -48,6 +58,5 @@ public class S3BPacketScoreboardObjective implements Packet<ProxyHandler>
*/
public void processPacket(ProxyHandler handler)
{
handler.handleScoreboardObjective(this);
}
}

View file

@ -8,10 +8,26 @@ import proxy.network.PacketBuffer;
public class S3CPacketUpdateScore implements Packet<ProxyHandler>
{
private static enum Action
{
CHANGE,
REMOVE;
}
private String name = "";
private String objective = "";
private int value;
private S3CPacketUpdateScore.Action action;
public S3CPacketUpdateScore() {
}
public S3CPacketUpdateScore(String name, String objective, int value, boolean remove) {
this.name = name;
this.objective = objective;
this.value = value;
this.action = remove ? Action.REMOVE : Action.CHANGE;
}
/**
* Reads the raw packet data from the data stream.
@ -48,12 +64,5 @@ public class S3CPacketUpdateScore implements Packet<ProxyHandler>
*/
public void processPacket(ProxyHandler handler)
{
handler.handleUpdateScore(this);
}
public static enum Action
{
CHANGE,
REMOVE;
}
}

View file

@ -10,6 +10,14 @@ public class S3DPacketDisplayScoreboard implements Packet<ProxyHandler>
{
private int position;
private String scoreName;
public S3DPacketDisplayScoreboard() {
}
public S3DPacketDisplayScoreboard(int position, String scoreName) {
this.position = position;
this.scoreName = scoreName;
}
/**
* Reads the raw packet data from the data stream.
@ -34,6 +42,5 @@ public class S3DPacketDisplayScoreboard implements Packet<ProxyHandler>
*/
public void processPacket(ProxyHandler handler)
{
handler.handleDisplayScoreboard(this);
}
}

View file

@ -20,6 +20,18 @@ public class S3EPacketTeams implements Packet<ProxyHandler>
private Collection<String> players;
private int action;
private int friendlyFlags;
private static String getSortedTeamName(int sort, String player) {
sort ^= 0x80000000;
char[] chars = new char[10];
for(int z = 0; z < 2; z++) {
chars[z] = (char)((sort >> ((1 - z) * 16)) & 0xffff);
}
for(int z = 0; z < 8; z++) {
chars[z + 2] = (char)((z < player.length() ? player.charAt(z / 2) : 0) << 8 | (z + 1 < player.length() ? player.charAt(z / 2 + 1) : 0));
}
return new String(chars);
}
public S3EPacketTeams()
{
@ -27,6 +39,19 @@ public class S3EPacketTeams implements Packet<ProxyHandler>
this.color = -1;
this.players = Lists.newArrayList();
}
public S3EPacketTeams(int action, int sort, String prefix, String suffix, String player)
{
this.nameTagVisibility = "always";
this.color = -1;
this.players = Lists.newArrayList(player);
this.friendlyFlags = 1;
this.action = action;
this.name = getSortedTeamName(sort, player);
this.displayName = "";
this.prefix = prefix;
this.suffix = suffix;
}
/**
* Reads the raw packet data from the data stream.
@ -91,6 +116,5 @@ public class S3EPacketTeams implements Packet<ProxyHandler>
*/
public void processPacket(ProxyHandler handler)
{
handler.handleTeams(this);
}
}

View file

@ -6,66 +6,43 @@ import proxy.handler.ProxyHandler;
import proxy.network.Packet;
import proxy.network.PacketBuffer;
public class S42PacketCombatEvent implements Packet<ProxyHandler>
{
public S42PacketCombatEvent.Event eventType;
public int field_179774_b;
public int field_179775_c;
public int field_179772_d;
public String deathMessage;
public class S42PacketCombatEvent implements Packet<ProxyHandler> {
private static enum Event {
TYPE1, TYPE2, TYPE3;
}
/**
* Reads the raw packet data from the data stream.
*/
public void readPacketData(PacketBuffer buf) throws IOException
{
this.eventType = (S42PacketCombatEvent.Event)buf.readEnumValue(S42PacketCombatEvent.Event.class);
public Event ignored0;
public int ignored1;
public int ignored2;
public int ignored3;
public String ignored4;
if (this.eventType == S42PacketCombatEvent.Event.END_COMBAT)
{
this.field_179772_d = buf.readVarIntFromBuffer();
this.field_179775_c = buf.readInt();
}
else if (this.eventType == S42PacketCombatEvent.Event.ENTITY_DIED)
{
this.field_179774_b = buf.readVarIntFromBuffer();
this.field_179775_c = buf.readInt();
this.deathMessage = buf.readStringFromBuffer(32767);
}
}
public void readPacketData(PacketBuffer buf) throws IOException {
this.ignored0 = buf.readEnumValue(Event.class);
if(this.ignored0 == Event.TYPE2) {
this.ignored3 = buf.readVarIntFromBuffer();
this.ignored2 = buf.readInt();
}
else if(this.ignored0 == Event.TYPE3) {
this.ignored1 = buf.readVarIntFromBuffer();
this.ignored2 = buf.readInt();
this.ignored4 = buf.readStringFromBuffer(32767);
}
}
/**
* Writes the raw packet data to the data stream.
*/
public void writePacketData(PacketBuffer buf) throws IOException
{
buf.writeEnumValue(this.eventType);
public void writePacketData(PacketBuffer buf) throws IOException {
buf.writeEnumValue(this.ignored0);
if(this.ignored0 == Event.TYPE2) {
buf.writeVarIntToBuffer(this.ignored3);
buf.writeInt(this.ignored2);
}
else if(this.ignored0 == Event.TYPE3) {
buf.writeVarIntToBuffer(this.ignored1);
buf.writeInt(this.ignored2);
buf.writeString(this.ignored4);
}
}
if (this.eventType == S42PacketCombatEvent.Event.END_COMBAT)
{
buf.writeVarIntToBuffer(this.field_179772_d);
buf.writeInt(this.field_179775_c);
}
else if (this.eventType == S42PacketCombatEvent.Event.ENTITY_DIED)
{
buf.writeVarIntToBuffer(this.field_179774_b);
buf.writeInt(this.field_179775_c);
buf.writeString(this.deathMessage);
}
}
/**
* Passes this Packet on to the NetHandler for processing.
*/
public void processPacket(ProxyHandler handler)
{
handler.handleCombatEvent(this);
}
public static enum Event
{
ENTER_COMBAT,
END_COMBAT,
ENTITY_DIED;
}
public void processPacket(ProxyHandler handler) {
}
}

View file

@ -10,6 +10,14 @@ public class S47PacketPlayerListHeaderFooter implements Packet<ProxyHandler>
{
private String header;
private String footer;
public S47PacketPlayerListHeaderFooter() {
}
public S47PacketPlayerListHeaderFooter(String header, String footer) {
this.header = header;
this.footer = footer;
}
/**
* Reads the raw packet data from the data stream.
@ -34,6 +42,5 @@ public class S47PacketPlayerListHeaderFooter implements Packet<ProxyHandler>
*/
public void processPacket(ProxyHandler handler)
{
handler.handlePlayerListHeaderFooter(this);
}
}

View file

@ -10,6 +10,14 @@ public class S48PacketResourcePackSend implements Packet<ProxyHandler>
{
private String url;
private String hash;
public S48PacketResourcePackSend() {
}
public S48PacketResourcePackSend(String url, String hash) {
this.url = url;
this.hash = hash;
}
/**
* Reads the raw packet data from the data stream.
@ -34,6 +42,5 @@ public class S48PacketResourcePackSend implements Packet<ProxyHandler>
*/
public void processPacket(ProxyHandler handler)
{
handler.handleResourcePack(this);
}
}

View file

@ -13,6 +13,8 @@ public class User {
private byte[] hash;
private byte[] salt;
protected boolean admin;
protected String skinTexture;
protected String skinSignature;
public User(String username) {
this.username = username;