clean up
This commit is contained in:
parent
45834e0cd4
commit
eaf3bbb0e9
164 changed files with 1415 additions and 2875 deletions
|
@ -50,16 +50,16 @@ import com.google.common.util.concurrent.ListenableFuture;
|
|||
import com.google.common.util.concurrent.ListenableFutureTask;
|
||||
import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
||||
|
||||
import proxy.network.EnumPacketDirection;
|
||||
import proxy.network.MessageDeserializer;
|
||||
import proxy.network.MessageDeserializer2;
|
||||
import proxy.network.MessageSerializer;
|
||||
import proxy.network.MessageSerializer2;
|
||||
import proxy.network.NetHandlerHandshake;
|
||||
import proxy.network.NetHandlerPlayServer;
|
||||
import proxy.network.NetworkManager;
|
||||
import proxy.network.ThreadQuickExitException;
|
||||
import proxy.packet.play.server.S40PacketDisconnect;
|
||||
import proxy.network.PacketDirection;
|
||||
import proxy.network.PacketDecoder;
|
||||
import proxy.network.PacketSplitter;
|
||||
import proxy.network.PacketEncoder;
|
||||
import proxy.network.PacketPrepender;
|
||||
import proxy.network.Handler.ThreadQuickExitException;
|
||||
import proxy.network.HandshakeHandler;
|
||||
import proxy.network.ProxyHandler;
|
||||
import proxy.network.Connection;
|
||||
import proxy.packet.S40PacketDisconnect;
|
||||
import proxy.util.ChatColor;
|
||||
import proxy.util.ServerInfo;
|
||||
import proxy.util.User;
|
||||
|
@ -82,10 +82,10 @@ public class Proxy {
|
|||
private volatile boolean running = true;
|
||||
|
||||
private final List<ChannelFuture> endpoints = Collections.<ChannelFuture>synchronizedList(Lists.newArrayList());
|
||||
private final List<NetworkManager> networkManagers = Collections.<NetworkManager>synchronizedList(Lists.newArrayList());
|
||||
private final List<Connection> networkManagers = Collections.<Connection>synchronizedList(Lists.newArrayList());
|
||||
private final Queue<FutureTask<?>> futureTaskQueue = Queues.<FutureTask<?>>newArrayDeque();
|
||||
private final Map<String, User> users = Maps.newHashMap();
|
||||
private final Map<String, NetHandlerPlayServer> players = Maps.newHashMap();
|
||||
private final Map<String, ProxyHandler> players = Maps.newHashMap();
|
||||
private final Thread serverThread;
|
||||
|
||||
private int compression = -1;
|
||||
|
@ -217,14 +217,14 @@ public class Proxy {
|
|||
}
|
||||
|
||||
p_initChannel_1_.pipeline().addLast((String)"timeout", (ChannelHandler)(new ReadTimeoutHandler(30)))
|
||||
.addLast((String)"splitter", (ChannelHandler)(new MessageDeserializer2()))
|
||||
.addLast((String)"decoder", (ChannelHandler)(new MessageDeserializer(EnumPacketDirection.SERVERBOUND)))
|
||||
.addLast((String)"prepender", (ChannelHandler)(new MessageSerializer2()))
|
||||
.addLast((String)"encoder", (ChannelHandler)(new MessageSerializer(EnumPacketDirection.CLIENTBOUND)));
|
||||
NetworkManager networkmanager = new NetworkManager(EnumPacketDirection.SERVERBOUND);
|
||||
.addLast((String)"splitter", (ChannelHandler)(new PacketSplitter()))
|
||||
.addLast((String)"decoder", (ChannelHandler)(new PacketDecoder(PacketDirection.SERVER)))
|
||||
.addLast((String)"prepender", (ChannelHandler)(new PacketPrepender()))
|
||||
.addLast((String)"encoder", (ChannelHandler)(new PacketEncoder(PacketDirection.CLIENT)));
|
||||
Connection networkmanager = new Connection(PacketDirection.SERVER);
|
||||
Proxy.this.networkManagers.add(networkmanager);
|
||||
p_initChannel_1_.pipeline().addLast((String)"packet_handler", (ChannelHandler)networkmanager);
|
||||
networkmanager.setNetHandler(new NetHandlerHandshake(Proxy.this, networkmanager));
|
||||
networkmanager.setNetHandler(new HandshakeHandler(Proxy.this, networkmanager));
|
||||
}
|
||||
}).group((EventLoopGroup)lazyloadbase.getValue()).localAddress(address, port)).bind().syncUninterruptibly());
|
||||
}
|
||||
|
@ -245,10 +245,10 @@ public class Proxy {
|
|||
|
||||
public void networkTick() {
|
||||
synchronized(this.networkManagers) {
|
||||
Iterator<NetworkManager> iterator = this.networkManagers.iterator();
|
||||
Iterator<Connection> iterator = this.networkManagers.iterator();
|
||||
|
||||
while(iterator.hasNext()) {
|
||||
final NetworkManager networkmanager = (NetworkManager)iterator.next();
|
||||
final Connection networkmanager = (Connection)iterator.next();
|
||||
|
||||
if(!networkmanager.hasNoChannel()) {
|
||||
if(!networkmanager.isChannelOpen()) {
|
||||
|
@ -346,7 +346,7 @@ public class Proxy {
|
|||
this.users.put(user.toLowerCase(Locale.US), password);
|
||||
}
|
||||
|
||||
public void setLoggedIn(String user, NetHandlerPlayServer handler) {
|
||||
public void setLoggedIn(String user, ProxyHandler handler) {
|
||||
this.players.put(user.toLowerCase(Locale.US), handler);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,103 +0,0 @@
|
|||
package proxy.nbt;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
|
||||
public abstract class NBTBase
|
||||
{
|
||||
abstract void write(DataOutput output) throws IOException;
|
||||
|
||||
abstract void read(DataInput input, int depth, NBTSizeTracker sizeTracker) throws IOException;
|
||||
|
||||
public abstract String toString();
|
||||
|
||||
/**
|
||||
* Gets the type byte for the tag.
|
||||
*/
|
||||
public abstract byte getId();
|
||||
|
||||
/**
|
||||
* Creates a new NBTBase object that corresponds with the passed in id.
|
||||
*/
|
||||
protected static NBTBase createNewByType(byte id)
|
||||
{
|
||||
switch (id)
|
||||
{
|
||||
case 0:
|
||||
return new NBTTagEnd();
|
||||
|
||||
case 1:
|
||||
return new NBTTagByte();
|
||||
|
||||
case 2:
|
||||
return new NBTTagShort();
|
||||
|
||||
case 3:
|
||||
return new NBTTagInt();
|
||||
|
||||
case 4:
|
||||
return new NBTTagLong();
|
||||
|
||||
case 5:
|
||||
return new NBTTagFloat();
|
||||
|
||||
case 6:
|
||||
return new NBTTagDouble();
|
||||
|
||||
case 7:
|
||||
return new NBTTagByteArray();
|
||||
|
||||
case 8:
|
||||
return new NBTTagString();
|
||||
|
||||
case 9:
|
||||
return new NBTTagList();
|
||||
|
||||
case 10:
|
||||
return new NBTTagCompound();
|
||||
|
||||
case 11:
|
||||
return new NBTTagIntArray();
|
||||
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a clone of the tag.
|
||||
*/
|
||||
public abstract NBTBase copy();
|
||||
|
||||
/**
|
||||
* Return whether this compound has no tags.
|
||||
*/
|
||||
public boolean hasNoTags()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean equals(Object p_equals_1_)
|
||||
{
|
||||
if (!(p_equals_1_ instanceof NBTBase))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
NBTBase nbtbase = (NBTBase)p_equals_1_;
|
||||
return this.getId() == nbtbase.getId();
|
||||
}
|
||||
}
|
||||
|
||||
public int hashCode()
|
||||
{
|
||||
return this.getId();
|
||||
}
|
||||
|
||||
protected String getString()
|
||||
{
|
||||
return this.toString();
|
||||
}
|
||||
}
|
|
@ -1,31 +0,0 @@
|
|||
package proxy.nbt;
|
||||
|
||||
public class NBTSizeTracker
|
||||
{
|
||||
public static final NBTSizeTracker INFINITE = new NBTSizeTracker(0L)
|
||||
{
|
||||
public void read(long bits)
|
||||
{
|
||||
}
|
||||
};
|
||||
private final long max;
|
||||
private long read;
|
||||
|
||||
public NBTSizeTracker(long max)
|
||||
{
|
||||
this.max = max;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tracks the reading of the given amount of bits(!)
|
||||
*/
|
||||
public void read(long bits)
|
||||
{
|
||||
this.read += bits / 8L;
|
||||
|
||||
if (this.read > this.max)
|
||||
{
|
||||
throw new RuntimeException("Tried to read NBT tag that was too big; tried to allocate: " + this.read + "bytes where max allowed: " + this.max);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,103 +0,0 @@
|
|||
package proxy.nbt;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
|
||||
public class NBTTagByte extends NBTBase
|
||||
{
|
||||
/** The byte value for the tag. */
|
||||
private byte data;
|
||||
|
||||
NBTTagByte()
|
||||
{
|
||||
}
|
||||
|
||||
public NBTTagByte(byte data)
|
||||
{
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write the actual data contents of the tag, implemented in NBT extension classes
|
||||
*/
|
||||
void write(DataOutput output) throws IOException
|
||||
{
|
||||
output.writeByte(this.data);
|
||||
}
|
||||
|
||||
void read(DataInput input, int depth, NBTSizeTracker sizeTracker) throws IOException
|
||||
{
|
||||
sizeTracker.read(72L);
|
||||
this.data = input.readByte();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the type byte for the tag.
|
||||
*/
|
||||
public byte getId()
|
||||
{
|
||||
return (byte)1;
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return "" + this.data + "b";
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a clone of the tag.
|
||||
*/
|
||||
public NBTBase copy()
|
||||
{
|
||||
return new NBTTagByte(this.data);
|
||||
}
|
||||
|
||||
public boolean equals(Object p_equals_1_)
|
||||
{
|
||||
if (super.equals(p_equals_1_))
|
||||
{
|
||||
NBTTagByte nbttagbyte = (NBTTagByte)p_equals_1_;
|
||||
return this.data == nbttagbyte.data;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public int hashCode()
|
||||
{
|
||||
return super.hashCode() ^ this.data;
|
||||
}
|
||||
|
||||
public long getLong()
|
||||
{
|
||||
return (long)this.data;
|
||||
}
|
||||
|
||||
public int getInt()
|
||||
{
|
||||
return this.data;
|
||||
}
|
||||
|
||||
public short getShort()
|
||||
{
|
||||
return (short)this.data;
|
||||
}
|
||||
|
||||
public byte getByte()
|
||||
{
|
||||
return this.data;
|
||||
}
|
||||
|
||||
public double getDouble()
|
||||
{
|
||||
return (double)this.data;
|
||||
}
|
||||
|
||||
public float getFloat()
|
||||
{
|
||||
return (float)this.data;
|
||||
}
|
||||
}
|
|
@ -1,77 +0,0 @@
|
|||
package proxy.nbt;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class NBTTagByteArray extends NBTBase
|
||||
{
|
||||
/** The byte array stored in the tag. */
|
||||
private byte[] data;
|
||||
|
||||
NBTTagByteArray()
|
||||
{
|
||||
}
|
||||
|
||||
public NBTTagByteArray(byte[] data)
|
||||
{
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write the actual data contents of the tag, implemented in NBT extension classes
|
||||
*/
|
||||
void write(DataOutput output) throws IOException
|
||||
{
|
||||
output.writeInt(this.data.length);
|
||||
output.write(this.data);
|
||||
}
|
||||
|
||||
void read(DataInput input, int depth, NBTSizeTracker sizeTracker) throws IOException
|
||||
{
|
||||
sizeTracker.read(192L);
|
||||
int i = input.readInt();
|
||||
sizeTracker.read((long)(8 * i));
|
||||
this.data = new byte[i];
|
||||
input.readFully(this.data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the type byte for the tag.
|
||||
*/
|
||||
public byte getId()
|
||||
{
|
||||
return (byte)7;
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return "[" + this.data.length + " bytes]";
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a clone of the tag.
|
||||
*/
|
||||
public NBTBase copy()
|
||||
{
|
||||
byte[] abyte = new byte[this.data.length];
|
||||
System.arraycopy(this.data, 0, abyte, 0, this.data.length);
|
||||
return new NBTTagByteArray(abyte);
|
||||
}
|
||||
|
||||
public boolean equals(Object p_equals_1_)
|
||||
{
|
||||
return super.equals(p_equals_1_) ? Arrays.equals(this.data, ((NBTTagByteArray)p_equals_1_).data) : false;
|
||||
}
|
||||
|
||||
public int hashCode()
|
||||
{
|
||||
return super.hashCode() ^ Arrays.hashCode(this.data);
|
||||
}
|
||||
|
||||
public byte[] getByteArray()
|
||||
{
|
||||
return this.data;
|
||||
}
|
||||
}
|
|
@ -1,397 +0,0 @@
|
|||
package proxy.nbt;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import java.util.Map.Entry;
|
||||
|
||||
public class NBTTagCompound extends NBTBase
|
||||
{
|
||||
private Map<String, NBTBase> tagMap = Maps.newHashMap();
|
||||
|
||||
/**
|
||||
* Write the actual data contents of the tag, implemented in NBT extension classes
|
||||
*/
|
||||
public void write(DataOutput output) throws IOException
|
||||
{
|
||||
for (String s : this.tagMap.keySet())
|
||||
{
|
||||
NBTBase nbtbase = (NBTBase)this.tagMap.get(s);
|
||||
writeEntry(s, nbtbase, output);
|
||||
}
|
||||
|
||||
output.writeByte(0);
|
||||
}
|
||||
|
||||
public void read(DataInput input, int depth, NBTSizeTracker sizeTracker) throws IOException
|
||||
{
|
||||
sizeTracker.read(384L);
|
||||
|
||||
if (depth > 512)
|
||||
{
|
||||
throw new RuntimeException("Tried to read NBT tag with too high complexity, depth > 512");
|
||||
}
|
||||
else
|
||||
{
|
||||
this.tagMap.clear();
|
||||
byte b0;
|
||||
|
||||
while ((b0 = readType(input, sizeTracker)) != 0)
|
||||
{
|
||||
String s = readKey(input, sizeTracker);
|
||||
sizeTracker.read((long)(224 + 16 * s.length()));
|
||||
NBTBase nbtbase = readNBT(b0, s, input, depth + 1, sizeTracker);
|
||||
|
||||
if (this.tagMap.put(s, nbtbase) != null)
|
||||
{
|
||||
sizeTracker.read(288L);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Set<String> getKeySet()
|
||||
{
|
||||
return this.tagMap.keySet();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the type byte for the tag.
|
||||
*/
|
||||
public byte getId()
|
||||
{
|
||||
return (byte)10;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores the given tag into the map with the given string key. This is mostly used to store tag lists.
|
||||
*/
|
||||
public void setTag(String key, NBTBase value)
|
||||
{
|
||||
this.tagMap.put(key, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores a new NBTTagByte with the given byte value into the map with the given string key.
|
||||
*/
|
||||
public void setByte(String key, byte value)
|
||||
{
|
||||
this.tagMap.put(key, new NBTTagByte(value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores a new NBTTagShort with the given short value into the map with the given string key.
|
||||
*/
|
||||
public void setShort(String key, short value)
|
||||
{
|
||||
this.tagMap.put(key, new NBTTagShort(value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores a new NBTTagInt with the given integer value into the map with the given string key.
|
||||
*/
|
||||
public void setInteger(String key, int value)
|
||||
{
|
||||
this.tagMap.put(key, new NBTTagInt(value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores a new NBTTagLong with the given long value into the map with the given string key.
|
||||
*/
|
||||
public void setLong(String key, long value)
|
||||
{
|
||||
this.tagMap.put(key, new NBTTagLong(value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores a new NBTTagFloat with the given float value into the map with the given string key.
|
||||
*/
|
||||
public void setFloat(String key, float value)
|
||||
{
|
||||
this.tagMap.put(key, new NBTTagFloat(value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores a new NBTTagDouble with the given double value into the map with the given string key.
|
||||
*/
|
||||
public void setDouble(String key, double value)
|
||||
{
|
||||
this.tagMap.put(key, new NBTTagDouble(value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores a new NBTTagString with the given string value into the map with the given string key.
|
||||
*/
|
||||
public void setString(String key, String value)
|
||||
{
|
||||
this.tagMap.put(key, new NBTTagString(value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores a new NBTTagByteArray with the given array as data into the map with the given string key.
|
||||
*/
|
||||
public void setByteArray(String key, byte[] value)
|
||||
{
|
||||
this.tagMap.put(key, new NBTTagByteArray(value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores a new NBTTagIntArray with the given array as data into the map with the given string key.
|
||||
*/
|
||||
public void setIntArray(String key, int[] value)
|
||||
{
|
||||
this.tagMap.put(key, new NBTTagIntArray(value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores the given boolean value as a NBTTagByte, storing 1 for true and 0 for false, using the given string key.
|
||||
*/
|
||||
public void setBoolean(String key, boolean value)
|
||||
{
|
||||
this.setByte(key, (byte)(value ? 1 : 0));
|
||||
}
|
||||
|
||||
/**
|
||||
* gets a generic tag with the specified name
|
||||
*/
|
||||
public NBTBase getTag(String key)
|
||||
{
|
||||
return (NBTBase)this.tagMap.get(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the ID byte for the given tag key
|
||||
*/
|
||||
public byte getTagId(String key)
|
||||
{
|
||||
NBTBase nbtbase = (NBTBase)this.tagMap.get(key);
|
||||
return nbtbase != null ? nbtbase.getId() : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the given string has been previously stored as a key in the map.
|
||||
*/
|
||||
public boolean hasKey(String key)
|
||||
{
|
||||
return this.tagMap.containsKey(key);
|
||||
}
|
||||
|
||||
public boolean hasKey(String key, int type)
|
||||
{
|
||||
int i = this.getTagId(key);
|
||||
return i == type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a string value using the specified key, or an empty string if no such key was stored.
|
||||
*/
|
||||
public String getString(String key)
|
||||
{
|
||||
try
|
||||
{
|
||||
return !this.hasKey(key, 8) ? "" : ((NBTBase)this.tagMap.get(key)).getString();
|
||||
}
|
||||
catch (ClassCastException var3)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a byte array using the specified key, or a zero-length array if no such key was stored.
|
||||
*/
|
||||
public byte[] getByteArray(String key)
|
||||
{
|
||||
try
|
||||
{
|
||||
return !this.hasKey(key, 7) ? new byte[0] : ((NBTTagByteArray)this.tagMap.get(key)).getByteArray();
|
||||
}
|
||||
catch (ClassCastException classcastexception)
|
||||
{
|
||||
throw new RuntimeException(classcastexception);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves an int array using the specified key, or a zero-length array if no such key was stored.
|
||||
*/
|
||||
public int[] getIntArray(String key)
|
||||
{
|
||||
try
|
||||
{
|
||||
return !this.hasKey(key, 11) ? new int[0] : ((NBTTagIntArray)this.tagMap.get(key)).getIntArray();
|
||||
}
|
||||
catch (ClassCastException classcastexception)
|
||||
{
|
||||
throw new RuntimeException(classcastexception);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a NBTTagCompound subtag matching the specified key, or a new empty NBTTagCompound if no such key was
|
||||
* stored.
|
||||
*/
|
||||
public NBTTagCompound getCompoundTag(String key)
|
||||
{
|
||||
try
|
||||
{
|
||||
return !this.hasKey(key, 10) ? new NBTTagCompound() : (NBTTagCompound)this.tagMap.get(key);
|
||||
}
|
||||
catch (ClassCastException classcastexception)
|
||||
{
|
||||
throw new RuntimeException(classcastexception);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the NBTTagList object with the given name. Args: name, NBTBase type
|
||||
*/
|
||||
public NBTTagList getTagList(String key, int type)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (this.getTagId(key) != 9)
|
||||
{
|
||||
return new NBTTagList();
|
||||
}
|
||||
else
|
||||
{
|
||||
NBTTagList nbttaglist = (NBTTagList)this.tagMap.get(key);
|
||||
return nbttaglist.tagCount() > 0 && nbttaglist.getTagType() != type ? new NBTTagList() : nbttaglist;
|
||||
}
|
||||
}
|
||||
catch (ClassCastException classcastexception)
|
||||
{
|
||||
throw new RuntimeException(classcastexception);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified tag.
|
||||
*/
|
||||
public void removeTag(String key)
|
||||
{
|
||||
this.tagMap.remove(key);
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
StringBuilder stringbuilder = new StringBuilder("{");
|
||||
|
||||
for (Entry<String, NBTBase> entry : this.tagMap.entrySet())
|
||||
{
|
||||
if (stringbuilder.length() != 1)
|
||||
{
|
||||
stringbuilder.append(',');
|
||||
}
|
||||
|
||||
stringbuilder.append((String)entry.getKey()).append(':').append(entry.getValue());
|
||||
}
|
||||
|
||||
return stringbuilder.append('}').toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether this compound has no tags.
|
||||
*/
|
||||
public boolean hasNoTags()
|
||||
{
|
||||
return this.tagMap.isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a clone of the tag.
|
||||
*/
|
||||
public NBTBase copy()
|
||||
{
|
||||
NBTTagCompound nbttagcompound = new NBTTagCompound();
|
||||
|
||||
for (String s : this.tagMap.keySet())
|
||||
{
|
||||
nbttagcompound.setTag(s, ((NBTBase)this.tagMap.get(s)).copy());
|
||||
}
|
||||
|
||||
return nbttagcompound;
|
||||
}
|
||||
|
||||
public boolean equals(Object p_equals_1_)
|
||||
{
|
||||
if (super.equals(p_equals_1_))
|
||||
{
|
||||
NBTTagCompound nbttagcompound = (NBTTagCompound)p_equals_1_;
|
||||
return this.tagMap.entrySet().equals(nbttagcompound.tagMap.entrySet());
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public int hashCode()
|
||||
{
|
||||
return super.hashCode() ^ this.tagMap.hashCode();
|
||||
}
|
||||
|
||||
private static void writeEntry(String name, NBTBase data, DataOutput output) throws IOException
|
||||
{
|
||||
output.writeByte(data.getId());
|
||||
|
||||
if (data.getId() != 0)
|
||||
{
|
||||
output.writeUTF(name);
|
||||
data.write(output);
|
||||
}
|
||||
}
|
||||
|
||||
private static byte readType(DataInput input, NBTSizeTracker sizeTracker) throws IOException
|
||||
{
|
||||
return input.readByte();
|
||||
}
|
||||
|
||||
private static String readKey(DataInput input, NBTSizeTracker sizeTracker) throws IOException
|
||||
{
|
||||
return input.readUTF();
|
||||
}
|
||||
|
||||
static NBTBase readNBT(byte id, String key, DataInput input, int depth, NBTSizeTracker sizeTracker) throws IOException
|
||||
{
|
||||
NBTBase nbtbase = NBTBase.createNewByType(id);
|
||||
|
||||
nbtbase.read(input, depth, sizeTracker);
|
||||
return nbtbase;
|
||||
}
|
||||
|
||||
/**
|
||||
* Merges this NBTTagCompound with the given compound. Any sub-compounds are merged using the same methods, other
|
||||
* types of tags are overwritten from the given compound.
|
||||
*/
|
||||
public void merge(NBTTagCompound other)
|
||||
{
|
||||
for (String s : other.tagMap.keySet())
|
||||
{
|
||||
NBTBase nbtbase = (NBTBase)other.tagMap.get(s);
|
||||
|
||||
if (nbtbase.getId() == 10)
|
||||
{
|
||||
if (this.hasKey(s, 10))
|
||||
{
|
||||
NBTTagCompound nbttagcompound = this.getCompoundTag(s);
|
||||
nbttagcompound.merge((NBTTagCompound)nbtbase);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setTag(s, nbtbase.copy());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setTag(s, nbtbase.copy());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,74 +0,0 @@
|
|||
package proxy.nbt;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
|
||||
public class NBTTagDouble extends NBTBase
|
||||
{
|
||||
/** The double value for the tag. */
|
||||
private double data;
|
||||
|
||||
NBTTagDouble()
|
||||
{
|
||||
}
|
||||
|
||||
public NBTTagDouble(double data)
|
||||
{
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write the actual data contents of the tag, implemented in NBT extension classes
|
||||
*/
|
||||
void write(DataOutput output) throws IOException
|
||||
{
|
||||
output.writeDouble(this.data);
|
||||
}
|
||||
|
||||
void read(DataInput input, int depth, NBTSizeTracker sizeTracker) throws IOException
|
||||
{
|
||||
sizeTracker.read(128L);
|
||||
this.data = input.readDouble();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the type byte for the tag.
|
||||
*/
|
||||
public byte getId()
|
||||
{
|
||||
return (byte)6;
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return "" + this.data + "d";
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a clone of the tag.
|
||||
*/
|
||||
public NBTBase copy()
|
||||
{
|
||||
return new NBTTagDouble(this.data);
|
||||
}
|
||||
|
||||
public boolean equals(Object p_equals_1_)
|
||||
{
|
||||
if (super.equals(p_equals_1_))
|
||||
{
|
||||
NBTTagDouble nbttagdouble = (NBTTagDouble)p_equals_1_;
|
||||
return this.data == nbttagdouble.data;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public int hashCode()
|
||||
{
|
||||
long i = Double.doubleToLongBits(this.data);
|
||||
return super.hashCode() ^ (int)(i ^ i >>> 32);
|
||||
}
|
||||
}
|
|
@ -1,41 +0,0 @@
|
|||
package proxy.nbt;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
|
||||
public class NBTTagEnd extends NBTBase
|
||||
{
|
||||
void read(DataInput input, int depth, NBTSizeTracker sizeTracker) throws IOException
|
||||
{
|
||||
sizeTracker.read(64L);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write the actual data contents of the tag, implemented in NBT extension classes
|
||||
*/
|
||||
void write(DataOutput output) throws IOException
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the type byte for the tag.
|
||||
*/
|
||||
public byte getId()
|
||||
{
|
||||
return (byte)0;
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return "END";
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a clone of the tag.
|
||||
*/
|
||||
public NBTBase copy()
|
||||
{
|
||||
return new NBTTagEnd();
|
||||
}
|
||||
}
|
|
@ -1,73 +0,0 @@
|
|||
package proxy.nbt;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
|
||||
public class NBTTagFloat extends NBTBase
|
||||
{
|
||||
/** The float value for the tag. */
|
||||
private float data;
|
||||
|
||||
NBTTagFloat()
|
||||
{
|
||||
}
|
||||
|
||||
public NBTTagFloat(float data)
|
||||
{
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write the actual data contents of the tag, implemented in NBT extension classes
|
||||
*/
|
||||
void write(DataOutput output) throws IOException
|
||||
{
|
||||
output.writeFloat(this.data);
|
||||
}
|
||||
|
||||
void read(DataInput input, int depth, NBTSizeTracker sizeTracker) throws IOException
|
||||
{
|
||||
sizeTracker.read(96L);
|
||||
this.data = input.readFloat();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the type byte for the tag.
|
||||
*/
|
||||
public byte getId()
|
||||
{
|
||||
return (byte)5;
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return "" + this.data + "f";
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a clone of the tag.
|
||||
*/
|
||||
public NBTBase copy()
|
||||
{
|
||||
return new NBTTagFloat(this.data);
|
||||
}
|
||||
|
||||
public boolean equals(Object p_equals_1_)
|
||||
{
|
||||
if (super.equals(p_equals_1_))
|
||||
{
|
||||
NBTTagFloat nbttagfloat = (NBTTagFloat)p_equals_1_;
|
||||
return this.data == nbttagfloat.data;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public int hashCode()
|
||||
{
|
||||
return super.hashCode() ^ Float.floatToIntBits(this.data);
|
||||
}
|
||||
}
|
|
@ -1,103 +0,0 @@
|
|||
package proxy.nbt;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
|
||||
public class NBTTagInt extends NBTBase
|
||||
{
|
||||
/** The integer value for the tag. */
|
||||
private int data;
|
||||
|
||||
NBTTagInt()
|
||||
{
|
||||
}
|
||||
|
||||
public NBTTagInt(int data)
|
||||
{
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write the actual data contents of the tag, implemented in NBT extension classes
|
||||
*/
|
||||
void write(DataOutput output) throws IOException
|
||||
{
|
||||
output.writeInt(this.data);
|
||||
}
|
||||
|
||||
void read(DataInput input, int depth, NBTSizeTracker sizeTracker) throws IOException
|
||||
{
|
||||
sizeTracker.read(96L);
|
||||
this.data = input.readInt();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the type byte for the tag.
|
||||
*/
|
||||
public byte getId()
|
||||
{
|
||||
return (byte)3;
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return "" + this.data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a clone of the tag.
|
||||
*/
|
||||
public NBTBase copy()
|
||||
{
|
||||
return new NBTTagInt(this.data);
|
||||
}
|
||||
|
||||
public boolean equals(Object p_equals_1_)
|
||||
{
|
||||
if (super.equals(p_equals_1_))
|
||||
{
|
||||
NBTTagInt nbttagint = (NBTTagInt)p_equals_1_;
|
||||
return this.data == nbttagint.data;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public int hashCode()
|
||||
{
|
||||
return super.hashCode() ^ this.data;
|
||||
}
|
||||
|
||||
public long getLong()
|
||||
{
|
||||
return (long)this.data;
|
||||
}
|
||||
|
||||
public int getInt()
|
||||
{
|
||||
return this.data;
|
||||
}
|
||||
|
||||
public short getShort()
|
||||
{
|
||||
return (short)(this.data & 65535);
|
||||
}
|
||||
|
||||
public byte getByte()
|
||||
{
|
||||
return (byte)(this.data & 255);
|
||||
}
|
||||
|
||||
public double getDouble()
|
||||
{
|
||||
return (double)this.data;
|
||||
}
|
||||
|
||||
public float getFloat()
|
||||
{
|
||||
return (float)this.data;
|
||||
}
|
||||
}
|
|
@ -1,92 +0,0 @@
|
|||
package proxy.nbt;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class NBTTagIntArray extends NBTBase
|
||||
{
|
||||
/** The array of saved integers */
|
||||
private int[] intArray;
|
||||
|
||||
NBTTagIntArray()
|
||||
{
|
||||
}
|
||||
|
||||
public NBTTagIntArray(int[] p_i45132_1_)
|
||||
{
|
||||
this.intArray = p_i45132_1_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write the actual data contents of the tag, implemented in NBT extension classes
|
||||
*/
|
||||
void write(DataOutput output) throws IOException
|
||||
{
|
||||
output.writeInt(this.intArray.length);
|
||||
|
||||
for (int i = 0; i < this.intArray.length; ++i)
|
||||
{
|
||||
output.writeInt(this.intArray[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void read(DataInput input, int depth, NBTSizeTracker sizeTracker) throws IOException
|
||||
{
|
||||
sizeTracker.read(192L);
|
||||
int i = input.readInt();
|
||||
sizeTracker.read((long)(32 * i));
|
||||
this.intArray = new int[i];
|
||||
|
||||
for (int j = 0; j < i; ++j)
|
||||
{
|
||||
this.intArray[j] = input.readInt();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the type byte for the tag.
|
||||
*/
|
||||
public byte getId()
|
||||
{
|
||||
return (byte)11;
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
String s = "[";
|
||||
|
||||
for (int i : this.intArray)
|
||||
{
|
||||
s = s + i + ",";
|
||||
}
|
||||
|
||||
return s + "]";
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a clone of the tag.
|
||||
*/
|
||||
public NBTBase copy()
|
||||
{
|
||||
int[] aint = new int[this.intArray.length];
|
||||
System.arraycopy(this.intArray, 0, aint, 0, this.intArray.length);
|
||||
return new NBTTagIntArray(aint);
|
||||
}
|
||||
|
||||
public boolean equals(Object p_equals_1_)
|
||||
{
|
||||
return super.equals(p_equals_1_) ? Arrays.equals(this.intArray, ((NBTTagIntArray)p_equals_1_).intArray) : false;
|
||||
}
|
||||
|
||||
public int hashCode()
|
||||
{
|
||||
return super.hashCode() ^ Arrays.hashCode(this.intArray);
|
||||
}
|
||||
|
||||
public int[] getIntArray()
|
||||
{
|
||||
return this.intArray;
|
||||
}
|
||||
}
|
|
@ -1,221 +0,0 @@
|
|||
package proxy.nbt;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import proxy.util.Log;
|
||||
|
||||
public class NBTTagList extends NBTBase
|
||||
{
|
||||
private List<NBTBase> tagList = Lists.newArrayList();
|
||||
|
||||
/**
|
||||
* The type byte for the tags in the list - they must all be of the same type.
|
||||
*/
|
||||
private byte tagType = 0;
|
||||
|
||||
/**
|
||||
* Write the actual data contents of the tag, implemented in NBT extension classes
|
||||
*/
|
||||
void write(DataOutput output) throws IOException
|
||||
{
|
||||
if (!this.tagList.isEmpty())
|
||||
{
|
||||
this.tagType = ((NBTBase)this.tagList.get(0)).getId();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.tagType = 0;
|
||||
}
|
||||
|
||||
output.writeByte(this.tagType);
|
||||
output.writeInt(this.tagList.size());
|
||||
|
||||
for (int i = 0; i < this.tagList.size(); ++i)
|
||||
{
|
||||
((NBTBase)this.tagList.get(i)).write(output);
|
||||
}
|
||||
}
|
||||
|
||||
void read(DataInput input, int depth, NBTSizeTracker sizeTracker) throws IOException
|
||||
{
|
||||
sizeTracker.read(296L);
|
||||
|
||||
if (depth > 512)
|
||||
{
|
||||
throw new RuntimeException("Tried to read NBT tag with too high complexity, depth > 512");
|
||||
}
|
||||
else
|
||||
{
|
||||
this.tagType = input.readByte();
|
||||
int i = input.readInt();
|
||||
|
||||
if (this.tagType == 0 && i > 0)
|
||||
{
|
||||
throw new RuntimeException("Missing type on ListTag");
|
||||
}
|
||||
else
|
||||
{
|
||||
sizeTracker.read(32L * (long)i);
|
||||
this.tagList = Lists.newArrayListWithCapacity(i);
|
||||
|
||||
for (int j = 0; j < i; ++j)
|
||||
{
|
||||
NBTBase nbtbase = NBTBase.createNewByType(this.tagType);
|
||||
nbtbase.read(input, depth + 1, sizeTracker);
|
||||
this.tagList.add(nbtbase);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the type byte for the tag.
|
||||
*/
|
||||
public byte getId()
|
||||
{
|
||||
return (byte)9;
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
StringBuilder stringbuilder = new StringBuilder("[");
|
||||
|
||||
for (int i = 0; i < this.tagList.size(); ++i)
|
||||
{
|
||||
if (i != 0)
|
||||
{
|
||||
stringbuilder.append(',');
|
||||
}
|
||||
|
||||
stringbuilder.append(i).append(':').append(this.tagList.get(i));
|
||||
}
|
||||
|
||||
return stringbuilder.append(']').toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the provided tag to the end of the list. There is no check to verify this tag is of the same type as any
|
||||
* previous tag.
|
||||
*/
|
||||
public void appendTag(NBTBase nbt)
|
||||
{
|
||||
if (nbt.getId() == 0)
|
||||
{
|
||||
Log.warn("Invalid TagEnd added to ListTag");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.tagType == 0)
|
||||
{
|
||||
this.tagType = nbt.getId();
|
||||
}
|
||||
else if (this.tagType != nbt.getId())
|
||||
{
|
||||
Log.warn("Adding mismatching tag types to tag list");
|
||||
return;
|
||||
}
|
||||
|
||||
this.tagList.add(nbt);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the given index to the given tag
|
||||
*/
|
||||
public void set(int idx, NBTBase nbt)
|
||||
{
|
||||
if (nbt.getId() == 0)
|
||||
{
|
||||
Log.warn("Invalid TagEnd added to ListTag");
|
||||
}
|
||||
else if (idx >= 0 && idx < this.tagList.size())
|
||||
{
|
||||
if (this.tagType == 0)
|
||||
{
|
||||
this.tagType = nbt.getId();
|
||||
}
|
||||
else if (this.tagType != nbt.getId())
|
||||
{
|
||||
Log.warn("Adding mismatching tag types to tag list");
|
||||
return;
|
||||
}
|
||||
|
||||
this.tagList.set(idx, nbt);
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.warn("index out of bounds to set tag in tag list");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a tag at the given index.
|
||||
*/
|
||||
public NBTBase removeTag(int i)
|
||||
{
|
||||
return (NBTBase)this.tagList.remove(i);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether this compound has no tags.
|
||||
*/
|
||||
public boolean hasNoTags()
|
||||
{
|
||||
return this.tagList.isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of tags in the list.
|
||||
*/
|
||||
public int tagCount()
|
||||
{
|
||||
return this.tagList.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a clone of the tag.
|
||||
*/
|
||||
public NBTBase copy()
|
||||
{
|
||||
NBTTagList nbttaglist = new NBTTagList();
|
||||
nbttaglist.tagType = this.tagType;
|
||||
|
||||
for (NBTBase nbtbase : this.tagList)
|
||||
{
|
||||
NBTBase nbtbase1 = nbtbase.copy();
|
||||
nbttaglist.tagList.add(nbtbase1);
|
||||
}
|
||||
|
||||
return nbttaglist;
|
||||
}
|
||||
|
||||
public boolean equals(Object p_equals_1_)
|
||||
{
|
||||
if (super.equals(p_equals_1_))
|
||||
{
|
||||
NBTTagList nbttaglist = (NBTTagList)p_equals_1_;
|
||||
|
||||
if (this.tagType == nbttaglist.tagType)
|
||||
{
|
||||
return this.tagList.equals(nbttaglist.tagList);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public int hashCode()
|
||||
{
|
||||
return super.hashCode() ^ this.tagList.hashCode();
|
||||
}
|
||||
|
||||
public int getTagType()
|
||||
{
|
||||
return this.tagType;
|
||||
}
|
||||
}
|
|
@ -1,103 +0,0 @@
|
|||
package proxy.nbt;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
|
||||
public class NBTTagLong extends NBTBase
|
||||
{
|
||||
/** The long value for the tag. */
|
||||
private long data;
|
||||
|
||||
NBTTagLong()
|
||||
{
|
||||
}
|
||||
|
||||
public NBTTagLong(long data)
|
||||
{
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write the actual data contents of the tag, implemented in NBT extension classes
|
||||
*/
|
||||
void write(DataOutput output) throws IOException
|
||||
{
|
||||
output.writeLong(this.data);
|
||||
}
|
||||
|
||||
void read(DataInput input, int depth, NBTSizeTracker sizeTracker) throws IOException
|
||||
{
|
||||
sizeTracker.read(128L);
|
||||
this.data = input.readLong();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the type byte for the tag.
|
||||
*/
|
||||
public byte getId()
|
||||
{
|
||||
return (byte)4;
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return "" + this.data + "L";
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a clone of the tag.
|
||||
*/
|
||||
public NBTBase copy()
|
||||
{
|
||||
return new NBTTagLong(this.data);
|
||||
}
|
||||
|
||||
public boolean equals(Object p_equals_1_)
|
||||
{
|
||||
if (super.equals(p_equals_1_))
|
||||
{
|
||||
NBTTagLong nbttaglong = (NBTTagLong)p_equals_1_;
|
||||
return this.data == nbttaglong.data;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public int hashCode()
|
||||
{
|
||||
return super.hashCode() ^ (int)(this.data ^ this.data >>> 32);
|
||||
}
|
||||
|
||||
public long getLong()
|
||||
{
|
||||
return this.data;
|
||||
}
|
||||
|
||||
public int getInt()
|
||||
{
|
||||
return (int)(this.data & -1L);
|
||||
}
|
||||
|
||||
public short getShort()
|
||||
{
|
||||
return (short)((int)(this.data & 65535L));
|
||||
}
|
||||
|
||||
public byte getByte()
|
||||
{
|
||||
return (byte)((int)(this.data & 255L));
|
||||
}
|
||||
|
||||
public double getDouble()
|
||||
{
|
||||
return (double)this.data;
|
||||
}
|
||||
|
||||
public float getFloat()
|
||||
{
|
||||
return (float)this.data;
|
||||
}
|
||||
}
|
|
@ -1,103 +0,0 @@
|
|||
package proxy.nbt;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
|
||||
public class NBTTagShort extends NBTBase
|
||||
{
|
||||
/** The short value for the tag. */
|
||||
private short data;
|
||||
|
||||
public NBTTagShort()
|
||||
{
|
||||
}
|
||||
|
||||
public NBTTagShort(short data)
|
||||
{
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write the actual data contents of the tag, implemented in NBT extension classes
|
||||
*/
|
||||
void write(DataOutput output) throws IOException
|
||||
{
|
||||
output.writeShort(this.data);
|
||||
}
|
||||
|
||||
void read(DataInput input, int depth, NBTSizeTracker sizeTracker) throws IOException
|
||||
{
|
||||
sizeTracker.read(80L);
|
||||
this.data = input.readShort();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the type byte for the tag.
|
||||
*/
|
||||
public byte getId()
|
||||
{
|
||||
return (byte)2;
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return "" + this.data + "s";
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a clone of the tag.
|
||||
*/
|
||||
public NBTBase copy()
|
||||
{
|
||||
return new NBTTagShort(this.data);
|
||||
}
|
||||
|
||||
public boolean equals(Object p_equals_1_)
|
||||
{
|
||||
if (super.equals(p_equals_1_))
|
||||
{
|
||||
NBTTagShort nbttagshort = (NBTTagShort)p_equals_1_;
|
||||
return this.data == nbttagshort.data;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public int hashCode()
|
||||
{
|
||||
return super.hashCode() ^ this.data;
|
||||
}
|
||||
|
||||
public long getLong()
|
||||
{
|
||||
return (long)this.data;
|
||||
}
|
||||
|
||||
public int getInt()
|
||||
{
|
||||
return this.data;
|
||||
}
|
||||
|
||||
public short getShort()
|
||||
{
|
||||
return this.data;
|
||||
}
|
||||
|
||||
public byte getByte()
|
||||
{
|
||||
return (byte)(this.data & 255);
|
||||
}
|
||||
|
||||
public double getDouble()
|
||||
{
|
||||
return (double)this.data;
|
||||
}
|
||||
|
||||
public float getFloat()
|
||||
{
|
||||
return (float)this.data;
|
||||
}
|
||||
}
|
|
@ -1,93 +0,0 @@
|
|||
package proxy.nbt;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
|
||||
public class NBTTagString extends NBTBase
|
||||
{
|
||||
/** The string value for the tag (cannot be empty). */
|
||||
private String data;
|
||||
|
||||
public NBTTagString()
|
||||
{
|
||||
this.data = "";
|
||||
}
|
||||
|
||||
public NBTTagString(String data)
|
||||
{
|
||||
this.data = data;
|
||||
|
||||
if (data == null)
|
||||
{
|
||||
throw new IllegalArgumentException("Empty string not allowed");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Write the actual data contents of the tag, implemented in NBT extension classes
|
||||
*/
|
||||
void write(DataOutput output) throws IOException
|
||||
{
|
||||
output.writeUTF(this.data);
|
||||
}
|
||||
|
||||
void read(DataInput input, int depth, NBTSizeTracker sizeTracker) throws IOException
|
||||
{
|
||||
sizeTracker.read(288L);
|
||||
this.data = input.readUTF();
|
||||
sizeTracker.read((long)(16 * this.data.length()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the type byte for the tag.
|
||||
*/
|
||||
public byte getId()
|
||||
{
|
||||
return (byte)8;
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return "\"" + this.data.replace("\"", "\\\"") + "\"";
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a clone of the tag.
|
||||
*/
|
||||
public NBTBase copy()
|
||||
{
|
||||
return new NBTTagString(this.data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether this compound has no tags.
|
||||
*/
|
||||
public boolean hasNoTags()
|
||||
{
|
||||
return this.data.isEmpty();
|
||||
}
|
||||
|
||||
public boolean equals(Object p_equals_1_)
|
||||
{
|
||||
if (!super.equals(p_equals_1_))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
NBTTagString nbttagstring = (NBTTagString)p_equals_1_;
|
||||
return this.data == null && nbttagstring.data == null || this.data != null && this.data.equals(nbttagstring.data);
|
||||
}
|
||||
}
|
||||
|
||||
public int hashCode()
|
||||
{
|
||||
return super.hashCode() ^ this.data.hashCode();
|
||||
}
|
||||
|
||||
public String getString()
|
||||
{
|
||||
return this.data;
|
||||
}
|
||||
}
|
42
proxy/src/main/java/proxy/nbt/Nbt.java
Executable file
42
proxy/src/main/java/proxy/nbt/Nbt.java
Executable file
|
@ -0,0 +1,42 @@
|
|||
package proxy.nbt;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
|
||||
abstract class Nbt {
|
||||
abstract void write(DataOutput output) throws IOException;
|
||||
abstract void read(DataInput input, int depth, Tracker tracker) throws IOException;
|
||||
abstract byte getId();
|
||||
|
||||
static Nbt createTag(byte id) {
|
||||
switch(id) {
|
||||
case 0:
|
||||
return new NbtNull();
|
||||
case 1:
|
||||
return new NbtByte();
|
||||
case 2:
|
||||
return new NbtShort();
|
||||
case 3:
|
||||
return new NbtInt();
|
||||
case 4:
|
||||
return new NbtLong();
|
||||
case 5:
|
||||
return new NbtFloat();
|
||||
case 6:
|
||||
return new NbtDouble();
|
||||
case 7:
|
||||
return new NbtByteArray();
|
||||
case 8:
|
||||
return new NbtString();
|
||||
case 9:
|
||||
return new NbtList();
|
||||
case 10:
|
||||
return new NbtCompound();
|
||||
case 11:
|
||||
return new NbtIntArray();
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
22
proxy/src/main/java/proxy/nbt/NbtByte.java
Executable file
22
proxy/src/main/java/proxy/nbt/NbtByte.java
Executable file
|
@ -0,0 +1,22 @@
|
|||
package proxy.nbt;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
|
||||
class NbtByte extends Nbt {
|
||||
private byte data;
|
||||
|
||||
void write(DataOutput output) throws IOException {
|
||||
output.writeByte(this.data);
|
||||
}
|
||||
|
||||
void read(DataInput input, int depth, Tracker tracker) throws IOException {
|
||||
tracker.read(72L);
|
||||
this.data = input.readByte();
|
||||
}
|
||||
|
||||
byte getId() {
|
||||
return (byte)1;
|
||||
}
|
||||
}
|
26
proxy/src/main/java/proxy/nbt/NbtByteArray.java
Executable file
26
proxy/src/main/java/proxy/nbt/NbtByteArray.java
Executable file
|
@ -0,0 +1,26 @@
|
|||
package proxy.nbt;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
|
||||
class NbtByteArray extends Nbt {
|
||||
private byte[] data;
|
||||
|
||||
void write(DataOutput output) throws IOException {
|
||||
output.writeInt(this.data.length);
|
||||
output.write(this.data);
|
||||
}
|
||||
|
||||
void read(DataInput input, int depth, Tracker tracker) throws IOException {
|
||||
tracker.read(192L);
|
||||
int len = input.readInt();
|
||||
tracker.read((long)(8 * len));
|
||||
this.data = new byte[len];
|
||||
input.readFully(this.data);
|
||||
}
|
||||
|
||||
byte getId() {
|
||||
return (byte)7;
|
||||
}
|
||||
}
|
68
proxy/src/main/java/proxy/nbt/NbtCompound.java
Executable file
68
proxy/src/main/java/proxy/nbt/NbtCompound.java
Executable file
|
@ -0,0 +1,68 @@
|
|||
package proxy.nbt;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
public class NbtCompound extends Nbt {
|
||||
private Map<String, Nbt> tags = Maps.newHashMap();
|
||||
|
||||
void write(DataOutput output) throws IOException {
|
||||
for(String key : this.tags.keySet()) {
|
||||
Nbt tag = this.tags.get(key);
|
||||
output.writeByte(tag.getId());
|
||||
if(tag.getId() != 0) {
|
||||
output.writeUTF(key);
|
||||
tag.write(output);
|
||||
}
|
||||
}
|
||||
output.writeByte(0);
|
||||
}
|
||||
|
||||
void read(DataInput input, int depth, Tracker tracker) throws IOException {
|
||||
tracker.read(384L);
|
||||
if(depth > 512)
|
||||
throw new RuntimeException("Tried to read tag tree deeper than 512");
|
||||
this.tags.clear();
|
||||
byte type;
|
||||
while((type = input.readByte()) != 0) {
|
||||
String key = input.readUTF();
|
||||
tracker.read((long)(224 + 16 * key.length()));
|
||||
Nbt tag = Nbt.createTag(type);
|
||||
tag.read(input, depth + 1, tracker);
|
||||
if(this.tags.put(key, tag) != null)
|
||||
tracker.read(288L);
|
||||
}
|
||||
}
|
||||
|
||||
byte getId() {
|
||||
return (byte)10;
|
||||
}
|
||||
|
||||
public String getString(String key) {
|
||||
Nbt tag = this.tags.get(key);
|
||||
return tag instanceof NbtString ? ((NbtString)tag).getData() : null;
|
||||
}
|
||||
|
||||
public int getStringListLength(String key) {
|
||||
Nbt tag = this.tags.get(key);
|
||||
return tag instanceof NbtList ? ((NbtList)tag).getStringListLength() : -1;
|
||||
}
|
||||
|
||||
public static NbtCompound readTag(DataInput input) throws IOException {
|
||||
if(input.readByte() != 10)
|
||||
throw new IOException("Root is not a compound");
|
||||
input.readUTF();
|
||||
NbtCompound tag = new NbtCompound();
|
||||
tag.read(input, 0, new Tracker());
|
||||
return tag;
|
||||
}
|
||||
|
||||
public static void writeTag(NbtCompound tag, DataOutput output) throws IOException {
|
||||
output.writeByte(tag.getId());
|
||||
output.writeUTF("");
|
||||
tag.write(output);
|
||||
}
|
||||
}
|
22
proxy/src/main/java/proxy/nbt/NbtDouble.java
Executable file
22
proxy/src/main/java/proxy/nbt/NbtDouble.java
Executable file
|
@ -0,0 +1,22 @@
|
|||
package proxy.nbt;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
|
||||
class NbtDouble extends Nbt {
|
||||
private double data;
|
||||
|
||||
void write(DataOutput output) throws IOException {
|
||||
output.writeDouble(this.data);
|
||||
}
|
||||
|
||||
void read(DataInput input, int depth, Tracker tracker) throws IOException {
|
||||
tracker.read(128L);
|
||||
this.data = input.readDouble();
|
||||
}
|
||||
|
||||
byte getId() {
|
||||
return (byte)6;
|
||||
}
|
||||
}
|
22
proxy/src/main/java/proxy/nbt/NbtFloat.java
Executable file
22
proxy/src/main/java/proxy/nbt/NbtFloat.java
Executable file
|
@ -0,0 +1,22 @@
|
|||
package proxy.nbt;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
|
||||
class NbtFloat extends Nbt {
|
||||
private float data;
|
||||
|
||||
void write(DataOutput output) throws IOException {
|
||||
output.writeFloat(this.data);
|
||||
}
|
||||
|
||||
void read(DataInput input, int depth, Tracker tracker) throws IOException {
|
||||
tracker.read(96L);
|
||||
this.data = input.readFloat();
|
||||
}
|
||||
|
||||
byte getId() {
|
||||
return (byte)5;
|
||||
}
|
||||
}
|
22
proxy/src/main/java/proxy/nbt/NbtInt.java
Executable file
22
proxy/src/main/java/proxy/nbt/NbtInt.java
Executable file
|
@ -0,0 +1,22 @@
|
|||
package proxy.nbt;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
|
||||
class NbtInt extends Nbt {
|
||||
private int data;
|
||||
|
||||
void write(DataOutput output) throws IOException {
|
||||
output.writeInt(this.data);
|
||||
}
|
||||
|
||||
void read(DataInput input, int depth, Tracker tracker) throws IOException {
|
||||
tracker.read(96L);
|
||||
this.data = input.readInt();
|
||||
}
|
||||
|
||||
byte getId() {
|
||||
return (byte)3;
|
||||
}
|
||||
}
|
30
proxy/src/main/java/proxy/nbt/NbtIntArray.java
Executable file
30
proxy/src/main/java/proxy/nbt/NbtIntArray.java
Executable file
|
@ -0,0 +1,30 @@
|
|||
package proxy.nbt;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
|
||||
class NbtIntArray extends Nbt {
|
||||
private int[] data;
|
||||
|
||||
void write(DataOutput output) throws IOException {
|
||||
output.writeInt(this.data.length);
|
||||
for(int z = 0; z < this.data.length; z++) {
|
||||
output.writeInt(this.data[z]);
|
||||
}
|
||||
}
|
||||
|
||||
void read(DataInput input, int depth, Tracker tracker) throws IOException {
|
||||
tracker.read(192L);
|
||||
int len = input.readInt();
|
||||
tracker.read((long)(32 * len));
|
||||
this.data = new int[len];
|
||||
for(int z = 0; z < len; z++) {
|
||||
this.data[z] = input.readInt();
|
||||
}
|
||||
}
|
||||
|
||||
byte getId() {
|
||||
return (byte)11;
|
||||
}
|
||||
}
|
47
proxy/src/main/java/proxy/nbt/NbtList.java
Executable file
47
proxy/src/main/java/proxy/nbt/NbtList.java
Executable file
|
@ -0,0 +1,47 @@
|
|||
package proxy.nbt;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
class NbtList extends Nbt {
|
||||
private List<Nbt> list = Lists.newArrayList();
|
||||
private byte type = 0;
|
||||
|
||||
void write(DataOutput output) throws IOException {
|
||||
this.type = this.list.isEmpty() ? 0 : this.list.get(0).getId();
|
||||
output.writeByte(this.type);
|
||||
output.writeInt(this.list.size());
|
||||
for(int z = 0; z < this.list.size(); z++) {
|
||||
this.list.get(z).write(output);
|
||||
}
|
||||
}
|
||||
|
||||
void read(DataInput input, int depth, Tracker tracker) throws IOException {
|
||||
tracker.read(296L);
|
||||
if(depth > 512)
|
||||
throw new RuntimeException("Tried to read tag tree deeper than 512");
|
||||
this.type = input.readByte();
|
||||
int len = input.readInt();
|
||||
if(this.type == 0 && len > 0)
|
||||
throw new RuntimeException("Type null on list tag");
|
||||
tracker.read(32L * (long)len);
|
||||
this.list = Lists.newArrayListWithCapacity(len);
|
||||
for(int z = 0; z < len; z++) {
|
||||
Nbt nbtbase = Nbt.createTag(this.type);
|
||||
nbtbase.read(input, depth + 1, tracker);
|
||||
this.list.add(nbtbase);
|
||||
}
|
||||
}
|
||||
|
||||
byte getId() {
|
||||
return (byte)9;
|
||||
}
|
||||
|
||||
int getStringListLength() {
|
||||
return this.type != 8 && !this.list.isEmpty() ? -1 : this.list.size();
|
||||
}
|
||||
}
|
22
proxy/src/main/java/proxy/nbt/NbtLong.java
Executable file
22
proxy/src/main/java/proxy/nbt/NbtLong.java
Executable file
|
@ -0,0 +1,22 @@
|
|||
package proxy.nbt;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
|
||||
class NbtLong extends Nbt {
|
||||
private long data;
|
||||
|
||||
void write(DataOutput output) throws IOException {
|
||||
output.writeLong(this.data);
|
||||
}
|
||||
|
||||
void read(DataInput input, int depth, Tracker tracker) throws IOException {
|
||||
tracker.read(128L);
|
||||
this.data = input.readLong();
|
||||
}
|
||||
|
||||
byte getId() {
|
||||
return (byte)4;
|
||||
}
|
||||
}
|
18
proxy/src/main/java/proxy/nbt/NbtNull.java
Executable file
18
proxy/src/main/java/proxy/nbt/NbtNull.java
Executable file
|
@ -0,0 +1,18 @@
|
|||
package proxy.nbt;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
|
||||
class NbtNull extends Nbt {
|
||||
void read(DataInput input, int depth, Tracker tracker) throws IOException {
|
||||
tracker.read(64L);
|
||||
}
|
||||
|
||||
void write(DataOutput output) throws IOException {
|
||||
}
|
||||
|
||||
byte getId() {
|
||||
return (byte)0;
|
||||
}
|
||||
}
|
22
proxy/src/main/java/proxy/nbt/NbtShort.java
Executable file
22
proxy/src/main/java/proxy/nbt/NbtShort.java
Executable file
|
@ -0,0 +1,22 @@
|
|||
package proxy.nbt;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
|
||||
class NbtShort extends Nbt {
|
||||
private short data;
|
||||
|
||||
void write(DataOutput output) throws IOException {
|
||||
output.writeShort(this.data);
|
||||
}
|
||||
|
||||
void read(DataInput input, int depth, Tracker tracker) throws IOException {
|
||||
tracker.read(80L);
|
||||
this.data = input.readShort();
|
||||
}
|
||||
|
||||
byte getId() {
|
||||
return (byte)2;
|
||||
}
|
||||
}
|
27
proxy/src/main/java/proxy/nbt/NbtString.java
Executable file
27
proxy/src/main/java/proxy/nbt/NbtString.java
Executable file
|
@ -0,0 +1,27 @@
|
|||
package proxy.nbt;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
|
||||
class NbtString extends Nbt {
|
||||
private String data;
|
||||
|
||||
void write(DataOutput output) throws IOException {
|
||||
output.writeUTF(this.data);
|
||||
}
|
||||
|
||||
void read(DataInput input, int depth, Tracker tracker) throws IOException {
|
||||
tracker.read(288L);
|
||||
this.data = input.readUTF();
|
||||
tracker.read((long)(16 * this.data.length()));
|
||||
}
|
||||
|
||||
byte getId() {
|
||||
return (byte)8;
|
||||
}
|
||||
|
||||
String getData() {
|
||||
return this.data;
|
||||
}
|
||||
}
|
11
proxy/src/main/java/proxy/nbt/Tracker.java
Executable file
11
proxy/src/main/java/proxy/nbt/Tracker.java
Executable file
|
@ -0,0 +1,11 @@
|
|||
package proxy.nbt;
|
||||
|
||||
class Tracker {
|
||||
private long read;
|
||||
|
||||
void read(long bits) {
|
||||
this.read += bits / 8L;
|
||||
if(this.read > 2097152L)
|
||||
throw new RuntimeException("Tried to read tag that was too big: Read " + this.read + " bytes, maximum 2097152 bytes");
|
||||
}
|
||||
}
|
|
@ -9,12 +9,12 @@ import java.util.List;
|
|||
import java.util.zip.DataFormatException;
|
||||
import java.util.zip.Inflater;
|
||||
|
||||
public class NettyCompressionDecoder extends ByteToMessageDecoder
|
||||
public class CompressingDecoder extends ByteToMessageDecoder
|
||||
{
|
||||
private final Inflater inflater;
|
||||
private int treshold;
|
||||
|
||||
public NettyCompressionDecoder(int treshold)
|
||||
public CompressingDecoder(int treshold)
|
||||
{
|
||||
this.treshold = treshold;
|
||||
this.inflater = new Inflater();
|
|
@ -5,13 +5,13 @@ import io.netty.channel.ChannelHandlerContext;
|
|||
import io.netty.handler.codec.MessageToByteEncoder;
|
||||
import java.util.zip.Deflater;
|
||||
|
||||
public class NettyCompressionEncoder extends MessageToByteEncoder<ByteBuf>
|
||||
public class CompressingEncoder extends MessageToByteEncoder<ByteBuf>
|
||||
{
|
||||
private final byte[] buffer = new byte[8192];
|
||||
private final Deflater deflater;
|
||||
private int treshold;
|
||||
|
||||
public NettyCompressionEncoder(int treshold)
|
||||
public CompressingEncoder(int treshold)
|
||||
{
|
||||
this.treshold = treshold;
|
||||
this.deflater = new Deflater();
|
|
@ -29,12 +29,13 @@ import java.util.concurrent.ConcurrentLinkedQueue;
|
|||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
||||
|
||||
import proxy.network.Handler.ThreadQuickExitException;
|
||||
import proxy.util.LazyLoader;
|
||||
import proxy.util.Log;
|
||||
|
||||
public class NetworkManager extends SimpleChannelInboundHandler<Packet>
|
||||
public class Connection extends SimpleChannelInboundHandler<Packet>
|
||||
{
|
||||
public static final AttributeKey<EnumConnectionState> STATE = AttributeKey.<EnumConnectionState>valueOf("protocol");
|
||||
public static final AttributeKey<Protocol> STATE = AttributeKey.<Protocol>valueOf("protocol");
|
||||
public static final LazyLoader<NioEventLoopGroup> CLIENT_NIO_EVENTLOOP = new LazyLoader<NioEventLoopGroup>()
|
||||
{
|
||||
protected NioEventLoopGroup load()
|
||||
|
@ -49,30 +50,30 @@ public class NetworkManager extends SimpleChannelInboundHandler<Packet>
|
|||
return new EpollEventLoopGroup(0, (new ThreadFactoryBuilder()).setNameFormat("Netty Epoll Client IO #%d").setDaemon(true).build());
|
||||
}
|
||||
};
|
||||
private final EnumPacketDirection direction;
|
||||
private final Queue<NetworkManager.InboundHandlerTuplePacketListener> outboundPacketsQueue = new ConcurrentLinkedQueue<NetworkManager.InboundHandlerTuplePacketListener>();
|
||||
private final PacketDirection direction;
|
||||
private final Queue<Connection.InboundHandlerTuplePacketListener> outboundPacketsQueue = new ConcurrentLinkedQueue<Connection.InboundHandlerTuplePacketListener>();
|
||||
private final ReentrantReadWriteLock readWriteLock = new ReentrantReadWriteLock();
|
||||
|
||||
private Channel channel;
|
||||
private SocketAddress socketAddress;
|
||||
private INetHandler packetListener;
|
||||
private String terminationReason;
|
||||
private SocketAddress address;
|
||||
private Handler handler;
|
||||
private String exitMessage;
|
||||
private boolean disconnected;
|
||||
|
||||
public NetworkManager(EnumPacketDirection packetDirection)
|
||||
public Connection(PacketDirection direction)
|
||||
{
|
||||
this.direction = packetDirection;
|
||||
this.direction = direction;
|
||||
}
|
||||
|
||||
public void channelActive(ChannelHandlerContext p_channelActive_1_) throws Exception
|
||||
{
|
||||
super.channelActive(p_channelActive_1_);
|
||||
this.channel = p_channelActive_1_.channel();
|
||||
this.socketAddress = this.channel.remoteAddress();
|
||||
this.address = this.channel.remoteAddress();
|
||||
|
||||
try
|
||||
{
|
||||
this.setConnectionState(EnumConnectionState.HANDSHAKING);
|
||||
this.setConnectionState(Protocol.HANDSHAKE);
|
||||
}
|
||||
catch (Throwable throwable)
|
||||
{
|
||||
|
@ -83,7 +84,7 @@ public class NetworkManager extends SimpleChannelInboundHandler<Packet>
|
|||
/**
|
||||
* Sets the new connection state and registers which packets this channel may send and receive
|
||||
*/
|
||||
public void setConnectionState(EnumConnectionState newState)
|
||||
public void setConnectionState(Protocol newState)
|
||||
{
|
||||
this.channel.attr(STATE).set(newState);
|
||||
this.channel.config().setAutoRead(true);
|
||||
|
@ -117,7 +118,7 @@ public class NetworkManager extends SimpleChannelInboundHandler<Packet>
|
|||
{
|
||||
try
|
||||
{
|
||||
p_channelRead0_2_.processPacket(this.packetListener);
|
||||
p_channelRead0_2_.processPacket(this.handler);
|
||||
}
|
||||
catch (ThreadQuickExitException var4)
|
||||
{
|
||||
|
@ -130,12 +131,12 @@ public class NetworkManager extends SimpleChannelInboundHandler<Packet>
|
|||
* Sets the NetHandler for this NetworkManager, no checks are made if this handler is suitable for the particular
|
||||
* connection state (protocol)
|
||||
*/
|
||||
public void setNetHandler(INetHandler handler)
|
||||
public void setNetHandler(Handler handler)
|
||||
{
|
||||
if(handler == null)
|
||||
throw new IllegalArgumentException("handler may not be null");
|
||||
Log.debug("Set listener of %s to %s", this, handler);
|
||||
this.packetListener = handler;
|
||||
this.handler = handler;
|
||||
}
|
||||
|
||||
public void sendPacket(Packet packetIn)
|
||||
|
@ -151,7 +152,7 @@ public class NetworkManager extends SimpleChannelInboundHandler<Packet>
|
|||
|
||||
try
|
||||
{
|
||||
this.outboundPacketsQueue.add(new NetworkManager.InboundHandlerTuplePacketListener(packetIn, (GenericFutureListener[])null));
|
||||
this.outboundPacketsQueue.add(new Connection.InboundHandlerTuplePacketListener(packetIn, (GenericFutureListener[])null));
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
@ -173,7 +174,7 @@ public class NetworkManager extends SimpleChannelInboundHandler<Packet>
|
|||
|
||||
try
|
||||
{
|
||||
this.outboundPacketsQueue.add(new NetworkManager.InboundHandlerTuplePacketListener(packetIn, new GenericFutureListener[] {listener}));
|
||||
this.outboundPacketsQueue.add(new Connection.InboundHandlerTuplePacketListener(packetIn, new GenericFutureListener[] {listener}));
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
@ -188,8 +189,8 @@ public class NetworkManager extends SimpleChannelInboundHandler<Packet>
|
|||
*/
|
||||
private void dispatchPacket(final Packet inPacket, final GenericFutureListener <? extends Future <? super Void >> [] futureListeners)
|
||||
{
|
||||
final EnumConnectionState enumconnectionstate = EnumConnectionState.getFromPacket(inPacket);
|
||||
final EnumConnectionState enumconnectionstate1 = (EnumConnectionState)this.channel.attr(STATE).get();
|
||||
final Protocol enumconnectionstate = Protocol.getFromPacket(inPacket);
|
||||
final Protocol enumconnectionstate1 = (Protocol)this.channel.attr(STATE).get();
|
||||
|
||||
if (enumconnectionstate1 != enumconnectionstate)
|
||||
{
|
||||
|
@ -221,10 +222,10 @@ public class NetworkManager extends SimpleChannelInboundHandler<Packet>
|
|||
{
|
||||
if (enumconnectionstate != enumconnectionstate1)
|
||||
{
|
||||
NetworkManager.this.setConnectionState(enumconnectionstate);
|
||||
Connection.this.setConnectionState(enumconnectionstate);
|
||||
}
|
||||
|
||||
ChannelFuture channelfuture1 = NetworkManager.this.channel.writeAndFlush(inPacket);
|
||||
ChannelFuture channelfuture1 = Connection.this.channel.writeAndFlush(inPacket);
|
||||
|
||||
if (futureListeners != null)
|
||||
{
|
||||
|
@ -250,7 +251,7 @@ public class NetworkManager extends SimpleChannelInboundHandler<Packet>
|
|||
{
|
||||
while (!this.outboundPacketsQueue.isEmpty())
|
||||
{
|
||||
NetworkManager.InboundHandlerTuplePacketListener networkmanager$inboundhandlertuplepacketlistener = (NetworkManager.InboundHandlerTuplePacketListener)this.outboundPacketsQueue.poll();
|
||||
Connection.InboundHandlerTuplePacketListener networkmanager$inboundhandlertuplepacketlistener = (Connection.InboundHandlerTuplePacketListener)this.outboundPacketsQueue.poll();
|
||||
this.dispatchPacket(networkmanager$inboundhandlertuplepacketlistener.packet, networkmanager$inboundhandlertuplepacketlistener.futureListeners);
|
||||
}
|
||||
}
|
||||
|
@ -267,8 +268,8 @@ public class NetworkManager extends SimpleChannelInboundHandler<Packet>
|
|||
public void processReceivedPackets()
|
||||
{
|
||||
this.flushOutboundQueue();
|
||||
if(this.packetListener != null)
|
||||
this.packetListener.update(this);
|
||||
if(this.handler != null)
|
||||
this.handler.update(this);
|
||||
this.channel.flush();
|
||||
}
|
||||
|
||||
|
@ -277,7 +278,7 @@ public class NetworkManager extends SimpleChannelInboundHandler<Packet>
|
|||
*/
|
||||
public SocketAddress getRemoteAddress()
|
||||
{
|
||||
return this.socketAddress;
|
||||
return this.address;
|
||||
}
|
||||
|
||||
public void closeChannel(String message)
|
||||
|
@ -285,7 +286,7 @@ public class NetworkManager extends SimpleChannelInboundHandler<Packet>
|
|||
if (this.channel.isOpen())
|
||||
{
|
||||
this.channel.close().awaitUninterruptibly();
|
||||
this.terminationReason = message;
|
||||
this.exitMessage = message;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -296,9 +297,9 @@ public class NetworkManager extends SimpleChannelInboundHandler<Packet>
|
|||
* @param serverPort The server port
|
||||
* @param useNativeTransport True if the client use the native transport system
|
||||
*/
|
||||
public static NetworkManager createNetworkManagerAndConnect(InetAddress address, int serverPort, boolean useNativeTransport)
|
||||
public static Connection createNetworkManagerAndConnect(InetAddress address, int serverPort, boolean useNativeTransport)
|
||||
{
|
||||
final NetworkManager networkmanager = new NetworkManager(EnumPacketDirection.CLIENTBOUND);
|
||||
final Connection networkmanager = new Connection(PacketDirection.CLIENT);
|
||||
Class <? extends SocketChannel > oclass;
|
||||
LazyLoader <? extends EventLoopGroup > lazyloadbase;
|
||||
|
||||
|
@ -326,7 +327,7 @@ public class NetworkManager extends SimpleChannelInboundHandler<Packet>
|
|||
;
|
||||
}
|
||||
|
||||
p_initChannel_1_.pipeline().addLast((String)"timeout", (ChannelHandler)(new ReadTimeoutHandler(30))).addLast((String)"splitter", (ChannelHandler)(new MessageDeserializer2())).addLast((String)"decoder", (ChannelHandler)(new MessageDeserializer(EnumPacketDirection.CLIENTBOUND))).addLast((String)"prepender", (ChannelHandler)(new MessageSerializer2())).addLast((String)"encoder", (ChannelHandler)(new MessageSerializer(EnumPacketDirection.SERVERBOUND))).addLast((String)"packet_handler", (ChannelHandler)networkmanager);
|
||||
p_initChannel_1_.pipeline().addLast((String)"timeout", (ChannelHandler)(new ReadTimeoutHandler(30))).addLast((String)"splitter", (ChannelHandler)(new PacketSplitter())).addLast((String)"decoder", (ChannelHandler)(new PacketDecoder(PacketDirection.CLIENT))).addLast((String)"prepender", (ChannelHandler)(new PacketPrepender())).addLast((String)"encoder", (ChannelHandler)(new PacketEncoder(PacketDirection.SERVER))).addLast((String)"packet_handler", (ChannelHandler)networkmanager);
|
||||
}
|
||||
})).channel(oclass)).connect(address, serverPort).syncUninterruptibly();
|
||||
return networkmanager;
|
||||
|
@ -345,9 +346,9 @@ public class NetworkManager extends SimpleChannelInboundHandler<Packet>
|
|||
/**
|
||||
* Gets the current handler for processing packets
|
||||
*/
|
||||
public INetHandler getNetHandler()
|
||||
public Handler getNetHandler()
|
||||
{
|
||||
return this.packetListener;
|
||||
return this.handler;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -355,7 +356,7 @@ public class NetworkManager extends SimpleChannelInboundHandler<Packet>
|
|||
*/
|
||||
public String getExitMessage()
|
||||
{
|
||||
return this.terminationReason;
|
||||
return this.exitMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -370,32 +371,32 @@ public class NetworkManager extends SimpleChannelInboundHandler<Packet>
|
|||
{
|
||||
if (treshold >= 0)
|
||||
{
|
||||
if (this.channel.pipeline().get("decompress") instanceof NettyCompressionDecoder)
|
||||
if (this.channel.pipeline().get("decompress") instanceof CompressingDecoder)
|
||||
{
|
||||
((NettyCompressionDecoder)this.channel.pipeline().get("decompress")).setCompressionTreshold(treshold);
|
||||
((CompressingDecoder)this.channel.pipeline().get("decompress")).setCompressionTreshold(treshold);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.channel.pipeline().addBefore("decoder", "decompress", new NettyCompressionDecoder(treshold));
|
||||
this.channel.pipeline().addBefore("decoder", "decompress", new CompressingDecoder(treshold));
|
||||
}
|
||||
|
||||
if (this.channel.pipeline().get("compress") instanceof NettyCompressionEncoder)
|
||||
if (this.channel.pipeline().get("compress") instanceof CompressingEncoder)
|
||||
{
|
||||
((NettyCompressionEncoder)this.channel.pipeline().get("decompress")).setCompressionTreshold(treshold);
|
||||
((CompressingEncoder)this.channel.pipeline().get("decompress")).setCompressionTreshold(treshold);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.channel.pipeline().addBefore("encoder", "compress", new NettyCompressionEncoder(treshold));
|
||||
this.channel.pipeline().addBefore("encoder", "compress", new CompressingEncoder(treshold));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.channel.pipeline().get("decompress") instanceof NettyCompressionDecoder)
|
||||
if (this.channel.pipeline().get("decompress") instanceof CompressingDecoder)
|
||||
{
|
||||
this.channel.pipeline().remove("decompress");
|
||||
}
|
||||
|
||||
if (this.channel.pipeline().get("compress") instanceof NettyCompressionEncoder)
|
||||
if (this.channel.pipeline().get("compress") instanceof CompressingEncoder)
|
||||
{
|
||||
this.channel.pipeline().remove("compress");
|
||||
}
|
|
@ -1,347 +0,0 @@
|
|||
package proxy.network;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.HashBiMap;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import proxy.packet.handshake.client.C00Handshake;
|
||||
import proxy.packet.login.client.C00PacketLoginStart;
|
||||
import proxy.packet.login.client.C01PacketEncryptionResponse;
|
||||
import proxy.packet.login.server.S00PacketDisconnect;
|
||||
import proxy.packet.login.server.S01PacketEncryptionRequest;
|
||||
import proxy.packet.login.server.S02PacketLoginSuccess;
|
||||
import proxy.packet.login.server.S03PacketEnableCompression;
|
||||
import proxy.packet.play.client.C00PacketKeepAlive;
|
||||
import proxy.packet.play.client.C01PacketChatMessage;
|
||||
import proxy.packet.play.client.C02PacketUseEntity;
|
||||
import proxy.packet.play.client.C03PacketPlayer;
|
||||
import proxy.packet.play.client.C07PacketPlayerDigging;
|
||||
import proxy.packet.play.client.C08PacketPlayerBlockPlacement;
|
||||
import proxy.packet.play.client.C09PacketHeldItemChange;
|
||||
import proxy.packet.play.client.C0APacketAnimation;
|
||||
import proxy.packet.play.client.C0BPacketEntityAction;
|
||||
import proxy.packet.play.client.C0CPacketInput;
|
||||
import proxy.packet.play.client.C0DPacketCloseWindow;
|
||||
import proxy.packet.play.client.C0EPacketClickWindow;
|
||||
import proxy.packet.play.client.C0FPacketConfirmTransaction;
|
||||
import proxy.packet.play.client.C10PacketCreativeInventoryAction;
|
||||
import proxy.packet.play.client.C11PacketEnchantItem;
|
||||
import proxy.packet.play.client.C12PacketUpdateSign;
|
||||
import proxy.packet.play.client.C13PacketPlayerAbilities;
|
||||
import proxy.packet.play.client.C14PacketTabComplete;
|
||||
import proxy.packet.play.client.C15PacketClientSettings;
|
||||
import proxy.packet.play.client.C16PacketClientStatus;
|
||||
import proxy.packet.play.client.C17PacketCustomPayload;
|
||||
import proxy.packet.play.client.C18PacketSpectate;
|
||||
import proxy.packet.play.client.C19PacketResourcePackStatus;
|
||||
import proxy.packet.play.server.S00PacketKeepAlive;
|
||||
import proxy.packet.play.server.S01PacketJoinGame;
|
||||
import proxy.packet.play.server.S02PacketChat;
|
||||
import proxy.packet.play.server.S03PacketTimeUpdate;
|
||||
import proxy.packet.play.server.S04PacketEntityEquipment;
|
||||
import proxy.packet.play.server.S05PacketSpawnPosition;
|
||||
import proxy.packet.play.server.S06PacketUpdateHealth;
|
||||
import proxy.packet.play.server.S07PacketRespawn;
|
||||
import proxy.packet.play.server.S08PacketPlayerPosLook;
|
||||
import proxy.packet.play.server.S09PacketHeldItemChange;
|
||||
import proxy.packet.play.server.S0APacketUseBed;
|
||||
import proxy.packet.play.server.S0BPacketAnimation;
|
||||
import proxy.packet.play.server.S0CPacketSpawnPlayer;
|
||||
import proxy.packet.play.server.S0DPacketCollectItem;
|
||||
import proxy.packet.play.server.S0EPacketSpawnObject;
|
||||
import proxy.packet.play.server.S0FPacketSpawnMob;
|
||||
import proxy.packet.play.server.S10PacketSpawnPainting;
|
||||
import proxy.packet.play.server.S11PacketSpawnExperienceOrb;
|
||||
import proxy.packet.play.server.S12PacketEntityVelocity;
|
||||
import proxy.packet.play.server.S13PacketDestroyEntities;
|
||||
import proxy.packet.play.server.S14PacketEntity;
|
||||
import proxy.packet.play.server.S18PacketEntityTeleport;
|
||||
import proxy.packet.play.server.S19PacketEntityHeadLook;
|
||||
import proxy.packet.play.server.S19PacketEntityStatus;
|
||||
import proxy.packet.play.server.S1BPacketEntityAttach;
|
||||
import proxy.packet.play.server.S1CPacketEntityMetadata;
|
||||
import proxy.packet.play.server.S1DPacketEntityEffect;
|
||||
import proxy.packet.play.server.S1EPacketRemoveEntityEffect;
|
||||
import proxy.packet.play.server.S1FPacketSetExperience;
|
||||
import proxy.packet.play.server.S20PacketEntityProperties;
|
||||
import proxy.packet.play.server.S21PacketChunkData;
|
||||
import proxy.packet.play.server.S22PacketMultiBlockChange;
|
||||
import proxy.packet.play.server.S23PacketBlockChange;
|
||||
import proxy.packet.play.server.S24PacketBlockAction;
|
||||
import proxy.packet.play.server.S25PacketBlockBreakAnim;
|
||||
import proxy.packet.play.server.S26PacketMapChunkBulk;
|
||||
import proxy.packet.play.server.S27PacketExplosion;
|
||||
import proxy.packet.play.server.S28PacketEffect;
|
||||
import proxy.packet.play.server.S29PacketSoundEffect;
|
||||
import proxy.packet.play.server.S2APacketParticles;
|
||||
import proxy.packet.play.server.S2BPacketChangeGameState;
|
||||
import proxy.packet.play.server.S2CPacketSpawnGlobalEntity;
|
||||
import proxy.packet.play.server.S2DPacketOpenWindow;
|
||||
import proxy.packet.play.server.S2EPacketCloseWindow;
|
||||
import proxy.packet.play.server.S2FPacketSetSlot;
|
||||
import proxy.packet.play.server.S30PacketWindowItems;
|
||||
import proxy.packet.play.server.S31PacketWindowProperty;
|
||||
import proxy.packet.play.server.S32PacketConfirmTransaction;
|
||||
import proxy.packet.play.server.S33PacketUpdateSign;
|
||||
import proxy.packet.play.server.S34PacketMaps;
|
||||
import proxy.packet.play.server.S35PacketUpdateTileEntity;
|
||||
import proxy.packet.play.server.S36PacketSignEditorOpen;
|
||||
import proxy.packet.play.server.S37PacketStatistics;
|
||||
import proxy.packet.play.server.S38PacketPlayerListItem;
|
||||
import proxy.packet.play.server.S39PacketPlayerAbilities;
|
||||
import proxy.packet.play.server.S3APacketTabComplete;
|
||||
import proxy.packet.play.server.S3BPacketScoreboardObjective;
|
||||
import proxy.packet.play.server.S3CPacketUpdateScore;
|
||||
import proxy.packet.play.server.S3DPacketDisplayScoreboard;
|
||||
import proxy.packet.play.server.S3EPacketTeams;
|
||||
import proxy.packet.play.server.S3FPacketCustomPayload;
|
||||
import proxy.packet.play.server.S40PacketDisconnect;
|
||||
import proxy.packet.play.server.S41PacketServerDifficulty;
|
||||
import proxy.packet.play.server.S42PacketCombatEvent;
|
||||
import proxy.packet.play.server.S43PacketCamera;
|
||||
import proxy.packet.play.server.S44PacketWorldBorder;
|
||||
import proxy.packet.play.server.S45PacketTitle;
|
||||
import proxy.packet.play.server.S46PacketSetCompressionLevel;
|
||||
import proxy.packet.play.server.S47PacketPlayerListHeaderFooter;
|
||||
import proxy.packet.play.server.S48PacketResourcePackSend;
|
||||
import proxy.packet.play.server.S49PacketUpdateEntityNBT;
|
||||
import proxy.packet.status.client.C00PacketServerQuery;
|
||||
import proxy.packet.status.client.C01PacketPing;
|
||||
import proxy.packet.status.server.S00PacketServerInfo;
|
||||
import proxy.packet.status.server.S01PacketPong;
|
||||
import proxy.util.Log;
|
||||
|
||||
public enum EnumConnectionState
|
||||
{
|
||||
HANDSHAKING(-1)
|
||||
{
|
||||
{
|
||||
this.registerPacket(EnumPacketDirection.SERVERBOUND, C00Handshake.class);
|
||||
}
|
||||
},
|
||||
PLAY(0)
|
||||
{
|
||||
{
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, S00PacketKeepAlive.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, S01PacketJoinGame.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, S02PacketChat.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, S03PacketTimeUpdate.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, S04PacketEntityEquipment.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, S05PacketSpawnPosition.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, S06PacketUpdateHealth.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, S07PacketRespawn.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, S08PacketPlayerPosLook.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, S09PacketHeldItemChange.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, S0APacketUseBed.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, S0BPacketAnimation.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, S0CPacketSpawnPlayer.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, S0DPacketCollectItem.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, S0EPacketSpawnObject.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, S0FPacketSpawnMob.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, S10PacketSpawnPainting.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, S11PacketSpawnExperienceOrb.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, S12PacketEntityVelocity.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, S13PacketDestroyEntities.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, S14PacketEntity.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, S14PacketEntity.S15PacketEntityRelMove.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, S14PacketEntity.S16PacketEntityLook.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, S14PacketEntity.S17PacketEntityLookMove.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, S18PacketEntityTeleport.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, S19PacketEntityHeadLook.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, S19PacketEntityStatus.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, S1BPacketEntityAttach.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, S1CPacketEntityMetadata.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, S1DPacketEntityEffect.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, S1EPacketRemoveEntityEffect.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, S1FPacketSetExperience.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, S20PacketEntityProperties.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, S21PacketChunkData.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, S22PacketMultiBlockChange.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, S23PacketBlockChange.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, S24PacketBlockAction.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, S25PacketBlockBreakAnim.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, S26PacketMapChunkBulk.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, S27PacketExplosion.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, S28PacketEffect.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, S29PacketSoundEffect.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, S2APacketParticles.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, S2BPacketChangeGameState.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, S2CPacketSpawnGlobalEntity.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, S2DPacketOpenWindow.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, S2EPacketCloseWindow.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, S2FPacketSetSlot.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, S30PacketWindowItems.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, S31PacketWindowProperty.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, S32PacketConfirmTransaction.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, S33PacketUpdateSign.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, S34PacketMaps.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, S35PacketUpdateTileEntity.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, S36PacketSignEditorOpen.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, S37PacketStatistics.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, S38PacketPlayerListItem.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, S39PacketPlayerAbilities.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, S3APacketTabComplete.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, S3BPacketScoreboardObjective.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, S3CPacketUpdateScore.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, S3DPacketDisplayScoreboard.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, S3EPacketTeams.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, S3FPacketCustomPayload.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, S40PacketDisconnect.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, S41PacketServerDifficulty.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, S42PacketCombatEvent.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, S43PacketCamera.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, S44PacketWorldBorder.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, S45PacketTitle.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, S46PacketSetCompressionLevel.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, S47PacketPlayerListHeaderFooter.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, S48PacketResourcePackSend.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, S49PacketUpdateEntityNBT.class);
|
||||
this.registerPacket(EnumPacketDirection.SERVERBOUND, C00PacketKeepAlive.class);
|
||||
this.registerPacket(EnumPacketDirection.SERVERBOUND, C01PacketChatMessage.class);
|
||||
this.registerPacket(EnumPacketDirection.SERVERBOUND, C02PacketUseEntity.class);
|
||||
this.registerPacket(EnumPacketDirection.SERVERBOUND, C03PacketPlayer.class);
|
||||
this.registerPacket(EnumPacketDirection.SERVERBOUND, C03PacketPlayer.C04PacketPlayerPosition.class);
|
||||
this.registerPacket(EnumPacketDirection.SERVERBOUND, C03PacketPlayer.C05PacketPlayerLook.class);
|
||||
this.registerPacket(EnumPacketDirection.SERVERBOUND, C03PacketPlayer.C06PacketPlayerPosLook.class);
|
||||
this.registerPacket(EnumPacketDirection.SERVERBOUND, C07PacketPlayerDigging.class);
|
||||
this.registerPacket(EnumPacketDirection.SERVERBOUND, C08PacketPlayerBlockPlacement.class);
|
||||
this.registerPacket(EnumPacketDirection.SERVERBOUND, C09PacketHeldItemChange.class);
|
||||
this.registerPacket(EnumPacketDirection.SERVERBOUND, C0APacketAnimation.class);
|
||||
this.registerPacket(EnumPacketDirection.SERVERBOUND, C0BPacketEntityAction.class);
|
||||
this.registerPacket(EnumPacketDirection.SERVERBOUND, C0CPacketInput.class);
|
||||
this.registerPacket(EnumPacketDirection.SERVERBOUND, C0DPacketCloseWindow.class);
|
||||
this.registerPacket(EnumPacketDirection.SERVERBOUND, C0EPacketClickWindow.class);
|
||||
this.registerPacket(EnumPacketDirection.SERVERBOUND, C0FPacketConfirmTransaction.class);
|
||||
this.registerPacket(EnumPacketDirection.SERVERBOUND, C10PacketCreativeInventoryAction.class);
|
||||
this.registerPacket(EnumPacketDirection.SERVERBOUND, C11PacketEnchantItem.class);
|
||||
this.registerPacket(EnumPacketDirection.SERVERBOUND, C12PacketUpdateSign.class);
|
||||
this.registerPacket(EnumPacketDirection.SERVERBOUND, C13PacketPlayerAbilities.class);
|
||||
this.registerPacket(EnumPacketDirection.SERVERBOUND, C14PacketTabComplete.class);
|
||||
this.registerPacket(EnumPacketDirection.SERVERBOUND, C15PacketClientSettings.class);
|
||||
this.registerPacket(EnumPacketDirection.SERVERBOUND, C16PacketClientStatus.class);
|
||||
this.registerPacket(EnumPacketDirection.SERVERBOUND, C17PacketCustomPayload.class);
|
||||
this.registerPacket(EnumPacketDirection.SERVERBOUND, C18PacketSpectate.class);
|
||||
this.registerPacket(EnumPacketDirection.SERVERBOUND, C19PacketResourcePackStatus.class);
|
||||
}
|
||||
},
|
||||
STATUS(1)
|
||||
{
|
||||
{
|
||||
this.registerPacket(EnumPacketDirection.SERVERBOUND, C00PacketServerQuery.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, S00PacketServerInfo.class);
|
||||
this.registerPacket(EnumPacketDirection.SERVERBOUND, C01PacketPing.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, S01PacketPong.class);
|
||||
}
|
||||
},
|
||||
LOGIN(2)
|
||||
{
|
||||
{
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, S00PacketDisconnect.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, S01PacketEncryptionRequest.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, S02PacketLoginSuccess.class);
|
||||
this.registerPacket(EnumPacketDirection.CLIENTBOUND, S03PacketEnableCompression.class);
|
||||
this.registerPacket(EnumPacketDirection.SERVERBOUND, C00PacketLoginStart.class);
|
||||
this.registerPacket(EnumPacketDirection.SERVERBOUND, C01PacketEncryptionResponse.class);
|
||||
}
|
||||
};
|
||||
|
||||
private static int field_181136_e = -1;
|
||||
private static int field_181137_f = 2;
|
||||
private static final EnumConnectionState[] STATES_BY_ID = new EnumConnectionState[field_181137_f - field_181136_e + 1];
|
||||
private static final Map < Class <? extends Packet > , EnumConnectionState > STATES_BY_CLASS = Maps. < Class <? extends Packet > , EnumConnectionState > newHashMap();
|
||||
private final int id;
|
||||
private final Map < EnumPacketDirection, BiMap < Integer, Class <? extends Packet >>> directionMaps;
|
||||
|
||||
private EnumConnectionState(int protocolId)
|
||||
{
|
||||
this.directionMaps = Maps.newEnumMap(EnumPacketDirection.class);
|
||||
this.id = protocolId;
|
||||
}
|
||||
|
||||
protected EnumConnectionState registerPacket(EnumPacketDirection direction, Class <? extends Packet > packetClass)
|
||||
{
|
||||
BiMap < Integer, Class <? extends Packet >> bimap = (BiMap)this.directionMaps.get(direction);
|
||||
|
||||
if (bimap == null)
|
||||
{
|
||||
bimap = HashBiMap. < Integer, Class <? extends Packet >> create();
|
||||
this.directionMaps.put(direction, bimap);
|
||||
}
|
||||
|
||||
if (bimap.containsValue(packetClass))
|
||||
{
|
||||
String s = direction + " packet " + packetClass + " is already known to ID " + bimap.inverse().get(packetClass);
|
||||
Log.error(s);
|
||||
throw new IllegalArgumentException(s);
|
||||
}
|
||||
else
|
||||
{
|
||||
bimap.put(Integer.valueOf(bimap.size()), packetClass);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public Integer getPacketId(EnumPacketDirection direction, Packet packetIn)
|
||||
{
|
||||
return (Integer)((BiMap)this.directionMaps.get(direction)).inverse().get(packetIn.getClass());
|
||||
}
|
||||
|
||||
public Packet getPacket(EnumPacketDirection direction, int packetId) throws InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchMethodException {
|
||||
Class <? extends Packet > oclass = (Class)((BiMap)this.directionMaps.get(direction)).get(Integer.valueOf(packetId));
|
||||
return oclass == null ? null : (Packet)oclass.getConstructor().newInstance();
|
||||
}
|
||||
|
||||
public int getId()
|
||||
{
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public static EnumConnectionState getById(int stateId)
|
||||
{
|
||||
return stateId >= field_181136_e && stateId <= field_181137_f ? STATES_BY_ID[stateId - field_181136_e] : null;
|
||||
}
|
||||
|
||||
public static EnumConnectionState getFromPacket(Packet packetIn)
|
||||
{
|
||||
return (EnumConnectionState)STATES_BY_CLASS.get(packetIn.getClass());
|
||||
}
|
||||
|
||||
static {
|
||||
for (EnumConnectionState enumconnectionstate : values())
|
||||
{
|
||||
int i = enumconnectionstate.getId();
|
||||
|
||||
if (i < field_181136_e || i > field_181137_f)
|
||||
{
|
||||
throw new Error("Invalid protocol ID " + Integer.toString(i));
|
||||
}
|
||||
|
||||
STATES_BY_ID[i - field_181136_e] = enumconnectionstate;
|
||||
|
||||
for (EnumPacketDirection enumpacketdirection : enumconnectionstate.directionMaps.keySet())
|
||||
{
|
||||
for (Class <? extends Packet > oclass : (enumconnectionstate.directionMaps.get(enumpacketdirection)).values())
|
||||
{
|
||||
if (STATES_BY_CLASS.containsKey(oclass) && STATES_BY_CLASS.get(oclass) != enumconnectionstate)
|
||||
{
|
||||
throw new Error("Packet " + oclass + " is already assigned to protocol " + STATES_BY_CLASS.get(oclass) + " - can\'t reassign to " + enumconnectionstate);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
oclass.getConstructor().newInstance();
|
||||
}
|
||||
catch (Throwable var10)
|
||||
{
|
||||
throw new Error("Packet " + oclass + " fails instantiation checks! " + oclass);
|
||||
}
|
||||
|
||||
STATES_BY_CLASS.put(oclass, enumconnectionstate);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
package proxy.network;
|
||||
|
||||
public enum EnumPacketDirection {
|
||||
SERVERBOUND, CLIENTBOUND;
|
||||
}
|
33
proxy/src/main/java/proxy/network/Handler.java
Executable file
33
proxy/src/main/java/proxy/network/Handler.java
Executable file
|
@ -0,0 +1,33 @@
|
|||
package proxy.network;
|
||||
|
||||
import proxy.Proxy;
|
||||
|
||||
public interface Handler {
|
||||
public static final class ThreadQuickExitException extends RuntimeException {
|
||||
public static final ThreadQuickExitException INSTANCE = new ThreadQuickExitException();
|
||||
|
||||
private ThreadQuickExitException() {
|
||||
this.setStackTrace(new StackTraceElement[0]);
|
||||
}
|
||||
|
||||
public synchronized Throwable fillInStackTrace() {
|
||||
this.setStackTrace(new StackTraceElement[0]);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
static <T extends Handler> void syncToMain(final Packet<T> packet, final T handler, Proxy proxy) throws ThreadQuickExitException {
|
||||
if(!proxy.isMainThread()) {
|
||||
proxy.schedule(new Runnable() {
|
||||
public void run() {
|
||||
packet.processPacket(handler);
|
||||
}
|
||||
});
|
||||
throw ThreadQuickExitException.INSTANCE;
|
||||
}
|
||||
}
|
||||
|
||||
void onDisconnect(Connection connection, String reason);
|
||||
default void update(Connection connection) {
|
||||
}
|
||||
}
|
49
proxy/src/main/java/proxy/network/HandshakeHandler.java
Executable file
49
proxy/src/main/java/proxy/network/HandshakeHandler.java
Executable file
|
@ -0,0 +1,49 @@
|
|||
package proxy.network;
|
||||
|
||||
import proxy.Proxy;
|
||||
import proxy.packet.H00PacketHandshake;
|
||||
import proxy.packet.R00PacketDisconnect;
|
||||
|
||||
public class HandshakeHandler implements Handler {
|
||||
private final Proxy proxy;
|
||||
private final Connection connection;
|
||||
|
||||
public HandshakeHandler(Proxy proxy, Connection connection) {
|
||||
this.proxy = proxy;
|
||||
this.connection = connection;
|
||||
}
|
||||
|
||||
public void processHandshake(H00PacketHandshake packet) {
|
||||
switch(packet.getRequestedState()) {
|
||||
case LOGIN:
|
||||
this.connection.setConnectionState(Protocol.LOGIN);
|
||||
|
||||
if(packet.getProtocolVersion() > 47) {
|
||||
String text = "Outdated server! I\'m still on 1.8.9";
|
||||
this.connection.sendPacket(new R00PacketDisconnect(text));
|
||||
this.connection.closeChannel(text);
|
||||
}
|
||||
else if(packet.getProtocolVersion() < 47) {
|
||||
String text = "Outdated client! Please use 1.8.9";
|
||||
this.connection.sendPacket(new R00PacketDisconnect(text));
|
||||
this.connection.closeChannel(text);
|
||||
}
|
||||
else {
|
||||
this.connection.setNetHandler(new LoginHandler(this.proxy, this.connection));
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case STATUS:
|
||||
this.connection.setConnectionState(Protocol.STATUS);
|
||||
this.connection.setNetHandler(new StatusHandler(this.proxy, this.connection));
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new UnsupportedOperationException("Invalid intention " + packet.getRequestedState());
|
||||
}
|
||||
}
|
||||
|
||||
public void onDisconnect(Connection connection, String reason) {
|
||||
}
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
package proxy.network;
|
||||
|
||||
public interface INetHandler {
|
||||
void onDisconnect(NetworkManager connection, String reason);
|
||||
default void update(NetworkManager connection) {
|
||||
}
|
||||
}
|
|
@ -3,20 +3,20 @@ package proxy.network;
|
|||
import io.netty.channel.ChannelFuture;
|
||||
import io.netty.channel.ChannelFutureListener;
|
||||
import proxy.Proxy;
|
||||
import proxy.packet.login.client.C00PacketLoginStart;
|
||||
import proxy.packet.login.client.C01PacketEncryptionResponse;
|
||||
import proxy.packet.login.server.S00PacketDisconnect;
|
||||
import proxy.packet.login.server.S02PacketLoginSuccess;
|
||||
import proxy.packet.login.server.S03PacketEnableCompression;
|
||||
import proxy.packet.L00PacketLoginStart;
|
||||
import proxy.packet.L01PacketEncryptionResponse;
|
||||
import proxy.packet.R00PacketDisconnect;
|
||||
import proxy.packet.R02PacketLoginSuccess;
|
||||
import proxy.packet.R03PacketEnableCompression;
|
||||
import proxy.util.Log;
|
||||
|
||||
public class NetHandlerLoginServer implements INetHandler {
|
||||
public class LoginHandler implements Handler {
|
||||
private static enum LoginState {
|
||||
INIT, WAITING, DONE;
|
||||
}
|
||||
|
||||
private final Proxy proxy;
|
||||
private final NetworkManager connection;
|
||||
private final Connection connection;
|
||||
|
||||
private LoginState state = LoginState.INIT;
|
||||
private int timer;
|
||||
|
@ -31,12 +31,12 @@ public class NetHandlerLoginServer implements INetHandler {
|
|||
return true;
|
||||
}
|
||||
|
||||
public NetHandlerLoginServer(Proxy proxy, NetworkManager connection) {
|
||||
public LoginHandler(Proxy proxy, Connection connection) {
|
||||
this.proxy = proxy;
|
||||
this.connection = connection;
|
||||
}
|
||||
|
||||
public void update(NetworkManager connection) {
|
||||
public void update(Connection connection) {
|
||||
if(this.state == LoginState.WAITING) {
|
||||
this.tryAcceptPlayer();
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ public class NetHandlerLoginServer implements INetHandler {
|
|||
public void disconnect(String reason) {
|
||||
try {
|
||||
Log.info("Disconnecting " + this.getConnectionInfo() + ": " + reason);
|
||||
this.connection.sendPacket(new S00PacketDisconnect(reason));
|
||||
this.connection.sendPacket(new R00PacketDisconnect(reason));
|
||||
this.connection.closeChannel(reason);
|
||||
}
|
||||
catch(Exception e) {
|
||||
|
@ -65,20 +65,20 @@ public class NetHandlerLoginServer implements INetHandler {
|
|||
this.state = LoginState.DONE;
|
||||
|
||||
if(this.proxy.getCompression() >= 0) {
|
||||
this.connection.sendPacket(new S03PacketEnableCompression(this.proxy.getCompression()), new ChannelFutureListener() {
|
||||
this.connection.sendPacket(new R03PacketEnableCompression(this.proxy.getCompression()), new ChannelFutureListener() {
|
||||
public void operationComplete(ChannelFuture p_operationComplete_1_) throws Exception {
|
||||
NetHandlerLoginServer.this.connection.setCompressionTreshold(NetHandlerLoginServer.this.proxy.getCompression());
|
||||
LoginHandler.this.connection.setCompressionTreshold(LoginHandler.this.proxy.getCompression());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
NetHandlerPlayServer handler = new NetHandlerPlayServer(this.proxy, this.connection, this.username);
|
||||
ProxyHandler handler = new ProxyHandler(this.proxy, this.connection, this.username);
|
||||
this.connection.setNetHandler(handler);
|
||||
this.connection.sendPacket(new S02PacketLoginSuccess(Proxy.getOfflineUUID(this.username), this.username));
|
||||
this.connection.sendPacket(new R02PacketLoginSuccess(Proxy.getOfflineUUID(this.username), this.username));
|
||||
handler.setupPlayer();
|
||||
}
|
||||
|
||||
public void onDisconnect(NetworkManager connection, String reason) {
|
||||
public void onDisconnect(Connection connection, String reason) {
|
||||
Log.info(this.getConnectionInfo() + " lost connection: " + reason);
|
||||
}
|
||||
|
||||
|
@ -87,7 +87,7 @@ public class NetHandlerLoginServer implements INetHandler {
|
|||
: String.valueOf(this.connection.getRemoteAddress());
|
||||
}
|
||||
|
||||
public void processLoginStart(C00PacketLoginStart packet) {
|
||||
public void processLoginStart(L00PacketLoginStart packet) {
|
||||
if(this.state != LoginState.INIT)
|
||||
throw new IllegalStateException("Unexpected hello packet");
|
||||
this.username = packet.getProfile();
|
||||
|
@ -98,7 +98,7 @@ public class NetHandlerLoginServer implements INetHandler {
|
|||
this.state = LoginState.WAITING;
|
||||
}
|
||||
|
||||
public void processEncryptionResponse(C01PacketEncryptionResponse packet) {
|
||||
public void processEncryptionResponse(L01PacketEncryptionResponse packet) {
|
||||
throw new IllegalStateException("Unexpected key packet");
|
||||
}
|
||||
}
|
|
@ -1,49 +0,0 @@
|
|||
package proxy.network;
|
||||
|
||||
import proxy.Proxy;
|
||||
import proxy.packet.handshake.client.C00Handshake;
|
||||
import proxy.packet.login.server.S00PacketDisconnect;
|
||||
|
||||
public class NetHandlerHandshake implements INetHandler {
|
||||
private final Proxy proxy;
|
||||
private final NetworkManager connection;
|
||||
|
||||
public NetHandlerHandshake(Proxy proxy, NetworkManager connection) {
|
||||
this.proxy = proxy;
|
||||
this.connection = connection;
|
||||
}
|
||||
|
||||
public void processHandshake(C00Handshake packet) {
|
||||
switch(packet.getRequestedState()) {
|
||||
case LOGIN:
|
||||
this.connection.setConnectionState(EnumConnectionState.LOGIN);
|
||||
|
||||
if(packet.getProtocolVersion() > 47) {
|
||||
String text = "Outdated server! I\'m still on 1.8.9";
|
||||
this.connection.sendPacket(new S00PacketDisconnect(text));
|
||||
this.connection.closeChannel(text);
|
||||
}
|
||||
else if(packet.getProtocolVersion() < 47) {
|
||||
String text = "Outdated client! Please use 1.8.9";
|
||||
this.connection.sendPacket(new S00PacketDisconnect(text));
|
||||
this.connection.closeChannel(text);
|
||||
}
|
||||
else {
|
||||
this.connection.setNetHandler(new NetHandlerLoginServer(this.proxy, this.connection));
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case STATUS:
|
||||
this.connection.setConnectionState(EnumConnectionState.STATUS);
|
||||
this.connection.setNetHandler(new NetHandlerStatusServer(this.proxy, this.connection));
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new UnsupportedOperationException("Invalid intention " + packet.getRequestedState());
|
||||
}
|
||||
}
|
||||
|
||||
public void onDisconnect(NetworkManager connection, String reason) {
|
||||
}
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
package proxy.network;
|
||||
|
||||
import proxy.packet.status.server.S00PacketServerInfo;
|
||||
import proxy.packet.status.server.S01PacketPong;
|
||||
|
||||
public class NetHandlerStatusClient implements INetHandler {
|
||||
public void handleServerInfo(S00PacketServerInfo packetIn) {
|
||||
|
||||
}
|
||||
|
||||
public void handlePong(S01PacketPong packetIn) {
|
||||
|
||||
}
|
||||
|
||||
public void onDisconnect(NetworkManager connection, String reason) {
|
||||
|
||||
}
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
package proxy.network;
|
||||
|
||||
import proxy.Proxy;
|
||||
import proxy.packet.status.client.C00PacketServerQuery;
|
||||
import proxy.packet.status.client.C01PacketPing;
|
||||
import proxy.packet.status.server.S00PacketServerInfo;
|
||||
import proxy.packet.status.server.S01PacketPong;
|
||||
|
||||
public class NetHandlerStatusServer implements INetHandler {
|
||||
private static final String EXIT_MESSAGE = "Status request has been handled.";
|
||||
|
||||
private final Proxy proxy;
|
||||
private final NetworkManager networkManager;
|
||||
|
||||
private boolean handled;
|
||||
|
||||
public NetHandlerStatusServer(Proxy proxy, NetworkManager netManager) {
|
||||
this.proxy = proxy;
|
||||
this.networkManager = netManager;
|
||||
}
|
||||
|
||||
public void onDisconnect(NetworkManager connection, String reason) {
|
||||
}
|
||||
|
||||
public void processServerQuery(C00PacketServerQuery packetIn) {
|
||||
if(this.handled) {
|
||||
this.networkManager.closeChannel(EXIT_MESSAGE);
|
||||
}
|
||||
else {
|
||||
this.handled = true;
|
||||
this.networkManager.sendPacket(new S00PacketServerInfo(this.proxy.getStatus()));
|
||||
}
|
||||
}
|
||||
|
||||
public void processPing(C01PacketPing packetIn) {
|
||||
this.networkManager.sendPacket(new S01PacketPong(packetIn.getClientTime()));
|
||||
this.networkManager.closeChannel(EXIT_MESSAGE);
|
||||
}
|
||||
}
|
|
@ -2,7 +2,7 @@ package proxy.network;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
public interface Packet<T extends INetHandler> {
|
||||
public interface Packet<T extends Handler> {
|
||||
void readPacketData(PacketBuffer buf) throws IOException;
|
||||
void writePacketData(PacketBuffer buf) throws IOException;
|
||||
void processPacket(T handler);
|
||||
|
|
|
@ -8,8 +8,6 @@ import io.netty.buffer.ByteBufProcessor;
|
|||
import io.netty.handler.codec.DecoderException;
|
||||
import io.netty.handler.codec.EncoderException;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
@ -20,8 +18,7 @@ import java.nio.channels.ScatteringByteChannel;
|
|||
import java.nio.charset.Charset;
|
||||
import java.util.UUID;
|
||||
|
||||
import proxy.nbt.NBTSizeTracker;
|
||||
import proxy.nbt.NBTTagCompound;
|
||||
import proxy.nbt.NbtCompound;
|
||||
import proxy.util.Vec3;
|
||||
import proxy.util.Stack;
|
||||
|
||||
|
@ -73,7 +70,7 @@ public class PacketBuffer extends ByteBuf
|
|||
|
||||
public void writeVector(Vec3 pos)
|
||||
{
|
||||
this.writeLong(pos.getData());
|
||||
this.writeLong(pos.pack());
|
||||
}
|
||||
|
||||
public String readChatComponent() throws IOException
|
||||
|
@ -187,25 +184,10 @@ public class PacketBuffer extends ByteBuf
|
|||
this.writeByte((int)value);
|
||||
}
|
||||
|
||||
private static NBTTagCompound readTag(DataInput in) throws IOException {
|
||||
if(in.readByte() != 10)
|
||||
throw new IOException("Root tag must be a named compound tag");
|
||||
in.readUTF();
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
tag.read(in, 0, new NBTSizeTracker(2097152L));
|
||||
return tag;
|
||||
}
|
||||
|
||||
private static void writeTag(NBTTagCompound tag, DataOutput out) throws IOException {
|
||||
out.writeByte(tag.getId());
|
||||
out.writeUTF("");
|
||||
tag.write(out);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a compressed NBTTagCompound to this buffer
|
||||
*/
|
||||
public void writeNBTTagCompoundToBuffer(NBTTagCompound nbt)
|
||||
public void writeNBTTagCompoundToBuffer(NbtCompound nbt)
|
||||
{
|
||||
if (nbt == null)
|
||||
{
|
||||
|
@ -215,7 +197,7 @@ public class PacketBuffer extends ByteBuf
|
|||
{
|
||||
try
|
||||
{
|
||||
writeTag(nbt, new ByteBufOutputStream(this));
|
||||
NbtCompound.writeTag(nbt, new ByteBufOutputStream(this));
|
||||
}
|
||||
catch (IOException ioexception)
|
||||
{
|
||||
|
@ -227,7 +209,7 @@ public class PacketBuffer extends ByteBuf
|
|||
/**
|
||||
* Reads a compressed NBTTagCompound from this buffer
|
||||
*/
|
||||
public NBTTagCompound readNBTTagCompoundFromBuffer() throws IOException
|
||||
public NbtCompound readNBTTagCompoundFromBuffer() throws IOException
|
||||
{
|
||||
int i = this.readerIndex();
|
||||
byte b0 = this.readByte();
|
||||
|
@ -239,7 +221,7 @@ public class PacketBuffer extends ByteBuf
|
|||
else
|
||||
{
|
||||
this.readerIndex(i);
|
||||
return readTag(new ByteBufInputStream(this));
|
||||
return NbtCompound.readTag(new ByteBufInputStream(this));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,11 +6,11 @@ import io.netty.handler.codec.ByteToMessageDecoder;
|
|||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
public class MessageDeserializer extends ByteToMessageDecoder
|
||||
public class PacketDecoder extends ByteToMessageDecoder
|
||||
{
|
||||
private final EnumPacketDirection direction;
|
||||
private final PacketDirection direction;
|
||||
|
||||
public MessageDeserializer(EnumPacketDirection direction)
|
||||
public PacketDecoder(PacketDirection direction)
|
||||
{
|
||||
this.direction = direction;
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ public class MessageDeserializer extends ByteToMessageDecoder
|
|||
{
|
||||
PacketBuffer packetbuffer = new PacketBuffer(p_decode_2_);
|
||||
int i = packetbuffer.readVarIntFromBuffer();
|
||||
Packet packet = ((EnumConnectionState)p_decode_1_.channel().attr(NetworkManager.STATE).get()).getPacket(this.direction, i);
|
||||
Packet packet = ((Protocol)p_decode_1_.channel().attr(Connection.STATE).get()).getPacket(this.direction, i);
|
||||
|
||||
if (packet == null)
|
||||
{
|
||||
|
@ -33,7 +33,7 @@ public class MessageDeserializer extends ByteToMessageDecoder
|
|||
|
||||
if (packetbuffer.readableBytes() > 0)
|
||||
{
|
||||
throw new IOException("Packet " + ((EnumConnectionState)p_decode_1_.channel().attr(NetworkManager.STATE).get()).getId() + "/" + i + " (" + packet.getClass().getSimpleName() + ") was larger than I expected, found " + packetbuffer.readableBytes() + " bytes extra whilst reading packet " + i);
|
||||
throw new IOException("Packet " + ((Protocol)p_decode_1_.channel().attr(Connection.STATE).get()).getId() + "/" + i + " (" + packet.getClass().getSimpleName() + ") was larger than I expected, found " + packetbuffer.readableBytes() + " bytes extra whilst reading packet " + i);
|
||||
}
|
||||
else
|
||||
{
|
5
proxy/src/main/java/proxy/network/PacketDirection.java
Executable file
5
proxy/src/main/java/proxy/network/PacketDirection.java
Executable file
|
@ -0,0 +1,5 @@
|
|||
package proxy.network;
|
||||
|
||||
public enum PacketDirection {
|
||||
SERVER, CLIENT;
|
||||
}
|
|
@ -7,18 +7,18 @@ import proxy.util.Log;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
public class MessageSerializer extends MessageToByteEncoder<Packet>
|
||||
public class PacketEncoder extends MessageToByteEncoder<Packet>
|
||||
{
|
||||
private final EnumPacketDirection direction;
|
||||
private final PacketDirection direction;
|
||||
|
||||
public MessageSerializer(EnumPacketDirection direction)
|
||||
public PacketEncoder(PacketDirection direction)
|
||||
{
|
||||
this.direction = direction;
|
||||
}
|
||||
|
||||
protected void encode(ChannelHandlerContext p_encode_1_, Packet p_encode_2_, ByteBuf p_encode_3_) throws IOException, Exception
|
||||
{
|
||||
Integer integer = ((EnumConnectionState)p_encode_1_.channel().attr(NetworkManager.STATE).get()).getPacketId(this.direction, p_encode_2_);
|
||||
Integer integer = ((Protocol)p_encode_1_.channel().attr(Connection.STATE).get()).getPacketId(this.direction, p_encode_2_);
|
||||
|
||||
if (integer == null)
|
||||
{
|
|
@ -4,7 +4,7 @@ import io.netty.buffer.ByteBuf;
|
|||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.handler.codec.MessageToByteEncoder;
|
||||
|
||||
public class MessageSerializer2 extends MessageToByteEncoder<ByteBuf>
|
||||
public class PacketPrepender extends MessageToByteEncoder<ByteBuf>
|
||||
{
|
||||
protected void encode(ChannelHandlerContext p_encode_1_, ByteBuf p_encode_2_, ByteBuf p_encode_3_) throws Exception
|
||||
{
|
|
@ -7,7 +7,7 @@ import io.netty.handler.codec.ByteToMessageDecoder;
|
|||
import io.netty.handler.codec.CorruptedFrameException;
|
||||
import java.util.List;
|
||||
|
||||
public class MessageDeserializer2 extends ByteToMessageDecoder
|
||||
public class PacketSplitter extends ByteToMessageDecoder
|
||||
{
|
||||
protected void decode(ChannelHandlerContext p_decode_1_, ByteBuf p_decode_2_, List<Object> p_decode_3_) throws Exception
|
||||
{
|
|
@ -1,16 +0,0 @@
|
|||
package proxy.network;
|
||||
|
||||
import proxy.Proxy;
|
||||
|
||||
public class PacketThreadUtil {
|
||||
public static <T extends INetHandler> void checkThreadAndEnqueue(final Packet<T> packet, final T handler, Proxy proxy) throws ThreadQuickExitException {
|
||||
if(!proxy.isMainThread()) {
|
||||
proxy.schedule(new Runnable() {
|
||||
public void run() {
|
||||
packet.processPacket(handler);
|
||||
}
|
||||
});
|
||||
throw ThreadQuickExitException.INSTANCE;
|
||||
}
|
||||
}
|
||||
}
|
243
proxy/src/main/java/proxy/network/Protocol.java
Executable file
243
proxy/src/main/java/proxy/network/Protocol.java
Executable file
|
@ -0,0 +1,243 @@
|
|||
package proxy.network;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.HashBiMap;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import proxy.packet.*;
|
||||
import proxy.util.Log;
|
||||
|
||||
public enum Protocol
|
||||
{
|
||||
HANDSHAKE(-1)
|
||||
{
|
||||
{
|
||||
this.registerPacket(PacketDirection.SERVER, H00PacketHandshake.class);
|
||||
}
|
||||
},
|
||||
PLAY(0)
|
||||
{
|
||||
{
|
||||
this.registerPacket(PacketDirection.CLIENT, S00PacketKeepAlive.class);
|
||||
this.registerPacket(PacketDirection.CLIENT, S01PacketJoinGame.class);
|
||||
this.registerPacket(PacketDirection.CLIENT, S02PacketChat.class);
|
||||
this.registerPacket(PacketDirection.CLIENT, S03PacketTimeUpdate.class);
|
||||
this.registerPacket(PacketDirection.CLIENT, S04PacketEntityEquipment.class);
|
||||
this.registerPacket(PacketDirection.CLIENT, S05PacketSpawnPosition.class);
|
||||
this.registerPacket(PacketDirection.CLIENT, S06PacketUpdateHealth.class);
|
||||
this.registerPacket(PacketDirection.CLIENT, S07PacketRespawn.class);
|
||||
this.registerPacket(PacketDirection.CLIENT, S08PacketPlayerPosLook.class);
|
||||
this.registerPacket(PacketDirection.CLIENT, S09PacketHeldItemChange.class);
|
||||
this.registerPacket(PacketDirection.CLIENT, S0APacketUseBed.class);
|
||||
this.registerPacket(PacketDirection.CLIENT, S0BPacketAnimation.class);
|
||||
this.registerPacket(PacketDirection.CLIENT, S0CPacketSpawnPlayer.class);
|
||||
this.registerPacket(PacketDirection.CLIENT, S0DPacketCollectItem.class);
|
||||
this.registerPacket(PacketDirection.CLIENT, S0EPacketSpawnObject.class);
|
||||
this.registerPacket(PacketDirection.CLIENT, S0FPacketSpawnMob.class);
|
||||
this.registerPacket(PacketDirection.CLIENT, S10PacketSpawnPainting.class);
|
||||
this.registerPacket(PacketDirection.CLIENT, S11PacketSpawnExperienceOrb.class);
|
||||
this.registerPacket(PacketDirection.CLIENT, S12PacketEntityVelocity.class);
|
||||
this.registerPacket(PacketDirection.CLIENT, S13PacketDestroyEntities.class);
|
||||
this.registerPacket(PacketDirection.CLIENT, S14PacketEntity.class);
|
||||
this.registerPacket(PacketDirection.CLIENT, S14PacketEntity.S15PacketEntityRelMove.class);
|
||||
this.registerPacket(PacketDirection.CLIENT, S14PacketEntity.S16PacketEntityLook.class);
|
||||
this.registerPacket(PacketDirection.CLIENT, S14PacketEntity.S17PacketEntityLookMove.class);
|
||||
this.registerPacket(PacketDirection.CLIENT, S18PacketEntityTeleport.class);
|
||||
this.registerPacket(PacketDirection.CLIENT, S19PacketEntityHeadLook.class);
|
||||
this.registerPacket(PacketDirection.CLIENT, S19PacketEntityStatus.class);
|
||||
this.registerPacket(PacketDirection.CLIENT, S1BPacketEntityAttach.class);
|
||||
this.registerPacket(PacketDirection.CLIENT, S1CPacketEntityMetadata.class);
|
||||
this.registerPacket(PacketDirection.CLIENT, S1DPacketEntityEffect.class);
|
||||
this.registerPacket(PacketDirection.CLIENT, S1EPacketRemoveEntityEffect.class);
|
||||
this.registerPacket(PacketDirection.CLIENT, S1FPacketSetExperience.class);
|
||||
this.registerPacket(PacketDirection.CLIENT, S20PacketEntityProperties.class);
|
||||
this.registerPacket(PacketDirection.CLIENT, S21PacketChunkData.class);
|
||||
this.registerPacket(PacketDirection.CLIENT, S22PacketMultiBlockChange.class);
|
||||
this.registerPacket(PacketDirection.CLIENT, S23PacketBlockChange.class);
|
||||
this.registerPacket(PacketDirection.CLIENT, S24PacketBlockAction.class);
|
||||
this.registerPacket(PacketDirection.CLIENT, S25PacketBlockBreakAnim.class);
|
||||
this.registerPacket(PacketDirection.CLIENT, S26PacketMapChunkBulk.class);
|
||||
this.registerPacket(PacketDirection.CLIENT, S27PacketExplosion.class);
|
||||
this.registerPacket(PacketDirection.CLIENT, S28PacketEffect.class);
|
||||
this.registerPacket(PacketDirection.CLIENT, S29PacketSoundEffect.class);
|
||||
this.registerPacket(PacketDirection.CLIENT, S2APacketParticles.class);
|
||||
this.registerPacket(PacketDirection.CLIENT, S2BPacketChangeGameState.class);
|
||||
this.registerPacket(PacketDirection.CLIENT, S2CPacketSpawnGlobalEntity.class);
|
||||
this.registerPacket(PacketDirection.CLIENT, S2DPacketOpenWindow.class);
|
||||
this.registerPacket(PacketDirection.CLIENT, S2EPacketCloseWindow.class);
|
||||
this.registerPacket(PacketDirection.CLIENT, S2FPacketSetSlot.class);
|
||||
this.registerPacket(PacketDirection.CLIENT, S30PacketWindowItems.class);
|
||||
this.registerPacket(PacketDirection.CLIENT, S31PacketWindowProperty.class);
|
||||
this.registerPacket(PacketDirection.CLIENT, S32PacketConfirmTransaction.class);
|
||||
this.registerPacket(PacketDirection.CLIENT, S33PacketUpdateSign.class);
|
||||
this.registerPacket(PacketDirection.CLIENT, S34PacketMaps.class);
|
||||
this.registerPacket(PacketDirection.CLIENT, S35PacketUpdateTileEntity.class);
|
||||
this.registerPacket(PacketDirection.CLIENT, S36PacketSignEditorOpen.class);
|
||||
this.registerPacket(PacketDirection.CLIENT, S37PacketStatistics.class);
|
||||
this.registerPacket(PacketDirection.CLIENT, S38PacketPlayerListItem.class);
|
||||
this.registerPacket(PacketDirection.CLIENT, S39PacketPlayerAbilities.class);
|
||||
this.registerPacket(PacketDirection.CLIENT, S3APacketTabComplete.class);
|
||||
this.registerPacket(PacketDirection.CLIENT, S3BPacketScoreboardObjective.class);
|
||||
this.registerPacket(PacketDirection.CLIENT, S3CPacketUpdateScore.class);
|
||||
this.registerPacket(PacketDirection.CLIENT, S3DPacketDisplayScoreboard.class);
|
||||
this.registerPacket(PacketDirection.CLIENT, S3EPacketTeams.class);
|
||||
this.registerPacket(PacketDirection.CLIENT, S3FPacketCustomPayload.class);
|
||||
this.registerPacket(PacketDirection.CLIENT, S40PacketDisconnect.class);
|
||||
this.registerPacket(PacketDirection.CLIENT, S41PacketServerDifficulty.class);
|
||||
this.registerPacket(PacketDirection.CLIENT, S42PacketCombatEvent.class);
|
||||
this.registerPacket(PacketDirection.CLIENT, S43PacketCamera.class);
|
||||
this.registerPacket(PacketDirection.CLIENT, S44PacketWorldBorder.class);
|
||||
this.registerPacket(PacketDirection.CLIENT, S45PacketTitle.class);
|
||||
this.registerPacket(PacketDirection.CLIENT, S46PacketSetCompressionLevel.class);
|
||||
this.registerPacket(PacketDirection.CLIENT, S47PacketPlayerListHeaderFooter.class);
|
||||
this.registerPacket(PacketDirection.CLIENT, S48PacketResourcePackSend.class);
|
||||
this.registerPacket(PacketDirection.CLIENT, S49PacketUpdateEntityNBT.class);
|
||||
this.registerPacket(PacketDirection.SERVER, C00PacketKeepAlive.class);
|
||||
this.registerPacket(PacketDirection.SERVER, C01PacketChatMessage.class);
|
||||
this.registerPacket(PacketDirection.SERVER, C02PacketUseEntity.class);
|
||||
this.registerPacket(PacketDirection.SERVER, C03PacketPlayer.class);
|
||||
this.registerPacket(PacketDirection.SERVER, C03PacketPlayer.C04PacketPlayerPosition.class);
|
||||
this.registerPacket(PacketDirection.SERVER, C03PacketPlayer.C05PacketPlayerLook.class);
|
||||
this.registerPacket(PacketDirection.SERVER, C03PacketPlayer.C06PacketPlayerPosLook.class);
|
||||
this.registerPacket(PacketDirection.SERVER, C07PacketPlayerDigging.class);
|
||||
this.registerPacket(PacketDirection.SERVER, C08PacketPlayerBlockPlacement.class);
|
||||
this.registerPacket(PacketDirection.SERVER, C09PacketHeldItemChange.class);
|
||||
this.registerPacket(PacketDirection.SERVER, C0APacketAnimation.class);
|
||||
this.registerPacket(PacketDirection.SERVER, C0BPacketEntityAction.class);
|
||||
this.registerPacket(PacketDirection.SERVER, C0CPacketInput.class);
|
||||
this.registerPacket(PacketDirection.SERVER, C0DPacketCloseWindow.class);
|
||||
this.registerPacket(PacketDirection.SERVER, C0EPacketClickWindow.class);
|
||||
this.registerPacket(PacketDirection.SERVER, C0FPacketConfirmTransaction.class);
|
||||
this.registerPacket(PacketDirection.SERVER, C10PacketCreativeInventoryAction.class);
|
||||
this.registerPacket(PacketDirection.SERVER, C11PacketEnchantItem.class);
|
||||
this.registerPacket(PacketDirection.SERVER, C12PacketUpdateSign.class);
|
||||
this.registerPacket(PacketDirection.SERVER, C13PacketPlayerAbilities.class);
|
||||
this.registerPacket(PacketDirection.SERVER, C14PacketTabComplete.class);
|
||||
this.registerPacket(PacketDirection.SERVER, C15PacketClientSettings.class);
|
||||
this.registerPacket(PacketDirection.SERVER, C16PacketClientStatus.class);
|
||||
this.registerPacket(PacketDirection.SERVER, C17PacketCustomPayload.class);
|
||||
this.registerPacket(PacketDirection.SERVER, C18PacketSpectate.class);
|
||||
this.registerPacket(PacketDirection.SERVER, C19PacketResourcePackStatus.class);
|
||||
}
|
||||
},
|
||||
STATUS(1)
|
||||
{
|
||||
{
|
||||
this.registerPacket(PacketDirection.SERVER, Q00PacketServerQuery.class);
|
||||
this.registerPacket(PacketDirection.CLIENT, I00PacketServerInfo.class);
|
||||
this.registerPacket(PacketDirection.SERVER, Q01PacketPing.class);
|
||||
this.registerPacket(PacketDirection.CLIENT, I01PacketPong.class);
|
||||
}
|
||||
},
|
||||
LOGIN(2)
|
||||
{
|
||||
{
|
||||
this.registerPacket(PacketDirection.CLIENT, R00PacketDisconnect.class);
|
||||
this.registerPacket(PacketDirection.CLIENT, R01PacketEncryptionRequest.class);
|
||||
this.registerPacket(PacketDirection.CLIENT, R02PacketLoginSuccess.class);
|
||||
this.registerPacket(PacketDirection.CLIENT, R03PacketEnableCompression.class);
|
||||
this.registerPacket(PacketDirection.SERVER, L00PacketLoginStart.class);
|
||||
this.registerPacket(PacketDirection.SERVER, L01PacketEncryptionResponse.class);
|
||||
}
|
||||
};
|
||||
|
||||
private static int field_181136_e = -1;
|
||||
private static int field_181137_f = 2;
|
||||
private static final Protocol[] STATES_BY_ID = new Protocol[field_181137_f - field_181136_e + 1];
|
||||
private static final Map < Class <? extends Packet > , Protocol > STATES_BY_CLASS = Maps. < Class <? extends Packet > , Protocol > newHashMap();
|
||||
private final int id;
|
||||
private final Map < PacketDirection, BiMap < Integer, Class <? extends Packet >>> directionMaps;
|
||||
|
||||
private Protocol(int protocolId)
|
||||
{
|
||||
this.directionMaps = Maps.newEnumMap(PacketDirection.class);
|
||||
this.id = protocolId;
|
||||
}
|
||||
|
||||
protected Protocol registerPacket(PacketDirection direction, Class <? extends Packet > packetClass)
|
||||
{
|
||||
BiMap < Integer, Class <? extends Packet >> bimap = (BiMap)this.directionMaps.get(direction);
|
||||
|
||||
if (bimap == null)
|
||||
{
|
||||
bimap = HashBiMap. < Integer, Class <? extends Packet >> create();
|
||||
this.directionMaps.put(direction, bimap);
|
||||
}
|
||||
|
||||
if (bimap.containsValue(packetClass))
|
||||
{
|
||||
String s = direction + " packet " + packetClass + " is already known to ID " + bimap.inverse().get(packetClass);
|
||||
Log.error(s);
|
||||
throw new IllegalArgumentException(s);
|
||||
}
|
||||
else
|
||||
{
|
||||
bimap.put(Integer.valueOf(bimap.size()), packetClass);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public Integer getPacketId(PacketDirection direction, Packet packetIn)
|
||||
{
|
||||
return (Integer)((BiMap)this.directionMaps.get(direction)).inverse().get(packetIn.getClass());
|
||||
}
|
||||
|
||||
public Packet getPacket(PacketDirection direction, int packetId) throws InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchMethodException {
|
||||
Class <? extends Packet > oclass = (Class)((BiMap)this.directionMaps.get(direction)).get(Integer.valueOf(packetId));
|
||||
return oclass == null ? null : (Packet)oclass.getConstructor().newInstance();
|
||||
}
|
||||
|
||||
public int getId()
|
||||
{
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public static Protocol getById(int stateId)
|
||||
{
|
||||
return stateId >= field_181136_e && stateId <= field_181137_f ? STATES_BY_ID[stateId - field_181136_e] : null;
|
||||
}
|
||||
|
||||
public static Protocol getFromPacket(Packet packetIn)
|
||||
{
|
||||
return (Protocol)STATES_BY_CLASS.get(packetIn.getClass());
|
||||
}
|
||||
|
||||
static {
|
||||
for (Protocol enumconnectionstate : values())
|
||||
{
|
||||
int i = enumconnectionstate.getId();
|
||||
|
||||
if (i < field_181136_e || i > field_181137_f)
|
||||
{
|
||||
throw new Error("Invalid protocol ID " + Integer.toString(i));
|
||||
}
|
||||
|
||||
STATES_BY_ID[i - field_181136_e] = enumconnectionstate;
|
||||
|
||||
for (PacketDirection enumpacketdirection : enumconnectionstate.directionMaps.keySet())
|
||||
{
|
||||
for (Class <? extends Packet > oclass : (enumconnectionstate.directionMaps.get(enumpacketdirection)).values())
|
||||
{
|
||||
if (STATES_BY_CLASS.containsKey(oclass) && STATES_BY_CLASS.get(oclass) != enumconnectionstate)
|
||||
{
|
||||
throw new Error("Packet " + oclass + " is already assigned to protocol " + STATES_BY_CLASS.get(oclass) + " - can\'t reassign to " + enumconnectionstate);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
oclass.getConstructor().newInstance();
|
||||
}
|
||||
catch (Throwable var10)
|
||||
{
|
||||
throw new Error("Packet " + oclass + " fails instantiation checks! " + oclass);
|
||||
}
|
||||
|
||||
STATES_BY_CLASS.put(oclass, enumconnectionstate);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -8,150 +8,50 @@ import java.net.InetAddress;
|
|||
import java.net.UnknownHostException;
|
||||
|
||||
import proxy.Proxy;
|
||||
import proxy.nbt.NBTTagList;
|
||||
import proxy.packet.handshake.client.C00Handshake;
|
||||
import proxy.packet.login.client.C00PacketLoginStart;
|
||||
import proxy.packet.login.server.S00PacketDisconnect;
|
||||
import proxy.packet.login.server.S01PacketEncryptionRequest;
|
||||
import proxy.packet.login.server.S02PacketLoginSuccess;
|
||||
import proxy.packet.login.server.S03PacketEnableCompression;
|
||||
import proxy.packet.play.client.C00PacketKeepAlive;
|
||||
import proxy.packet.play.client.C01PacketChatMessage;
|
||||
import proxy.packet.play.client.C02PacketUseEntity;
|
||||
import proxy.packet.play.client.C03PacketPlayer;
|
||||
import proxy.packet.play.client.C07PacketPlayerDigging;
|
||||
import proxy.packet.play.client.C08PacketPlayerBlockPlacement;
|
||||
import proxy.packet.play.client.C09PacketHeldItemChange;
|
||||
import proxy.packet.play.client.C0APacketAnimation;
|
||||
import proxy.packet.play.client.C0BPacketEntityAction;
|
||||
import proxy.packet.play.client.C0CPacketInput;
|
||||
import proxy.packet.play.client.C0DPacketCloseWindow;
|
||||
import proxy.packet.play.client.C0EPacketClickWindow;
|
||||
import proxy.packet.play.client.C0FPacketConfirmTransaction;
|
||||
import proxy.packet.play.client.C10PacketCreativeInventoryAction;
|
||||
import proxy.packet.play.client.C11PacketEnchantItem;
|
||||
import proxy.packet.play.client.C12PacketUpdateSign;
|
||||
import proxy.packet.play.client.C13PacketPlayerAbilities;
|
||||
import proxy.packet.play.client.C14PacketTabComplete;
|
||||
import proxy.packet.play.client.C15PacketClientSettings;
|
||||
import proxy.packet.play.client.C16PacketClientStatus;
|
||||
import proxy.packet.play.client.C17PacketCustomPayload;
|
||||
import proxy.packet.play.client.C18PacketSpectate;
|
||||
import proxy.packet.play.client.C19PacketResourcePackStatus;
|
||||
import proxy.packet.play.server.S00PacketKeepAlive;
|
||||
import proxy.packet.play.server.S01PacketJoinGame;
|
||||
import proxy.packet.play.server.S02PacketChat;
|
||||
import proxy.packet.play.server.S03PacketTimeUpdate;
|
||||
import proxy.packet.play.server.S04PacketEntityEquipment;
|
||||
import proxy.packet.play.server.S05PacketSpawnPosition;
|
||||
import proxy.packet.play.server.S06PacketUpdateHealth;
|
||||
import proxy.packet.play.server.S07PacketRespawn;
|
||||
import proxy.packet.play.server.S08PacketPlayerPosLook;
|
||||
import proxy.packet.play.server.S09PacketHeldItemChange;
|
||||
import proxy.packet.play.server.S0APacketUseBed;
|
||||
import proxy.packet.play.server.S0BPacketAnimation;
|
||||
import proxy.packet.play.server.S0CPacketSpawnPlayer;
|
||||
import proxy.packet.play.server.S0DPacketCollectItem;
|
||||
import proxy.packet.play.server.S0EPacketSpawnObject;
|
||||
import proxy.packet.play.server.S0FPacketSpawnMob;
|
||||
import proxy.packet.play.server.S10PacketSpawnPainting;
|
||||
import proxy.packet.play.server.S11PacketSpawnExperienceOrb;
|
||||
import proxy.packet.play.server.S12PacketEntityVelocity;
|
||||
import proxy.packet.play.server.S13PacketDestroyEntities;
|
||||
import proxy.packet.play.server.S14PacketEntity;
|
||||
import proxy.packet.play.server.S18PacketEntityTeleport;
|
||||
import proxy.packet.play.server.S19PacketEntityHeadLook;
|
||||
import proxy.packet.play.server.S19PacketEntityStatus;
|
||||
import proxy.packet.play.server.S1BPacketEntityAttach;
|
||||
import proxy.packet.play.server.S1CPacketEntityMetadata;
|
||||
import proxy.packet.play.server.S1DPacketEntityEffect;
|
||||
import proxy.packet.play.server.S1EPacketRemoveEntityEffect;
|
||||
import proxy.packet.play.server.S1FPacketSetExperience;
|
||||
import proxy.packet.play.server.S20PacketEntityProperties;
|
||||
import proxy.packet.play.server.S21PacketChunkData;
|
||||
import proxy.packet.play.server.S22PacketMultiBlockChange;
|
||||
import proxy.packet.play.server.S23PacketBlockChange;
|
||||
import proxy.packet.play.server.S24PacketBlockAction;
|
||||
import proxy.packet.play.server.S25PacketBlockBreakAnim;
|
||||
import proxy.packet.play.server.S26PacketMapChunkBulk;
|
||||
import proxy.packet.play.server.S27PacketExplosion;
|
||||
import proxy.packet.play.server.S28PacketEffect;
|
||||
import proxy.packet.play.server.S29PacketSoundEffect;
|
||||
import proxy.packet.play.server.S2APacketParticles;
|
||||
import proxy.packet.play.server.S2BPacketChangeGameState;
|
||||
import proxy.packet.play.server.S2CPacketSpawnGlobalEntity;
|
||||
import proxy.packet.play.server.S2DPacketOpenWindow;
|
||||
import proxy.packet.play.server.S2EPacketCloseWindow;
|
||||
import proxy.packet.play.server.S2FPacketSetSlot;
|
||||
import proxy.packet.play.server.S30PacketWindowItems;
|
||||
import proxy.packet.play.server.S31PacketWindowProperty;
|
||||
import proxy.packet.play.server.S32PacketConfirmTransaction;
|
||||
import proxy.packet.play.server.S33PacketUpdateSign;
|
||||
import proxy.packet.play.server.S34PacketMaps;
|
||||
import proxy.packet.play.server.S35PacketUpdateTileEntity;
|
||||
import proxy.packet.play.server.S36PacketSignEditorOpen;
|
||||
import proxy.packet.play.server.S37PacketStatistics;
|
||||
import proxy.packet.play.server.S38PacketPlayerListItem;
|
||||
import proxy.packet.play.server.S39PacketPlayerAbilities;
|
||||
import proxy.packet.play.server.S3APacketTabComplete;
|
||||
import proxy.packet.play.server.S3BPacketScoreboardObjective;
|
||||
import proxy.packet.play.server.S3CPacketUpdateScore;
|
||||
import proxy.packet.play.server.S3DPacketDisplayScoreboard;
|
||||
import proxy.packet.play.server.S3EPacketTeams;
|
||||
import proxy.packet.play.server.S3FPacketCustomPayload;
|
||||
import proxy.packet.play.server.S40PacketDisconnect;
|
||||
import proxy.packet.play.server.S41PacketServerDifficulty;
|
||||
import proxy.packet.play.server.S42PacketCombatEvent;
|
||||
import proxy.packet.play.server.S43PacketCamera;
|
||||
import proxy.packet.play.server.S44PacketWorldBorder;
|
||||
import proxy.packet.play.server.S45PacketTitle;
|
||||
import proxy.packet.play.server.S46PacketSetCompressionLevel;
|
||||
import proxy.packet.play.server.S47PacketPlayerListHeaderFooter;
|
||||
import proxy.packet.play.server.S48PacketResourcePackSend;
|
||||
import proxy.packet.play.server.S49PacketUpdateEntityNBT;
|
||||
import proxy.packet.*;
|
||||
import proxy.util.ChatColor;
|
||||
import proxy.util.User;
|
||||
import proxy.util.Stack;
|
||||
import proxy.util.Log;
|
||||
|
||||
public class NetHandlerPlayServer implements INetHandler {
|
||||
public class ProxyLoginHandler implements INetHandler {
|
||||
public void handleEncryptionRequest(S01PacketEncryptionRequest packetIn) {
|
||||
NetHandlerPlayServer.this.server.closeChannel("Online mode auth request received");
|
||||
NetHandlerPlayServer.this.disconnect("Server tried to authenticate, check if online-mode ist set to false");
|
||||
public class ProxyHandler implements Handler {
|
||||
public class ProxyLoginHandler implements Handler {
|
||||
public void handleEncryptionRequest(R01PacketEncryptionRequest packetIn) {
|
||||
ProxyHandler.this.server.closeChannel("Online mode auth request received");
|
||||
ProxyHandler.this.disconnect("Server tried to authenticate, check if online-mode ist set to false");
|
||||
}
|
||||
|
||||
public void handleLoginSuccess(S02PacketLoginSuccess packetIn) {
|
||||
if(!NetHandlerPlayServer.this.username.equals(packetIn.getName()) || !Proxy.getOfflineUUID(NetHandlerPlayServer.this.username).equals(packetIn.getId())) {
|
||||
NetHandlerPlayServer.this.server.closeChannel("Different profile received");
|
||||
NetHandlerPlayServer.this.disconnect("Server returned a different profile, check if server or plugins tamper with profiles");
|
||||
public void handleLoginSuccess(R02PacketLoginSuccess packetIn) {
|
||||
if(!ProxyHandler.this.username.equals(packetIn.getName()) || !Proxy.getOfflineUUID(ProxyHandler.this.username).equals(packetIn.getId())) {
|
||||
ProxyHandler.this.server.closeChannel("Different profile received");
|
||||
ProxyHandler.this.disconnect("Server returned a different profile, check if server or plugins tamper with profiles");
|
||||
}
|
||||
NetHandlerPlayServer.this.server.setNetHandler(NetHandlerPlayServer.this);
|
||||
NetHandlerPlayServer.this.server.setConnectionState(EnumConnectionState.PLAY);
|
||||
NetHandlerPlayServer.this.connected = true;
|
||||
NetHandlerPlayServer.this.connecting = false;
|
||||
Log.info("Connected %s to forward host", NetHandlerPlayServer.this.username);
|
||||
ProxyHandler.this.server.setNetHandler(ProxyHandler.this);
|
||||
ProxyHandler.this.server.setConnectionState(Protocol.PLAY);
|
||||
ProxyHandler.this.connected = true;
|
||||
ProxyHandler.this.connecting = false;
|
||||
Log.info("Connected %s to forward host", ProxyHandler.this.username);
|
||||
}
|
||||
|
||||
public void handleDisconnect(S00PacketDisconnect packetIn) {
|
||||
NetHandlerPlayServer.this.server.closeChannel("Kicked by server on login: " + packetIn.getReason());
|
||||
NetHandlerPlayServer.this.disconnect("Kicked by server on login");
|
||||
public void handleDisconnect(R00PacketDisconnect packetIn) {
|
||||
ProxyHandler.this.server.closeChannel("Kicked by server on login: " + packetIn.getReason());
|
||||
ProxyHandler.this.disconnect("Kicked by server on login");
|
||||
}
|
||||
|
||||
public void handleEnableCompression(S03PacketEnableCompression packetIn) {
|
||||
NetHandlerPlayServer.this.server.setCompressionTreshold(packetIn.getCompressionTreshold());
|
||||
public void handleEnableCompression(R03PacketEnableCompression packetIn) {
|
||||
ProxyHandler.this.server.setCompressionTreshold(packetIn.getCompressionTreshold());
|
||||
}
|
||||
|
||||
public void onDisconnect(NetworkManager connection, String reason) {
|
||||
NetHandlerPlayServer.this.onDisconnect(connection, reason);
|
||||
public void onDisconnect(Connection connection, String reason) {
|
||||
ProxyHandler.this.onDisconnect(connection, reason);
|
||||
}
|
||||
}
|
||||
|
||||
private final Proxy proxy;
|
||||
private final NetworkManager client;
|
||||
private final Connection client;
|
||||
private final String username;
|
||||
|
||||
private NetworkManager server;
|
||||
private Connection server;
|
||||
|
||||
private int networkTickCount;
|
||||
private long lastPingTime;
|
||||
|
@ -186,7 +86,7 @@ public class NetHandlerPlayServer implements INetHandler {
|
|||
return true;
|
||||
}
|
||||
|
||||
public NetHandlerPlayServer(Proxy proxy, NetworkManager client, String username) {
|
||||
public ProxyHandler(Proxy proxy, Connection client, String username) {
|
||||
this.proxy = proxy;
|
||||
this.client = client;
|
||||
this.username = username;
|
||||
|
@ -208,7 +108,7 @@ public class NetHandlerPlayServer implements INetHandler {
|
|||
this.sendToClient(new S02PacketChat(String.format(fmt, args)));
|
||||
}
|
||||
|
||||
public void update(NetworkManager connection) {
|
||||
public void update(Connection connection) {
|
||||
if(connection == this.server)
|
||||
return;
|
||||
if(!this.connected) {
|
||||
|
@ -246,13 +146,13 @@ public class NetHandlerPlayServer implements INetHandler {
|
|||
public void disconnect(final String reason) {
|
||||
this.client.sendPacket(new S40PacketDisconnect(reason), new GenericFutureListener<Future<? super Void>>() {
|
||||
public void operationComplete(Future<? super Void> p_operationComplete_1_) throws Exception {
|
||||
NetHandlerPlayServer.this.client.closeChannel(reason);
|
||||
ProxyHandler.this.client.closeChannel(reason);
|
||||
}
|
||||
});
|
||||
this.client.disableAutoRead();
|
||||
this.proxy.schedule(new Runnable() {
|
||||
public void run() {
|
||||
NetHandlerPlayServer.this.client.checkDisconnected();
|
||||
ProxyHandler.this.client.checkDisconnected();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -260,9 +160,9 @@ public class NetHandlerPlayServer implements INetHandler {
|
|||
private void connectToServer() {
|
||||
this.proxy.setLoggedIn(this.username, this);
|
||||
Log.info("Connecting %s to %s:%d", this.username, this.proxy.getForwardHost(), this.proxy.getForwardPort());
|
||||
final NetworkManager conn;
|
||||
final Connection conn;
|
||||
try {
|
||||
conn = NetworkManager.createNetworkManagerAndConnect(InetAddress.getByName(IDN.toASCII(this.proxy.getForwardHost())), this.proxy.getForwardPort(), this.proxy.isUsingEPoll());
|
||||
conn = Connection.createNetworkManagerAndConnect(InetAddress.getByName(IDN.toASCII(this.proxy.getForwardHost())), this.proxy.getForwardPort(), this.proxy.isUsingEPoll());
|
||||
}
|
||||
catch(UnknownHostException e) {
|
||||
this.disconnect("Could not connect to server: unknown host, check if the hostname is correct");
|
||||
|
@ -275,9 +175,9 @@ public class NetHandlerPlayServer implements INetHandler {
|
|||
return;
|
||||
}
|
||||
conn.setNetHandler(new ProxyLoginHandler());
|
||||
conn.sendPacket(new C00Handshake(47, this.proxy.getForwardHost(), this.proxy.getForwardPort(), EnumConnectionState.LOGIN), new GenericFutureListener<Future<? super Void>>() {
|
||||
conn.sendPacket(new H00PacketHandshake(47, this.proxy.getForwardHost(), this.proxy.getForwardPort(), Protocol.LOGIN), new GenericFutureListener<Future<? super Void>>() {
|
||||
public void operationComplete(Future<? super Void> future) throws Exception {
|
||||
conn.sendPacket(new C00PacketLoginStart(NetHandlerPlayServer.this.username));
|
||||
conn.sendPacket(new L00PacketLoginStart(ProxyHandler.this.username));
|
||||
}
|
||||
});
|
||||
this.server = conn;
|
||||
|
@ -306,7 +206,7 @@ public class NetHandlerPlayServer implements INetHandler {
|
|||
}
|
||||
}
|
||||
|
||||
public void onDisconnect(NetworkManager connection, String reason) {
|
||||
public void onDisconnect(Connection connection, String reason) {
|
||||
if(connection == this.server) {
|
||||
this.disconnect(reason);
|
||||
Log.info("Server disconnected, kicking player %s", this.username);
|
||||
|
@ -375,7 +275,7 @@ public class NetHandlerPlayServer implements INetHandler {
|
|||
|
||||
public void processUpdateSign(C12PacketUpdateSign packetIn) {
|
||||
if(!this.connected) {
|
||||
PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.proxy);
|
||||
Handler.syncToMain(packetIn, this, this.proxy);
|
||||
String line1 = ChatColor.fromJsonString(packetIn.getLines()[0]);
|
||||
String line2 = ChatColor.fromJsonString(packetIn.getLines()[1]);
|
||||
if(line1 == null || line2 == null || line1.length() > 50 || line2.length() > 50 || !isValidString(line1) || !isValidString(line2))
|
||||
|
@ -516,9 +416,9 @@ public class NetHandlerPlayServer implements INetHandler {
|
|||
try {
|
||||
Stack itemstack1 = packetbuffer.readStack();
|
||||
|
||||
if(itemstack1 != null) {
|
||||
NBTTagList pages = itemstack1.getTag().getTagList("pages", 8);
|
||||
if(pages.tagCount() > 50)
|
||||
if(itemstack1 != null && itemstack1.getTag() != null) {
|
||||
int pages = itemstack1.getTag().getStringListLength("pages");
|
||||
if(pages > 50)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -536,12 +436,12 @@ public class NetHandlerPlayServer implements INetHandler {
|
|||
try {
|
||||
Stack itemstack = packetbuffer.readStack();
|
||||
|
||||
if(itemstack != null) {
|
||||
if(itemstack != null && itemstack.getTag() != null) {
|
||||
String title = itemstack.getTag().getString("title");
|
||||
if(title.length() > 50 || !isValidString(title))
|
||||
if(title != null && (title.length() > 50 || !isValidString(title)))
|
||||
return;
|
||||
NBTTagList pages = itemstack.getTag().getTagList("pages", 8);
|
||||
if(pages.tagCount() > 50)
|
||||
int pages = itemstack.getTag().getStringListLength("pages");
|
||||
if(pages > 50)
|
||||
return;
|
||||
}
|
||||
}
|
39
proxy/src/main/java/proxy/network/StatusHandler.java
Executable file
39
proxy/src/main/java/proxy/network/StatusHandler.java
Executable file
|
@ -0,0 +1,39 @@
|
|||
package proxy.network;
|
||||
|
||||
import proxy.Proxy;
|
||||
import proxy.packet.I00PacketServerInfo;
|
||||
import proxy.packet.I01PacketPong;
|
||||
import proxy.packet.Q00PacketServerQuery;
|
||||
import proxy.packet.Q01PacketPing;
|
||||
|
||||
public class StatusHandler implements Handler {
|
||||
private static final String EXIT_MESSAGE = "Status request has been handled.";
|
||||
|
||||
private final Proxy proxy;
|
||||
private final Connection connection;
|
||||
|
||||
private boolean handled;
|
||||
|
||||
public StatusHandler(Proxy proxy, Connection connection) {
|
||||
this.proxy = proxy;
|
||||
this.connection = connection;
|
||||
}
|
||||
|
||||
public void onDisconnect(Connection connection, String reason) {
|
||||
}
|
||||
|
||||
public void processServerQuery(Q00PacketServerQuery packet) {
|
||||
if(this.handled) {
|
||||
this.connection.closeChannel(EXIT_MESSAGE);
|
||||
}
|
||||
else {
|
||||
this.handled = true;
|
||||
this.connection.sendPacket(new I00PacketServerInfo(this.proxy.getStatus()));
|
||||
}
|
||||
}
|
||||
|
||||
public void processPing(Q01PacketPing packet) {
|
||||
this.connection.sendPacket(new I01PacketPong(packet.getClientTime()));
|
||||
this.connection.closeChannel(EXIT_MESSAGE);
|
||||
}
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
package proxy.network;
|
||||
|
||||
public final class ThreadQuickExitException extends RuntimeException {
|
||||
public static final ThreadQuickExitException INSTANCE = new ThreadQuickExitException();
|
||||
|
||||
private ThreadQuickExitException() {
|
||||
this.setStackTrace(new StackTraceElement[0]);
|
||||
}
|
||||
|
||||
public synchronized Throwable fillInStackTrace() {
|
||||
this.setStackTrace(new StackTraceElement[0]);
|
||||
return this;
|
||||
}
|
||||
}
|
|
@ -1,12 +1,12 @@
|
|||
package proxy.packet.play.client;
|
||||
package proxy.packet;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import proxy.network.NetHandlerPlayServer;
|
||||
import proxy.network.ProxyHandler;
|
||||
import proxy.network.Packet;
|
||||
import proxy.network.PacketBuffer;
|
||||
|
||||
public class C00PacketKeepAlive implements Packet<NetHandlerPlayServer>
|
||||
public class C00PacketKeepAlive implements Packet<ProxyHandler>
|
||||
{
|
||||
private int key;
|
||||
|
||||
|
@ -22,7 +22,7 @@ public class C00PacketKeepAlive implements Packet<NetHandlerPlayServer>
|
|||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(NetHandlerPlayServer handler)
|
||||
public void processPacket(ProxyHandler handler)
|
||||
{
|
||||
handler.processKeepAlive(this);
|
||||
}
|
|
@ -1,12 +1,12 @@
|
|||
package proxy.packet.play.client;
|
||||
package proxy.packet;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import proxy.network.NetHandlerPlayServer;
|
||||
import proxy.network.ProxyHandler;
|
||||
import proxy.network.Packet;
|
||||
import proxy.network.PacketBuffer;
|
||||
|
||||
public class C01PacketChatMessage implements Packet<NetHandlerPlayServer>
|
||||
public class C01PacketChatMessage implements Packet<ProxyHandler>
|
||||
{
|
||||
private String message;
|
||||
|
||||
|
@ -43,7 +43,7 @@ public class C01PacketChatMessage implements Packet<NetHandlerPlayServer>
|
|||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(NetHandlerPlayServer handler)
|
||||
public void processPacket(ProxyHandler handler)
|
||||
{
|
||||
handler.processChatMessage(this);
|
||||
}
|
|
@ -1,12 +1,12 @@
|
|||
package proxy.packet.play.client;
|
||||
package proxy.packet;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import proxy.network.NetHandlerPlayServer;
|
||||
import proxy.network.ProxyHandler;
|
||||
import proxy.network.Packet;
|
||||
import proxy.network.PacketBuffer;
|
||||
|
||||
public class C02PacketUseEntity implements Packet<NetHandlerPlayServer>
|
||||
public class C02PacketUseEntity implements Packet<ProxyHandler>
|
||||
{
|
||||
private int entityId;
|
||||
private C02PacketUseEntity.Action action;
|
||||
|
@ -49,7 +49,7 @@ public class C02PacketUseEntity implements Packet<NetHandlerPlayServer>
|
|||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(NetHandlerPlayServer handler)
|
||||
public void processPacket(ProxyHandler handler)
|
||||
{
|
||||
handler.processUseEntity(this);
|
||||
}
|
|
@ -1,12 +1,12 @@
|
|||
package proxy.packet.play.client;
|
||||
package proxy.packet;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import proxy.network.NetHandlerPlayServer;
|
||||
import proxy.network.ProxyHandler;
|
||||
import proxy.network.Packet;
|
||||
import proxy.network.PacketBuffer;
|
||||
|
||||
public class C03PacketPlayer implements Packet<NetHandlerPlayServer>
|
||||
public class C03PacketPlayer implements Packet<ProxyHandler>
|
||||
{
|
||||
protected double x;
|
||||
protected double y;
|
||||
|
@ -20,7 +20,7 @@ public class C03PacketPlayer implements Packet<NetHandlerPlayServer>
|
|||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(NetHandlerPlayServer handler)
|
||||
public void processPacket(ProxyHandler handler)
|
||||
{
|
||||
handler.processPlayer(this);
|
||||
}
|
|
@ -1,13 +1,13 @@
|
|||
package proxy.packet.play.client;
|
||||
package proxy.packet;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import proxy.network.NetHandlerPlayServer;
|
||||
import proxy.network.ProxyHandler;
|
||||
import proxy.network.Packet;
|
||||
import proxy.network.PacketBuffer;
|
||||
import proxy.util.Vec3;
|
||||
|
||||
public class C07PacketPlayerDigging implements Packet<NetHandlerPlayServer>
|
||||
public class C07PacketPlayerDigging implements Packet<ProxyHandler>
|
||||
{
|
||||
private Vec3 position;
|
||||
private byte facing;
|
||||
|
@ -36,7 +36,7 @@ public class C07PacketPlayerDigging implements Packet<NetHandlerPlayServer>
|
|||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(NetHandlerPlayServer handler)
|
||||
public void processPacket(ProxyHandler handler)
|
||||
{
|
||||
handler.processPlayerDigging(this);
|
||||
}
|
|
@ -1,14 +1,14 @@
|
|||
package proxy.packet.play.client;
|
||||
package proxy.packet;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import proxy.network.NetHandlerPlayServer;
|
||||
import proxy.network.ProxyHandler;
|
||||
import proxy.network.Packet;
|
||||
import proxy.network.PacketBuffer;
|
||||
import proxy.util.Vec3;
|
||||
import proxy.util.Stack;
|
||||
|
||||
public class C08PacketPlayerBlockPlacement implements Packet<NetHandlerPlayServer>
|
||||
public class C08PacketPlayerBlockPlacement implements Packet<ProxyHandler>
|
||||
{
|
||||
private Vec3 position;
|
||||
private int placedBlockDirection;
|
||||
|
@ -46,7 +46,7 @@ public class C08PacketPlayerBlockPlacement implements Packet<NetHandlerPlayServe
|
|||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(NetHandlerPlayServer handler)
|
||||
public void processPacket(ProxyHandler handler)
|
||||
{
|
||||
handler.processPlayerBlockPlacement(this);
|
||||
}
|
|
@ -1,12 +1,12 @@
|
|||
package proxy.packet.play.client;
|
||||
package proxy.packet;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import proxy.network.NetHandlerPlayServer;
|
||||
import proxy.network.ProxyHandler;
|
||||
import proxy.network.Packet;
|
||||
import proxy.network.PacketBuffer;
|
||||
|
||||
public class C09PacketHeldItemChange implements Packet<NetHandlerPlayServer>
|
||||
public class C09PacketHeldItemChange implements Packet<ProxyHandler>
|
||||
{
|
||||
private int slotId;
|
||||
|
||||
|
@ -29,7 +29,7 @@ public class C09PacketHeldItemChange implements Packet<NetHandlerPlayServer>
|
|||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(NetHandlerPlayServer handler)
|
||||
public void processPacket(ProxyHandler handler)
|
||||
{
|
||||
handler.processHeldItemChange(this);
|
||||
}
|
|
@ -1,12 +1,12 @@
|
|||
package proxy.packet.play.client;
|
||||
package proxy.packet;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import proxy.network.NetHandlerPlayServer;
|
||||
import proxy.network.ProxyHandler;
|
||||
import proxy.network.Packet;
|
||||
import proxy.network.PacketBuffer;
|
||||
|
||||
public class C0APacketAnimation implements Packet<NetHandlerPlayServer>
|
||||
public class C0APacketAnimation implements Packet<ProxyHandler>
|
||||
{
|
||||
/**
|
||||
* Reads the raw packet data from the data stream.
|
||||
|
@ -25,7 +25,7 @@ public class C0APacketAnimation implements Packet<NetHandlerPlayServer>
|
|||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(NetHandlerPlayServer handler)
|
||||
public void processPacket(ProxyHandler handler)
|
||||
{
|
||||
handler.handleAnimation(this);
|
||||
}
|
|
@ -1,12 +1,12 @@
|
|||
package proxy.packet.play.client;
|
||||
package proxy.packet;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import proxy.network.NetHandlerPlayServer;
|
||||
import proxy.network.ProxyHandler;
|
||||
import proxy.network.Packet;
|
||||
import proxy.network.PacketBuffer;
|
||||
|
||||
public class C0BPacketEntityAction implements Packet<NetHandlerPlayServer>
|
||||
public class C0BPacketEntityAction implements Packet<ProxyHandler>
|
||||
{
|
||||
private int entityID;
|
||||
private C0BPacketEntityAction.Action action;
|
||||
|
@ -35,7 +35,7 @@ public class C0BPacketEntityAction implements Packet<NetHandlerPlayServer>
|
|||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(NetHandlerPlayServer handler)
|
||||
public void processPacket(ProxyHandler handler)
|
||||
{
|
||||
handler.processEntityAction(this);
|
||||
}
|
|
@ -1,12 +1,12 @@
|
|||
package proxy.packet.play.client;
|
||||
package proxy.packet;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import proxy.network.NetHandlerPlayServer;
|
||||
import proxy.network.ProxyHandler;
|
||||
import proxy.network.Packet;
|
||||
import proxy.network.PacketBuffer;
|
||||
|
||||
public class C0CPacketInput implements Packet<NetHandlerPlayServer>
|
||||
public class C0CPacketInput implements Packet<ProxyHandler>
|
||||
{
|
||||
private float strafeSpeed;
|
||||
private float forwardSpeed;
|
||||
|
@ -50,7 +50,7 @@ public class C0CPacketInput implements Packet<NetHandlerPlayServer>
|
|||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(NetHandlerPlayServer handler)
|
||||
public void processPacket(ProxyHandler handler)
|
||||
{
|
||||
handler.processInput(this);
|
||||
}
|
|
@ -1,19 +1,19 @@
|
|||
package proxy.packet.play.client;
|
||||
package proxy.packet;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import proxy.network.NetHandlerPlayServer;
|
||||
import proxy.network.ProxyHandler;
|
||||
import proxy.network.Packet;
|
||||
import proxy.network.PacketBuffer;
|
||||
|
||||
public class C0DPacketCloseWindow implements Packet<NetHandlerPlayServer>
|
||||
public class C0DPacketCloseWindow implements Packet<ProxyHandler>
|
||||
{
|
||||
private int windowId;
|
||||
|
||||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(NetHandlerPlayServer handler)
|
||||
public void processPacket(ProxyHandler handler)
|
||||
{
|
||||
handler.processCloseWindow(this);
|
||||
}
|
|
@ -1,13 +1,13 @@
|
|||
package proxy.packet.play.client;
|
||||
package proxy.packet;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import proxy.network.NetHandlerPlayServer;
|
||||
import proxy.network.ProxyHandler;
|
||||
import proxy.network.Packet;
|
||||
import proxy.network.PacketBuffer;
|
||||
import proxy.util.Stack;
|
||||
|
||||
public class C0EPacketClickWindow implements Packet<NetHandlerPlayServer>
|
||||
public class C0EPacketClickWindow implements Packet<ProxyHandler>
|
||||
{
|
||||
private int windowId;
|
||||
private int slotId;
|
||||
|
@ -19,7 +19,7 @@ public class C0EPacketClickWindow implements Packet<NetHandlerPlayServer>
|
|||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(NetHandlerPlayServer handler)
|
||||
public void processPacket(ProxyHandler handler)
|
||||
{
|
||||
handler.processClickWindow(this);
|
||||
}
|
|
@ -1,12 +1,12 @@
|
|||
package proxy.packet.play.client;
|
||||
package proxy.packet;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import proxy.network.NetHandlerPlayServer;
|
||||
import proxy.network.ProxyHandler;
|
||||
import proxy.network.Packet;
|
||||
import proxy.network.PacketBuffer;
|
||||
|
||||
public class C0FPacketConfirmTransaction implements Packet<NetHandlerPlayServer>
|
||||
public class C0FPacketConfirmTransaction implements Packet<ProxyHandler>
|
||||
{
|
||||
private int windowId;
|
||||
private short uid;
|
||||
|
@ -15,7 +15,7 @@ public class C0FPacketConfirmTransaction implements Packet<NetHandlerPlayServer>
|
|||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(NetHandlerPlayServer handler)
|
||||
public void processPacket(ProxyHandler handler)
|
||||
{
|
||||
handler.processConfirmTransaction(this);
|
||||
}
|
|
@ -1,13 +1,13 @@
|
|||
package proxy.packet.play.client;
|
||||
package proxy.packet;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import proxy.network.NetHandlerPlayServer;
|
||||
import proxy.network.ProxyHandler;
|
||||
import proxy.network.Packet;
|
||||
import proxy.network.PacketBuffer;
|
||||
import proxy.util.Stack;
|
||||
|
||||
public class C10PacketCreativeInventoryAction implements Packet<NetHandlerPlayServer>
|
||||
public class C10PacketCreativeInventoryAction implements Packet<ProxyHandler>
|
||||
{
|
||||
private int slotId;
|
||||
private Stack stack;
|
||||
|
@ -15,7 +15,7 @@ public class C10PacketCreativeInventoryAction implements Packet<NetHandlerPlaySe
|
|||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(NetHandlerPlayServer handler)
|
||||
public void processPacket(ProxyHandler handler)
|
||||
{
|
||||
handler.processCreativeInventoryAction(this);
|
||||
}
|
|
@ -1,12 +1,12 @@
|
|||
package proxy.packet.play.client;
|
||||
package proxy.packet;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import proxy.network.NetHandlerPlayServer;
|
||||
import proxy.network.ProxyHandler;
|
||||
import proxy.network.Packet;
|
||||
import proxy.network.PacketBuffer;
|
||||
|
||||
public class C11PacketEnchantItem implements Packet<NetHandlerPlayServer>
|
||||
public class C11PacketEnchantItem implements Packet<ProxyHandler>
|
||||
{
|
||||
private int windowId;
|
||||
private int button;
|
||||
|
@ -14,7 +14,7 @@ public class C11PacketEnchantItem implements Packet<NetHandlerPlayServer>
|
|||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(NetHandlerPlayServer handler)
|
||||
public void processPacket(ProxyHandler handler)
|
||||
{
|
||||
handler.processEnchantItem(this);
|
||||
}
|
|
@ -1,13 +1,13 @@
|
|||
package proxy.packet.play.client;
|
||||
package proxy.packet;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import proxy.network.NetHandlerPlayServer;
|
||||
import proxy.network.ProxyHandler;
|
||||
import proxy.network.Packet;
|
||||
import proxy.network.PacketBuffer;
|
||||
import proxy.util.Vec3;
|
||||
|
||||
public class C12PacketUpdateSign implements Packet<NetHandlerPlayServer>
|
||||
public class C12PacketUpdateSign implements Packet<ProxyHandler>
|
||||
{
|
||||
private Vec3 pos;
|
||||
private String[] lines;
|
||||
|
@ -42,7 +42,7 @@ public class C12PacketUpdateSign implements Packet<NetHandlerPlayServer>
|
|||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(NetHandlerPlayServer handler)
|
||||
public void processPacket(ProxyHandler handler)
|
||||
{
|
||||
handler.processUpdateSign(this);
|
||||
}
|
|
@ -1,12 +1,12 @@
|
|||
package proxy.packet.play.client;
|
||||
package proxy.packet;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import proxy.network.NetHandlerPlayServer;
|
||||
import proxy.network.ProxyHandler;
|
||||
import proxy.network.Packet;
|
||||
import proxy.network.PacketBuffer;
|
||||
|
||||
public class C13PacketPlayerAbilities implements Packet<NetHandlerPlayServer>
|
||||
public class C13PacketPlayerAbilities implements Packet<ProxyHandler>
|
||||
{
|
||||
private boolean invulnerable;
|
||||
private boolean flying;
|
||||
|
@ -64,7 +64,7 @@ public class C13PacketPlayerAbilities implements Packet<NetHandlerPlayServer>
|
|||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(NetHandlerPlayServer handler)
|
||||
public void processPacket(ProxyHandler handler)
|
||||
{
|
||||
handler.processPlayerAbilities(this);
|
||||
}
|
|
@ -1,13 +1,13 @@
|
|||
package proxy.packet.play.client;
|
||||
package proxy.packet;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import proxy.network.NetHandlerPlayServer;
|
||||
import proxy.network.ProxyHandler;
|
||||
import proxy.network.Packet;
|
||||
import proxy.network.PacketBuffer;
|
||||
import proxy.util.Vec3;
|
||||
|
||||
public class C14PacketTabComplete implements Packet<NetHandlerPlayServer>
|
||||
public class C14PacketTabComplete implements Packet<ProxyHandler>
|
||||
{
|
||||
private String message;
|
||||
private Vec3 targetBlock;
|
||||
|
@ -59,7 +59,7 @@ public class C14PacketTabComplete implements Packet<NetHandlerPlayServer>
|
|||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(NetHandlerPlayServer handler)
|
||||
public void processPacket(ProxyHandler handler)
|
||||
{
|
||||
handler.processTabComplete(this);
|
||||
}
|
|
@ -1,12 +1,12 @@
|
|||
package proxy.packet.play.client;
|
||||
package proxy.packet;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import proxy.network.NetHandlerPlayServer;
|
||||
import proxy.network.ProxyHandler;
|
||||
import proxy.network.Packet;
|
||||
import proxy.network.PacketBuffer;
|
||||
|
||||
public class C15PacketClientSettings implements Packet<NetHandlerPlayServer>
|
||||
public class C15PacketClientSettings implements Packet<ProxyHandler>
|
||||
{
|
||||
private String lang;
|
||||
private int view;
|
||||
|
@ -41,7 +41,7 @@ public class C15PacketClientSettings implements Packet<NetHandlerPlayServer>
|
|||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(NetHandlerPlayServer handler)
|
||||
public void processPacket(ProxyHandler handler)
|
||||
{
|
||||
handler.processClientSettings(this);
|
||||
}
|
|
@ -1,12 +1,12 @@
|
|||
package proxy.packet.play.client;
|
||||
package proxy.packet;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import proxy.network.NetHandlerPlayServer;
|
||||
import proxy.network.ProxyHandler;
|
||||
import proxy.network.Packet;
|
||||
import proxy.network.PacketBuffer;
|
||||
|
||||
public class C16PacketClientStatus implements Packet<NetHandlerPlayServer>
|
||||
public class C16PacketClientStatus implements Packet<ProxyHandler>
|
||||
{
|
||||
private C16PacketClientStatus.EnumState status;
|
||||
|
||||
|
@ -29,7 +29,7 @@ public class C16PacketClientStatus implements Packet<NetHandlerPlayServer>
|
|||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(NetHandlerPlayServer handler)
|
||||
public void processPacket(ProxyHandler handler)
|
||||
{
|
||||
handler.processClientStatus(this);
|
||||
}
|
|
@ -1,15 +1,15 @@
|
|||
package proxy.packet.play.client;
|
||||
package proxy.packet;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import proxy.network.NetHandlerPlayServer;
|
||||
import proxy.network.ProxyHandler;
|
||||
import proxy.network.Packet;
|
||||
import proxy.network.PacketBuffer;
|
||||
|
||||
public class C17PacketCustomPayload implements Packet<NetHandlerPlayServer>
|
||||
public class C17PacketCustomPayload implements Packet<ProxyHandler>
|
||||
{
|
||||
private String channel;
|
||||
private PacketBuffer data;
|
||||
|
@ -44,7 +44,7 @@ public class C17PacketCustomPayload implements Packet<NetHandlerPlayServer>
|
|||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(NetHandlerPlayServer handler)
|
||||
public void processPacket(ProxyHandler handler)
|
||||
{
|
||||
handler.processVanilla250Packet(this);
|
||||
}
|
|
@ -1,13 +1,13 @@
|
|||
package proxy.packet.play.client;
|
||||
package proxy.packet;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.UUID;
|
||||
|
||||
import proxy.network.NetHandlerPlayServer;
|
||||
import proxy.network.ProxyHandler;
|
||||
import proxy.network.Packet;
|
||||
import proxy.network.PacketBuffer;
|
||||
|
||||
public class C18PacketSpectate implements Packet<NetHandlerPlayServer>
|
||||
public class C18PacketSpectate implements Packet<ProxyHandler>
|
||||
{
|
||||
private UUID id;
|
||||
|
||||
|
@ -30,7 +30,7 @@ public class C18PacketSpectate implements Packet<NetHandlerPlayServer>
|
|||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(NetHandlerPlayServer handler)
|
||||
public void processPacket(ProxyHandler handler)
|
||||
{
|
||||
handler.handleSpectate(this);
|
||||
}
|
|
@ -1,12 +1,12 @@
|
|||
package proxy.packet.play.client;
|
||||
package proxy.packet;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import proxy.network.NetHandlerPlayServer;
|
||||
import proxy.network.ProxyHandler;
|
||||
import proxy.network.Packet;
|
||||
import proxy.network.PacketBuffer;
|
||||
|
||||
public class C19PacketResourcePackStatus implements Packet<NetHandlerPlayServer>
|
||||
public class C19PacketResourcePackStatus implements Packet<ProxyHandler>
|
||||
{
|
||||
private String hash;
|
||||
private C19PacketResourcePackStatus.Action status;
|
||||
|
@ -32,7 +32,7 @@ public class C19PacketResourcePackStatus implements Packet<NetHandlerPlayServer>
|
|||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(NetHandlerPlayServer handler)
|
||||
public void processPacket(ProxyHandler handler)
|
||||
{
|
||||
handler.handleResourcePackStatus(this);
|
||||
}
|
|
@ -1,24 +1,24 @@
|
|||
package proxy.packet.handshake.client;
|
||||
package proxy.packet;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import proxy.network.EnumConnectionState;
|
||||
import proxy.network.NetHandlerHandshake;
|
||||
import proxy.network.Protocol;
|
||||
import proxy.network.HandshakeHandler;
|
||||
import proxy.network.Packet;
|
||||
import proxy.network.PacketBuffer;
|
||||
|
||||
public class C00Handshake implements Packet<NetHandlerHandshake>
|
||||
public class H00PacketHandshake implements Packet<HandshakeHandler>
|
||||
{
|
||||
private int protocolVersion;
|
||||
private String ip;
|
||||
private int port;
|
||||
private EnumConnectionState requestedState;
|
||||
private Protocol requestedState;
|
||||
|
||||
public C00Handshake()
|
||||
public H00PacketHandshake()
|
||||
{
|
||||
}
|
||||
|
||||
public C00Handshake(int version, String ip, int port, EnumConnectionState requestedState)
|
||||
public H00PacketHandshake(int version, String ip, int port, Protocol requestedState)
|
||||
{
|
||||
this.protocolVersion = version;
|
||||
this.ip = ip;
|
||||
|
@ -34,7 +34,7 @@ public class C00Handshake implements Packet<NetHandlerHandshake>
|
|||
this.protocolVersion = buf.readVarIntFromBuffer();
|
||||
this.ip = buf.readStringFromBuffer(255);
|
||||
this.port = buf.readUnsignedShort();
|
||||
this.requestedState = EnumConnectionState.getById(buf.readVarIntFromBuffer());
|
||||
this.requestedState = Protocol.getById(buf.readVarIntFromBuffer());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -51,12 +51,12 @@ public class C00Handshake implements Packet<NetHandlerHandshake>
|
|||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(NetHandlerHandshake handler)
|
||||
public void processPacket(HandshakeHandler handler)
|
||||
{
|
||||
handler.processHandshake(this);
|
||||
}
|
||||
|
||||
public EnumConnectionState getRequestedState()
|
||||
public Protocol getRequestedState()
|
||||
{
|
||||
return this.requestedState;
|
||||
}
|
|
@ -1,20 +1,20 @@
|
|||
package proxy.packet.status.server;
|
||||
package proxy.packet;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import proxy.network.NetHandlerStatusClient;
|
||||
import proxy.network.StatusHandler;
|
||||
import proxy.network.Packet;
|
||||
import proxy.network.PacketBuffer;
|
||||
import proxy.util.ServerInfo;
|
||||
|
||||
public class S00PacketServerInfo implements Packet<NetHandlerStatusClient> {
|
||||
public class I00PacketServerInfo implements Packet<StatusHandler> {
|
||||
|
||||
private String response;
|
||||
|
||||
public S00PacketServerInfo() {
|
||||
public I00PacketServerInfo() {
|
||||
}
|
||||
|
||||
public S00PacketServerInfo(ServerInfo responseIn) {
|
||||
public I00PacketServerInfo(ServerInfo responseIn) {
|
||||
this.response = responseIn.serialize();
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,6 @@ public class S00PacketServerInfo implements Packet<NetHandlerStatusClient> {
|
|||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(NetHandlerStatusClient handler) {
|
||||
handler.handleServerInfo(this);
|
||||
public void processPacket(StatusHandler handler) {
|
||||
}
|
||||
}
|
|
@ -1,20 +1,20 @@
|
|||
package proxy.packet.status.server;
|
||||
package proxy.packet;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import proxy.network.NetHandlerStatusClient;
|
||||
import proxy.network.StatusHandler;
|
||||
import proxy.network.Packet;
|
||||
import proxy.network.PacketBuffer;
|
||||
|
||||
public class S01PacketPong implements Packet<NetHandlerStatusClient>
|
||||
public class I01PacketPong implements Packet<StatusHandler>
|
||||
{
|
||||
private long clientTime;
|
||||
|
||||
public S01PacketPong()
|
||||
public I01PacketPong()
|
||||
{
|
||||
}
|
||||
|
||||
public S01PacketPong(long time)
|
||||
public I01PacketPong(long time)
|
||||
{
|
||||
this.clientTime = time;
|
||||
}
|
||||
|
@ -38,8 +38,7 @@ public class S01PacketPong implements Packet<NetHandlerStatusClient>
|
|||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(NetHandlerStatusClient handler)
|
||||
public void processPacket(StatusHandler handler)
|
||||
{
|
||||
handler.handlePong(this);
|
||||
}
|
||||
}
|
|
@ -1,20 +1,20 @@
|
|||
package proxy.packet.login.client;
|
||||
package proxy.packet;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import proxy.network.NetHandlerLoginServer;
|
||||
import proxy.network.LoginHandler;
|
||||
import proxy.network.Packet;
|
||||
import proxy.network.PacketBuffer;
|
||||
|
||||
public class C00PacketLoginStart implements Packet<NetHandlerLoginServer>
|
||||
public class L00PacketLoginStart implements Packet<LoginHandler>
|
||||
{
|
||||
private String profile;
|
||||
|
||||
public C00PacketLoginStart()
|
||||
public L00PacketLoginStart()
|
||||
{
|
||||
}
|
||||
|
||||
public C00PacketLoginStart(String profileIn)
|
||||
public L00PacketLoginStart(String profileIn)
|
||||
{
|
||||
this.profile = profileIn;
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ public class C00PacketLoginStart implements Packet<NetHandlerLoginServer>
|
|||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(NetHandlerLoginServer handler)
|
||||
public void processPacket(LoginHandler handler)
|
||||
{
|
||||
handler.processLoginStart(this);
|
||||
}
|
|
@ -1,12 +1,12 @@
|
|||
package proxy.packet.login.client;
|
||||
package proxy.packet;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import proxy.network.NetHandlerLoginServer;
|
||||
import proxy.network.LoginHandler;
|
||||
import proxy.network.Packet;
|
||||
import proxy.network.PacketBuffer;
|
||||
|
||||
public class C01PacketEncryptionResponse implements Packet<NetHandlerLoginServer>
|
||||
public class L01PacketEncryptionResponse implements Packet<LoginHandler>
|
||||
{
|
||||
private byte[] secretKeyEncrypted = new byte[0];
|
||||
private byte[] verifyTokenEncrypted = new byte[0];
|
||||
|
@ -32,7 +32,7 @@ public class C01PacketEncryptionResponse implements Packet<NetHandlerLoginServer
|
|||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(NetHandlerLoginServer handler)
|
||||
public void processPacket(LoginHandler handler)
|
||||
{
|
||||
handler.processEncryptionResponse(this);
|
||||
}
|
|
@ -1,12 +1,12 @@
|
|||
package proxy.packet.status.client;
|
||||
package proxy.packet;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import proxy.network.NetHandlerStatusServer;
|
||||
import proxy.network.StatusHandler;
|
||||
import proxy.network.Packet;
|
||||
import proxy.network.PacketBuffer;
|
||||
|
||||
public class C00PacketServerQuery implements Packet<NetHandlerStatusServer>
|
||||
public class Q00PacketServerQuery implements Packet<StatusHandler>
|
||||
{
|
||||
/**
|
||||
* Reads the raw packet data from the data stream.
|
||||
|
@ -25,7 +25,7 @@ public class C00PacketServerQuery implements Packet<NetHandlerStatusServer>
|
|||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(NetHandlerStatusServer handler)
|
||||
public void processPacket(StatusHandler handler)
|
||||
{
|
||||
handler.processServerQuery(this);
|
||||
}
|
|
@ -1,20 +1,20 @@
|
|||
package proxy.packet.status.client;
|
||||
package proxy.packet;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import proxy.network.NetHandlerStatusServer;
|
||||
import proxy.network.StatusHandler;
|
||||
import proxy.network.Packet;
|
||||
import proxy.network.PacketBuffer;
|
||||
|
||||
public class C01PacketPing implements Packet<NetHandlerStatusServer>
|
||||
public class Q01PacketPing implements Packet<StatusHandler>
|
||||
{
|
||||
private long clientTime;
|
||||
|
||||
public C01PacketPing()
|
||||
public Q01PacketPing()
|
||||
{
|
||||
}
|
||||
|
||||
public C01PacketPing(long ping)
|
||||
public Q01PacketPing(long ping)
|
||||
{
|
||||
this.clientTime = ping;
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ public class C01PacketPing implements Packet<NetHandlerStatusServer>
|
|||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(NetHandlerStatusServer handler)
|
||||
public void processPacket(StatusHandler handler)
|
||||
{
|
||||
handler.processPing(this);
|
||||
}
|
|
@ -1,21 +1,21 @@
|
|||
package proxy.packet.login.server;
|
||||
package proxy.packet;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import proxy.network.NetHandlerPlayServer.ProxyLoginHandler;
|
||||
import proxy.network.ProxyHandler.ProxyLoginHandler;
|
||||
import proxy.network.Packet;
|
||||
import proxy.network.PacketBuffer;
|
||||
import proxy.util.ChatColor;
|
||||
|
||||
public class S00PacketDisconnect implements Packet<ProxyLoginHandler>
|
||||
public class R00PacketDisconnect implements Packet<ProxyLoginHandler>
|
||||
{
|
||||
private String reason;
|
||||
|
||||
public S00PacketDisconnect()
|
||||
public R00PacketDisconnect()
|
||||
{
|
||||
}
|
||||
|
||||
public S00PacketDisconnect(String reasonIn)
|
||||
public R00PacketDisconnect(String reasonIn)
|
||||
{
|
||||
this.reason = ChatColor.toJsonString(reasonIn);
|
||||
}
|
|
@ -1,12 +1,12 @@
|
|||
package proxy.packet.login.server;
|
||||
package proxy.packet;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import proxy.network.NetHandlerPlayServer.ProxyLoginHandler;
|
||||
import proxy.network.ProxyHandler.ProxyLoginHandler;
|
||||
import proxy.network.Packet;
|
||||
import proxy.network.PacketBuffer;
|
||||
|
||||
public class S01PacketEncryptionRequest implements Packet<ProxyLoginHandler>
|
||||
public class R01PacketEncryptionRequest implements Packet<ProxyLoginHandler>
|
||||
{
|
||||
private String hashedServerId;
|
||||
private byte[] publicKey;
|
|
@ -1,22 +1,22 @@
|
|||
package proxy.packet.login.server;
|
||||
package proxy.packet;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.UUID;
|
||||
|
||||
import proxy.network.NetHandlerPlayServer.ProxyLoginHandler;
|
||||
import proxy.network.ProxyHandler.ProxyLoginHandler;
|
||||
import proxy.network.Packet;
|
||||
import proxy.network.PacketBuffer;
|
||||
|
||||
public class S02PacketLoginSuccess implements Packet<ProxyLoginHandler>
|
||||
public class R02PacketLoginSuccess implements Packet<ProxyLoginHandler>
|
||||
{
|
||||
private UUID id;
|
||||
private String name;
|
||||
|
||||
public S02PacketLoginSuccess()
|
||||
public R02PacketLoginSuccess()
|
||||
{
|
||||
}
|
||||
|
||||
public S02PacketLoginSuccess(UUID id, String name)
|
||||
public R02PacketLoginSuccess(UUID id, String name)
|
||||
{
|
||||
this.id = id;
|
||||
this.name = name;
|
|
@ -1,20 +1,20 @@
|
|||
package proxy.packet.login.server;
|
||||
package proxy.packet;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import proxy.network.NetHandlerPlayServer.ProxyLoginHandler;
|
||||
import proxy.network.ProxyHandler.ProxyLoginHandler;
|
||||
import proxy.network.Packet;
|
||||
import proxy.network.PacketBuffer;
|
||||
|
||||
public class S03PacketEnableCompression implements Packet<ProxyLoginHandler>
|
||||
public class R03PacketEnableCompression implements Packet<ProxyLoginHandler>
|
||||
{
|
||||
private int compressionTreshold;
|
||||
|
||||
public S03PacketEnableCompression()
|
||||
public R03PacketEnableCompression()
|
||||
{
|
||||
}
|
||||
|
||||
public S03PacketEnableCompression(int compressionTresholdIn)
|
||||
public R03PacketEnableCompression(int compressionTresholdIn)
|
||||
{
|
||||
this.compressionTreshold = compressionTresholdIn;
|
||||
}
|
|
@ -1,12 +1,12 @@
|
|||
package proxy.packet.play.server;
|
||||
package proxy.packet;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import proxy.network.NetHandlerPlayServer;
|
||||
import proxy.network.ProxyHandler;
|
||||
import proxy.network.Packet;
|
||||
import proxy.network.PacketBuffer;
|
||||
|
||||
public class S00PacketKeepAlive implements Packet<NetHandlerPlayServer>
|
||||
public class S00PacketKeepAlive implements Packet<ProxyHandler>
|
||||
{
|
||||
private int id;
|
||||
|
||||
|
@ -22,7 +22,7 @@ public class S00PacketKeepAlive implements Packet<NetHandlerPlayServer>
|
|||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(NetHandlerPlayServer handler)
|
||||
public void processPacket(ProxyHandler handler)
|
||||
{
|
||||
handler.handleKeepAlive(this);
|
||||
}
|
|
@ -1,12 +1,12 @@
|
|||
package proxy.packet.play.server;
|
||||
package proxy.packet;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import proxy.network.NetHandlerPlayServer;
|
||||
import proxy.network.ProxyHandler;
|
||||
import proxy.network.Packet;
|
||||
import proxy.network.PacketBuffer;
|
||||
|
||||
public class S01PacketJoinGame implements Packet<NetHandlerPlayServer>
|
||||
public class S01PacketJoinGame implements Packet<ProxyHandler>
|
||||
{
|
||||
private int entityId;
|
||||
private boolean hardcoreMode;
|
||||
|
@ -74,7 +74,7 @@ public class S01PacketJoinGame implements Packet<NetHandlerPlayServer>
|
|||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(NetHandlerPlayServer handler)
|
||||
public void processPacket(ProxyHandler handler)
|
||||
{
|
||||
handler.handleJoinGame(this);
|
||||
}
|
|
@ -1,13 +1,13 @@
|
|||
package proxy.packet.play.server;
|
||||
package proxy.packet;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import proxy.network.NetHandlerPlayServer;
|
||||
import proxy.network.ProxyHandler;
|
||||
import proxy.network.Packet;
|
||||
import proxy.network.PacketBuffer;
|
||||
import proxy.util.ChatColor;
|
||||
|
||||
public class S02PacketChat implements Packet<NetHandlerPlayServer>
|
||||
public class S02PacketChat implements Packet<ProxyHandler>
|
||||
{
|
||||
private String chatComponent;
|
||||
private byte type;
|
||||
|
@ -43,7 +43,7 @@ public class S02PacketChat implements Packet<NetHandlerPlayServer>
|
|||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(NetHandlerPlayServer handler)
|
||||
public void processPacket(ProxyHandler handler)
|
||||
{
|
||||
handler.handleChat(this);
|
||||
}
|
|
@ -1,12 +1,12 @@
|
|||
package proxy.packet.play.server;
|
||||
package proxy.packet;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import proxy.network.NetHandlerPlayServer;
|
||||
import proxy.network.ProxyHandler;
|
||||
import proxy.network.Packet;
|
||||
import proxy.network.PacketBuffer;
|
||||
|
||||
public class S03PacketTimeUpdate implements Packet<NetHandlerPlayServer>
|
||||
public class S03PacketTimeUpdate implements Packet<ProxyHandler>
|
||||
{
|
||||
private long totalWorldTime;
|
||||
private long worldTime;
|
||||
|
@ -52,7 +52,7 @@ public class S03PacketTimeUpdate implements Packet<NetHandlerPlayServer>
|
|||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(NetHandlerPlayServer handler)
|
||||
public void processPacket(ProxyHandler handler)
|
||||
{
|
||||
handler.handleTimeUpdate(this);
|
||||
}
|
|
@ -1,13 +1,13 @@
|
|||
package proxy.packet.play.server;
|
||||
package proxy.packet;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import proxy.network.NetHandlerPlayServer;
|
||||
import proxy.network.ProxyHandler;
|
||||
import proxy.network.Packet;
|
||||
import proxy.network.PacketBuffer;
|
||||
import proxy.util.Stack;
|
||||
|
||||
public class S04PacketEntityEquipment implements Packet<NetHandlerPlayServer>
|
||||
public class S04PacketEntityEquipment implements Packet<ProxyHandler>
|
||||
{
|
||||
private int entityID;
|
||||
private int equipmentSlot;
|
||||
|
@ -36,7 +36,7 @@ public class S04PacketEntityEquipment implements Packet<NetHandlerPlayServer>
|
|||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(NetHandlerPlayServer handler)
|
||||
public void processPacket(ProxyHandler handler)
|
||||
{
|
||||
handler.handleEntityEquipment(this);
|
||||
}
|
|
@ -1,13 +1,13 @@
|
|||
package proxy.packet.play.server;
|
||||
package proxy.packet;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import proxy.network.NetHandlerPlayServer;
|
||||
import proxy.network.ProxyHandler;
|
||||
import proxy.network.Packet;
|
||||
import proxy.network.PacketBuffer;
|
||||
import proxy.util.Vec3;
|
||||
|
||||
public class S05PacketSpawnPosition implements Packet<NetHandlerPlayServer>
|
||||
public class S05PacketSpawnPosition implements Packet<ProxyHandler>
|
||||
{
|
||||
private Vec3 spawnBlockPos;
|
||||
|
||||
|
@ -30,7 +30,7 @@ public class S05PacketSpawnPosition implements Packet<NetHandlerPlayServer>
|
|||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(NetHandlerPlayServer handler)
|
||||
public void processPacket(ProxyHandler handler)
|
||||
{
|
||||
handler.handleSpawnPosition(this);
|
||||
}
|
|
@ -1,12 +1,12 @@
|
|||
package proxy.packet.play.server;
|
||||
package proxy.packet;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import proxy.network.NetHandlerPlayServer;
|
||||
import proxy.network.ProxyHandler;
|
||||
import proxy.network.Packet;
|
||||
import proxy.network.PacketBuffer;
|
||||
|
||||
public class S06PacketUpdateHealth implements Packet<NetHandlerPlayServer>
|
||||
public class S06PacketUpdateHealth implements Packet<ProxyHandler>
|
||||
{
|
||||
private float health;
|
||||
private int foodLevel;
|
||||
|
@ -35,7 +35,7 @@ public class S06PacketUpdateHealth implements Packet<NetHandlerPlayServer>
|
|||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(NetHandlerPlayServer handler)
|
||||
public void processPacket(ProxyHandler handler)
|
||||
{
|
||||
handler.handleUpdateHealth(this);
|
||||
}
|
|
@ -1,12 +1,12 @@
|
|||
package proxy.packet.play.server;
|
||||
package proxy.packet;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import proxy.network.NetHandlerPlayServer;
|
||||
import proxy.network.ProxyHandler;
|
||||
import proxy.network.Packet;
|
||||
import proxy.network.PacketBuffer;
|
||||
|
||||
public class S07PacketRespawn implements Packet<NetHandlerPlayServer>
|
||||
public class S07PacketRespawn implements Packet<ProxyHandler>
|
||||
{
|
||||
private int dimensionID;
|
||||
private byte difficulty;
|
||||
|
@ -28,7 +28,7 @@ public class S07PacketRespawn implements Packet<NetHandlerPlayServer>
|
|||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(NetHandlerPlayServer handler)
|
||||
public void processPacket(ProxyHandler handler)
|
||||
{
|
||||
handler.handleRespawn(this);
|
||||
}
|
|
@ -1,15 +1,15 @@
|
|||
package proxy.packet.play.server;
|
||||
package proxy.packet;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.Set;
|
||||
|
||||
import proxy.network.NetHandlerPlayServer;
|
||||
import proxy.network.ProxyHandler;
|
||||
import proxy.network.Packet;
|
||||
import proxy.network.PacketBuffer;
|
||||
|
||||
public class S08PacketPlayerPosLook implements Packet<NetHandlerPlayServer>
|
||||
public class S08PacketPlayerPosLook implements Packet<ProxyHandler>
|
||||
{
|
||||
private double x;
|
||||
private double y;
|
||||
|
@ -61,7 +61,7 @@ public class S08PacketPlayerPosLook implements Packet<NetHandlerPlayServer>
|
|||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(NetHandlerPlayServer handler)
|
||||
public void processPacket(ProxyHandler handler)
|
||||
{
|
||||
handler.handlePlayerPosLook(this);
|
||||
}
|
|
@ -1,12 +1,12 @@
|
|||
package proxy.packet.play.server;
|
||||
package proxy.packet;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import proxy.network.NetHandlerPlayServer;
|
||||
import proxy.network.ProxyHandler;
|
||||
import proxy.network.Packet;
|
||||
import proxy.network.PacketBuffer;
|
||||
|
||||
public class S09PacketHeldItemChange implements Packet<NetHandlerPlayServer>
|
||||
public class S09PacketHeldItemChange implements Packet<ProxyHandler>
|
||||
{
|
||||
private int heldItemHotbarIndex;
|
||||
|
||||
|
@ -29,7 +29,7 @@ public class S09PacketHeldItemChange implements Packet<NetHandlerPlayServer>
|
|||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(NetHandlerPlayServer handler)
|
||||
public void processPacket(ProxyHandler handler)
|
||||
{
|
||||
handler.handleHeldItemChange(this);
|
||||
}
|
|
@ -1,13 +1,13 @@
|
|||
package proxy.packet.play.server;
|
||||
package proxy.packet;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import proxy.network.NetHandlerPlayServer;
|
||||
import proxy.network.ProxyHandler;
|
||||
import proxy.network.Packet;
|
||||
import proxy.network.PacketBuffer;
|
||||
import proxy.util.Vec3;
|
||||
|
||||
public class S0APacketUseBed implements Packet<NetHandlerPlayServer>
|
||||
public class S0APacketUseBed implements Packet<ProxyHandler>
|
||||
{
|
||||
private int playerID;
|
||||
private Vec3 bedPos;
|
||||
|
@ -33,7 +33,7 @@ public class S0APacketUseBed implements Packet<NetHandlerPlayServer>
|
|||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(NetHandlerPlayServer handler)
|
||||
public void processPacket(ProxyHandler handler)
|
||||
{
|
||||
handler.handleUseBed(this);
|
||||
}
|
|
@ -1,12 +1,12 @@
|
|||
package proxy.packet.play.server;
|
||||
package proxy.packet;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import proxy.network.NetHandlerPlayServer;
|
||||
import proxy.network.ProxyHandler;
|
||||
import proxy.network.Packet;
|
||||
import proxy.network.PacketBuffer;
|
||||
|
||||
public class S0BPacketAnimation implements Packet<NetHandlerPlayServer>
|
||||
public class S0BPacketAnimation implements Packet<ProxyHandler>
|
||||
{
|
||||
private int entityId;
|
||||
private int type;
|
||||
|
@ -32,7 +32,7 @@ public class S0BPacketAnimation implements Packet<NetHandlerPlayServer>
|
|||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(NetHandlerPlayServer handler)
|
||||
public void processPacket(ProxyHandler handler)
|
||||
{
|
||||
handler.handleAnimation(this);
|
||||
}
|
|
@ -1,15 +1,15 @@
|
|||
package proxy.packet.play.server;
|
||||
package proxy.packet;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import proxy.network.NetHandlerPlayServer;
|
||||
import proxy.network.ProxyHandler;
|
||||
import proxy.network.Packet;
|
||||
import proxy.network.PacketBuffer;
|
||||
import proxy.util.EntityData;
|
||||
|
||||
public class S0CPacketSpawnPlayer implements Packet<NetHandlerPlayServer>
|
||||
public class S0CPacketSpawnPlayer implements Packet<ProxyHandler>
|
||||
{
|
||||
private int entityId;
|
||||
private UUID playerId;
|
||||
|
@ -56,7 +56,7 @@ public class S0CPacketSpawnPlayer implements Packet<NetHandlerPlayServer>
|
|||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(NetHandlerPlayServer handler)
|
||||
public void processPacket(ProxyHandler handler)
|
||||
{
|
||||
handler.handleSpawnPlayer(this);
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue