Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-27 00:22:51 +01:00
1.8 packet enum, add a small number of nullable annotations
Dieser Commit ist enthalten in:
Ursprung
545ab2de79
Commit
baf1b851c4
@ -1,5 +1,6 @@
|
||||
package us.myles.ViaVersion;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import us.myles.ViaVersion.api.Via;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
import us.myles.ViaVersion.api.platform.TaskId;
|
||||
@ -207,6 +208,7 @@ public class ViaManager {
|
||||
/**
|
||||
* @see ViaConnectionManager#getConnectedClient(UUID)
|
||||
*/
|
||||
@Nullable
|
||||
public UserConnection getConnection(UUID playerUUID) {
|
||||
return platform.getConnectionManager().getConnectedClient(playerUUID);
|
||||
}
|
||||
|
@ -16,7 +16,11 @@ import us.myles.ViaVersion.protocols.base.ProtocolInfo;
|
||||
import us.myles.ViaVersion.util.PipelineUtil;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
public class PacketWrapper {
|
||||
public static final int PASSTHROUGH_ID = 1000;
|
||||
@ -249,8 +253,9 @@ public class PacketWrapper {
|
||||
* Clear the input buffer / readable objects
|
||||
*/
|
||||
public void clearInputBuffer() {
|
||||
if (inputBuffer != null)
|
||||
if (inputBuffer != null) {
|
||||
inputBuffer.clear();
|
||||
}
|
||||
readableObjects.clear(); // :(
|
||||
}
|
||||
|
||||
|
@ -1,12 +1,14 @@
|
||||
package us.myles.ViaVersion.api;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class Pair<X, Y> {
|
||||
private final X key;
|
||||
private Y value;
|
||||
|
||||
public Pair(X key, Y value) {
|
||||
public Pair(@Nullable X key, @Nullable Y value) {
|
||||
this.key = key;
|
||||
this.value = value;
|
||||
}
|
||||
@ -19,7 +21,7 @@ public class Pair<X, Y> {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(Y value) {
|
||||
public void setValue(@Nullable Y value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
package us.myles.ViaVersion.api;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class Triple<A, B, C> {
|
||||
@ -7,20 +9,23 @@ public class Triple<A, B, C> {
|
||||
private final B second;
|
||||
private final C third;
|
||||
|
||||
public Triple(A first, B second, C third) {
|
||||
public Triple(@Nullable A first, @Nullable B second, @Nullable C third) {
|
||||
this.first = first;
|
||||
this.second = second;
|
||||
this.third = third;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public A getFirst() {
|
||||
return first;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public B getSecond() {
|
||||
return second;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public C getThird() {
|
||||
return third;
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package us.myles.ViaVersion.api;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
import us.myles.ViaVersion.api.protocol.Protocol;
|
||||
import us.myles.ViaVersion.protocols.base.ProtocolInfo;
|
||||
@ -20,6 +21,7 @@ public abstract class ViaListener {
|
||||
* @param uuid UUID object
|
||||
* @return The UserConnection
|
||||
*/
|
||||
@Nullable
|
||||
protected UserConnection getUserConnection(UUID uuid) {
|
||||
return Via.getManager().getConnection(uuid);
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package us.myles.ViaVersion.api.boss;
|
||||
|
||||
public enum BossColor {
|
||||
|
||||
PINK(0),
|
||||
BLUE(1),
|
||||
RED(2),
|
||||
|
@ -1,6 +1,7 @@
|
||||
package us.myles.ViaVersion.api.boss;
|
||||
|
||||
public enum BossFlag {
|
||||
|
||||
DARKEN_SKY(1),
|
||||
PLAY_BOSS_MUSIC(2);
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package us.myles.ViaVersion.api.boss;
|
||||
|
||||
public enum BossStyle {
|
||||
|
||||
SOLID(0),
|
||||
SEGMENTED_6(1),
|
||||
SEGMENTED_10(2),
|
||||
|
@ -1,5 +1,7 @@
|
||||
package us.myles.ViaVersion.api.command;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ViaVersionCommand {
|
||||
@ -25,6 +27,7 @@ public interface ViaVersionCommand {
|
||||
* @param name subcommand name
|
||||
* @return ViaSubCommand instance
|
||||
*/
|
||||
@Nullable
|
||||
ViaSubCommand getSubCommand(String name);
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,6 @@
|
||||
package us.myles.ViaVersion.api.data;
|
||||
|
||||
public interface ExternalJoinGameListener {
|
||||
|
||||
void onExternalJoinGame(int playerEntityId);
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonIOException;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import us.myles.ViaVersion.api.Via;
|
||||
import us.myles.ViaVersion.util.GsonUtil;
|
||||
|
||||
@ -127,6 +128,7 @@ public class MappingDataLoader {
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static Map.Entry<String, JsonElement> mapIdentifierEntry(Map.Entry<String, JsonElement> entry, JsonObject oldIdentifiers, JsonObject newIdentifiers, JsonObject diffIdentifiers) {
|
||||
Map.Entry<String, JsonElement> value = findValue(newIdentifiers, entry.getValue().getAsString());
|
||||
if (value == null) {
|
||||
@ -181,6 +183,7 @@ public class MappingDataLoader {
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static Map.Entry<String, JsonElement> findValue(JsonObject object, String needle) {
|
||||
for (Map.Entry<String, JsonElement> entry : object.entrySet()) {
|
||||
String value = entry.getValue().getAsString();
|
||||
@ -191,6 +194,7 @@ public class MappingDataLoader {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static Integer findIndex(JsonArray array, String value) {
|
||||
for (int i = 0; i < array.size(); i++) {
|
||||
JsonElement v = array.get(i);
|
||||
|
@ -6,6 +6,7 @@ import io.netty.channel.ChannelFuture;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.Via;
|
||||
import us.myles.ViaVersion.api.ViaVersionConfig;
|
||||
@ -36,7 +37,7 @@ public class UserConnection {
|
||||
private int secondsObserved;
|
||||
private int warnings;
|
||||
|
||||
public UserConnection(Channel channel) {
|
||||
public UserConnection(@Nullable Channel channel) {
|
||||
this.channel = channel;
|
||||
}
|
||||
|
||||
@ -47,6 +48,7 @@ public class UserConnection {
|
||||
* @param <T> The type of the class you want to get.
|
||||
* @return The requested object
|
||||
*/
|
||||
@Nullable
|
||||
public <T extends StoredObject> T get(Class<T> objectClass) {
|
||||
return (T) storedObjects.get(objectClass);
|
||||
}
|
||||
@ -84,8 +86,8 @@ public class UserConnection {
|
||||
* @param packet The raw packet to send
|
||||
* @param currentThread Should it run in the same thread
|
||||
*/
|
||||
public void sendRawPacket(final ByteBuf packet, boolean currentThread) {
|
||||
final ChannelHandler handler = channel.pipeline().get(Via.getManager().getInjector().getEncoderName());
|
||||
public void sendRawPacket(ByteBuf packet, boolean currentThread) {
|
||||
ChannelHandler handler = channel.pipeline().get(Via.getManager().getInjector().getEncoderName());
|
||||
if (currentThread) {
|
||||
channel.pipeline().context(handler).writeAndFlush(packet);
|
||||
} else {
|
||||
@ -99,8 +101,8 @@ public class UserConnection {
|
||||
* @param packet The raw packet to send
|
||||
* @return ChannelFuture of the packet being sent
|
||||
*/
|
||||
public ChannelFuture sendRawPacketFuture(final ByteBuf packet) {
|
||||
final ChannelHandler handler = channel.pipeline().get(Via.getManager().getInjector().getEncoderName());
|
||||
public ChannelFuture sendRawPacketFuture(ByteBuf packet) {
|
||||
ChannelHandler handler = channel.pipeline().get(Via.getManager().getInjector().getEncoderName());
|
||||
return channel.pipeline().context(handler).writeAndFlush(packet);
|
||||
}
|
||||
|
||||
@ -109,7 +111,7 @@ public class UserConnection {
|
||||
*
|
||||
* @param packet The packet to send
|
||||
*/
|
||||
public void sendRawPacket(final ByteBuf packet) {
|
||||
public void sendRawPacket(ByteBuf packet) {
|
||||
sendRawPacket(packet, false);
|
||||
}
|
||||
|
||||
@ -177,12 +179,12 @@ public class UserConnection {
|
||||
*
|
||||
* @param reason The reason to use, not used if player is not active.
|
||||
*/
|
||||
public void disconnect(final String reason) {
|
||||
public void disconnect(String reason) {
|
||||
if (!channel.isOpen()) return;
|
||||
if (pendingDisconnect) return;
|
||||
pendingDisconnect = true;
|
||||
if (get(ProtocolInfo.class).getUuid() != null) {
|
||||
final UUID uuid = get(ProtocolInfo.class).getUuid();
|
||||
UUID uuid = get(ProtocolInfo.class).getUuid();
|
||||
Via.getPlatform().runSync(() -> {
|
||||
if (!Via.getPlatform().kickPlayer(uuid, ChatColor.translateAlternateColorCodes('&', reason))) {
|
||||
channel.close(); // =)
|
||||
@ -197,8 +199,8 @@ public class UserConnection {
|
||||
* @param packet Raw packet to be sent
|
||||
* @param currentThread If {@code true} executes immediately, {@code false} submits a task to EventLoop
|
||||
*/
|
||||
public void sendRawPacketToServer(final ByteBuf packet, boolean currentThread) {
|
||||
final ByteBuf buf = packet.alloc().buffer();
|
||||
public void sendRawPacketToServer(ByteBuf packet, boolean currentThread) {
|
||||
ByteBuf buf = packet.alloc().buffer();
|
||||
try {
|
||||
try {
|
||||
Type.VAR_INT.write(buf, PacketWrapper.PASSTHROUGH_ID);
|
||||
@ -207,7 +209,7 @@ public class UserConnection {
|
||||
Via.getPlatform().getLogger().warning("Type.VAR_INT.write thrown an exception: " + e);
|
||||
}
|
||||
buf.writeBytes(packet);
|
||||
final ChannelHandlerContext context = PipelineUtil
|
||||
ChannelHandlerContext context = PipelineUtil
|
||||
.getPreviousContext(Via.getManager().getInjector().getDecoderName(), channel.pipeline());
|
||||
if (currentThread) {
|
||||
if (context != null) {
|
||||
@ -248,6 +250,7 @@ public class UserConnection {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Channel getChannel() {
|
||||
return channel;
|
||||
}
|
||||
@ -272,11 +275,12 @@ public class UserConnection {
|
||||
this.pendingDisconnect = pendingDisconnect;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Object getLastPacket() {
|
||||
return lastPacket;
|
||||
}
|
||||
|
||||
public void setLastPacket(Object lastPacket) {
|
||||
public void setLastPacket(@Nullable Object lastPacket) {
|
||||
this.lastPacket = lastPacket;
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,12 @@
|
||||
package us.myles.ViaVersion.api.entities;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public interface EntityType {
|
||||
|
||||
int getId();
|
||||
|
||||
@Nullable
|
||||
EntityType getParent();
|
||||
|
||||
String name();
|
||||
|
@ -1,6 +1,7 @@
|
||||
package us.myles.ViaVersion.api.minecraft.chunks;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@ -145,7 +146,7 @@ public class ChunkSection {
|
||||
*
|
||||
* @param data The value to set the block light to
|
||||
*/
|
||||
public void setBlockLight(byte[] data) {
|
||||
public void setBlockLight(@Nullable byte[] data) {
|
||||
if (data.length != LIGHT_LENGTH) throw new IllegalArgumentException("Data length != " + LIGHT_LENGTH);
|
||||
if (this.blockLight == null) {
|
||||
this.blockLight = new NibbleArray(data);
|
||||
@ -159,7 +160,7 @@ public class ChunkSection {
|
||||
*
|
||||
* @param data The value to set the sky light to
|
||||
*/
|
||||
public void setSkyLight(byte[] data) {
|
||||
public void setSkyLight(@Nullable byte[] data) {
|
||||
if (data.length != LIGHT_LENGTH) throw new IllegalArgumentException("Data length != " + LIGHT_LENGTH);
|
||||
if (this.skyLight == null) {
|
||||
this.skyLight = new NibbleArray(data);
|
||||
@ -168,18 +169,22 @@ public class ChunkSection {
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public byte[] getBlockLight() {
|
||||
return blockLight == null ? null : blockLight.getHandle();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public NibbleArray getBlockLightNibbleArray() {
|
||||
return blockLight;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public byte[] getSkyLight() {
|
||||
return skyLight == null ? null : skyLight.getHandle();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public NibbleArray getSkyLightNibbleArray() {
|
||||
return skyLight;
|
||||
}
|
||||
|
@ -2,6 +2,9 @@ package us.myles.ViaVersion.api.minecraft.item;
|
||||
|
||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class Item {
|
||||
@SerializedName(value = "identifier", alternate = "id")
|
||||
@ -13,7 +16,7 @@ public class Item {
|
||||
public Item() {
|
||||
}
|
||||
|
||||
public Item(int identifier, byte amount, short data, CompoundTag tag) {
|
||||
public Item(int identifier, byte amount, short data, @Nullable CompoundTag tag) {
|
||||
this.identifier = identifier;
|
||||
this.amount = amount;
|
||||
this.data = data;
|
||||
@ -48,11 +51,12 @@ public class Item {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public CompoundTag getTag() {
|
||||
return tag;
|
||||
}
|
||||
|
||||
public void setTag(CompoundTag tag) {
|
||||
public void setTag(@Nullable CompoundTag tag) {
|
||||
this.tag = tag;
|
||||
}
|
||||
|
||||
@ -64,7 +68,7 @@ public class Item {
|
||||
if (identifier != item.identifier) return false;
|
||||
if (amount != item.amount) return false;
|
||||
if (data != item.data) return false;
|
||||
return tag != null ? tag.equals(item.tag) : item.tag == null;
|
||||
return Objects.equals(tag, item.tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,6 +1,7 @@
|
||||
package us.myles.ViaVersion.api.platform;
|
||||
|
||||
import io.netty.channel.ChannelFutureListener;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
import us.myles.ViaVersion.protocols.base.ProtocolInfo;
|
||||
|
||||
@ -51,6 +52,7 @@ public class ViaConnectionManager {
|
||||
* Note that connections are removed as soon as their channel is closed,
|
||||
* so avoid using this method during player quits for example.
|
||||
*/
|
||||
@Nullable
|
||||
public UserConnection getConnectedClient(UUID clientIdentifier) {
|
||||
return clients.get(clientIdentifier);
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
package us.myles.ViaVersion.api.platform.providers;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@ -22,6 +24,7 @@ public class ViaProviders {
|
||||
providers.put(provider, value);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public <T extends Provider> T get(Class<T> provider) {
|
||||
Provider rawProvider = providers.get(provider);
|
||||
if (rawProvider != null) {
|
||||
|
@ -1,6 +1,7 @@
|
||||
package us.myles.ViaVersion.api.protocol;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.Via;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
@ -47,8 +48,8 @@ public abstract class Protocol<C1 extends ClientboundPacketType, C2 extends Clie
|
||||
/**
|
||||
* Creates a protocol with automated id mapping if the respective enums are not null.
|
||||
*/
|
||||
protected Protocol(Class<C1> oldClientboundPacketEnum, Class<C2> clientboundPacketEnum,
|
||||
Class<S1> oldServerboundPacketEnum, Class<S2> serverboundPacketEnum) {
|
||||
protected Protocol(@Nullable Class<C1> oldClientboundPacketEnum, @Nullable Class<C2> clientboundPacketEnum,
|
||||
@Nullable Class<S1> oldServerboundPacketEnum, @Nullable Class<S2> serverboundPacketEnum) {
|
||||
this(oldClientboundPacketEnum, clientboundPacketEnum, oldServerboundPacketEnum, serverboundPacketEnum, false);
|
||||
}
|
||||
|
||||
@ -57,8 +58,8 @@ public abstract class Protocol<C1 extends ClientboundPacketType, C2 extends Clie
|
||||
*
|
||||
* @param hasMappingDataToLoad whether an async executor should call the {@Link #loadMappingData} method
|
||||
*/
|
||||
protected Protocol(Class<C1> oldClientboundPacketEnum, Class<C2> clientboundPacketEnum,
|
||||
Class<S1> oldServerboundPacketEnum, Class<S2> serverboundPacketEnum, boolean hasMappingDataToLoad) {
|
||||
protected Protocol(@Nullable Class<C1> oldClientboundPacketEnum, @Nullable Class<C2> clientboundPacketEnum,
|
||||
@Nullable Class<S1> oldServerboundPacketEnum, @Nullable Class<S2> serverboundPacketEnum, boolean hasMappingDataToLoad) {
|
||||
this.oldClientboundPacketEnum = oldClientboundPacketEnum;
|
||||
this.newClientboundPacketEnum = clientboundPacketEnum;
|
||||
this.oldServerboundPacketEnum = oldServerboundPacketEnum;
|
||||
@ -282,7 +283,7 @@ public abstract class Protocol<C1 extends ClientboundPacketType, C2 extends Clie
|
||||
* @param packetType clientbound packet type the server sends
|
||||
* @param packetRemapper remapper
|
||||
*/
|
||||
public void registerOutgoing(C1 packetType, PacketRemapper packetRemapper) {
|
||||
public void registerOutgoing(C1 packetType, @Nullable PacketRemapper packetRemapper) {
|
||||
ClientboundPacketType mappedPacket = oldClientboundPacketEnum == newClientboundPacketEnum ? packetType
|
||||
: Arrays.stream(newClientboundPacketEnum.getEnumConstants()).filter(en -> en.name().equals(packetType.name())).findAny().orElse(null);
|
||||
Preconditions.checkNotNull(mappedPacket, "Packet type " + packetType + " in " + packetType.getClass().getSimpleName() + " could not be automatically mapped!");
|
||||
@ -299,7 +300,7 @@ public abstract class Protocol<C1 extends ClientboundPacketType, C2 extends Clie
|
||||
* @param mappedPacketType clientbound packet type after transforming for the client
|
||||
* @param packetRemapper remapper
|
||||
*/
|
||||
public void registerOutgoing(C1 packetType, C2 mappedPacketType, PacketRemapper packetRemapper) {
|
||||
public void registerOutgoing(C1 packetType, @Nullable C2 mappedPacketType, @Nullable PacketRemapper packetRemapper) {
|
||||
registerOutgoing(State.PLAY, packetType.ordinal(), mappedPacketType != null ? mappedPacketType.ordinal() : -1, packetRemapper);
|
||||
}
|
||||
|
||||
@ -310,7 +311,7 @@ public abstract class Protocol<C1 extends ClientboundPacketType, C2 extends Clie
|
||||
* @param packetType clientbound packet type the server initially sends
|
||||
* @param mappedPacketType clientbound packet type after transforming for the client
|
||||
*/
|
||||
public void registerOutgoing(C1 packetType, C2 mappedPacketType) {
|
||||
public void registerOutgoing(C1 packetType, @Nullable C2 mappedPacketType) {
|
||||
registerOutgoing(packetType, mappedPacketType, null);
|
||||
}
|
||||
|
||||
@ -324,7 +325,7 @@ public abstract class Protocol<C1 extends ClientboundPacketType, C2 extends Clie
|
||||
* @param packetType serverbound packet type the client sends
|
||||
* @param packetRemapper remapper
|
||||
*/
|
||||
public void registerIncoming(S2 packetType, PacketRemapper packetRemapper) {
|
||||
public void registerIncoming(S2 packetType, @Nullable PacketRemapper packetRemapper) {
|
||||
Preconditions.checkArgument(packetType.getClass() == newServerboundPacketEnum);
|
||||
|
||||
ServerboundPacketType mappedPacket = oldServerboundPacketEnum == newServerboundPacketEnum ? packetType
|
||||
@ -343,7 +344,7 @@ public abstract class Protocol<C1 extends ClientboundPacketType, C2 extends Clie
|
||||
* @param mappedPacketType serverbound packet type after transforming for the server
|
||||
* @param packetRemapper remapper
|
||||
*/
|
||||
public void registerIncoming(S2 packetType, S1 mappedPacketType, PacketRemapper packetRemapper) {
|
||||
public void registerIncoming(S2 packetType, @Nullable S1 mappedPacketType, @Nullable PacketRemapper packetRemapper) {
|
||||
registerIncoming(State.PLAY, mappedPacketType != null ? mappedPacketType.ordinal() : -1, packetType.ordinal(), packetRemapper);
|
||||
}
|
||||
|
||||
@ -409,7 +410,7 @@ public abstract class Protocol<C1 extends ClientboundPacketType, C2 extends Clie
|
||||
}
|
||||
}
|
||||
|
||||
public <T> T get(Class<T> objectClass) {
|
||||
public @Nullable <T> T get(Class<T> objectClass) {
|
||||
return (T) storedObjects.get(objectClass);
|
||||
}
|
||||
|
||||
@ -466,7 +467,7 @@ public abstract class Protocol<C1 extends ClientboundPacketType, C2 extends Clie
|
||||
private final int newID;
|
||||
private final PacketRemapper remapper;
|
||||
|
||||
public ProtocolPacket(State state, int oldID, int newID, PacketRemapper remapper) {
|
||||
public ProtocolPacket(State state, int oldID, int newID, @Nullable PacketRemapper remapper) {
|
||||
this.state = state;
|
||||
this.oldID = oldID;
|
||||
this.newID = newID;
|
||||
@ -485,6 +486,7 @@ public abstract class Protocol<C1 extends ClientboundPacketType, C2 extends Clie
|
||||
return newID;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public PacketRemapper getRemapper() {
|
||||
return remapper;
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class ProtocolPipeline extends Protocol {
|
||||
public class ProtocolPipeline extends SimpleProtocol {
|
||||
private List<Protocol> protocolList;
|
||||
private UserConnection userConnection;
|
||||
|
||||
|
@ -2,6 +2,7 @@ package us.myles.ViaVersion.api.protocol;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Range;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import us.myles.ViaVersion.api.Pair;
|
||||
import us.myles.ViaVersion.api.Via;
|
||||
import us.myles.ViaVersion.api.data.MappingDataLoader;
|
||||
@ -224,6 +225,7 @@ public class ProtocolRegistry {
|
||||
* @param serverVersion The desired output version
|
||||
* @return The path which has been generated, null if failed.
|
||||
*/
|
||||
@Nullable
|
||||
private static List<Pair<Integer, Protocol>> getProtocolPath(List<Pair<Integer, Protocol>> current, int clientVersion, int serverVersion) {
|
||||
if (clientVersion == serverVersion) return null; // We're already there
|
||||
if (current.size() > 50) return null; // Fail safe, protocol too complicated.
|
||||
@ -273,6 +275,7 @@ public class ProtocolRegistry {
|
||||
* @param serverVersion The desired output server version
|
||||
* @return The path it generated, null if it failed.
|
||||
*/
|
||||
@Nullable
|
||||
public static List<Pair<Integer, Protocol>> getProtocolPath(int clientVersion, int serverVersion) {
|
||||
Pair<Integer, Integer> protocolKey = new Pair<>(clientVersion, serverVersion);
|
||||
// Check cache
|
||||
@ -367,6 +370,7 @@ public class ProtocolRegistry {
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static CompletableFuture<Void> getMappingLoaderFuture(Class<? extends Protocol> protocolClass) {
|
||||
synchronized (MAPPING_LOADER_LOCK) {
|
||||
if (mappingsLoaded) return null;
|
||||
|
@ -1,8 +1,8 @@
|
||||
package us.myles.ViaVersion.api.protocol;
|
||||
|
||||
/**
|
||||
* Dummy protocol class for when you do not need any of the existing packet type enums
|
||||
* or automated channel mappings.
|
||||
* Dummy protocol class for when you do not need any of the
|
||||
* existing packet type enums or automated channel mappings.
|
||||
*
|
||||
* @see Protocol
|
||||
*/
|
||||
@ -17,8 +17,4 @@ public abstract class SimpleProtocol extends Protocol<SimpleProtocol.DummyPacket
|
||||
|
||||
public enum DummyPacketTypes implements ClientboundPacketType, ServerboundPacketType {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package us.myles.ViaVersion.api.remapper;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.exception.InformativeException;
|
||||
@ -8,7 +9,7 @@ public abstract class ValueTransformer<T1, T2> implements ValueWriter<T1> {
|
||||
private final Type<T1> inputType;
|
||||
private final Type<T2> outputType;
|
||||
|
||||
public ValueTransformer(Type<T1> inputType, Type<T2> outputType) {
|
||||
public ValueTransformer(@Nullable Type<T1> inputType, Type<T2> outputType) {
|
||||
this.inputType = inputType;
|
||||
this.outputType = outputType;
|
||||
}
|
||||
@ -37,6 +38,7 @@ public abstract class ValueTransformer<T1, T2> implements ValueWriter<T1> {
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Type<T1> getInputType() {
|
||||
return inputType;
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package us.myles.ViaVersion.api.rewriters;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import us.myles.ViaVersion.api.minecraft.BlockChangeRecord;
|
||||
import us.myles.ViaVersion.api.minecraft.Position;
|
||||
import us.myles.ViaVersion.api.minecraft.item.Item;
|
||||
@ -93,7 +94,7 @@ public class BlockRewriter {
|
||||
}
|
||||
|
||||
public void registerSpawnParticle(ClientboundPacketType packetType, int blockId, int fallingDustId, int itemId,
|
||||
IdRewriteFunction particleRewriteFunction, ItemRewriter.RewriteFunction itemRewriteFunction, Type<Item> itemType, Type<?> coordType) {
|
||||
@Nullable IdRewriteFunction particleRewriteFunction, ItemRewriter.RewriteFunction itemRewriteFunction, Type<Item> itemType, Type<?> coordType) {
|
||||
protocol.registerOutgoing(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
|
@ -1,5 +1,6 @@
|
||||
package us.myles.ViaVersion.api.rewriters;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import us.myles.ViaVersion.api.Via;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
import us.myles.ViaVersion.api.entities.EntityType;
|
||||
@ -58,7 +59,7 @@ public abstract class MetadataRewriter {
|
||||
}
|
||||
}
|
||||
|
||||
public void registerJoinGame(ClientboundPacketType packetType, EntityType playerType) {
|
||||
public void registerJoinGame(ClientboundPacketType packetType, @Nullable EntityType playerType) {
|
||||
protocol.registerOutgoing(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
@ -157,7 +158,7 @@ public abstract class MetadataRewriter {
|
||||
});
|
||||
}
|
||||
|
||||
public void registerMetadataRewriter(ClientboundPacketType packetType, Type<List<Metadata>> oldMetaType, Type<List<Metadata>> newMetaType) {
|
||||
public void registerMetadataRewriter(ClientboundPacketType packetType, @Nullable Type<List<Metadata>> oldMetaType, Type<List<Metadata>> newMetaType) {
|
||||
protocol.registerOutgoing(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
@ -213,7 +214,7 @@ public abstract class MetadataRewriter {
|
||||
* @param metaType type of the metadata list
|
||||
* @return handler for tracking and rewriting entities
|
||||
*/
|
||||
public PacketHandler getTrackerAndRewriter(Type<List<Metadata>> metaType) {
|
||||
public PacketHandler getTrackerAndRewriter(@Nullable Type<List<Metadata>> metaType) {
|
||||
return wrapper -> {
|
||||
int entityId = wrapper.get(Type.VAR_INT, 0);
|
||||
int type = wrapper.get(Type.VAR_INT, 1);
|
||||
@ -233,7 +234,7 @@ public abstract class MetadataRewriter {
|
||||
};
|
||||
}
|
||||
|
||||
public PacketHandler getTrackerAndRewriter(Type<List<Metadata>> metaType, EntityType entityType) {
|
||||
public PacketHandler getTrackerAndRewriter(@Nullable Type<List<Metadata>> metaType, EntityType entityType) {
|
||||
return wrapper -> {
|
||||
int entityId = wrapper.get(Type.VAR_INT, 0);
|
||||
// Register Type ID
|
||||
|
@ -1,5 +1,6 @@
|
||||
package us.myles.ViaVersion.api.storage;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import us.myles.ViaVersion.api.data.ExternalJoinGameListener;
|
||||
import us.myles.ViaVersion.api.data.StoredObject;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
@ -30,6 +31,7 @@ public abstract class EntityTracker extends StoredObject implements ExternalJoin
|
||||
return clientEntityTypes.containsKey(entityId);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public EntityType getEntity(int entityId) {
|
||||
return clientEntityTypes.get(entityId);
|
||||
}
|
||||
|
@ -247,6 +247,7 @@ public abstract class CommonBoss<T> extends BossBar<T> {
|
||||
}
|
||||
|
||||
private enum UpdateAction {
|
||||
|
||||
ADD(0),
|
||||
REMOVE(1),
|
||||
UPDATE_HEALTH(2),
|
||||
|
@ -8,6 +8,7 @@ import us.myles.ViaVersion.api.platform.providers.ViaProviders;
|
||||
import us.myles.ViaVersion.api.protocol.Protocol;
|
||||
import us.myles.ViaVersion.api.protocol.ProtocolPipeline;
|
||||
import us.myles.ViaVersion.api.protocol.ProtocolRegistry;
|
||||
import us.myles.ViaVersion.api.protocol.SimpleProtocol;
|
||||
import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
@ -16,7 +17,7 @@ import us.myles.ViaVersion.packets.State;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class BaseProtocol extends Protocol {
|
||||
public class BaseProtocol extends SimpleProtocol {
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
|
@ -12,6 +12,7 @@ import us.myles.ViaVersion.api.Via;
|
||||
import us.myles.ViaVersion.api.protocol.Protocol;
|
||||
import us.myles.ViaVersion.api.protocol.ProtocolRegistry;
|
||||
import us.myles.ViaVersion.api.protocol.ProtocolVersion;
|
||||
import us.myles.ViaVersion.api.protocol.SimpleProtocol;
|
||||
import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
@ -23,7 +24,7 @@ import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class BaseProtocol1_7 extends Protocol {
|
||||
public class BaseProtocol1_7 extends SimpleProtocol {
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
|
@ -0,0 +1,81 @@
|
||||
package us.myles.ViaVersion.protocols.protocol1_8;
|
||||
|
||||
import us.myles.ViaVersion.api.protocol.ClientboundPacketType;
|
||||
|
||||
public enum ClientboundPackets1_8 implements ClientboundPacketType {
|
||||
|
||||
KEEP_ALIVE, // 0x00
|
||||
JOIN_GAME, // 0x01
|
||||
CHAT_MESSAGE, // 0x02
|
||||
TIME_UPDATE, // 0x03
|
||||
ENTITY_EQUIPMENT, // 0x04
|
||||
SPAWN_POSITION, // 0x05
|
||||
UPDATE_HEALTH, // 0x06
|
||||
RESPAWN, // 0x07
|
||||
PLAYER_POSITION, // 0x08
|
||||
HELD_ITEM_CHANGE, // 0x09
|
||||
USE_BED, // 0x0A
|
||||
ENTITY_ANIMATION, // 0x0B
|
||||
SPAWN_PLAYER, // 0x0C
|
||||
COLLECT_ITEM, // 0x0D
|
||||
SPAWN_ENTITY, // 0x0E
|
||||
SPAWN_MOB, // 0x0F
|
||||
SPAWN_PAINTING, // 0x10
|
||||
SPAWN_EXPERIENCE_ORB, // 0x11
|
||||
ENTITY_VELOCITY, // 0x12
|
||||
DESTROY_ENTITIES, // 0x13
|
||||
ENTITY_MOVEMENT, // 0x14
|
||||
ENTITY_POSITION, // 0x15
|
||||
ENTITY_ROTATION, // 0x16
|
||||
ENTITY_POSITION_AND_ROTATION, // 0x17
|
||||
ENTITY_TELEPORT, // 0x18
|
||||
ENTITY_HEAD_LOOK, // 0x19
|
||||
ENTITY_STATUS, // 0x1A
|
||||
ATTACH_ENTITY, // 0x1B
|
||||
ENTITY_METADATA, // 0x1C
|
||||
ENTITY_EFFECT, // 0x1D
|
||||
REMOVE_ENTITY_EFFECT, // 0x1E
|
||||
SET_EXPERIENCE, // 0x1F
|
||||
ENTITY_PROPERTIES, // 0x20
|
||||
CHUNK_DATA, // 0x21
|
||||
MULTI_BLOCK_CHANGE, // 0x22
|
||||
BLOCK_CHANGE, // 0x23
|
||||
BLOCK_ACTION, // 0x24
|
||||
BLOCK_BREAK_ANIMATION, // 0x25
|
||||
MAP_BULK_CHUNK, // 0x26
|
||||
EXPLOSION, // 0x27
|
||||
EFFECT, // 0x28
|
||||
NAMED_SOUND, // 0x29
|
||||
SPAWN_PARTICLE, // 0x2A
|
||||
GAME_EVENT, // 0x2B
|
||||
SPAWN_GLOBAL_ENTITY, // 0x2C
|
||||
OPEN_WINDOW, // 0x2D
|
||||
CLOSE_WINDOW, // 0x2E
|
||||
SET_SLOT, // 0x2F
|
||||
WINDOW_ITEMS, // 0x30
|
||||
WINDOW_PROPERTY, // 0x31
|
||||
WINDOW_CONFIRMATION, // 0x32
|
||||
UPDATE_SIGN, // 0x33
|
||||
MAP_DATA, // 0x34
|
||||
BLOCK_ENTITY_DATA, // 0x35
|
||||
OPEN_SIGN_EDITOR, // 0x36
|
||||
STATISTICS, // 0x37
|
||||
PLAYER_INFO, // 0x38
|
||||
PLAYER_ABILITIES, // 0x39
|
||||
TAB_COMPLETE, // 0x3A
|
||||
SCOREBOARD_OBJECTIVE, // 0x3B
|
||||
UPDATE_SCORE, // 0x3C
|
||||
DISPLAY_SCOREBOARD, // 0x3D
|
||||
TEAMS, // 0x3E
|
||||
PLUGIN_MESSAGE, // 0x3F
|
||||
DISCONNECT, // 0x40
|
||||
SERVER_DIFFICULTY, // 0x41
|
||||
COMBAT_EVENT, // 0x42
|
||||
CAMERA, // 0x43
|
||||
WORLD_BORDER, // 0x44
|
||||
TITLE, // 0x45
|
||||
SET_COMPRESSION, // 0x46
|
||||
TAB_LIST, // 0x47
|
||||
RESOURCE_PACK, // 0x48
|
||||
UPDATE_ENTITY_NBT, // 0x49
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package us.myles.ViaVersion.protocols.protocol1_8;
|
||||
|
||||
import us.myles.ViaVersion.api.protocol.ServerboundPacketType;
|
||||
|
||||
public enum ServerboundPackets1_8 implements ServerboundPacketType {
|
||||
|
||||
KEEP_ALIVE, // 0x00
|
||||
CHAT_MESSAGE, // 0x01
|
||||
INTERACT_ENTITY, // 0x02
|
||||
PLAYER_MOVEMENT, // 0x03
|
||||
PLAYER_POSITION, // 0x04
|
||||
PLAYER_ROTATION, // 0x05
|
||||
PLAYER_POSITION_AND_ROTATION, // 0x06
|
||||
PLAYER_DIGGING, // 0x07
|
||||
PLAYER_BLOCK_PLACEMENT, // 0x08
|
||||
HELD_ITEM_CHANGE, // 0x09
|
||||
ANIMATION, // 0x0A
|
||||
ENTITY_ACTION, // 0x0B
|
||||
STEER_VEHICLE, // 0x0C
|
||||
CLOSE_WINDOW, // 0x0D
|
||||
CLICK_WINDOW, // 0x0E
|
||||
WINDOW_CONFIRMATION, // 0x0F
|
||||
CREATIVE_INVENTORY_ACTION, // 0x10
|
||||
CLICK_WINDOW_BUTTON, // 0x11
|
||||
UPDATE_SIGN, // 0x12
|
||||
PLAYER_ABILITIES, // 0x13
|
||||
TAB_COMPLETE, // 0x14
|
||||
CLIENT_SETTINGS, // 0x15
|
||||
CLIENT_STATUS, // 0x16
|
||||
PLUGIN_MESSAGE, // 0x17
|
||||
SPECTATE, // 0x18
|
||||
RESOURCE_PACK_STATUS, // 0x19
|
||||
}
|
@ -6,11 +6,13 @@ import us.myles.ViaVersion.api.Via;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
import us.myles.ViaVersion.api.minecraft.item.Item;
|
||||
import us.myles.ViaVersion.api.platform.providers.ViaProviders;
|
||||
import us.myles.ViaVersion.api.protocol.SimpleProtocol;
|
||||
import us.myles.ViaVersion.api.protocol.Protocol;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.remapper.ValueTransformer;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.ViaVersion.protocols.protocol1_8.ClientboundPackets1_8;
|
||||
import us.myles.ViaVersion.protocols.protocol1_8.ServerboundPackets1_8;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.metadata.MetadataRewriter1_9To1_8;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.packets.*;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.providers.*;
|
||||
@ -19,7 +21,7 @@ import us.myles.ViaVersion.util.GsonUtil;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Protocol1_9To1_8 extends SimpleProtocol {
|
||||
public class Protocol1_9To1_8 extends Protocol<ClientboundPackets1_8, ClientboundPackets1_9, ServerboundPackets1_8, ServerboundPackets1_9> {
|
||||
public static final ValueTransformer<String, String> FIX_JSON = new ValueTransformer<String, String>(Type.STRING) {
|
||||
@Override
|
||||
public String transform(PacketWrapper wrapper, String line) {
|
||||
@ -27,6 +29,10 @@ public class Protocol1_9To1_8 extends SimpleProtocol {
|
||||
}
|
||||
};
|
||||
|
||||
public Protocol1_9To1_8() {
|
||||
super(ClientboundPackets1_8.class, ClientboundPackets1_9.class, ServerboundPackets1_8.class, ServerboundPackets1_9.class);
|
||||
}
|
||||
|
||||
public static String fixJson(String line) {
|
||||
if (line == null || line.equalsIgnoreCase("null")) {
|
||||
line = "{\"text\":\"\"}";
|
||||
|
@ -13,13 +13,18 @@ import us.myles.ViaVersion.api.remapper.ValueTransformer;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.api.type.types.version.Types1_8;
|
||||
import us.myles.ViaVersion.api.type.types.version.Types1_9;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.ViaVersion.protocols.protocol1_8.ClientboundPackets1_8;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.ItemRewriter;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9To1_8;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.ServerboundPackets1_9;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.metadata.MetadataRewriter1_9To1_8;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.storage.EntityTracker1_9;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class EntityPackets {
|
||||
public static final ValueTransformer<Byte, Short> toNewShort = new ValueTransformer<Byte, Short>(Type.SHORT) {
|
||||
@ -31,7 +36,7 @@ public class EntityPackets {
|
||||
|
||||
public static void register(Protocol1_9To1_8 protocol) {
|
||||
// Attach Entity Packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x1B, 0x3A, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_8.ATTACH_ENTITY, new PacketRemapper() {
|
||||
|
||||
@Override
|
||||
public void registerMap() {
|
||||
@ -67,8 +72,7 @@ public class EntityPackets {
|
||||
});
|
||||
}
|
||||
});
|
||||
// Entity Teleport Packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x18, 0x4A, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_8.ENTITY_TELEPORT, new PacketRemapper() {
|
||||
|
||||
@Override
|
||||
public void registerMap() {
|
||||
@ -100,8 +104,7 @@ public class EntityPackets {
|
||||
|
||||
}
|
||||
});
|
||||
// Entity Look Move Packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x17, 0x26, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_8.ENTITY_POSITION_AND_ROTATION, new PacketRemapper() {
|
||||
|
||||
@Override
|
||||
public void registerMap() {
|
||||
@ -116,8 +119,7 @@ public class EntityPackets {
|
||||
map(Type.BOOLEAN); // 6 - On Ground
|
||||
}
|
||||
});
|
||||
// Entity Relative Move Packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x15, 0x25, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_8.ENTITY_POSITION, new PacketRemapper() {
|
||||
|
||||
@Override
|
||||
public void registerMap() {
|
||||
@ -129,8 +131,7 @@ public class EntityPackets {
|
||||
map(Type.BOOLEAN); // 4 - On Ground
|
||||
}
|
||||
});
|
||||
// Entity Equipment Packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x04, 0x3C, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_8.ENTITY_EQUIPMENT, new PacketRemapper() {
|
||||
|
||||
@Override
|
||||
public void registerMap() {
|
||||
@ -178,8 +179,7 @@ public class EntityPackets {
|
||||
});
|
||||
}
|
||||
});
|
||||
// Entity Metadata Packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x1C, 0x39, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_8.ENTITY_METADATA, new PacketRemapper() {
|
||||
|
||||
@Override
|
||||
public void registerMap() {
|
||||
@ -217,7 +217,7 @@ public class EntityPackets {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
List<Metadata> metadataList = wrapper.get(Types1_9.METADATA_LIST, 0);
|
||||
if (metadataList.size() == 0) {
|
||||
if (metadataList.isEmpty()) {
|
||||
wrapper.cancel();
|
||||
}
|
||||
}
|
||||
@ -225,9 +225,7 @@ public class EntityPackets {
|
||||
}
|
||||
});
|
||||
|
||||
// Entity Effect Packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x1D, 0x4C, new PacketRemapper() {
|
||||
|
||||
protocol.registerOutgoing(ClientboundPackets1_8.ENTITY_EFFECT, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Entity ID
|
||||
@ -246,16 +244,12 @@ public class EntityPackets {
|
||||
}
|
||||
});
|
||||
|
||||
protocol.cancelOutgoing(ClientboundPackets1_8.UPDATE_ENTITY_NBT);
|
||||
|
||||
// Update Entity NBT
|
||||
protocol.cancelOutgoing(State.PLAY, 0x49, 0x49);
|
||||
|
||||
// Combat Event Packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x42, 0x2C, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_8.COMBAT_EVENT, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); //Event id
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
@ -269,8 +263,7 @@ public class EntityPackets {
|
||||
}
|
||||
});
|
||||
|
||||
// Entity Properties Packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x20, 0x4B, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_8.ENTITY_PROPERTIES, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT);
|
||||
@ -326,22 +319,8 @@ public class EntityPackets {
|
||||
});
|
||||
|
||||
|
||||
/* Packets which do not have any field remapping or handlers */
|
||||
|
||||
protocol.registerOutgoing(State.PLAY, 0x1A, 0x1B); // Entity Status Packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x16, 0x27); // Entity Look Packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x14, 0x28); // Entity Packet
|
||||
|
||||
protocol.registerOutgoing(State.PLAY, 0x0A, 0x2F); // Use Bed Packet
|
||||
|
||||
protocol.registerOutgoing(State.PLAY, 0x1E, 0x31); // Remove Entity Effect Packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x19, 0x34); // Entity Head Look Packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x12, 0x3B); // Entity Velocity Packet
|
||||
|
||||
/* Incoming Packets */
|
||||
|
||||
// Entity Action Packet
|
||||
protocol.registerIncoming(State.PLAY, 0x0B, 0x14, new PacketRemapper() {
|
||||
protocol.registerIncoming(ServerboundPackets1_9.ENTITY_ACTION, new PacketRemapper() {
|
||||
|
||||
@Override
|
||||
public void registerMap() {
|
||||
@ -362,9 +341,7 @@ public class EntityPackets {
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// Use Entity Packet
|
||||
protocol.registerIncoming(State.PLAY, 0x02, 0x0A, new PacketRemapper() {
|
||||
protocol.registerIncoming(ServerboundPackets1_9.INTERACT_ENTITY, new PacketRemapper() {
|
||||
|
||||
@Override
|
||||
public void registerMap() {
|
||||
@ -391,11 +368,5 @@ public class EntityPackets {
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
/* Packets which do not have any field remapping or handlers */
|
||||
|
||||
protocol.registerIncoming(State.PLAY, 0x0C, 0x15); // Steer Vehicle Packet
|
||||
protocol.registerIncoming(State.PLAY, 0x18, 0x1B); // Spectate Packet
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -7,17 +7,17 @@ import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.remapper.ValueCreator;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.ViaVersion.protocols.protocol1_8.ClientboundPackets1_8;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.ItemRewriter;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9To1_8;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.ServerboundPackets1_9;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.storage.EntityTracker1_9;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.storage.InventoryTracker;
|
||||
|
||||
public class InventoryPackets {
|
||||
|
||||
public static void register(Protocol protocol) {
|
||||
// Window Property Packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x31, 0x15, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_8.WINDOW_PROPERTY, new PacketRemapper() {
|
||||
|
||||
@Override
|
||||
public void registerMap() {
|
||||
@ -56,8 +56,7 @@ public class InventoryPackets {
|
||||
});
|
||||
}
|
||||
});
|
||||
// Window Open Packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x2D, 0x13, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_8.OPEN_WINDOW, new PacketRemapper() {
|
||||
|
||||
@Override
|
||||
public void registerMap() {
|
||||
@ -87,12 +86,9 @@ public class InventoryPackets {
|
||||
});
|
||||
}
|
||||
});
|
||||
// Window Set Slot Packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x2F, 0x16, new PacketRemapper() {
|
||||
|
||||
protocol.registerOutgoing(ClientboundPackets1_8.SET_SLOT, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
|
||||
map(Type.BYTE); // 0 - Window ID
|
||||
map(Type.SHORT); // 1 - Slot ID
|
||||
map(Type.ITEM); // 2 - Slot Value
|
||||
@ -121,8 +117,7 @@ public class InventoryPackets {
|
||||
});
|
||||
}
|
||||
});
|
||||
// Window Set Slots Packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x30, 0x14, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_8.WINDOW_ITEMS, new PacketRemapper() {
|
||||
|
||||
@Override
|
||||
public void registerMap() {
|
||||
@ -162,8 +157,7 @@ public class InventoryPackets {
|
||||
});
|
||||
}
|
||||
});
|
||||
// Close Window Packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x2E, 0x12, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_8.CLOSE_WINDOW, new PacketRemapper() {
|
||||
|
||||
@Override
|
||||
public void registerMap() {
|
||||
@ -179,8 +173,7 @@ public class InventoryPackets {
|
||||
}
|
||||
});
|
||||
|
||||
// Map Packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x34, 0x24, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_8.MAP_DATA, new PacketRemapper() {
|
||||
|
||||
@Override
|
||||
public void registerMap() {
|
||||
@ -196,14 +189,9 @@ public class InventoryPackets {
|
||||
}
|
||||
});
|
||||
|
||||
/* Packets which do not have any field remapping or handlers */
|
||||
protocol.registerOutgoing(State.PLAY, 0x09, 0x37); // Held Item Change Packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x32, 0x11); // Confirm Transaction Packet
|
||||
|
||||
/* Incoming Packets */
|
||||
|
||||
// Creative Inventory Slot Action Packet
|
||||
protocol.registerIncoming(State.PLAY, 0x10, 0x18, new PacketRemapper() {
|
||||
protocol.registerIncoming(ServerboundPackets1_9.CREATIVE_INVENTORY_ACTION, new PacketRemapper() {
|
||||
|
||||
@Override
|
||||
public void registerMap() {
|
||||
@ -240,8 +228,7 @@ public class InventoryPackets {
|
||||
}
|
||||
});
|
||||
|
||||
// Player Click Window Packet
|
||||
protocol.registerIncoming(State.PLAY, 0x0E, 0x07, new PacketRemapper() {
|
||||
protocol.registerIncoming(ServerboundPackets1_9.CLICK_WINDOW, new PacketRemapper() {
|
||||
|
||||
@Override
|
||||
public void registerMap() {
|
||||
@ -297,8 +284,7 @@ public class InventoryPackets {
|
||||
}
|
||||
});
|
||||
|
||||
// Close Window Incoming Packet
|
||||
protocol.registerIncoming(State.PLAY, 0x0D, 0x08, new PacketRemapper() {
|
||||
protocol.registerIncoming(ServerboundPackets1_9.CLOSE_WINDOW, new PacketRemapper() {
|
||||
|
||||
@Override
|
||||
public void registerMap() {
|
||||
@ -313,8 +299,7 @@ public class InventoryPackets {
|
||||
}
|
||||
});
|
||||
|
||||
// Held Item Change Packet
|
||||
protocol.registerIncoming(State.PLAY, 0x09, 0x17, new PacketRemapper() {
|
||||
protocol.registerIncoming(ServerboundPackets1_9.HELD_ITEM_CHANGE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
// Blocking patch
|
||||
@ -330,10 +315,5 @@ public class InventoryPackets {
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
/* Packets which do not have any field remapping or handlers */
|
||||
|
||||
protocol.registerIncoming(State.PLAY, 0x0F, 0x05); // Confirm Transaction Packet
|
||||
protocol.registerIncoming(State.PLAY, 0x11, 0x06); // Enchant Item Packet
|
||||
}
|
||||
}
|
||||
|
@ -5,16 +5,16 @@ import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.Via;
|
||||
import us.myles.ViaVersion.api.entities.Entity1_10Types;
|
||||
import us.myles.ViaVersion.api.minecraft.item.Item;
|
||||
import us.myles.ViaVersion.api.protocol.Protocol;
|
||||
import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.remapper.ValueCreator;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.ViaVersion.protocols.base.ProtocolInfo;
|
||||
import us.myles.ViaVersion.protocols.protocol1_8.ClientboundPackets1_8;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.ItemRewriter;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.PlayerMovementMapper;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9To1_8;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.ServerboundPackets1_9;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.chat.ChatRewriter;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.chat.GameMode;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.providers.CommandBlockProvider;
|
||||
@ -24,9 +24,8 @@ import us.myles.ViaVersion.protocols.protocol1_9to1_8.storage.EntityTracker1_9;
|
||||
import us.myles.ViaVersion.util.GsonUtil;
|
||||
|
||||
public class PlayerPackets {
|
||||
public static void register(Protocol protocol) {
|
||||
// Chat Message Packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x02, 0x0F, new PacketRemapper() {
|
||||
public static void register(Protocol1_9To1_8 protocol) {
|
||||
protocol.registerOutgoing(ClientboundPackets1_8.CHAT_MESSAGE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.STRING, Protocol1_9To1_8.FIX_JSON); // 0 - Chat Message (json)
|
||||
@ -47,8 +46,7 @@ public class PlayerPackets {
|
||||
}
|
||||
});
|
||||
|
||||
// Header and Footer Packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x47, 0x48, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_8.TAB_LIST, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.STRING, Protocol1_9To1_8.FIX_JSON); // 0 - Header
|
||||
@ -56,16 +54,14 @@ public class PlayerPackets {
|
||||
}
|
||||
});
|
||||
|
||||
// Disconnect Packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x40, 0x1A, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_8.DISCONNECT, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.STRING, Protocol1_9To1_8.FIX_JSON); // 0 - Reason
|
||||
}
|
||||
});
|
||||
|
||||
// Title Packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x45, 0x45, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_8.TITLE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Action
|
||||
@ -83,8 +79,7 @@ public class PlayerPackets {
|
||||
}
|
||||
});
|
||||
|
||||
// Player Position Packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x08, 0x2E, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_8.PLAYER_POSITION, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.DOUBLE); // 0 - Player X
|
||||
@ -105,8 +100,7 @@ public class PlayerPackets {
|
||||
}
|
||||
});
|
||||
|
||||
// Team Packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x3E, 0x41, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_8.TEAMS, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.STRING); // 0 - Team Name
|
||||
@ -170,8 +164,7 @@ public class PlayerPackets {
|
||||
}
|
||||
});
|
||||
|
||||
// Join Game Packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x01, 0x23, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_8.JOIN_GAME, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.INT); // 0 - Player ID
|
||||
@ -230,8 +223,7 @@ public class PlayerPackets {
|
||||
}
|
||||
});
|
||||
|
||||
// Player List Item Packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x38, 0x2D, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_8.PLAYER_INFO, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Action
|
||||
@ -283,8 +275,7 @@ public class PlayerPackets {
|
||||
}
|
||||
});
|
||||
|
||||
// Packet Plugin Message Outgoing
|
||||
protocol.registerOutgoing(State.PLAY, 0x3F, 0x18, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_8.PLUGIN_MESSAGE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.STRING); // 0 - Channel Name
|
||||
@ -326,8 +317,7 @@ public class PlayerPackets {
|
||||
}
|
||||
});
|
||||
|
||||
// Update Health Packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x06, 0x3E, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_8.UPDATE_HEALTH, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.FLOAT); // 0 - Health
|
||||
@ -346,8 +336,7 @@ public class PlayerPackets {
|
||||
}
|
||||
});
|
||||
|
||||
// Respawn Packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x07, 0x33, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_8.RESPAWN, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.INT); // 0 - Dimension
|
||||
@ -380,8 +369,7 @@ public class PlayerPackets {
|
||||
}
|
||||
});
|
||||
|
||||
// Change Game State Packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x2B, 0x1E, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_8.GAME_EVENT, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.UNSIGNED_BYTE); //0 - Reason
|
||||
@ -400,33 +388,11 @@ public class PlayerPackets {
|
||||
});
|
||||
|
||||
/* Removed packets */
|
||||
protocol.cancelOutgoing(ClientboundPackets1_8.SET_COMPRESSION);
|
||||
|
||||
// Set Compression
|
||||
protocol.cancelOutgoing(State.PLAY, 0x46, 0x46);
|
||||
|
||||
/* Packets which do not have any field remapping or handlers */
|
||||
|
||||
protocol.registerOutgoing(State.PLAY, 0x3A, 0x0E); // Tab Complete Response Packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x0B, 0x06); // Animation Packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x37, 0x07); // Stats Packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x36, 0x2A); // Open Sign Editor Packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x39, 0x2B); // Player Abilities Packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x00, 0x1F); // Keep Alive Packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x48, 0x32); // Resource Pack Send Packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x43, 0x36); // Camera Packet
|
||||
|
||||
protocol.registerOutgoing(State.PLAY, 0x3D, 0x38); // Display Scoreboard Packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x3B, 0x3F); // Scoreboard Objective Packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x3C, 0x42); // Update Score Packet
|
||||
|
||||
protocol.registerOutgoing(State.PLAY, 0x05, 0x43); // Spawn Position Packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x1F, 0x3D); // Set XP Packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x0D, 0x49); // Collect Item Packet
|
||||
|
||||
/* Incoming Packets */
|
||||
|
||||
// Tab Complete Request Packet
|
||||
protocol.registerIncoming(State.PLAY, 0x14, 0x01, new PacketRemapper() {
|
||||
protocol.registerIncoming(ServerboundPackets1_9.TAB_COMPLETE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.STRING); // 0 - Requested Command
|
||||
@ -434,8 +400,7 @@ public class PlayerPackets {
|
||||
}
|
||||
});
|
||||
|
||||
// Client Settings Packet
|
||||
protocol.registerIncoming(State.PLAY, 0x15, 0x04, new PacketRemapper() {
|
||||
protocol.registerIncoming(ServerboundPackets1_9.CLIENT_SETTINGS, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.STRING); // 0 - locale
|
||||
@ -463,25 +428,18 @@ public class PlayerPackets {
|
||||
}
|
||||
});
|
||||
|
||||
// Animation Request Packet
|
||||
protocol.registerIncoming(State.PLAY, 0x0A, 0x1A, new PacketRemapper() {
|
||||
protocol.registerIncoming(ServerboundPackets1_9.ANIMATION, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT, Type.NOTHING); // 0 - Hand
|
||||
}
|
||||
});
|
||||
|
||||
// TP Confirm
|
||||
protocol.cancelIncoming(State.PLAY, 0x00);
|
||||
protocol.cancelIncoming(ServerboundPackets1_9.TELEPORT_CONFIRM);
|
||||
protocol.cancelIncoming(ServerboundPackets1_9.VEHICLE_MOVE);
|
||||
protocol.cancelIncoming(ServerboundPackets1_9.STEER_BOAT);
|
||||
|
||||
// Vehicle Move
|
||||
protocol.cancelIncoming(State.PLAY, 0x10);
|
||||
|
||||
// Steer Boat
|
||||
protocol.cancelIncoming(State.PLAY, 0x11);
|
||||
|
||||
// Packet Plugin Message Incoming
|
||||
protocol.registerIncoming(State.PLAY, 0x17, 0x09, new PacketRemapper() {
|
||||
protocol.registerIncoming(ServerboundPackets1_9.PLUGIN_MESSAGE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.STRING); // 0 - Channel Name
|
||||
@ -514,8 +472,7 @@ public class PlayerPackets {
|
||||
}
|
||||
});
|
||||
|
||||
// Client Status Packet
|
||||
protocol.registerIncoming(State.PLAY, 0x16, 0x03, new PacketRemapper() {
|
||||
protocol.registerIncoming(ServerboundPackets1_9.CLIENT_STATUS, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Action ID
|
||||
@ -536,8 +493,7 @@ public class PlayerPackets {
|
||||
}
|
||||
});
|
||||
|
||||
// Player Position Packet
|
||||
protocol.registerIncoming(State.PLAY, 0x04, 0x0C, new PacketRemapper() {
|
||||
protocol.registerIncoming(ServerboundPackets1_9.PLAYER_POSITION, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.DOUBLE); // 0 - X
|
||||
@ -547,9 +503,7 @@ public class PlayerPackets {
|
||||
handler(new PlayerMovementMapper());
|
||||
}
|
||||
});
|
||||
|
||||
// Player Move & Look Packet
|
||||
protocol.registerIncoming(State.PLAY, 0x06, 0x0D, new PacketRemapper() {
|
||||
protocol.registerIncoming(ServerboundPackets1_9.PLAYER_POSITION_AND_ROTATION, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.DOUBLE); // 0 - X
|
||||
@ -561,9 +515,7 @@ public class PlayerPackets {
|
||||
handler(new PlayerMovementMapper());
|
||||
}
|
||||
});
|
||||
|
||||
// Player Look Packet
|
||||
protocol.registerIncoming(State.PLAY, 0x05, 0x0E, new PacketRemapper() {
|
||||
protocol.registerIncoming(ServerboundPackets1_9.PLAYER_ROTATION, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.FLOAT); // 0 - Yaw
|
||||
@ -572,24 +524,12 @@ public class PlayerPackets {
|
||||
handler(new PlayerMovementMapper());
|
||||
}
|
||||
});
|
||||
|
||||
// Player Packet
|
||||
protocol.registerIncoming(State.PLAY, 0x03, 0x0F, new PacketRemapper() {
|
||||
protocol.registerIncoming(ServerboundPackets1_9.PLAYER_MOVEMENT, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.BOOLEAN); // 0 - Ground
|
||||
handler(new PlayerMovementMapper());
|
||||
}
|
||||
});
|
||||
|
||||
/* Packets which do not have any field remapping or handlers */
|
||||
|
||||
protocol.registerIncoming(State.PLAY, 0x01, 0x02); // Chat Message Packet
|
||||
protocol.registerIncoming(State.PLAY, 0x13, 0x12); // Player Abilities Request Packet
|
||||
protocol.registerIncoming(State.PLAY, 0x19, 0x16); // Resource Pack Status Packet
|
||||
|
||||
protocol.registerIncoming(State.PLAY, 0x00, 0x0B); // Keep Alive Request Packet
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,6 @@ import us.myles.ViaVersion.api.entities.Entity1_10Types;
|
||||
import us.myles.ViaVersion.api.minecraft.item.Item;
|
||||
import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
|
||||
import us.myles.ViaVersion.api.minecraft.metadata.types.MetaType1_9;
|
||||
import us.myles.ViaVersion.api.protocol.Protocol;
|
||||
import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.remapper.ValueCreator;
|
||||
@ -14,7 +13,7 @@ import us.myles.ViaVersion.api.remapper.ValueTransformer;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.api.type.types.version.Types1_8;
|
||||
import us.myles.ViaVersion.api.type.types.version.Types1_9;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.ViaVersion.protocols.protocol1_8.ClientboundPackets1_8;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.ItemRewriter;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9To1_8;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.metadata.MetadataRewriter1_9To1_8;
|
||||
@ -32,8 +31,7 @@ public class SpawnPackets {
|
||||
};
|
||||
|
||||
public static void register(Protocol1_9To1_8 protocol) {
|
||||
// Spawn Object Packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x0E, 0x00, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_8.SPAWN_ENTITY, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Entity ID
|
||||
@ -118,8 +116,7 @@ public class SpawnPackets {
|
||||
}
|
||||
});
|
||||
|
||||
// Spawn XP Packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x11, 0x01, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_8.SPAWN_EXPERIENCE_ORB, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Entity ID
|
||||
@ -143,8 +140,7 @@ public class SpawnPackets {
|
||||
}
|
||||
});
|
||||
|
||||
// Spawn Global Entity Packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x2C, 0x02, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_8.SPAWN_GLOBAL_ENTITY, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Entity ID
|
||||
@ -167,8 +163,7 @@ public class SpawnPackets {
|
||||
}
|
||||
});
|
||||
|
||||
// Spawn Mob Packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x0F, 0x03, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_8.SPAWN_MOB, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Entity ID
|
||||
@ -235,8 +230,7 @@ public class SpawnPackets {
|
||||
}
|
||||
});
|
||||
|
||||
// Spawn Painting Packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x10, 0x04, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_8.SPAWN_PAINTING, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Entity ID
|
||||
@ -251,8 +245,6 @@ public class SpawnPackets {
|
||||
tracker.sendMetadataBuffer(entityID);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
create(new ValueCreator() {
|
||||
@Override
|
||||
public void write(PacketWrapper wrapper) throws Exception {
|
||||
@ -268,8 +260,7 @@ public class SpawnPackets {
|
||||
}
|
||||
});
|
||||
|
||||
// Spawn Player Packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x0C, 0x05, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_8.SPAWN_PLAYER, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Entity ID
|
||||
@ -341,8 +332,7 @@ public class SpawnPackets {
|
||||
}
|
||||
});
|
||||
|
||||
// Entity Destroy Packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x13, 0x30, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_8.DESTROY_ENTITIES, new PacketRemapper() {
|
||||
|
||||
@Override
|
||||
public void registerMap() {
|
||||
|
@ -13,9 +13,10 @@ import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.remapper.ValueCreator;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.ViaVersion.protocols.protocol1_8.ClientboundPackets1_8;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.ItemRewriter;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9To1_8;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.ServerboundPackets1_9;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.providers.BulkChunkTranslatorProvider;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.providers.CommandBlockProvider;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.sounds.Effect;
|
||||
@ -31,8 +32,7 @@ import java.util.Optional;
|
||||
|
||||
public class WorldPackets {
|
||||
public static void register(Protocol protocol) {
|
||||
// Sign Update Packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x33, 0x46, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_8.UPDATE_SIGN, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.POSITION); // 0 - Sign Position
|
||||
@ -43,8 +43,7 @@ public class WorldPackets {
|
||||
}
|
||||
});
|
||||
|
||||
// Play Effect Packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x28, 0x21, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_8.EFFECT, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.INT); // 0 - Effect ID
|
||||
@ -76,8 +75,7 @@ public class WorldPackets {
|
||||
}
|
||||
});
|
||||
|
||||
// Play Named Sound Effect Packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x29, 0x19, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_8.NAMED_SOUND, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.STRING); // 0 - Sound Name
|
||||
@ -105,7 +103,6 @@ public class WorldPackets {
|
||||
int z = wrapper.passthrough(Type.INT); //Position Z
|
||||
if (tracker.interactedBlockRecently((int) Math.floor(x / 8.0), (int) Math.floor(y / 8.0), (int) Math.floor(z / 8.0))) {
|
||||
wrapper.cancel();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -113,8 +110,7 @@ public class WorldPackets {
|
||||
}
|
||||
});
|
||||
|
||||
// Chunk Packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x21, 0x20, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_8.CHUNK_DATA, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@ -141,8 +137,7 @@ public class WorldPackets {
|
||||
}
|
||||
});
|
||||
|
||||
// Bulk Chunk Packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x26, -1, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_8.MAP_BULK_CHUNK, null, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@ -176,8 +171,7 @@ public class WorldPackets {
|
||||
}
|
||||
});
|
||||
|
||||
// Update Block Entity Packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x35, 0x09, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_8.BLOCK_ENTITY_DATA, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.POSITION); // 0 - Block Position
|
||||
@ -214,29 +208,17 @@ public class WorldPackets {
|
||||
}
|
||||
});
|
||||
|
||||
// Block Change Packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x23, 0x0B, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_8.BLOCK_CHANGE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.POSITION);
|
||||
map(Type.VAR_INT);
|
||||
}
|
||||
});
|
||||
/* Packets which do not have any field remapping or handlers */
|
||||
|
||||
protocol.registerOutgoing(State.PLAY, 0x25, 0x08); // Block Break Animation Packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x24, 0x0A); // Block Action Packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x41, 0x0D); // Server Difficulty Packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x22, 0x10); // Multi Block Change Packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x27, 0x1C); // Explosion Packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x2A, 0x22); // Particle Packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x03, 0x44); // Update Time Packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x44, 0x35); // World Border Packet
|
||||
|
||||
/* Incoming Packets */
|
||||
|
||||
// Sign Update Request Packet
|
||||
protocol.registerIncoming(State.PLAY, 0x12, 0x19, new PacketRemapper() {
|
||||
protocol.registerIncoming(ServerboundPackets1_9.UPDATE_SIGN, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.POSITION); // 0 - Sign Position
|
||||
@ -247,8 +229,7 @@ public class WorldPackets {
|
||||
}
|
||||
});
|
||||
|
||||
// Player Digging Packet
|
||||
protocol.registerIncoming(State.PLAY, 0x07, 0x13, new PacketRemapper() {
|
||||
protocol.registerIncoming(ServerboundPackets1_9.PLAYER_DIGGING, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT, Type.UNSIGNED_BYTE); // 0 - Status
|
||||
@ -279,8 +260,7 @@ public class WorldPackets {
|
||||
}
|
||||
});
|
||||
|
||||
// Use Item Packet
|
||||
protocol.registerIncoming(State.PLAY, -1, 0x1D, new PacketRemapper() {
|
||||
protocol.registerIncoming(ServerboundPackets1_9.USE_ITEM, null, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@ -324,8 +304,7 @@ public class WorldPackets {
|
||||
}
|
||||
});
|
||||
|
||||
// Block Placement Packet
|
||||
protocol.registerIncoming(State.PLAY, 0x08, 0x1C, new PacketRemapper() {
|
||||
protocol.registerIncoming(ServerboundPackets1_9.PLAYER_BLOCK_PLACEMENT, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.POSITION); // 0 - Position
|
||||
|
@ -3,6 +3,7 @@ package us.myles.ViaVersion.update;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParseException;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import us.myles.ViaVersion.api.Via;
|
||||
import us.myles.ViaVersion.util.GsonUtil;
|
||||
|
||||
@ -40,6 +41,7 @@ public class UpdateUtil {
|
||||
});
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static String getUpdateMessage(boolean console) {
|
||||
if (Via.getPlatform().getPluginVersion().equals("${project.version}")) {
|
||||
return "You are using a debug/custom version, consider updating.";
|
||||
@ -71,6 +73,7 @@ public class UpdateUtil {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static String getNewestVersion() {
|
||||
try {
|
||||
URL url = new URL(URL + PLUGIN + LATEST_VERSION + "?" + System.currentTimeMillis());
|
||||
|
@ -10,7 +10,7 @@ import java.util.regex.Pattern;
|
||||
public class Version implements Comparable<Version> {
|
||||
private static final Pattern semVer = Pattern.compile("(?<a>0|[1-9]\\d*)\\.(?<b>0|[1-9]\\d*)(?:\\.(?<c>0|[1-9]\\d*))?(?:-(?<tag>[A-z0-9.-]*))?");
|
||||
private final int[] parts = new int[3];
|
||||
private String tag;
|
||||
private final String tag;
|
||||
|
||||
public Version(String value) {
|
||||
if (value == null)
|
||||
@ -48,9 +48,9 @@ public class Version implements Comparable<Version> {
|
||||
}
|
||||
|
||||
// Simple tag check
|
||||
if (verA.tag.length() == 0 && verB.tag.length() > 0)
|
||||
if (verA.tag.isEmpty() && !verB.tag.isEmpty())
|
||||
return 1;
|
||||
if (verA.tag.length() > 0 && verB.tag.length() == 0)
|
||||
if (!verA.tag.isEmpty() && verB.tag.isEmpty())
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
@ -74,7 +74,7 @@ public class Version implements Comparable<Version> {
|
||||
for (int i = 0; i < parts.length; i += 1)
|
||||
split[i] = String.valueOf(parts[i]);
|
||||
|
||||
return Joiner.on(".").join(split) + (tag.length() != 0 ? "-" + tag : "");
|
||||
return Joiner.on(".").join(split) + (!tag.isEmpty() ? "-" + tag : "");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -2,5 +2,6 @@ package us.myles.ViaVersion.util;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface BiIntConsumer {
|
||||
|
||||
void consume(int i1, int i2);
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package us.myles.ViaVersion.util;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.yaml.snakeyaml.DumperOptions;
|
||||
import org.yaml.snakeyaml.Yaml;
|
||||
import org.yaml.snakeyaml.representer.Representer;
|
||||
@ -124,6 +125,7 @@ public abstract class Config implements ConfigurationProvider {
|
||||
return this.config;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public <T> T get(String key, Class<T> clazz, T def) {
|
||||
Object o = this.config.get(key);
|
||||
if (o != null) {
|
||||
@ -142,7 +144,8 @@ public abstract class Config implements ConfigurationProvider {
|
||||
}
|
||||
}
|
||||
|
||||
public String getString(String key, String def) {
|
||||
@Nullable
|
||||
public String getString(String key, @Nullable String def) {
|
||||
final Object o = this.config.get(key);
|
||||
if (o != null) {
|
||||
return (String) o;
|
||||
|
8
pom.xml
8
pom.xml
@ -126,6 +126,14 @@
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- JetBrains Annotations -->
|
||||
<dependency>
|
||||
<groupId>org.jetbrains</groupId>
|
||||
<artifactId>annotations</artifactId>
|
||||
<version>19.0.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- JUnit -->
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
|
@ -1,5 +1,6 @@
|
||||
package us.myles.ViaVersion.sponge.commands;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.spongepowered.api.command.CommandCallable;
|
||||
import org.spongepowered.api.command.CommandException;
|
||||
import org.spongepowered.api.command.CommandResult;
|
||||
@ -9,7 +10,6 @@ import org.spongepowered.api.world.Location;
|
||||
import org.spongepowered.api.world.World;
|
||||
import us.myles.ViaVersion.commands.ViaCommandHandler;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren