JavaDoc for quite a lot of the API classes... yay

This commit is contained in:
Myles 2016-03-22 18:02:46 +00:00
parent eccbb567e8
commit af53275ab9
30 changed files with 474 additions and 61 deletions

View File

@ -8,9 +8,6 @@ import io.netty.channel.socket.SocketChannel;
import lombok.NonNull; import lombok.NonNull;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import us.myles.ViaVersion.api.ViaVersion; import us.myles.ViaVersion.api.ViaVersion;
import us.myles.ViaVersion.api.ViaVersionAPI; import us.myles.ViaVersion.api.ViaVersionAPI;
@ -20,12 +17,10 @@ import us.myles.ViaVersion.api.boss.BossColor;
import us.myles.ViaVersion.api.boss.BossStyle; import us.myles.ViaVersion.api.boss.BossStyle;
import us.myles.ViaVersion.api.data.UserConnection; import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.protocol.ProtocolRegistry; import us.myles.ViaVersion.api.protocol.ProtocolRegistry;
import us.myles.ViaVersion.protocols.base.ProtocolInfo;
import us.myles.ViaVersion.boss.ViaBossBar; import us.myles.ViaVersion.boss.ViaBossBar;
import us.myles.ViaVersion.commands.ViaVersionCommand; import us.myles.ViaVersion.commands.ViaVersionCommand;
import us.myles.ViaVersion.handlers.ViaVersionInitializer; import us.myles.ViaVersion.handlers.ViaVersionInitializer;
import us.myles.ViaVersion.protocols.protocol1_9to1_8.listeners.ArmorListener; import us.myles.ViaVersion.protocols.base.ProtocolInfo;
import us.myles.ViaVersion.protocols.protocol1_9to1_8.listeners.CommandBlockListener;
import us.myles.ViaVersion.update.UpdateListener; import us.myles.ViaVersion.update.UpdateListener;
import us.myles.ViaVersion.update.UpdateUtil; import us.myles.ViaVersion.update.UpdateUtil;
import us.myles.ViaVersion.util.Configuration; import us.myles.ViaVersion.util.Configuration;
@ -248,11 +243,11 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaVersionAPI, ViaVe
return getDescription().getVersion(); return getDescription().getVersion();
} }
public UserConnection getConnection(UUID playerUUID){ public UserConnection getConnection(UUID playerUUID) {
return portedPlayers.get(playerUUID); return portedPlayers.get(playerUUID);
} }
public UserConnection getConnection(Player player){ public UserConnection getConnection(Player player) {
return portedPlayers.get(player.getUniqueId()); return portedPlayers.get(player.getUniqueId());
} }

View File

@ -31,6 +31,13 @@ public class PacketWrapper {
this.userConnection = userConnection; this.userConnection = userConnection;
} }
/**
* Get a part from the output
*
* @param type The type of the part you wish to get.
* @param index The index of the part (relative to the type)
* @return The requested type or throws ArrayIndexOutOfBounds
*/
public <T> T get(Type<T> type, int index) { public <T> T get(Type<T> type, int index) {
int currentIndex = 0; int currentIndex = 0;
for (Pair<Type, Object> packetValue : packetValues) { for (Pair<Type, Object> packetValue : packetValues) {
@ -44,6 +51,13 @@ public class PacketWrapper {
throw new ArrayIndexOutOfBoundsException("Could not find type " + type.getTypeName() + " at " + index); throw new ArrayIndexOutOfBoundsException("Could not find type " + type.getTypeName() + " at " + index);
} }
/**
* Set a currently existing part in the output
*
* @param type The type of the part you wish to set.
* @param index The index of the part (relative to the type)
* @param value The value of the part you wish to set it to.
*/
public <T> void set(Type<T> type, int index, T value) { public <T> void set(Type<T> type, int index, T value) {
int currentIndex = 0; int currentIndex = 0;
for (Pair<Type, Object> packetValue : packetValues) { for (Pair<Type, Object> packetValue : packetValues) {
@ -58,6 +72,13 @@ public class PacketWrapper {
throw new ArrayIndexOutOfBoundsException("Could not find type " + type.getTypeName() + " at " + index); throw new ArrayIndexOutOfBoundsException("Could not find type " + type.getTypeName() + " at " + index);
} }
/**
* Read a type from the input.
*
* @param type The type you wish to read
* @return The requested type
* @throws Exception If it fails to read
*/
public <T> T read(Type<T> type) throws Exception { public <T> T read(Type<T> type) throws Exception {
if (type == Type.NOTHING) return null; if (type == Type.NOTHING) return null;
if (readableObjects.isEmpty()) { if (readableObjects.isEmpty()) {
@ -78,17 +99,35 @@ public class PacketWrapper {
} }
} }
/**
* Write a type to the output.
*
* @param type The type to write.
* @param value The value of the type to write.
*/
public <T> void write(Type<T> type, T value) { public <T> void write(Type<T> type, T value) {
packetValues.add(new Pair<Type, Object>(type, value)); packetValues.add(new Pair<Type, Object>(type, value));
} }
/**
* Take a value from the input and write to the output.
*
* @param type The type to read and write.
* @return The type which was read/written.
* @throws Exception If it failed to read or write
*/
public <T> T passthrough(Type<T> type) throws Exception { public <T> T passthrough(Type<T> type) throws Exception {
T value = read(type); T value = read(type);
write(type, value); write(type, value);
return value; return value;
} }
/**
* Write the current output to a buffer.
*
* @param buffer The buffer to write to.
* @throws Exception Throws an exception if it fails to write a value.
*/
public void writeToBuffer(ByteBuf buffer) throws Exception { public void writeToBuffer(ByteBuf buffer) throws Exception {
if (id != -1) { if (id != -1) {
Type.VAR_INT.write(buffer, id); Type.VAR_INT.write(buffer, id);
@ -121,6 +160,9 @@ public class PacketWrapper {
writeRemaining(buffer); writeRemaining(buffer);
} }
/**
* Clear the input buffer / readable objects
*/
public void clearInputBuffer() { public void clearInputBuffer() {
if (inputBuffer != null) if (inputBuffer != null)
inputBuffer.clear(); inputBuffer.clear();
@ -133,34 +175,72 @@ public class PacketWrapper {
} }
} }
/**
* Send this packet to the associated user.
* Be careful not to send packets twice.
*
* @throws Exception if it fails to write
*/
public void send() throws Exception { public void send() throws Exception {
if (!isCancelled()) {
ByteBuf output = inputBuffer == null ? Unpooled.buffer() : inputBuffer.alloc().buffer(); ByteBuf output = inputBuffer == null ? Unpooled.buffer() : inputBuffer.alloc().buffer();
writeToBuffer(output); writeToBuffer(output);
user().sendRawPacket(output); user().sendRawPacket(output);
} }
}
public PacketWrapper create(int packetID) throws Exception { /**
* Create a new packet for the target of this packet.
*
* @param packetID The ID of the new packet
* @return The newly created packet wrapper
*/
public PacketWrapper create(int packetID) {
return new PacketWrapper(packetID, null, user()); return new PacketWrapper(packetID, null, user());
} }
/**
* Create a new packet with values.
*
* @param packetID The ID of the new packet
* @param init A ValueCreator to write to the packet.
* @return The newly created packet wrapper
* @throws Exception If it failed to write the values from the ValueCreator.
*/
public PacketWrapper create(int packetID, ValueCreator init) throws Exception { public PacketWrapper create(int packetID, ValueCreator init) throws Exception {
PacketWrapper wrapper = create(packetID); PacketWrapper wrapper = create(packetID);
init.write(wrapper); init.write(wrapper);
return wrapper; return wrapper;
} }
/**
* Cancel this packet from sending
*/
public void cancel() { public void cancel() {
this.send = false; this.send = false;
} }
/**
* Check if this packet is cancelled.
*
* @return True if the packet won't be sent.
*/
public boolean isCancelled() { public boolean isCancelled() {
return !this.send; return !this.send;
} }
/**
* Get the user associated with this Packet
*
* @return The user
*/
public UserConnection user() { public UserConnection user() {
return this.userConnection; return this.userConnection;
} }
/**
* Reset the reader, so that it can be read again.
*/
public void resetReader() { public void resetReader() {
this.readableObjects.addAll(packetValues); this.readableObjects.addAll(packetValues);
this.packetValues.clear(); this.packetValues.clear();

View File

@ -1,7 +1,6 @@
package us.myles.ViaVersion.api; package us.myles.ViaVersion.api;
import lombok.Getter; import lombok.Getter;
import lombok.Setter;
import us.myles.ViaVersion.ViaVersionPlugin; import us.myles.ViaVersion.ViaVersionPlugin;
public class ViaVersion { public class ViaVersion {

View File

@ -6,8 +6,6 @@ import io.netty.channel.socket.SocketChannel;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import java.util.ArrayList;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
@ -27,18 +25,41 @@ public class UserConnection {
this.channel = socketChannel; this.channel = socketChannel;
} }
/**
* Get an object from the storage
*
* @param objectClass The class of the object to get
* @return The requested object
*/
public <T extends StoredObject> T get(Class<T> objectClass) { public <T extends StoredObject> T get(Class<T> objectClass) {
return (T) storedObjects.get(objectClass); return (T) storedObjects.get(objectClass);
} }
public <T extends StoredObject> boolean has(Class<T> objectClass) { /**
* Check if the storage has an object
*
* @param objectClass The object class to check
* @return True if the object is in the storage
*/
public boolean has(Class<? extends StoredObject> objectClass) {
return storedObjects.containsKey(objectClass); return storedObjects.containsKey(objectClass);
} }
/**
* Put an object into the stored objects based on class
*
* @param object The object to store.
*/
public void put(StoredObject object) { public void put(StoredObject object) {
storedObjects.put(object.getClass(), object); storedObjects.put(object.getClass(), object);
} }
/**
* Send a raw packet to the player
*
* @param packet The raw packet to send
* @param currentThread Should it run in the same thread
*/
public void sendRawPacket(final ByteBuf packet, boolean currentThread) { public void sendRawPacket(final ByteBuf packet, boolean currentThread) {
final ChannelHandler handler = channel.pipeline().get("encoder"); final ChannelHandler handler = channel.pipeline().get("encoder");
if (currentThread) { if (currentThread) {
@ -53,6 +74,11 @@ public class UserConnection {
} }
} }
/**
* Send a raw packet to the player (netty thread)
*
* @param packet The packet to send
*/
public void sendRawPacket(final ByteBuf packet) { public void sendRawPacket(final ByteBuf packet) {
sendRawPacket(packet, false); sendRawPacket(packet, false);
} }

View File

@ -25,6 +25,11 @@ public class Chunk {
this.unloadPacket = true; this.unloadPacket = true;
} }
/**
* Does this chunk have biome data
*
* @return True if the chunk has biome data
*/
public boolean hasBiomeData() { public boolean hasBiomeData() {
return biomeData != null && groundUp; return biomeData != null && groundUp;
} }

View File

@ -31,10 +31,26 @@ public class ChunkSection {
palette.add(0); // AIR palette.add(0); // AIR
} }
/**
* Set a block in the chunk
*
* @param x Block X
* @param y Block Y
* @param z Block Z
* @param type The type of the block
* @param data The data value of the block
*/
public void setBlock(int x, int y, int z, int type, int data) { public void setBlock(int x, int y, int z, int type, int data) {
setBlock(index(x, y, z), type, data); setBlock(index(x, y, z), type, data);
} }
/**
* Set a block in the chunk based on the index
*
* @param idx Index
* @param type The type of the block
* @param data The data value of the block
*/
public void setBlock(int idx, int type, int data) { public void setBlock(int idx, int type, int data) {
int hash = type << 4 | (data & 0xF); int hash = type << 4 | (data & 0xF);
int index = palette.indexOf(hash); int index = palette.indexOf(hash);
@ -46,10 +62,20 @@ public class ChunkSection {
blocks[idx] = index; blocks[idx] = index;
} }
/**
* Set the block light array
*
* @param data The value to set the block light to
*/
public void setBlockLight(byte[] data) { public void setBlockLight(byte[] data) {
blockLight.setHandle(data); blockLight.setHandle(data);
} }
/**
* Set the sky light array
*
* @param data The value to set the sky light to
*/
public void setSkyLight(byte[] data) { public void setSkyLight(byte[] data) {
if (data.length != LIGHT_LENGTH) throw new IllegalArgumentException("Data length != " + LIGHT_LENGTH); if (data.length != LIGHT_LENGTH) throw new IllegalArgumentException("Data length != " + LIGHT_LENGTH);
this.skyLight = new NibbleArray(data); this.skyLight = new NibbleArray(data);
@ -59,6 +85,12 @@ public class ChunkSection {
return z << 8 | y << 4 | x; return z << 8 | y << 4 | x;
} }
/**
* Write the blocks to a buffer.
*
* @param output The buffer to write to.
* @throws Exception Throws if it failed to write.
*/
public void writeBlocks(ByteBuf output) throws Exception { public void writeBlocks(ByteBuf output) throws Exception {
// Write bits per block // Write bits per block
int bitsPerBlock = 4; int bitsPerBlock = 4;
@ -94,14 +126,29 @@ public class ChunkSection {
} }
} }
/**
* Write the block light to a buffer
*
* @param output The buffer to write to
*/
public void writeBlockLight(ByteBuf output) { public void writeBlockLight(ByteBuf output) {
output.writeBytes(blockLight.getHandle()); output.writeBytes(blockLight.getHandle());
} }
/**
* Write the sky light to a buffer
*
* @param output The buffer to write to
*/
public void writeSkyLight(ByteBuf output) { public void writeSkyLight(ByteBuf output) {
output.writeBytes(skyLight.getHandle()); output.writeBytes(skyLight.getHandle());
} }
/**
* Check if sky light is present
*
* @return True if skylight is present
*/
public boolean hasSkyLight() { public boolean hasSkyLight() {
return skyLight != null; return skyLight != null;
} }

View File

@ -21,10 +21,24 @@ public class NibbleArray {
this.handle = handle; this.handle = handle;
} }
/**
* Get the value at a desired X, Y, Z
*
* @param x Block X
* @param y Block Y
* @param z Block Z
* @return The value at the given XYZ
*/
public byte get(int x, int y, int z) { public byte get(int x, int y, int z) {
return get(y << 8 | z << 4 | x); return get(y << 8 | z << 4 | x);
} }
/**
* Get the value at an index
*
* @param index The index to lookup
* @return The value at that index.
*/
public byte get(int index) { public byte get(int index) {
byte value = handle[index / 2]; byte value = handle[index / 2];
if (index % 2 == 0) { if (index % 2 == 0) {
@ -34,10 +48,24 @@ public class NibbleArray {
} }
} }
/**
* Set the value based on an x, y, z
*
* @param x Block X
* @param y Block Y
* @param z Block Z
* @param value Desired Value
*/
public void set(int x, int y, int z, int value) { public void set(int x, int y, int z, int value) {
set(y << 8 | z << 4 | x, value); set(y << 8 | z << 4 | x, value);
} }
/**
* Set a value at an index
*
* @param index The index to set the value at.
* @param value The desired value
*/
public void set(int index, int value) { public void set(int index, int value) {
index /= 2; index /= 2;
if (index % 2 == 0) { if (index % 2 == 0) {
@ -47,23 +75,48 @@ public class NibbleArray {
} }
} }
/**
* The size of this nibble
*
* @return The size as an int of the nibble
*/
public int size() { public int size() {
return handle.length * 2; return handle.length * 2;
} }
/**
* Get the actual number of bytes
*
* @return The number of bytes based on the handle.
*/
public int actualSize() { public int actualSize() {
return handle.length; return handle.length;
} }
/**
* Fill the array with a value
*
* @param value Value to fill with
*/
public void fill(byte value) { public void fill(byte value) {
value &= 0xF; // Max nibble size (= 16) value &= 0xF; // Max nibble size (= 16)
Arrays.fill(handle, (byte) ((value << 4) | value)); Arrays.fill(handle, (byte) ((value << 4) | value));
} }
/**
* Get the byte array behind this nibble
*
* @return The byte array
*/
public byte[] getHandle() { public byte[] getHandle() {
return handle; return handle;
} }
/**
* Copy a byte array into this nibble
*
* @param handle The byte array to copy in.
*/
public void setHandle(byte[] handle) { public void setHandle(byte[] handle) {
if (handle.length != this.handle.length) { if (handle.length != this.handle.length) {
throw new IllegalArgumentException("Length of handle must equal to size of nibble array!"); throw new IllegalArgumentException("Length of handle must equal to size of nibble array!");

View File

@ -17,6 +17,12 @@ public class Item {
private short data; private short data;
private CompoundTag tag; private CompoundTag tag;
/**
* Create an item from a bukkit stack (doesn't save NBT)
*
* @param stack The stack to convert from
* @return The output stack
*/
public static Item getItem(ItemStack stack) { public static Item getItem(ItemStack stack) {
if (stack == null) return null; if (stack == null) return null;
return new Item((short) stack.getTypeId(), (byte) stack.getAmount(), stack.getDurability(), null); return new Item((short) stack.getTypeId(), (byte) stack.getAmount(), stack.getDurability(), null);

View File

@ -23,40 +23,104 @@ public abstract class Protocol {
registerListeners(); registerListeners();
} }
/**
* Should this protocol filter an object packet from this class.
* Default: false
*
* @param packetClass The class of the current input
* @return True if it should handle the filtering
*/
public boolean isFiltered(Class packetClass) { public boolean isFiltered(Class packetClass) {
return false; return false;
} }
/**
* Filter a packet into the output
*
* @param info The current user connection
* @param packet The input packet as an object (NMS)
* @param output The list to put the object into.
* @throws Exception Throws exception if cancelled / error.
*/
protected void filterPacket(UserConnection info, Object packet, List output) throws Exception { protected void filterPacket(UserConnection info, Object packet, List output) throws Exception {
output.add(packet); output.add(packet);
} }
/**
* Register listeners for this protocol
*/
protected void registerListeners() { protected void registerListeners() {
} }
/**
* Register the packets for this protocol
*/
protected abstract void registerPackets(); protected abstract void registerPackets();
/**
* Initialise a user for this protocol setting up objects.
*
* @param userConnection The user to initialise
*/
public abstract void init(UserConnection userConnection); public abstract void init(UserConnection userConnection);
/**
* Register an incoming packet, with simple id transformation.
*
* @param state The state which the packet is sent in.
* @param oldPacketID The old packet ID
* @param newPacketID The new packet ID
*/
public void registerIncoming(State state, int oldPacketID, int newPacketID) { public void registerIncoming(State state, int oldPacketID, int newPacketID) {
registerIncoming(state, oldPacketID, newPacketID, null); registerIncoming(state, oldPacketID, newPacketID, null);
} }
/**
* Register an incoming packet, with id transformation and remapper.
*
* @param state The state which the packet is sent in.
* @param oldPacketID The old packet ID
* @param newPacketID The new packet ID
* @param packetRemapper The remapper to use for the packet
*/
public void registerIncoming(State state, int oldPacketID, int newPacketID, PacketRemapper packetRemapper) { public void registerIncoming(State state, int oldPacketID, int newPacketID, PacketRemapper packetRemapper) {
ProtocolPacket protocolPacket = new ProtocolPacket(state, oldPacketID, newPacketID, packetRemapper); ProtocolPacket protocolPacket = new ProtocolPacket(state, oldPacketID, newPacketID, packetRemapper);
incoming.put(new Pair<>(state, newPacketID), protocolPacket); incoming.put(new Pair<>(state, newPacketID), protocolPacket);
} }
/**
* Register an outgoing packet, with simple id transformation.
*
* @param state The state which the packet is sent in.
* @param oldPacketID The old packet ID
* @param newPacketID The new packet ID
*/
public void registerOutgoing(State state, int oldPacketID, int newPacketID) { public void registerOutgoing(State state, int oldPacketID, int newPacketID) {
registerOutgoing(state, oldPacketID, newPacketID, null); registerOutgoing(state, oldPacketID, newPacketID, null);
} }
/**
* Register an outgoing packet, with id transformation and remapper.
*
* @param state The state which the packet is sent in.
* @param oldPacketID The old packet ID
* @param newPacketID The new packet ID
* @param packetRemapper The remapper to use for the packet
*/
public void registerOutgoing(State state, int oldPacketID, int newPacketID, PacketRemapper packetRemapper) { public void registerOutgoing(State state, int oldPacketID, int newPacketID, PacketRemapper packetRemapper) {
ProtocolPacket protocolPacket = new ProtocolPacket(state, oldPacketID, newPacketID, packetRemapper); ProtocolPacket protocolPacket = new ProtocolPacket(state, oldPacketID, newPacketID, packetRemapper);
outgoing.put(new Pair<>(state, oldPacketID), protocolPacket); outgoing.put(new Pair<>(state, oldPacketID), protocolPacket);
} }
/**
* Transform a packet using this protocol
*
* @param direction The direction the packet is going in
* @param state The current protocol state
* @param packetWrapper The packet wrapper to transform
* @throws Exception Throws exception if it fails to transform
*/
public void transform(Direction direction, State state, PacketWrapper packetWrapper) throws Exception { public void transform(Direction direction, State state, PacketWrapper packetWrapper) throws Exception {
Pair<State, Integer> statePacket = new Pair<>(state, packetWrapper.getId()); Pair<State, Integer> statePacket = new Pair<>(state, packetWrapper.getId());
Map<Pair<State, Integer>, ProtocolPacket> packetMap = (direction == Direction.OUTGOING ? outgoing : incoming); Map<Pair<State, Integer>, ProtocolPacket> packetMap = (direction == Direction.OUTGOING ? outgoing : incoming);

View File

@ -47,6 +47,12 @@ public class ProtocolPipeline extends Protocol {
} }
} }
/**
* Add a protocol to the current pipeline
* This will call the .init method.
*
* @param protocol The protocol to add to the end
*/
public void add(Protocol protocol) { public void add(Protocol protocol) {
if (protocolList != null) { if (protocolList != null) {
protocolList.addLast(protocol); protocolList.addLast(protocol);
@ -95,16 +101,16 @@ public class ProtocolPipeline extends Protocol {
} }
// Filter :) This would be not hard coded too, sorry :( // Filter :) This would be not hard coded too, sorry :(
if(type == PacketType.PLAY_CHUNK_DATA) return; if (type == PacketType.PLAY_CHUNK_DATA) return;
if(type == PacketType.PLAY_TIME_UPDATE) return; if (type == PacketType.PLAY_TIME_UPDATE) return;
if(type == PacketType.PLAY_KEEP_ALIVE) return; if (type == PacketType.PLAY_KEEP_ALIVE) return;
if(type == PacketType.PLAY_KEEP_ALIVE_REQUEST) return; if (type == PacketType.PLAY_KEEP_ALIVE_REQUEST) return;
if(type == PacketType.PLAY_ENTITY_LOOK_MOVE) return; if (type == PacketType.PLAY_ENTITY_LOOK_MOVE) return;
if(type == PacketType.PLAY_ENTITY_LOOK) return; if (type == PacketType.PLAY_ENTITY_LOOK) return;
if(type == PacketType.PLAY_ENTITY_RELATIVE_MOVE) return; if (type == PacketType.PLAY_ENTITY_RELATIVE_MOVE) return;
if(type == PacketType.PLAY_PLAYER_POSITION_LOOK_REQUEST) return; if (type == PacketType.PLAY_PLAYER_POSITION_LOOK_REQUEST) return;
if(type == PacketType.PLAY_PLAYER_LOOK_REQUEST) return; if (type == PacketType.PLAY_PLAYER_LOOK_REQUEST) return;
if(type == PacketType.PLAY_PLAYER_POSITION_REQUEST) return; if (type == PacketType.PLAY_PLAYER_POSITION_REQUEST) return;
packet = type.name(); packet = type.name();
} }
@ -121,6 +127,12 @@ public class ProtocolPipeline extends Protocol {
} }
} }
/**
* Check if the pipeline contains a protocol
*
* @param pipeClass The class to check
* @return True if the protocol class is in the pipeline
*/
public boolean contains(Class<? extends Protocol> pipeClass) { public boolean contains(Class<? extends Protocol> pipeClass) {
for (Protocol protocol : protocolList) { for (Protocol protocol : protocolList) {
if (protocol.getClass().equals(pipeClass)) return true; if (protocol.getClass().equals(pipeClass)) return true;
@ -128,6 +140,14 @@ public class ProtocolPipeline extends Protocol {
return false; return false;
} }
/**
* Use the pipeline to filter a NMS packet
*
* @param o The NMS packet object
* @param list The output list to write to
* @return If it should not write the input object to te list.
* @throws Exception If it failed to convert / packet cancelld.
*/
public boolean filter(Object o, List list) throws Exception { public boolean filter(Object o, List list) throws Exception {
for (Protocol protocol : protocolList) { for (Protocol protocol : protocolList) {
if (protocol.isFiltered(o.getClass())) { if (protocol.isFiltered(o.getClass())) {

View File

@ -1,8 +1,8 @@
package us.myles.ViaVersion.api.protocol; package us.myles.ViaVersion.api.protocol;
import us.myles.ViaVersion.api.Pair;
import us.myles.ViaVersion.protocols.protocol1_9_1to1_9.Protocol1_9_1TO1_9; import us.myles.ViaVersion.protocols.protocol1_9_1to1_9.Protocol1_9_1TO1_9;
import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9TO1_8; import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9TO1_8;
import us.myles.ViaVersion.api.Pair;
import java.util.*; import java.util.*;
@ -17,6 +17,13 @@ public class ProtocolRegistry {
registerProtocol(new Protocol1_9_1TO1_9(), Collections.singletonList(ProtocolVersion.V1_9_1_PRE2), ProtocolVersion.V1_9); registerProtocol(new Protocol1_9_1TO1_9(), Collections.singletonList(ProtocolVersion.V1_9_1_PRE2), ProtocolVersion.V1_9);
} }
/**
* Register a protocol
*
* @param protocol The protocol to register.
* @param supported Supported client versions.
* @param output The output server version it converts to.
*/
public static void registerProtocol(Protocol protocol, List<Integer> supported, Integer output) { public static void registerProtocol(Protocol protocol, List<Integer> supported, Integer output) {
for (Integer version : supported) { for (Integer version : supported) {
if (!registryMap.containsKey(version)) { if (!registryMap.containsKey(version)) {
@ -27,6 +34,11 @@ public class ProtocolRegistry {
} }
} }
/**
* Check if this plugin is useful to the server.
*
* @return True if there is a useful pipe
*/
public static boolean isWorkingPipe() { public static boolean isWorkingPipe() {
for (Map<Integer, Protocol> maps : registryMap.values()) { for (Map<Integer, Protocol> maps : registryMap.values()) {
if (maps.containsKey(SERVER_PROTOCOL)) return true; if (maps.containsKey(SERVER_PROTOCOL)) return true;
@ -34,6 +46,14 @@ public class ProtocolRegistry {
return false; // No destination for protocol return false; // No destination for protocol
} }
/**
* Calculate a path to get from an input protocol to the servers protocol.
*
* @param current The current items in the path
* @param clientVersion The current input version
* @param serverVersion The desired output version
* @return The path which has been generated, null if failed.
*/
private static List<Pair<Integer, Protocol>> getProtocolPath(List<Pair<Integer, Protocol>> current, int clientVersion, int serverVersion) { private static List<Pair<Integer, Protocol>> getProtocolPath(List<Pair<Integer, Protocol>> current, int clientVersion, int serverVersion) {
if (current.size() > 50) return null; // Fail safe, protocol too complicated. if (current.size() > 50) return null; // Fail safe, protocol too complicated.
@ -69,7 +89,15 @@ public class ProtocolRegistry {
return null; return null;
} }
/**
* Calculate a path from a client version to server version
*
* @param clientVersion The input client version
* @param serverVersion The desired output server version
* @return The path it generated, null if it failed.
*/
public static List<Pair<Integer, Protocol>> getProtocolPath(int clientVersion, int serverVersion) { public static List<Pair<Integer, Protocol>> getProtocolPath(int clientVersion, int serverVersion) {
// TODO: Cache
return getProtocolPath(new ArrayList<Pair<Integer, Protocol>>(), clientVersion, serverVersion); return getProtocolPath(new ArrayList<Pair<Integer, Protocol>>(), clientVersion, serverVersion);
} }
} }

View File

@ -3,6 +3,12 @@ package us.myles.ViaVersion.api.remapper;
import us.myles.ViaVersion.api.PacketWrapper; import us.myles.ViaVersion.api.PacketWrapper;
public abstract class PacketHandler implements ValueWriter { public abstract class PacketHandler implements ValueWriter {
/**
* Handle a packet
*
* @param wrapper The associated wrapper
* @throws Exception Throws exception if it failed to handle the packet
*/
public abstract void handle(PacketWrapper wrapper) throws Exception; public abstract void handle(PacketWrapper wrapper) throws Exception;
@Override @Override

View File

@ -1,8 +1,8 @@
package us.myles.ViaVersion.api.remapper; package us.myles.ViaVersion.api.remapper;
import us.myles.ViaVersion.api.PacketWrapper; import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.api.Pair; import us.myles.ViaVersion.api.Pair;
import us.myles.ViaVersion.api.type.Type;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -14,33 +14,75 @@ public abstract class PacketRemapper {
registerMap(); registerMap();
} }
/**
* Map a type to the same type.
*
* @param type Type to map
*/
public void map(Type type) { public void map(Type type) {
TypeRemapper remapper = new TypeRemapper(type); TypeRemapper remapper = new TypeRemapper(type);
map(remapper, remapper); map(remapper, remapper);
} }
/**
* Map a type from an old type to a new type
*
* @param oldType The old type
* @param newType The new type
*/
public void map(Type oldType, Type newType) { public void map(Type oldType, Type newType) {
map(new TypeRemapper(oldType), new TypeRemapper(newType)); map(new TypeRemapper(oldType), new TypeRemapper(newType));
} }
/**
* Map a type from an old type to a transformed new type.
*
* @param oldType The old type
* @param transformer The transformer to use to produce the new type.
*/
public <T1, T2> void map(Type<T1> oldType, ValueTransformer<T1, T2> transformer) { public <T1, T2> void map(Type<T1> oldType, ValueTransformer<T1, T2> transformer) {
map(new TypeRemapper(oldType), transformer); map(new TypeRemapper(oldType), transformer);
} }
/**
* Map a type using a basic ValueReader to a ValueWriter
*
* @param inputReader The reader to read with.
* @param outputWriter The writer to write with.
*/
public <T> void map(ValueReader<T> inputReader, ValueWriter<T> outputWriter) { public <T> void map(ValueReader<T> inputReader, ValueWriter<T> outputWriter) {
valueRemappers.add(new Pair<ValueReader, ValueWriter>(inputReader, outputWriter)); valueRemappers.add(new Pair<ValueReader, ValueWriter>(inputReader, outputWriter));
} }
/**
* Create a value
*
* @param creator The creator to used to make the value(s).
*/
public void create(ValueCreator creator) { public void create(ValueCreator creator) {
map(new TypeRemapper(Type.NOTHING), creator); map(new TypeRemapper(Type.NOTHING), creator);
} }
/**
* Create a handler
*
* @param handler The handler to use to handle the current packet.
*/
public void handler(PacketHandler handler) { public void handler(PacketHandler handler) {
map(new TypeRemapper(Type.NOTHING), handler); map(new TypeRemapper(Type.NOTHING), handler);
} }
/**
* Register the mappings for this packet
*/
public abstract void registerMap(); public abstract void registerMap();
/**
* Remap a packet wrapper
*
* @param packetWrapper The wrapper to remap
* @throws Exception Throws if it fails to write / read to the packet.
*/
public void remap(PacketWrapper packetWrapper) throws Exception { public void remap(PacketWrapper packetWrapper) throws Exception {
// Read all the current values // Read all the current values
for (Pair<ValueReader, ValueWriter> valueRemapper : valueRemappers) { for (Pair<ValueReader, ValueWriter> valueRemapper : valueRemappers) {

View File

@ -3,6 +3,12 @@ package us.myles.ViaVersion.api.remapper;
import us.myles.ViaVersion.api.PacketWrapper; import us.myles.ViaVersion.api.PacketWrapper;
public abstract class ValueCreator implements ValueWriter { public abstract class ValueCreator implements ValueWriter {
/**
* Write new values to a Packet.
*
* @param wrapper The packet to write to
* @throws Exception Throws exception if it fails to write.
*/
public abstract void write(PacketWrapper wrapper) throws Exception; public abstract void write(PacketWrapper wrapper) throws Exception;
@Override @Override

View File

@ -3,5 +3,12 @@ package us.myles.ViaVersion.api.remapper;
import us.myles.ViaVersion.api.PacketWrapper; import us.myles.ViaVersion.api.PacketWrapper;
public interface ValueReader<T> { public interface ValueReader<T> {
/**
* Reads value from a PacketWrapper
*
* @param wrapper The wrapper to read from
* @return Returns the desired type
* @throws Exception Throws exception if it fails to read
*/
T read(PacketWrapper wrapper) throws Exception; T read(PacketWrapper wrapper) throws Exception;
} }

View File

@ -10,6 +10,14 @@ public abstract class ValueTransformer<T1, T2> implements ValueWriter<T1> {
this.outputType = outputType; this.outputType = outputType;
} }
/**
* Transform a value from one type to another
*
* @param wrapper The current packet
* @param inputValue The input value
* @return The value to write to the wrapper
* @throws Exception Throws exception if it fails to transform a value
*/
public abstract T2 transform(PacketWrapper wrapper, T1 inputValue) throws Exception; public abstract T2 transform(PacketWrapper wrapper, T1 inputValue) throws Exception;
@Override @Override

View File

@ -3,5 +3,12 @@ package us.myles.ViaVersion.api.remapper;
import us.myles.ViaVersion.api.PacketWrapper; import us.myles.ViaVersion.api.PacketWrapper;
public interface ValueWriter<T> { public interface ValueWriter<T> {
/**
* Write a value to a packet
*
* @param writer The packet wrapper to write to
* @param inputValue The value to write
* @throws Exception Throws exception if it fails to write
*/
void write(PacketWrapper writer, T inputValue) throws Exception; void write(PacketWrapper writer, T inputValue) throws Exception;
} }

View File

@ -3,5 +3,12 @@ package us.myles.ViaVersion.api.type;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
public interface ByteBufReader<T> { public interface ByteBufReader<T> {
/**
* Read a value from a ByteBuf
*
* @param buffer The buffer to read from.
* @return The type based on the class type.
* @throws Exception Throws exception if it failed reading.
*/
T read(ByteBuf buffer) throws Exception; T read(ByteBuf buffer) throws Exception;
} }

View File

@ -3,5 +3,12 @@ package us.myles.ViaVersion.api.type;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
public interface ByteBufWriter<T> { public interface ByteBufWriter<T> {
/**
* Write an object to a type to a ByteBuf
*
* @param buffer The buffer to write to
* @param object The object to write
* @throws Exception Throws if it failed to write
*/
void write(ByteBuf buffer, T object) throws Exception; void write(ByteBuf buffer, T object) throws Exception;
} }

View File

@ -1,5 +1,11 @@
package us.myles.ViaVersion.api.type; package us.myles.ViaVersion.api.type;
public interface TypeConverter<T> { public interface TypeConverter<T> {
/**
* Convert from a type to the current type
*
* @param o The input object
* @return The converted type as an object
*/
T from(Object o); T from(Object o);
} }

View File

@ -12,7 +12,6 @@ import us.myles.ViaVersion.api.boss.BossColor;
import us.myles.ViaVersion.api.boss.BossFlag; import us.myles.ViaVersion.api.boss.BossFlag;
import us.myles.ViaVersion.api.boss.BossStyle; import us.myles.ViaVersion.api.boss.BossStyle;
import us.myles.ViaVersion.api.type.Type; import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.packets.PacketType;
import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9TO1_8; import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9TO1_8;
import java.util.*; import java.util.*;

View File

@ -6,9 +6,9 @@ import io.netty.handler.codec.ByteToMessageDecoder;
import us.myles.ViaVersion.CancelException; import us.myles.ViaVersion.CancelException;
import us.myles.ViaVersion.api.PacketWrapper; import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.data.UserConnection; import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.protocols.base.ProtocolInfo;
import us.myles.ViaVersion.api.type.Type; import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.packets.Direction; import us.myles.ViaVersion.packets.Direction;
import us.myles.ViaVersion.protocols.base.ProtocolInfo;
import us.myles.ViaVersion.util.PipelineUtil; import us.myles.ViaVersion.util.PipelineUtil;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;

View File

@ -6,9 +6,9 @@ import io.netty.handler.codec.MessageToByteEncoder;
import us.myles.ViaVersion.CancelException; import us.myles.ViaVersion.CancelException;
import us.myles.ViaVersion.api.PacketWrapper; import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.data.UserConnection; import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.protocols.base.ProtocolInfo;
import us.myles.ViaVersion.api.type.Type; import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.packets.Direction; import us.myles.ViaVersion.packets.Direction;
import us.myles.ViaVersion.protocols.base.ProtocolInfo;
import us.myles.ViaVersion.util.PipelineUtil; import us.myles.ViaVersion.util.PipelineUtil;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;

View File

@ -1,13 +1,12 @@
package us.myles.ViaVersion.protocols.protocol1_9to1_8; package us.myles.ViaVersion.protocols.protocol1_9to1_8;
import java.util.HashMap;
import lombok.Getter; import lombok.Getter;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import java.util.HashMap;
@RequiredArgsConstructor @RequiredArgsConstructor
@Getter @Getter
public enum ArmorType { public enum ArmorType {
@ -34,18 +33,19 @@ public enum ArmorType {
GOLD_BOOTS(1, 317, Material.GOLD_BOOTS), GOLD_BOOTS(1, 317, Material.GOLD_BOOTS),
NONE(0, 0, Material.AIR); NONE(0, 0, Material.AIR);
private final int armorPoints;
private final int id;
private final Material type;
private static HashMap<Material, ArmorType> armor; private static HashMap<Material, ArmorType> armor;
static { static {
armor = new HashMap<Material, ArmorType>(); armor = new HashMap<Material, ArmorType>();
for(ArmorType a : ArmorType.values()) { for (ArmorType a : ArmorType.values()) {
armor.put(a.getType(), a); armor.put(a.getType(), a);
} }
} }
private final int armorPoints;
private final int id;
private final Material type;
public static ArmorType findByType(Material type) { public static ArmorType findByType(Material type) {
ArmorType t = armor.get(type); ArmorType t = armor.get(type);
return t == null ? ArmorType.NONE : t; return t == null ? ArmorType.NONE : t;

View File

@ -5,16 +5,15 @@ import com.google.gson.GsonBuilder;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.Plugin;
import us.myles.ViaVersion.ViaVersionPlugin; import us.myles.ViaVersion.ViaVersionPlugin;
import us.myles.ViaVersion.api.PacketWrapper; import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.ViaVersion; import us.myles.ViaVersion.api.ViaVersion;
import us.myles.ViaVersion.api.data.UserConnection; import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.minecraft.metadata.Metadata; import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
import us.myles.ViaVersion.api.protocol.Protocol; import us.myles.ViaVersion.api.protocol.Protocol;
import us.myles.ViaVersion.protocols.base.ProtocolInfo;
import us.myles.ViaVersion.api.remapper.ValueTransformer; import us.myles.ViaVersion.api.remapper.ValueTransformer;
import us.myles.ViaVersion.api.type.Type; import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.protocols.base.ProtocolInfo;
import us.myles.ViaVersion.protocols.protocol1_9to1_8.listeners.ArmorListener; import us.myles.ViaVersion.protocols.protocol1_9to1_8.listeners.ArmorListener;
import us.myles.ViaVersion.protocols.protocol1_9to1_8.listeners.CommandBlockListener; import us.myles.ViaVersion.protocols.protocol1_9to1_8.listeners.CommandBlockListener;
import us.myles.ViaVersion.protocols.protocol1_9to1_8.packets.*; import us.myles.ViaVersion.protocols.protocol1_9to1_8.packets.*;

View File

@ -21,7 +21,6 @@ import us.myles.ViaVersion.api.ViaVersion;
import us.myles.ViaVersion.api.data.UserConnection; import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.type.Type; import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.protocols.base.ProtocolInfo; import us.myles.ViaVersion.protocols.base.ProtocolInfo;
import us.myles.ViaVersion.protocols.protocol1_9_1to1_9.Protocol1_9_1TO1_9;
import us.myles.ViaVersion.protocols.protocol1_9to1_8.ArmorType; import us.myles.ViaVersion.protocols.protocol1_9to1_8.ArmorType;
import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9TO1_8; import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9TO1_8;
@ -35,9 +34,9 @@ public class ArmorListener implements Listener {
public static void sendArmorUpdate(Player player) { public static void sendArmorUpdate(Player player) {
// Ensure that the player is on our pipe // Ensure that the player is on our pipe
UserConnection userConnection = ((ViaVersionPlugin)ViaVersion.getInstance()).getConnection(player); UserConnection userConnection = ((ViaVersionPlugin) ViaVersion.getInstance()).getConnection(player);
if(userConnection == null) return; if (userConnection == null) return;
if(!userConnection.get(ProtocolInfo.class).getPipeline().contains(Protocol1_9TO1_8.class)) return; if (!userConnection.get(ProtocolInfo.class).getPipeline().contains(Protocol1_9TO1_8.class)) return;
int armor = ArmorType.calculateArmorPoints(player.getInventory().getArmorContents()); int armor = ArmorType.calculateArmorPoints(player.getInventory().getArmorContents());
try { try {

View File

@ -24,7 +24,6 @@ import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.minecraft.Position; import us.myles.ViaVersion.api.minecraft.Position;
import us.myles.ViaVersion.api.type.Type; import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.protocols.base.ProtocolInfo; import us.myles.ViaVersion.protocols.base.ProtocolInfo;
import us.myles.ViaVersion.protocols.protocol1_9_1to1_9.Protocol1_9_1TO1_9;
import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9TO1_8; import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9TO1_8;
import us.myles.ViaVersion.util.ReflectionUtil; import us.myles.ViaVersion.util.ReflectionUtil;
@ -61,9 +60,9 @@ public class CommandBlockListener implements Listener {
public void onInteract(PlayerInteractEvent e) { public void onInteract(PlayerInteractEvent e) {
if (e.getAction() == Action.RIGHT_CLICK_BLOCK && plugin.isPorted(e.getPlayer()) && e.getPlayer().isOp()) { if (e.getAction() == Action.RIGHT_CLICK_BLOCK && plugin.isPorted(e.getPlayer()) && e.getPlayer().isOp()) {
// Ensure that the player is on our pipe // Ensure that the player is on our pipe
UserConnection userConnection = ((ViaVersionPlugin)ViaVersion.getInstance()).getConnection(e.getPlayer()); UserConnection userConnection = ((ViaVersionPlugin) ViaVersion.getInstance()).getConnection(e.getPlayer());
if(userConnection == null) return; if (userConnection == null) return;
if(!userConnection.get(ProtocolInfo.class).getPipeline().contains(Protocol1_9TO1_8.class)) return; if (!userConnection.get(ProtocolInfo.class).getPipeline().contains(Protocol1_9TO1_8.class)) return;
try { try {
sendCommandBlockPacket(e.getClickedBlock(), e.getPlayer()); sendCommandBlockPacket(e.getClickedBlock(), e.getPlayer());
@ -77,8 +76,8 @@ public class CommandBlockListener implements Listener {
if (p.isOp() && plugin.isPorted(p)) { if (p.isOp() && plugin.isPorted(p)) {
// Ensure that the player is on our pipe // Ensure that the player is on our pipe
UserConnection userConnection = ((ViaVersionPlugin) ViaVersion.getInstance()).getConnection(p); UserConnection userConnection = ((ViaVersionPlugin) ViaVersion.getInstance()).getConnection(p);
if(userConnection == null) return; if (userConnection == null) return;
if(!userConnection.get(ProtocolInfo.class).getPipeline().contains(Protocol1_9TO1_8.class)) return; if (!userConnection.get(ProtocolInfo.class).getPipeline().contains(Protocol1_9TO1_8.class)) return;
try { try {
ByteBuf buf = Unpooled.buffer(); ByteBuf buf = Unpooled.buffer();

View File

@ -1,7 +1,6 @@
package us.myles.ViaVersion.protocols.protocol1_9to1_8.packets; package us.myles.ViaVersion.protocols.protocol1_9to1_8.packets;
import org.bukkit.Material; import org.bukkit.Material;
import us.myles.ViaVersion.ViaVersionPlugin;
import us.myles.ViaVersion.api.PacketWrapper; import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.ViaVersion; import us.myles.ViaVersion.api.ViaVersion;
import us.myles.ViaVersion.api.minecraft.item.Item; import us.myles.ViaVersion.api.minecraft.item.Item;
@ -183,7 +182,7 @@ public class EntityPackets {
EntityTracker tracker = wrapper.user().get(EntityTracker.class); EntityTracker tracker = wrapper.user().get(EntityTracker.class);
if (tracker.getClientEntityTypes().containsKey(entityID)) { if (tracker.getClientEntityTypes().containsKey(entityID)) {
MetadataRewriter.transform(tracker.getClientEntityTypes().get(entityID), metadataList); MetadataRewriter.transform(tracker.getClientEntityTypes().get(entityID), metadataList);
} else if(!ViaVersion.getConfig().isUnknownEntitiesSuppressed()){ } else if (!ViaVersion.getConfig().isUnknownEntitiesSuppressed()) {
System.out.println("Unable to find entity for metadata, entity ID: " + entityID); System.out.println("Unable to find entity for metadata, entity ID: " + entityID);
} }
} }

View File

@ -2,7 +2,6 @@ package us.myles.ViaVersion.protocols.protocol1_9to1_8.packets;
import org.spacehq.opennbt.tag.builtin.CompoundTag; import org.spacehq.opennbt.tag.builtin.CompoundTag;
import org.spacehq.opennbt.tag.builtin.StringTag; import org.spacehq.opennbt.tag.builtin.StringTag;
import us.myles.ViaVersion.ViaVersionPlugin;
import us.myles.ViaVersion.api.PacketWrapper; import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.ViaVersion; import us.myles.ViaVersion.api.ViaVersion;
import us.myles.ViaVersion.api.minecraft.chunks.Chunk; import us.myles.ViaVersion.api.minecraft.chunks.Chunk;

View File

@ -16,8 +16,8 @@ import us.myles.ViaVersion.api.data.StoredObject;
import us.myles.ViaVersion.api.data.UserConnection; import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.minecraft.item.Item; import us.myles.ViaVersion.api.minecraft.item.Item;
import us.myles.ViaVersion.api.minecraft.metadata.Metadata; import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
import us.myles.ViaVersion.protocols.base.ProtocolInfo;
import us.myles.ViaVersion.api.type.Type; import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.protocols.base.ProtocolInfo;
import java.util.*; import java.util.*;