Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-27 00:22:51 +01:00
Rename abstract Protocol to AbstractProtocol
This prevents confusion around the previously equally named interface and abstract class
Dieser Commit ist enthalten in:
Ursprung
95e20677fd
Commit
cadb5ec64c
@ -0,0 +1,407 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||||
|
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
|
package com.viaversion.viaversion.api.protocol;
|
||||||
|
|
||||||
|
import com.google.common.base.Preconditions;
|
||||||
|
import com.viaversion.viaversion.api.Via;
|
||||||
|
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
|
||||||
|
import com.viaversion.viaversion.api.protocol.packet.Direction;
|
||||||
|
import com.viaversion.viaversion.api.protocol.packet.PacketType;
|
||||||
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
|
import com.viaversion.viaversion.api.protocol.packet.ServerboundPacketType;
|
||||||
|
import com.viaversion.viaversion.api.protocol.packet.State;
|
||||||
|
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||||
|
import com.viaversion.viaversion.exception.CancelException;
|
||||||
|
import com.viaversion.viaversion.exception.InformativeException;
|
||||||
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
public abstract class AbstractProtocol<C1 extends ClientboundPacketType, C2 extends ClientboundPacketType, S1 extends ServerboundPacketType, S2 extends ServerboundPacketType>
|
||||||
|
implements Protocol<C1, C2, S1, S2> {
|
||||||
|
private final Map<Packet, ProtocolPacket> incoming = new HashMap<>();
|
||||||
|
private final Map<Packet, ProtocolPacket> outgoing = new HashMap<>();
|
||||||
|
private final Map<Class, Object> storedObjects = new HashMap<>(); // currently only used for MetadataRewriters
|
||||||
|
protected final Class<C1> oldClientboundPacketEnum;
|
||||||
|
protected final Class<C2> newClientboundPacketEnum;
|
||||||
|
protected final Class<S1> oldServerboundPacketEnum;
|
||||||
|
protected final Class<S2> newServerboundPacketEnum;
|
||||||
|
|
||||||
|
protected AbstractProtocol() {
|
||||||
|
this(null, null, null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a protocol with automated id mapping if the respective enums are not null.
|
||||||
|
*/
|
||||||
|
protected AbstractProtocol(@Nullable Class<C1> oldClientboundPacketEnum, @Nullable Class<C2> clientboundPacketEnum,
|
||||||
|
@Nullable Class<S1> oldServerboundPacketEnum, @Nullable Class<S2> serverboundPacketEnum) {
|
||||||
|
this.oldClientboundPacketEnum = oldClientboundPacketEnum;
|
||||||
|
this.newClientboundPacketEnum = clientboundPacketEnum;
|
||||||
|
this.oldServerboundPacketEnum = oldServerboundPacketEnum;
|
||||||
|
this.newServerboundPacketEnum = serverboundPacketEnum;
|
||||||
|
registerPackets();
|
||||||
|
|
||||||
|
// Register the rest of the ids with no handlers if necessary
|
||||||
|
if (oldClientboundPacketEnum != null && clientboundPacketEnum != null
|
||||||
|
&& oldClientboundPacketEnum != clientboundPacketEnum) {
|
||||||
|
registerOutgoingChannelIdChanges();
|
||||||
|
}
|
||||||
|
if (oldServerboundPacketEnum != null && serverboundPacketEnum != null
|
||||||
|
&& oldServerboundPacketEnum != serverboundPacketEnum) {
|
||||||
|
registerIncomingChannelIdChanges();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void registerOutgoingChannelIdChanges() {
|
||||||
|
ClientboundPacketType[] newConstants = newClientboundPacketEnum.getEnumConstants();
|
||||||
|
Map<String, ClientboundPacketType> newClientboundPackets = new HashMap<>(newConstants.length);
|
||||||
|
for (ClientboundPacketType newConstant : newConstants) {
|
||||||
|
newClientboundPackets.put(newConstant.name(), newConstant);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (ClientboundPacketType packet : oldClientboundPacketEnum.getEnumConstants()) {
|
||||||
|
ClientboundPacketType mappedPacket = newClientboundPackets.get(packet.name());
|
||||||
|
int oldId = packet.ordinal();
|
||||||
|
if (mappedPacket == null) {
|
||||||
|
// Packet doesn't exist on new client
|
||||||
|
Preconditions.checkArgument(hasRegisteredOutgoing(State.PLAY, oldId),
|
||||||
|
"Packet " + packet + " in " + getClass().getSimpleName() + " has no mapping - it needs to be manually cancelled or remapped!");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
int newId = mappedPacket.ordinal();
|
||||||
|
if (!hasRegisteredOutgoing(State.PLAY, oldId)) {
|
||||||
|
registerOutgoing(State.PLAY, oldId, newId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void registerIncomingChannelIdChanges() {
|
||||||
|
ServerboundPacketType[] oldConstants = oldServerboundPacketEnum.getEnumConstants();
|
||||||
|
Map<String, ServerboundPacketType> oldServerboundConstants = new HashMap<>(oldConstants.length);
|
||||||
|
for (ServerboundPacketType oldConstant : oldConstants) {
|
||||||
|
oldServerboundConstants.put(oldConstant.name(), oldConstant);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (ServerboundPacketType packet : newServerboundPacketEnum.getEnumConstants()) {
|
||||||
|
ServerboundPacketType mappedPacket = oldServerboundConstants.get(packet.name());
|
||||||
|
int newId = packet.ordinal();
|
||||||
|
if (mappedPacket == null) {
|
||||||
|
// Packet doesn't exist on old server
|
||||||
|
Preconditions.checkArgument(hasRegisteredIncoming(State.PLAY, newId),
|
||||||
|
"Packet " + packet + " in " + getClass().getSimpleName() + " has no mapping - it needs to be manually cancelled or remapped!");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
int oldId = mappedPacket.ordinal();
|
||||||
|
if (!hasRegisteredIncoming(State.PLAY, newId)) {
|
||||||
|
registerIncoming(State.PLAY, oldId, newId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register the packets for this protocol. To be overriden.
|
||||||
|
*/
|
||||||
|
protected void registerPackets() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final void loadMappingData() {
|
||||||
|
getMappingData().load();
|
||||||
|
onMappingDataLoaded();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called after {@link #loadMappingData()} is called; load extra mapping data for the protocol.
|
||||||
|
* <p>
|
||||||
|
* To be overridden if needed.
|
||||||
|
*/
|
||||||
|
protected void onMappingDataLoaded() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void registerIncoming(State state, int oldPacketID, int newPacketID, PacketRemapper packetRemapper, boolean override) {
|
||||||
|
ProtocolPacket protocolPacket = new ProtocolPacket(state, oldPacketID, newPacketID, packetRemapper);
|
||||||
|
Packet packet = new Packet(state, newPacketID);
|
||||||
|
if (!override && incoming.containsKey(packet)) {
|
||||||
|
Via.getPlatform().getLogger().log(Level.WARNING, packet + " already registered!" +
|
||||||
|
" If this override is intentional, set override to true. Stacktrace: ", new Exception());
|
||||||
|
}
|
||||||
|
incoming.put(packet, protocolPacket);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void cancelIncoming(State state, int oldPacketID, int newPacketID) {
|
||||||
|
registerIncoming(state, oldPacketID, newPacketID, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
handler(PacketWrapper::cancel);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void cancelOutgoing(State state, int oldPacketID, int newPacketID) {
|
||||||
|
registerOutgoing(state, oldPacketID, newPacketID, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
handler(PacketWrapper::cancel);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void registerOutgoing(State state, int oldPacketID, int newPacketID, PacketRemapper packetRemapper, boolean override) {
|
||||||
|
ProtocolPacket protocolPacket = new ProtocolPacket(state, oldPacketID, newPacketID, packetRemapper);
|
||||||
|
Packet packet = new Packet(state, oldPacketID);
|
||||||
|
if (!override && outgoing.containsKey(packet)) {
|
||||||
|
Via.getPlatform().getLogger().log(Level.WARNING, packet + " already registered!" +
|
||||||
|
" If override is intentional, set override to true. Stacktrace: ", new Exception());
|
||||||
|
}
|
||||||
|
outgoing.put(packet, protocolPacket);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void registerOutgoing(C1 packetType, @Nullable PacketRemapper packetRemapper) {
|
||||||
|
checkPacketType(packetType, packetType.getClass() == oldClientboundPacketEnum);
|
||||||
|
|
||||||
|
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!");
|
||||||
|
|
||||||
|
int oldId = packetType.ordinal();
|
||||||
|
int newId = mappedPacket.ordinal();
|
||||||
|
registerOutgoing(State.PLAY, oldId, newId, packetRemapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void registerOutgoing(C1 packetType, @Nullable C2 mappedPacketType, @Nullable PacketRemapper packetRemapper) {
|
||||||
|
checkPacketType(packetType, packetType.getClass() == oldClientboundPacketEnum);
|
||||||
|
checkPacketType(mappedPacketType, mappedPacketType == null || mappedPacketType.getClass() == newClientboundPacketEnum);
|
||||||
|
|
||||||
|
registerOutgoing(State.PLAY, packetType.ordinal(), mappedPacketType != null ? mappedPacketType.ordinal() : -1, packetRemapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void cancelOutgoing(C1 packetType) {
|
||||||
|
cancelOutgoing(State.PLAY, packetType.ordinal(), packetType.ordinal());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void registerIncoming(S2 packetType, @Nullable PacketRemapper packetRemapper) {
|
||||||
|
checkPacketType(packetType, packetType.getClass() == newServerboundPacketEnum);
|
||||||
|
|
||||||
|
ServerboundPacketType mappedPacket = oldServerboundPacketEnum == newServerboundPacketEnum ? packetType
|
||||||
|
: Arrays.stream(oldServerboundPacketEnum.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!");
|
||||||
|
|
||||||
|
int oldId = mappedPacket.ordinal();
|
||||||
|
int newId = packetType.ordinal();
|
||||||
|
registerIncoming(State.PLAY, oldId, newId, packetRemapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void registerIncoming(S2 packetType, @Nullable S1 mappedPacketType, @Nullable PacketRemapper packetRemapper) {
|
||||||
|
checkPacketType(packetType, packetType.getClass() == newServerboundPacketEnum);
|
||||||
|
checkPacketType(mappedPacketType, mappedPacketType == null || mappedPacketType.getClass() == oldServerboundPacketEnum);
|
||||||
|
|
||||||
|
registerIncoming(State.PLAY, mappedPacketType != null ? mappedPacketType.ordinal() : -1, packetType.ordinal(), packetRemapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void cancelIncoming(S2 packetType) {
|
||||||
|
Preconditions.checkArgument(packetType.getClass() == newServerboundPacketEnum);
|
||||||
|
cancelIncoming(State.PLAY, -1, packetType.ordinal());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasRegisteredOutgoing(State state, int oldPacketID) {
|
||||||
|
Packet packet = new Packet(state, oldPacketID);
|
||||||
|
return outgoing.containsKey(packet);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasRegisteredIncoming(State state, int newPacketId) {
|
||||||
|
Packet packet = new Packet(state, newPacketId);
|
||||||
|
return incoming.containsKey(packet);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void transform(Direction direction, State state, PacketWrapper packetWrapper) throws Exception {
|
||||||
|
Packet statePacket = new Packet(state, packetWrapper.getId());
|
||||||
|
Map<Packet, ProtocolPacket> packetMap = (direction == Direction.OUTGOING ? outgoing : incoming);
|
||||||
|
ProtocolPacket protocolPacket = packetMap.get(statePacket);
|
||||||
|
if (protocolPacket == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Write packet id
|
||||||
|
int oldId = packetWrapper.getId();
|
||||||
|
int newId = direction == Direction.OUTGOING ? protocolPacket.getNewID() : protocolPacket.getOldID();
|
||||||
|
packetWrapper.setId(newId);
|
||||||
|
|
||||||
|
PacketRemapper remapper = protocolPacket.getRemapper();
|
||||||
|
if (remapper != null) {
|
||||||
|
try {
|
||||||
|
remapper.remap(packetWrapper);
|
||||||
|
} catch (InformativeException e) { // Catch InformativeExceptions, pass through CancelExceptions
|
||||||
|
throwRemapError(direction, state, oldId, newId, e);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (packetWrapper.isCancelled()) {
|
||||||
|
throw CancelException.generate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void throwRemapError(Direction direction, State state, int oldId, int newId, InformativeException e) throws InformativeException {
|
||||||
|
// Don't print errors during handshake
|
||||||
|
if (state == State.HANDSHAKE) {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
|
||||||
|
Class<? extends PacketType> packetTypeClass = state == State.PLAY ? (direction == Direction.OUTGOING ? oldClientboundPacketEnum : newServerboundPacketEnum) : null;
|
||||||
|
if (packetTypeClass != null) {
|
||||||
|
PacketType[] enumConstants = packetTypeClass.getEnumConstants();
|
||||||
|
PacketType packetType = oldId < enumConstants.length && oldId >= 0 ? enumConstants[oldId] : null;
|
||||||
|
Via.getPlatform().getLogger().warning("ERROR IN " + getClass().getSimpleName() + " IN REMAP OF " + packetType + " (" + toNiceHex(oldId) + ")");
|
||||||
|
} else {
|
||||||
|
Via.getPlatform().getLogger().warning("ERROR IN " + getClass().getSimpleName()
|
||||||
|
+ " IN REMAP OF " + toNiceHex(oldId) + "->" + toNiceHex(newId));
|
||||||
|
}
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String toNiceHex(int id) {
|
||||||
|
String hex = Integer.toHexString(id).toUpperCase();
|
||||||
|
return (hex.length() == 1 ? "0x0" : "0x") + hex;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param packetType packet type
|
||||||
|
* @param isValid expression to check the packet's validity
|
||||||
|
* @throws IllegalArgumentException if the given expression is not met
|
||||||
|
*/
|
||||||
|
private void checkPacketType(PacketType packetType, boolean isValid) {
|
||||||
|
if (!isValid) {
|
||||||
|
throw new IllegalArgumentException("Packet type " + packetType + " in " + packetType.getClass().getSimpleName() + " is taken from the wrong enum");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @Nullable <T> T get(Class<T> objectClass) {
|
||||||
|
return (T) storedObjects.get(objectClass);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void put(Object object) {
|
||||||
|
storedObjects.put(object.getClass(), object);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasMappingDataToLoad() {
|
||||||
|
return getMappingData() != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Protocol:" + getClass().getSimpleName();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Packet {
|
||||||
|
private final State state;
|
||||||
|
private final int packetId;
|
||||||
|
|
||||||
|
public Packet(State state, int packetId) {
|
||||||
|
this.state = state;
|
||||||
|
this.packetId = packetId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public State getState() {
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPacketId() {
|
||||||
|
return packetId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Packet{" + "state=" + state + ", packetId=" + packetId + '}';
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) return true;
|
||||||
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
|
Packet that = (Packet) o;
|
||||||
|
return packetId == that.packetId && state == that.state;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
int result = state != null ? state.hashCode() : 0;
|
||||||
|
result = 31 * result + packetId;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class ProtocolPacket {
|
||||||
|
private final State state;
|
||||||
|
private final int oldID;
|
||||||
|
private final int newID;
|
||||||
|
private final PacketRemapper remapper;
|
||||||
|
|
||||||
|
public ProtocolPacket(State state, int oldID, int newID, @Nullable PacketRemapper remapper) {
|
||||||
|
this.state = state;
|
||||||
|
this.oldID = oldID;
|
||||||
|
this.newID = newID;
|
||||||
|
this.remapper = remapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
public State getState() {
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getOldID() {
|
||||||
|
return oldID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getNewID() {
|
||||||
|
return newID;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public PacketRemapper getRemapper() {
|
||||||
|
return remapper;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -22,8 +22,6 @@
|
|||||||
*/
|
*/
|
||||||
package com.viaversion.viaversion.api.protocol;
|
package com.viaversion.viaversion.api.protocol;
|
||||||
|
|
||||||
import com.viaversion.viaversion.api.protocol.base.SimpleProtocol;
|
public abstract class AbstractSimpleProtocol extends AbstractProtocol<SimpleProtocol.DummyPacketTypes, SimpleProtocol.DummyPacketTypes,
|
||||||
|
|
||||||
public abstract class AbstractSimpleProtocol extends Protocol<SimpleProtocol.DummyPacketTypes, SimpleProtocol.DummyPacketTypes,
|
|
||||||
SimpleProtocol.DummyPacketTypes, SimpleProtocol.DummyPacketTypes> implements SimpleProtocol {
|
SimpleProtocol.DummyPacketTypes, SimpleProtocol.DummyPacketTypes> implements SimpleProtocol {
|
||||||
}
|
}
|
||||||
|
@ -22,386 +22,247 @@
|
|||||||
*/
|
*/
|
||||||
package com.viaversion.viaversion.api.protocol;
|
package com.viaversion.viaversion.api.protocol;
|
||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||||
import com.viaversion.viaversion.api.Via;
|
import com.viaversion.viaversion.api.data.MappingData;
|
||||||
|
import com.viaversion.viaversion.api.platform.providers.ViaProviders;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
|
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.Direction;
|
import com.viaversion.viaversion.api.protocol.packet.Direction;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketType;
|
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.ServerboundPacketType;
|
import com.viaversion.viaversion.api.protocol.packet.ServerboundPacketType;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.State;
|
import com.viaversion.viaversion.api.protocol.packet.State;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||||
import com.viaversion.viaversion.exception.CancelException;
|
|
||||||
import com.viaversion.viaversion.exception.InformativeException;
|
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
import java.util.Arrays;
|
/**
|
||||||
import java.util.HashMap;
|
* Abstract protocol class handling packet transformation between two protocol versions.
|
||||||
import java.util.Map;
|
* Clientbound and serverbount packet types can be set to enforce correct usage of them.
|
||||||
import java.util.logging.Level;
|
*
|
||||||
|
* @param <C1> old clientbound packet types
|
||||||
public abstract class Protocol<C1 extends ClientboundPacketType, C2 extends ClientboundPacketType, S1 extends ServerboundPacketType, S2 extends ServerboundPacketType>
|
* @param <C2> new clientbound packet types
|
||||||
implements com.viaversion.viaversion.api.protocol.base.Protocol<C1, C2, S1, S2> {
|
* @param <S1> old serverbound packet types
|
||||||
private final Map<Packet, ProtocolPacket> incoming = new HashMap<>();
|
* @param <S2> new serverbound packet types
|
||||||
private final Map<Packet, ProtocolPacket> outgoing = new HashMap<>();
|
* @see SimpleProtocol for a helper class if you do not want to define any of the types above
|
||||||
private final Map<Class, Object> storedObjects = new HashMap<>(); // currently only used for MetadataRewriters
|
*/
|
||||||
protected final Class<C1> oldClientboundPacketEnum;
|
public interface Protocol<C1 extends ClientboundPacketType, C2 extends ClientboundPacketType, S1 extends ServerboundPacketType, S2 extends ServerboundPacketType> {
|
||||||
protected final Class<C2> newClientboundPacketEnum;
|
|
||||||
protected final Class<S1> oldServerboundPacketEnum;
|
|
||||||
protected final Class<S2> newServerboundPacketEnum;
|
|
||||||
|
|
||||||
protected Protocol() {
|
|
||||||
this(null, null, null, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a protocol with automated id mapping if the respective enums are not null.
|
* 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
|
||||||
*/
|
*/
|
||||||
protected Protocol(@Nullable Class<C1> oldClientboundPacketEnum, @Nullable Class<C2> clientboundPacketEnum,
|
default void registerIncoming(State state, int oldPacketID, int newPacketID) {
|
||||||
@Nullable Class<S1> oldServerboundPacketEnum, @Nullable Class<S2> serverboundPacketEnum) {
|
registerIncoming(state, oldPacketID, newPacketID, null);
|
||||||
this.oldClientboundPacketEnum = oldClientboundPacketEnum;
|
|
||||||
this.newClientboundPacketEnum = clientboundPacketEnum;
|
|
||||||
this.oldServerboundPacketEnum = oldServerboundPacketEnum;
|
|
||||||
this.newServerboundPacketEnum = serverboundPacketEnum;
|
|
||||||
registerPackets();
|
|
||||||
|
|
||||||
// Register the rest of the ids with no handlers if necessary
|
|
||||||
if (oldClientboundPacketEnum != null && clientboundPacketEnum != null
|
|
||||||
&& oldClientboundPacketEnum != clientboundPacketEnum) {
|
|
||||||
registerOutgoingChannelIdChanges();
|
|
||||||
}
|
|
||||||
if (oldServerboundPacketEnum != null && serverboundPacketEnum != null
|
|
||||||
&& oldServerboundPacketEnum != serverboundPacketEnum) {
|
|
||||||
registerIncomingChannelIdChanges();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void registerOutgoingChannelIdChanges() {
|
|
||||||
ClientboundPacketType[] newConstants = newClientboundPacketEnum.getEnumConstants();
|
|
||||||
Map<String, ClientboundPacketType> newClientboundPackets = new HashMap<>(newConstants.length);
|
|
||||||
for (ClientboundPacketType newConstant : newConstants) {
|
|
||||||
newClientboundPackets.put(newConstant.name(), newConstant);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (ClientboundPacketType packet : oldClientboundPacketEnum.getEnumConstants()) {
|
|
||||||
ClientboundPacketType mappedPacket = newClientboundPackets.get(packet.name());
|
|
||||||
int oldId = packet.ordinal();
|
|
||||||
if (mappedPacket == null) {
|
|
||||||
// Packet doesn't exist on new client
|
|
||||||
Preconditions.checkArgument(hasRegisteredOutgoing(State.PLAY, oldId),
|
|
||||||
"Packet " + packet + " in " + getClass().getSimpleName() + " has no mapping - it needs to be manually cancelled or remapped!");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
int newId = mappedPacket.ordinal();
|
|
||||||
if (!hasRegisteredOutgoing(State.PLAY, oldId)) {
|
|
||||||
registerOutgoing(State.PLAY, oldId, newId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void registerIncomingChannelIdChanges() {
|
|
||||||
ServerboundPacketType[] oldConstants = oldServerboundPacketEnum.getEnumConstants();
|
|
||||||
Map<String, ServerboundPacketType> oldServerboundConstants = new HashMap<>(oldConstants.length);
|
|
||||||
for (ServerboundPacketType oldConstant : oldConstants) {
|
|
||||||
oldServerboundConstants.put(oldConstant.name(), oldConstant);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (ServerboundPacketType packet : newServerboundPacketEnum.getEnumConstants()) {
|
|
||||||
ServerboundPacketType mappedPacket = oldServerboundConstants.get(packet.name());
|
|
||||||
int newId = packet.ordinal();
|
|
||||||
if (mappedPacket == null) {
|
|
||||||
// Packet doesn't exist on old server
|
|
||||||
Preconditions.checkArgument(hasRegisteredIncoming(State.PLAY, newId),
|
|
||||||
"Packet " + packet + " in " + getClass().getSimpleName() + " has no mapping - it needs to be manually cancelled or remapped!");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
int oldId = mappedPacket.ordinal();
|
|
||||||
if (!hasRegisteredIncoming(State.PLAY, newId)) {
|
|
||||||
registerIncoming(State.PLAY, oldId, newId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register the packets for this protocol. To be overriden.
|
* 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
|
||||||
*/
|
*/
|
||||||
protected void registerPackets() {
|
default void registerIncoming(State state, int oldPacketID, int newPacketID, PacketRemapper packetRemapper) {
|
||||||
|
registerIncoming(state, oldPacketID, newPacketID, packetRemapper, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
void registerIncoming(State state, int oldPacketID, int newPacketID, PacketRemapper packetRemapper, boolean override);
|
||||||
public final void loadMappingData() {
|
|
||||||
getMappingData().load();
|
void cancelIncoming(State state, int oldPacketID, int newPacketID);
|
||||||
onMappingDataLoaded();
|
|
||||||
|
default void cancelIncoming(State state, int newPacketID) {
|
||||||
|
cancelIncoming(state, -1, newPacketID);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called after {@link #loadMappingData()} is called; load extra mapping data for the protocol.
|
* 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
|
||||||
|
*/
|
||||||
|
default void registerOutgoing(State state, int oldPacketID, int newPacketID) {
|
||||||
|
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
|
||||||
|
*/
|
||||||
|
default void registerOutgoing(State state, int oldPacketID, int newPacketID, PacketRemapper packetRemapper) {
|
||||||
|
registerOutgoing(state, oldPacketID, newPacketID, packetRemapper, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void cancelOutgoing(State state, int oldPacketID, int newPacketID);
|
||||||
|
|
||||||
|
default void cancelOutgoing(State state, int oldPacketID) {
|
||||||
|
cancelOutgoing(state, oldPacketID, -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void registerOutgoing(State state, int oldPacketID, int newPacketID, PacketRemapper packetRemapper, boolean override);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers an outgoing protocol and automatically maps it to the new id.
|
||||||
|
*
|
||||||
|
* @param packetType clientbound packet type the server sends
|
||||||
|
* @param packetRemapper remapper
|
||||||
|
*/
|
||||||
|
void registerOutgoing(C1 packetType, @Nullable PacketRemapper packetRemapper);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers an outgoing protocol.
|
||||||
|
*
|
||||||
|
* @param packetType clientbound packet type the server initially sends
|
||||||
|
* @param mappedPacketType clientbound packet type after transforming for the client
|
||||||
|
* @param packetRemapper remapper
|
||||||
|
*/
|
||||||
|
void registerOutgoing(C1 packetType, C2 mappedPacketType, @Nullable PacketRemapper packetRemapper);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Maps a packet type to another packet type without a packet handler.
|
||||||
|
* Note that this should not be called for simple channel mappings of the same packet; this is already done automatically.
|
||||||
|
*
|
||||||
|
* @param packetType clientbound packet type the server initially sends
|
||||||
|
* @param mappedPacketType clientbound packet type after transforming for the client
|
||||||
|
*/
|
||||||
|
default void registerOutgoing(C1 packetType, @Nullable C2 mappedPacketType) {
|
||||||
|
registerOutgoing(packetType, mappedPacketType, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cancels any clientbound packets from the given type.
|
||||||
|
*
|
||||||
|
* @param packetType clientbound packet type to cancel
|
||||||
|
*/
|
||||||
|
void cancelOutgoing(C1 packetType);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers an incoming protocol and automatically maps it to the server's id.
|
||||||
|
*
|
||||||
|
* @param packetType serverbound packet type the client sends
|
||||||
|
* @param packetRemapper remapper
|
||||||
|
*/
|
||||||
|
void registerIncoming(S2 packetType, @Nullable PacketRemapper packetRemapper);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers an incoming protocol.
|
||||||
|
*
|
||||||
|
* @param packetType serverbound packet type initially sent by the client
|
||||||
|
* @param mappedPacketType serverbound packet type after transforming for the server
|
||||||
|
* @param packetRemapper remapper
|
||||||
|
*/
|
||||||
|
void registerIncoming(S2 packetType, @Nullable S1 mappedPacketType, @Nullable PacketRemapper packetRemapper);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cancels any serverbound packets from the given type.
|
||||||
|
*
|
||||||
|
* @param packetType serverbound packet type to cancel
|
||||||
|
*/
|
||||||
|
void cancelIncoming(S2 packetType);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if an outgoing packet has already been registered.
|
||||||
|
*
|
||||||
|
* @param state state which the packet is sent in
|
||||||
|
* @param oldPacketID old packet ID
|
||||||
|
* @return true if already registered
|
||||||
|
*/
|
||||||
|
boolean hasRegisteredOutgoing(State state, int oldPacketID);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if an incoming packet has already been registered.
|
||||||
|
*
|
||||||
|
* @param state state which the packet is sent in
|
||||||
|
* @param newPacketId packet ID
|
||||||
|
* @return true if already registered
|
||||||
|
*/
|
||||||
|
boolean hasRegisteredIncoming(State state, int newPacketId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
||||||
|
*/
|
||||||
|
void transform(Direction direction, State state, PacketWrapper packetWrapper) throws Exception;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a cached object by the given type if present.
|
||||||
|
*
|
||||||
|
* @param objectClass class of the object to get
|
||||||
|
* @param <T> type
|
||||||
|
* @return object if present, else null
|
||||||
|
*/
|
||||||
|
@Nullable <T> T get(Class<T> objectClass);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Caches an object, retrievable by using {@link #get(Class)}.
|
||||||
|
*
|
||||||
|
* @param object object to cache
|
||||||
|
*/
|
||||||
|
void put(Object object);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if this Protocol's {@link #loadMappingData()} method should be called.
|
||||||
|
* <p>
|
||||||
|
* This does *not* necessarily mean that {@link #getMappingData()} is non-null, since this may be
|
||||||
|
* overriden, depending on special cases.
|
||||||
|
*
|
||||||
|
* @return true if this Protocol's {@link #loadMappingData()} method should be called
|
||||||
|
*/
|
||||||
|
boolean hasMappingDataToLoad();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads the protocol's mapping data.
|
||||||
|
*
|
||||||
|
* @throws NullPointerException if this protocol has no mapping data
|
||||||
|
*/
|
||||||
|
void loadMappingData();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle protocol registration phase, use this to register providers / tasks.
|
||||||
* <p>
|
* <p>
|
||||||
* To be overridden if needed.
|
* To be overridden if needed.
|
||||||
|
*
|
||||||
|
* @param providers The current providers
|
||||||
*/
|
*/
|
||||||
protected void onMappingDataLoaded() {
|
default void register(ViaProviders providers) {
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void registerIncoming(State state, int oldPacketID, int newPacketID, PacketRemapper packetRemapper, boolean override) {
|
|
||||||
ProtocolPacket protocolPacket = new ProtocolPacket(state, oldPacketID, newPacketID, packetRemapper);
|
|
||||||
Packet packet = new Packet(state, newPacketID);
|
|
||||||
if (!override && incoming.containsKey(packet)) {
|
|
||||||
Via.getPlatform().getLogger().log(Level.WARNING, packet + " already registered!" +
|
|
||||||
" If this override is intentional, set override to true. Stacktrace: ", new Exception());
|
|
||||||
}
|
|
||||||
incoming.put(packet, protocolPacket);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void cancelIncoming(State state, int oldPacketID, int newPacketID) {
|
|
||||||
registerIncoming(state, oldPacketID, newPacketID, new PacketRemapper() {
|
|
||||||
@Override
|
|
||||||
public void registerMap() {
|
|
||||||
handler(PacketWrapper::cancel);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void cancelOutgoing(State state, int oldPacketID, int newPacketID) {
|
|
||||||
registerOutgoing(state, oldPacketID, newPacketID, new PacketRemapper() {
|
|
||||||
@Override
|
|
||||||
public void registerMap() {
|
|
||||||
handler(PacketWrapper::cancel);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void registerOutgoing(State state, int oldPacketID, int newPacketID, PacketRemapper packetRemapper, boolean override) {
|
|
||||||
ProtocolPacket protocolPacket = new ProtocolPacket(state, oldPacketID, newPacketID, packetRemapper);
|
|
||||||
Packet packet = new Packet(state, oldPacketID);
|
|
||||||
if (!override && outgoing.containsKey(packet)) {
|
|
||||||
Via.getPlatform().getLogger().log(Level.WARNING, packet + " already registered!" +
|
|
||||||
" If override is intentional, set override to true. Stacktrace: ", new Exception());
|
|
||||||
}
|
|
||||||
outgoing.put(packet, protocolPacket);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void registerOutgoing(C1 packetType, @Nullable PacketRemapper packetRemapper) {
|
|
||||||
checkPacketType(packetType, packetType.getClass() == oldClientboundPacketEnum);
|
|
||||||
|
|
||||||
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!");
|
|
||||||
|
|
||||||
int oldId = packetType.ordinal();
|
|
||||||
int newId = mappedPacket.ordinal();
|
|
||||||
registerOutgoing(State.PLAY, oldId, newId, packetRemapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void registerOutgoing(C1 packetType, @Nullable C2 mappedPacketType, @Nullable PacketRemapper packetRemapper) {
|
|
||||||
checkPacketType(packetType, packetType.getClass() == oldClientboundPacketEnum);
|
|
||||||
checkPacketType(mappedPacketType, mappedPacketType == null || mappedPacketType.getClass() == newClientboundPacketEnum);
|
|
||||||
|
|
||||||
registerOutgoing(State.PLAY, packetType.ordinal(), mappedPacketType != null ? mappedPacketType.ordinal() : -1, packetRemapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void cancelOutgoing(C1 packetType) {
|
|
||||||
cancelOutgoing(State.PLAY, packetType.ordinal(), packetType.ordinal());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void registerIncoming(S2 packetType, @Nullable PacketRemapper packetRemapper) {
|
|
||||||
checkPacketType(packetType, packetType.getClass() == newServerboundPacketEnum);
|
|
||||||
|
|
||||||
ServerboundPacketType mappedPacket = oldServerboundPacketEnum == newServerboundPacketEnum ? packetType
|
|
||||||
: Arrays.stream(oldServerboundPacketEnum.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!");
|
|
||||||
|
|
||||||
int oldId = mappedPacket.ordinal();
|
|
||||||
int newId = packetType.ordinal();
|
|
||||||
registerIncoming(State.PLAY, oldId, newId, packetRemapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void registerIncoming(S2 packetType, @Nullable S1 mappedPacketType, @Nullable PacketRemapper packetRemapper) {
|
|
||||||
checkPacketType(packetType, packetType.getClass() == newServerboundPacketEnum);
|
|
||||||
checkPacketType(mappedPacketType, mappedPacketType == null || mappedPacketType.getClass() == oldServerboundPacketEnum);
|
|
||||||
|
|
||||||
registerIncoming(State.PLAY, mappedPacketType != null ? mappedPacketType.ordinal() : -1, packetType.ordinal(), packetRemapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void cancelIncoming(S2 packetType) {
|
|
||||||
Preconditions.checkArgument(packetType.getClass() == newServerboundPacketEnum);
|
|
||||||
cancelIncoming(State.PLAY, -1, packetType.ordinal());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasRegisteredOutgoing(State state, int oldPacketID) {
|
|
||||||
Packet packet = new Packet(state, oldPacketID);
|
|
||||||
return outgoing.containsKey(packet);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasRegisteredIncoming(State state, int newPacketId) {
|
|
||||||
Packet packet = new Packet(state, newPacketId);
|
|
||||||
return incoming.containsKey(packet);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void transform(Direction direction, State state, PacketWrapper packetWrapper) throws Exception {
|
|
||||||
Packet statePacket = new Packet(state, packetWrapper.getId());
|
|
||||||
Map<Packet, ProtocolPacket> packetMap = (direction == Direction.OUTGOING ? outgoing : incoming);
|
|
||||||
ProtocolPacket protocolPacket = packetMap.get(statePacket);
|
|
||||||
if (protocolPacket == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Write packet id
|
|
||||||
int oldId = packetWrapper.getId();
|
|
||||||
int newId = direction == Direction.OUTGOING ? protocolPacket.getNewID() : protocolPacket.getOldID();
|
|
||||||
packetWrapper.setId(newId);
|
|
||||||
|
|
||||||
PacketRemapper remapper = protocolPacket.getRemapper();
|
|
||||||
if (remapper != null) {
|
|
||||||
try {
|
|
||||||
remapper.remap(packetWrapper);
|
|
||||||
} catch (InformativeException e) { // Catch InformativeExceptions, pass through CancelExceptions
|
|
||||||
throwRemapError(direction, state, oldId, newId, e);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (packetWrapper.isCancelled()) {
|
|
||||||
throw CancelException.generate();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void throwRemapError(Direction direction, State state, int oldId, int newId, InformativeException e) throws InformativeException {
|
|
||||||
// Don't print errors during handshake
|
|
||||||
if (state == State.HANDSHAKE) {
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
|
|
||||||
Class<? extends PacketType> packetTypeClass = state == State.PLAY ? (direction == Direction.OUTGOING ? oldClientboundPacketEnum : newServerboundPacketEnum) : null;
|
|
||||||
if (packetTypeClass != null) {
|
|
||||||
PacketType[] enumConstants = packetTypeClass.getEnumConstants();
|
|
||||||
PacketType packetType = oldId < enumConstants.length && oldId >= 0 ? enumConstants[oldId] : null;
|
|
||||||
Via.getPlatform().getLogger().warning("ERROR IN " + getClass().getSimpleName() + " IN REMAP OF " + packetType + " (" + toNiceHex(oldId) + ")");
|
|
||||||
} else {
|
|
||||||
Via.getPlatform().getLogger().warning("ERROR IN " + getClass().getSimpleName()
|
|
||||||
+ " IN REMAP OF " + toNiceHex(oldId) + "->" + toNiceHex(newId));
|
|
||||||
}
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String toNiceHex(int id) {
|
|
||||||
String hex = Integer.toHexString(id).toUpperCase();
|
|
||||||
return (hex.length() == 1 ? "0x0" : "0x") + hex;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param packetType packet type
|
* Initialise a user for this protocol setting up objects.
|
||||||
* @param isValid expression to check the packet's validity
|
* /!\ WARNING - May be called more than once in a single {@link UserConnection}
|
||||||
* @throws IllegalArgumentException if the given expression is not met
|
* <p>
|
||||||
|
* To be overridden if needed.
|
||||||
|
*
|
||||||
|
* @param userConnection The user to initialise
|
||||||
*/
|
*/
|
||||||
private void checkPacketType(PacketType packetType, boolean isValid) {
|
default void init(UserConnection userConnection) {
|
||||||
if (!isValid) {
|
|
||||||
throw new IllegalArgumentException("Packet type " + packetType + " in " + packetType.getClass().getSimpleName() + " is taken from the wrong enum");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
/**
|
||||||
public @Nullable <T> T get(Class<T> objectClass) {
|
* Returns the protocol's mapping data if present.
|
||||||
return (T) storedObjects.get(objectClass);
|
*
|
||||||
|
* @return mapping data if present
|
||||||
|
*/
|
||||||
|
default @Nullable MappingData getMappingData() {
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
/**
|
||||||
public void put(Object object) {
|
* Returns whether this protocol is a base protocol.
|
||||||
storedObjects.put(object.getClass(), object);
|
*
|
||||||
}
|
* @return whether this represents a base protocol
|
||||||
|
*/
|
||||||
@Override
|
default boolean isBaseProtocol() {
|
||||||
public boolean hasMappingDataToLoad() {
|
return false;
|
||||||
return getMappingData() != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "Protocol:" + getClass().getSimpleName();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class Packet {
|
|
||||||
private final State state;
|
|
||||||
private final int packetId;
|
|
||||||
|
|
||||||
public Packet(State state, int packetId) {
|
|
||||||
this.state = state;
|
|
||||||
this.packetId = packetId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public State getState() {
|
|
||||||
return state;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getPacketId() {
|
|
||||||
return packetId;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "Packet{" + "state=" + state + ", packetId=" + packetId + '}';
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
if (this == o) return true;
|
|
||||||
if (o == null || getClass() != o.getClass()) return false;
|
|
||||||
Packet that = (Packet) o;
|
|
||||||
return packetId == that.packetId && state == that.state;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
int result = state != null ? state.hashCode() : 0;
|
|
||||||
result = 31 * result + packetId;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class ProtocolPacket {
|
|
||||||
private final State state;
|
|
||||||
private final int oldID;
|
|
||||||
private final int newID;
|
|
||||||
private final PacketRemapper remapper;
|
|
||||||
|
|
||||||
public ProtocolPacket(State state, int oldID, int newID, @Nullable PacketRemapper remapper) {
|
|
||||||
this.state = state;
|
|
||||||
this.oldID = oldID;
|
|
||||||
this.newID = newID;
|
|
||||||
this.remapper = remapper;
|
|
||||||
}
|
|
||||||
|
|
||||||
public State getState() {
|
|
||||||
return state;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getOldID() {
|
|
||||||
return oldID;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getNewID() {
|
|
||||||
return newID;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
public PacketRemapper getRemapper() {
|
|
||||||
return remapper;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,6 @@ package com.viaversion.viaversion.api.protocol;
|
|||||||
|
|
||||||
import com.google.common.collect.Range;
|
import com.google.common.collect.Range;
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||||
import com.viaversion.viaversion.api.protocol.base.Protocol;
|
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketType;
|
import com.viaversion.viaversion.api.protocol.packet.PacketType;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||||
|
@ -22,8 +22,6 @@
|
|||||||
*/
|
*/
|
||||||
package com.viaversion.viaversion.api.protocol;
|
package com.viaversion.viaversion.api.protocol;
|
||||||
|
|
||||||
import com.viaversion.viaversion.api.protocol.base.Protocol;
|
|
||||||
|
|
||||||
public interface ProtocolPathEntry {
|
public interface ProtocolPathEntry {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -23,8 +23,6 @@
|
|||||||
package com.viaversion.viaversion.api.protocol;
|
package com.viaversion.viaversion.api.protocol;
|
||||||
|
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||||
import com.viaversion.viaversion.api.protocol.base.Protocol;
|
|
||||||
import com.viaversion.viaversion.api.protocol.base.SimpleProtocol;
|
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
package com.viaversion.viaversion.api.protocol.base;
|
package com.viaversion.viaversion.api.protocol;
|
||||||
|
|
||||||
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
|
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.ServerboundPacketType;
|
import com.viaversion.viaversion.api.protocol.packet.ServerboundPacketType;
|
||||||
@ -29,7 +29,7 @@ import com.viaversion.viaversion.api.protocol.packet.ServerboundPacketType;
|
|||||||
* Dummy protocol class when there is no need of any of the
|
* Dummy protocol class when there is no need of any of the
|
||||||
* existing packet type enums or automated channel mappings.
|
* existing packet type enums or automated channel mappings.
|
||||||
*
|
*
|
||||||
* @see com.viaversion.viaversion.api.protocol.base.Protocol
|
* @see Protocol
|
||||||
*/
|
*/
|
||||||
public interface SimpleProtocol extends Protocol<SimpleProtocol.DummyPacketTypes, SimpleProtocol.DummyPacketTypes, SimpleProtocol.DummyPacketTypes, SimpleProtocol.DummyPacketTypes> {
|
public interface SimpleProtocol extends Protocol<SimpleProtocol.DummyPacketTypes, SimpleProtocol.DummyPacketTypes, SimpleProtocol.DummyPacketTypes, SimpleProtocol.DummyPacketTypes> {
|
||||||
|
|
@ -1,268 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
|
||||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
|
||||||
* in the Software without restriction, including without limitation the rights
|
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
|
||||||
* furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in all
|
|
||||||
* copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
* SOFTWARE.
|
|
||||||
*/
|
|
||||||
package com.viaversion.viaversion.api.protocol.base;
|
|
||||||
|
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
|
||||||
import com.viaversion.viaversion.api.data.MappingData;
|
|
||||||
import com.viaversion.viaversion.api.platform.providers.ViaProviders;
|
|
||||||
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
|
|
||||||
import com.viaversion.viaversion.api.protocol.packet.Direction;
|
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
|
||||||
import com.viaversion.viaversion.api.protocol.packet.ServerboundPacketType;
|
|
||||||
import com.viaversion.viaversion.api.protocol.packet.State;
|
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Abstract protocol class handling packet transformation between two protocol versions.
|
|
||||||
* Clientbound and serverbount packet types can be set to enforce correct usage of them.
|
|
||||||
*
|
|
||||||
* @param <C1> old clientbound packet types
|
|
||||||
* @param <C2> new clientbound packet types
|
|
||||||
* @param <S1> old serverbound packet types
|
|
||||||
* @param <S2> new serverbound packet types
|
|
||||||
* @see SimpleProtocol for a helper class if you do not want to define any of the types above
|
|
||||||
*/
|
|
||||||
public interface Protocol<C1 extends ClientboundPacketType, C2 extends ClientboundPacketType, S1 extends ServerboundPacketType, S2 extends ServerboundPacketType> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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
|
|
||||||
*/
|
|
||||||
default void registerIncoming(State state, int oldPacketID, int newPacketID) {
|
|
||||||
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
|
|
||||||
*/
|
|
||||||
default void registerIncoming(State state, int oldPacketID, int newPacketID, PacketRemapper packetRemapper) {
|
|
||||||
registerIncoming(state, oldPacketID, newPacketID, packetRemapper, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
void registerIncoming(State state, int oldPacketID, int newPacketID, PacketRemapper packetRemapper, boolean override);
|
|
||||||
|
|
||||||
void cancelIncoming(State state, int oldPacketID, int newPacketID);
|
|
||||||
|
|
||||||
default void cancelIncoming(State state, int newPacketID) {
|
|
||||||
cancelIncoming(state, -1, newPacketID);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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
|
|
||||||
*/
|
|
||||||
default void registerOutgoing(State state, int oldPacketID, int newPacketID) {
|
|
||||||
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
|
|
||||||
*/
|
|
||||||
default void registerOutgoing(State state, int oldPacketID, int newPacketID, PacketRemapper packetRemapper) {
|
|
||||||
registerOutgoing(state, oldPacketID, newPacketID, packetRemapper, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
void cancelOutgoing(State state, int oldPacketID, int newPacketID);
|
|
||||||
|
|
||||||
default void cancelOutgoing(State state, int oldPacketID) {
|
|
||||||
cancelOutgoing(state, oldPacketID, -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
void registerOutgoing(State state, int oldPacketID, int newPacketID, PacketRemapper packetRemapper, boolean override);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Registers an outgoing protocol and automatically maps it to the new id.
|
|
||||||
*
|
|
||||||
* @param packetType clientbound packet type the server sends
|
|
||||||
* @param packetRemapper remapper
|
|
||||||
*/
|
|
||||||
void registerOutgoing(C1 packetType, @Nullable PacketRemapper packetRemapper);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Registers an outgoing protocol.
|
|
||||||
*
|
|
||||||
* @param packetType clientbound packet type the server initially sends
|
|
||||||
* @param mappedPacketType clientbound packet type after transforming for the client
|
|
||||||
* @param packetRemapper remapper
|
|
||||||
*/
|
|
||||||
void registerOutgoing(C1 packetType, C2 mappedPacketType, @Nullable PacketRemapper packetRemapper);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Maps a packet type to another packet type without a packet handler.
|
|
||||||
* Note that this should not be called for simple channel mappings of the same packet; this is already done automatically.
|
|
||||||
*
|
|
||||||
* @param packetType clientbound packet type the server initially sends
|
|
||||||
* @param mappedPacketType clientbound packet type after transforming for the client
|
|
||||||
*/
|
|
||||||
default void registerOutgoing(C1 packetType, @Nullable C2 mappedPacketType) {
|
|
||||||
registerOutgoing(packetType, mappedPacketType, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Cancels any clientbound packets from the given type.
|
|
||||||
*
|
|
||||||
* @param packetType clientbound packet type to cancel
|
|
||||||
*/
|
|
||||||
void cancelOutgoing(C1 packetType);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Registers an incoming protocol and automatically maps it to the server's id.
|
|
||||||
*
|
|
||||||
* @param packetType serverbound packet type the client sends
|
|
||||||
* @param packetRemapper remapper
|
|
||||||
*/
|
|
||||||
void registerIncoming(S2 packetType, @Nullable PacketRemapper packetRemapper);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Registers an incoming protocol.
|
|
||||||
*
|
|
||||||
* @param packetType serverbound packet type initially sent by the client
|
|
||||||
* @param mappedPacketType serverbound packet type after transforming for the server
|
|
||||||
* @param packetRemapper remapper
|
|
||||||
*/
|
|
||||||
void registerIncoming(S2 packetType, @Nullable S1 mappedPacketType, @Nullable PacketRemapper packetRemapper);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Cancels any serverbound packets from the given type.
|
|
||||||
*
|
|
||||||
* @param packetType serverbound packet type to cancel
|
|
||||||
*/
|
|
||||||
void cancelIncoming(S2 packetType);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks if an outgoing packet has already been registered.
|
|
||||||
*
|
|
||||||
* @param state state which the packet is sent in
|
|
||||||
* @param oldPacketID old packet ID
|
|
||||||
* @return true if already registered
|
|
||||||
*/
|
|
||||||
boolean hasRegisteredOutgoing(State state, int oldPacketID);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks if an incoming packet has already been registered.
|
|
||||||
*
|
|
||||||
* @param state state which the packet is sent in
|
|
||||||
* @param newPacketId packet ID
|
|
||||||
* @return true if already registered
|
|
||||||
*/
|
|
||||||
boolean hasRegisteredIncoming(State state, int newPacketId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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
|
|
||||||
*/
|
|
||||||
void transform(Direction direction, State state, PacketWrapper packetWrapper) throws Exception;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a cached object by the given type if present.
|
|
||||||
*
|
|
||||||
* @param objectClass class of the object to get
|
|
||||||
* @param <T> type
|
|
||||||
* @return object if present, else null
|
|
||||||
*/
|
|
||||||
@Nullable <T> T get(Class<T> objectClass);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Caches an object, retrievable by using {@link #get(Class)}.
|
|
||||||
*
|
|
||||||
* @param object object to cache
|
|
||||||
*/
|
|
||||||
void put(Object object);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns true if this Protocol's {@link #loadMappingData()} method should be called.
|
|
||||||
* <p>
|
|
||||||
* This does *not* necessarily mean that {@link #getMappingData()} is non-null, since this may be
|
|
||||||
* overriden, depending on special cases.
|
|
||||||
*
|
|
||||||
* @return true if this Protocol's {@link #loadMappingData()} method should be called
|
|
||||||
*/
|
|
||||||
boolean hasMappingDataToLoad();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Loads the protocol's mapping data.
|
|
||||||
*
|
|
||||||
* @throws NullPointerException if this protocol has no mapping data
|
|
||||||
*/
|
|
||||||
void loadMappingData();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handle protocol registration phase, use this to register providers / tasks.
|
|
||||||
* <p>
|
|
||||||
* To be overridden if needed.
|
|
||||||
*
|
|
||||||
* @param providers The current providers
|
|
||||||
*/
|
|
||||||
default void register(ViaProviders providers) {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initialise a user for this protocol setting up objects.
|
|
||||||
* /!\ WARNING - May be called more than once in a single {@link UserConnection}
|
|
||||||
* <p>
|
|
||||||
* To be overridden if needed.
|
|
||||||
*
|
|
||||||
* @param userConnection The user to initialise
|
|
||||||
*/
|
|
||||||
default void init(UserConnection userConnection) {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the protocol's mapping data if present.
|
|
||||||
*
|
|
||||||
* @return mapping data if present
|
|
||||||
*/
|
|
||||||
default @Nullable MappingData getMappingData() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns whether this protocol is a base protocol.
|
|
||||||
*
|
|
||||||
* @return whether this represents a base protocol
|
|
||||||
*/
|
|
||||||
default boolean isBaseProtocol() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
@ -24,7 +24,7 @@ package com.viaversion.viaversion.api.protocol.packet;
|
|||||||
|
|
||||||
import com.viaversion.viaversion.api.Via;
|
import com.viaversion.viaversion.api.Via;
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||||
import com.viaversion.viaversion.api.protocol.base.Protocol;
|
import com.viaversion.viaversion.api.protocol.Protocol;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.ValueCreator;
|
import com.viaversion.viaversion.api.protocol.remapper.ValueCreator;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.exception.InformativeException;
|
import com.viaversion.viaversion.exception.InformativeException;
|
||||||
|
@ -17,12 +17,12 @@
|
|||||||
*/
|
*/
|
||||||
package com.viaversion.viaversion.bukkit.listeners;
|
package com.viaversion.viaversion.bukkit.listeners;
|
||||||
|
|
||||||
|
import com.viaversion.viaversion.api.protocol.Protocol;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
import com.viaversion.viaversion.ViaListener;
|
import com.viaversion.viaversion.ViaListener;
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||||
import com.viaversion.viaversion.api.protocol.Protocol;
|
|
||||||
|
|
||||||
public class ViaBukkitListener extends ViaListener implements Listener {
|
public class ViaBukkitListener extends ViaListener implements Listener {
|
||||||
private final Plugin plugin;
|
private final Plugin plugin;
|
||||||
|
@ -24,7 +24,7 @@ import com.viaversion.viaversion.api.connection.UserConnection;
|
|||||||
import com.viaversion.viaversion.api.platform.ExternalJoinGameListener;
|
import com.viaversion.viaversion.api.platform.ExternalJoinGameListener;
|
||||||
import com.viaversion.viaversion.api.protocol.ProtocolPathEntry;
|
import com.viaversion.viaversion.api.protocol.ProtocolPathEntry;
|
||||||
import com.viaversion.viaversion.api.protocol.ProtocolPipeline;
|
import com.viaversion.viaversion.api.protocol.ProtocolPipeline;
|
||||||
import com.viaversion.viaversion.api.protocol.base.Protocol;
|
import com.viaversion.viaversion.api.protocol.Protocol;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
|
@ -28,7 +28,7 @@ public abstract class ViaListener {
|
|||||||
private final Class<? extends Protocol> requiredPipeline;
|
private final Class<? extends Protocol> requiredPipeline;
|
||||||
private boolean registered;
|
private boolean registered;
|
||||||
|
|
||||||
public ViaListener(Class<? extends Protocol> requiredPipeline) {
|
protected ViaListener(Class<? extends Protocol> requiredPipeline) {
|
||||||
this.requiredPipeline = requiredPipeline;
|
this.requiredPipeline = requiredPipeline;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ import com.viaversion.viaversion.api.data.MappingDataLoader;
|
|||||||
import com.viaversion.viaversion.api.protocol.ProtocolManager;
|
import com.viaversion.viaversion.api.protocol.ProtocolManager;
|
||||||
import com.viaversion.viaversion.api.protocol.ProtocolPathEntry;
|
import com.viaversion.viaversion.api.protocol.ProtocolPathEntry;
|
||||||
import com.viaversion.viaversion.api.protocol.ProtocolPathKey;
|
import com.viaversion.viaversion.api.protocol.ProtocolPathKey;
|
||||||
import com.viaversion.viaversion.api.protocol.base.Protocol;
|
import com.viaversion.viaversion.api.protocol.Protocol;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||||
import com.viaversion.viaversion.api.protocol.version.ServerProtocolVersion;
|
import com.viaversion.viaversion.api.protocol.version.ServerProtocolVersion;
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
package com.viaversion.viaversion.protocol;
|
package com.viaversion.viaversion.protocol;
|
||||||
|
|
||||||
import com.viaversion.viaversion.api.protocol.ProtocolPathEntry;
|
import com.viaversion.viaversion.api.protocol.ProtocolPathEntry;
|
||||||
import com.viaversion.viaversion.api.protocol.base.Protocol;
|
import com.viaversion.viaversion.api.protocol.Protocol;
|
||||||
|
|
||||||
public class ProtocolPathEntryImpl implements ProtocolPathEntry {
|
public class ProtocolPathEntryImpl implements ProtocolPathEntry {
|
||||||
private final int outputProtocolVersion;
|
private final int outputProtocolVersion;
|
||||||
|
@ -28,7 +28,7 @@ import com.viaversion.viaversion.api.connection.UserConnection;
|
|||||||
import com.viaversion.viaversion.api.platform.ViaPlatform;
|
import com.viaversion.viaversion.api.platform.ViaPlatform;
|
||||||
import com.viaversion.viaversion.api.protocol.AbstractSimpleProtocol;
|
import com.viaversion.viaversion.api.protocol.AbstractSimpleProtocol;
|
||||||
import com.viaversion.viaversion.api.protocol.ProtocolPipeline;
|
import com.viaversion.viaversion.api.protocol.ProtocolPipeline;
|
||||||
import com.viaversion.viaversion.api.protocol.base.Protocol;
|
import com.viaversion.viaversion.api.protocol.Protocol;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.Direction;
|
import com.viaversion.viaversion.api.protocol.packet.Direction;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.State;
|
import com.viaversion.viaversion.api.protocol.packet.State;
|
||||||
|
@ -25,7 +25,7 @@ package com.viaversion.viaversion.protocol.packet;
|
|||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
import com.viaversion.viaversion.api.Via;
|
import com.viaversion.viaversion.api.Via;
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||||
import com.viaversion.viaversion.api.protocol.base.Protocol;
|
import com.viaversion.viaversion.api.protocol.Protocol;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.Direction;
|
import com.viaversion.viaversion.api.protocol.packet.Direction;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketType;
|
import com.viaversion.viaversion.api.protocol.packet.PacketType;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
|
@ -24,7 +24,7 @@ import com.viaversion.viaversion.api.platform.providers.ViaProviders;
|
|||||||
import com.viaversion.viaversion.api.protocol.AbstractSimpleProtocol;
|
import com.viaversion.viaversion.api.protocol.AbstractSimpleProtocol;
|
||||||
import com.viaversion.viaversion.api.protocol.ProtocolPathEntry;
|
import com.viaversion.viaversion.api.protocol.ProtocolPathEntry;
|
||||||
import com.viaversion.viaversion.api.protocol.ProtocolPipeline;
|
import com.viaversion.viaversion.api.protocol.ProtocolPipeline;
|
||||||
import com.viaversion.viaversion.api.protocol.base.Protocol;
|
import com.viaversion.viaversion.api.protocol.Protocol;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.Direction;
|
import com.viaversion.viaversion.api.protocol.packet.Direction;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.State;
|
import com.viaversion.viaversion.api.protocol.packet.State;
|
||||||
|
@ -19,7 +19,7 @@ package com.viaversion.viaversion.protocols.protocol1_10to1_9_3;
|
|||||||
|
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||||
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
||||||
import com.viaversion.viaversion.api.protocol.Protocol;
|
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.State;
|
import com.viaversion.viaversion.api.protocol.packet.State;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||||
@ -35,7 +35,7 @@ import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ServerboundPac
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
|
|
||||||
public class Protocol1_10To1_9_3_4 extends Protocol<ClientboundPackets1_9_3, ClientboundPackets1_9_3, ServerboundPackets1_9_3, ServerboundPackets1_9_3> {
|
public class Protocol1_10To1_9_3_4 extends AbstractProtocol<ClientboundPackets1_9_3, ClientboundPackets1_9_3, ServerboundPackets1_9_3, ServerboundPackets1_9_3> {
|
||||||
|
|
||||||
public static final ValueTransformer<Short, Float> TO_NEW_PITCH = new ValueTransformer<Short, Float>(Type.FLOAT) {
|
public static final ValueTransformer<Short, Float> TO_NEW_PITCH = new ValueTransformer<Short, Float>(Type.FLOAT) {
|
||||||
@Override
|
@Override
|
||||||
|
@ -17,12 +17,12 @@
|
|||||||
*/
|
*/
|
||||||
package com.viaversion.viaversion.protocols.protocol1_11_1to1_11;
|
package com.viaversion.viaversion.protocols.protocol1_11_1to1_11;
|
||||||
|
|
||||||
import com.viaversion.viaversion.api.protocol.Protocol;
|
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_11_1to1_11.packets.InventoryPackets;
|
import com.viaversion.viaversion.protocols.protocol1_11_1to1_11.packets.InventoryPackets;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3;
|
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3;
|
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3;
|
||||||
|
|
||||||
public class Protocol1_11_1To1_11 extends Protocol<ClientboundPackets1_9_3, ClientboundPackets1_9_3, ServerboundPackets1_9_3, ServerboundPackets1_9_3> {
|
public class Protocol1_11_1To1_11 extends AbstractProtocol<ClientboundPackets1_9_3, ClientboundPackets1_9_3, ServerboundPackets1_9_3, ServerboundPackets1_9_3> {
|
||||||
|
|
||||||
public Protocol1_11_1To1_11() {
|
public Protocol1_11_1To1_11() {
|
||||||
super(ClientboundPackets1_9_3.class, ClientboundPackets1_9_3.class, ServerboundPackets1_9_3.class, ServerboundPackets1_9_3.class);
|
super(ClientboundPackets1_9_3.class, ClientboundPackets1_9_3.class, ServerboundPackets1_9_3.class, ServerboundPackets1_9_3.class);
|
||||||
|
@ -23,7 +23,7 @@ import com.viaversion.viaversion.api.Via;
|
|||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||||
import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
|
import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
|
||||||
import com.viaversion.viaversion.api.minecraft.entities.Entity1_11Types;
|
import com.viaversion.viaversion.api.minecraft.entities.Entity1_11Types;
|
||||||
import com.viaversion.viaversion.api.protocol.Protocol;
|
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||||
@ -43,7 +43,7 @@ import com.viaversion.viaversion.rewriter.MetadataRewriter;
|
|||||||
import com.viaversion.viaversion.rewriter.SoundRewriter;
|
import com.viaversion.viaversion.rewriter.SoundRewriter;
|
||||||
import com.viaversion.viaversion.util.Pair;
|
import com.viaversion.viaversion.util.Pair;
|
||||||
|
|
||||||
public class Protocol1_11To1_10 extends Protocol<ClientboundPackets1_9_3, ClientboundPackets1_9_3, ServerboundPackets1_9_3, ServerboundPackets1_9_3> {
|
public class Protocol1_11To1_10 extends AbstractProtocol<ClientboundPackets1_9_3, ClientboundPackets1_9_3, ServerboundPackets1_9_3, ServerboundPackets1_9_3> {
|
||||||
private static final ValueTransformer<Float, Short> toOldByte = new ValueTransformer<Float, Short>(Type.UNSIGNED_BYTE) {
|
private static final ValueTransformer<Float, Short> toOldByte = new ValueTransformer<Float, Short>(Type.UNSIGNED_BYTE) {
|
||||||
@Override
|
@Override
|
||||||
public Short transform(PacketWrapper wrapper, Float inputValue) throws Exception {
|
public Short transform(PacketWrapper wrapper, Float inputValue) throws Exception {
|
||||||
|
@ -17,11 +17,11 @@
|
|||||||
*/
|
*/
|
||||||
package com.viaversion.viaversion.protocols.protocol1_12_1to1_12;
|
package com.viaversion.viaversion.protocols.protocol1_12_1to1_12;
|
||||||
|
|
||||||
import com.viaversion.viaversion.api.protocol.Protocol;
|
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_12to1_11_1.ClientboundPackets1_12;
|
import com.viaversion.viaversion.protocols.protocol1_12to1_11_1.ClientboundPackets1_12;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_12to1_11_1.ServerboundPackets1_12;
|
import com.viaversion.viaversion.protocols.protocol1_12to1_11_1.ServerboundPackets1_12;
|
||||||
|
|
||||||
public class Protocol1_12_1To1_12 extends Protocol<ClientboundPackets1_12, ClientboundPackets1_12_1, ServerboundPackets1_12, ServerboundPackets1_12_1> {
|
public class Protocol1_12_1To1_12 extends AbstractProtocol<ClientboundPackets1_12, ClientboundPackets1_12_1, ServerboundPackets1_12, ServerboundPackets1_12_1> {
|
||||||
|
|
||||||
public Protocol1_12_1To1_12() {
|
public Protocol1_12_1To1_12() {
|
||||||
super(ClientboundPackets1_12.class, ClientboundPackets1_12_1.class, ServerboundPackets1_12.class, ServerboundPackets1_12_1.class);
|
super(ClientboundPackets1_12.class, ClientboundPackets1_12_1.class, ServerboundPackets1_12.class, ServerboundPackets1_12_1.class);
|
||||||
|
@ -17,13 +17,13 @@
|
|||||||
*/
|
*/
|
||||||
package com.viaversion.viaversion.protocols.protocol1_12_2to1_12_1;
|
package com.viaversion.viaversion.protocols.protocol1_12_2to1_12_1;
|
||||||
|
|
||||||
import com.viaversion.viaversion.api.protocol.Protocol;
|
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_12_1to1_12.ClientboundPackets1_12_1;
|
import com.viaversion.viaversion.protocols.protocol1_12_1to1_12.ClientboundPackets1_12_1;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_12_1to1_12.ServerboundPackets1_12_1;
|
import com.viaversion.viaversion.protocols.protocol1_12_1to1_12.ServerboundPackets1_12_1;
|
||||||
|
|
||||||
public class Protocol1_12_2To1_12_1 extends Protocol {
|
public class Protocol1_12_2To1_12_1 extends AbstractProtocol<ClientboundPackets1_12_1, ClientboundPackets1_12_1, ServerboundPackets1_12_1, ServerboundPackets1_12_1> {
|
||||||
|
|
||||||
public Protocol1_12_2To1_12_1() {
|
public Protocol1_12_2To1_12_1() {
|
||||||
super(ClientboundPackets1_12_1.class, ClientboundPackets1_12_1.class, ServerboundPackets1_12_1.class, ServerboundPackets1_12_1.class);
|
super(ClientboundPackets1_12_1.class, ClientboundPackets1_12_1.class, ServerboundPackets1_12_1.class, ServerboundPackets1_12_1.class);
|
||||||
|
@ -26,7 +26,7 @@ import com.viaversion.viaversion.api.connection.UserConnection;
|
|||||||
import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
|
import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
|
||||||
import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection;
|
import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection;
|
||||||
import com.viaversion.viaversion.api.platform.providers.ViaProviders;
|
import com.viaversion.viaversion.api.platform.providers.ViaProviders;
|
||||||
import com.viaversion.viaversion.api.protocol.Protocol;
|
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||||
@ -44,7 +44,7 @@ import com.viaversion.viaversion.protocols.protocol1_9to1_8.Protocol1_9To1_8;
|
|||||||
import com.viaversion.viaversion.rewriter.MetadataRewriter;
|
import com.viaversion.viaversion.rewriter.MetadataRewriter;
|
||||||
import com.viaversion.viaversion.rewriter.SoundRewriter;
|
import com.viaversion.viaversion.rewriter.SoundRewriter;
|
||||||
|
|
||||||
public class Protocol1_12To1_11_1 extends Protocol<ClientboundPackets1_9_3, ClientboundPackets1_12, ServerboundPackets1_9_3, ServerboundPackets1_12> {
|
public class Protocol1_12To1_11_1 extends AbstractProtocol<ClientboundPackets1_9_3, ClientboundPackets1_12, ServerboundPackets1_9_3, ServerboundPackets1_12> {
|
||||||
|
|
||||||
public Protocol1_12To1_11_1() {
|
public Protocol1_12To1_11_1() {
|
||||||
super(ClientboundPackets1_9_3.class, ClientboundPackets1_12.class, ServerboundPackets1_9_3.class, ServerboundPackets1_12.class);
|
super(ClientboundPackets1_9_3.class, ClientboundPackets1_12.class, ServerboundPackets1_9_3.class, ServerboundPackets1_12.class);
|
||||||
|
@ -21,7 +21,7 @@ import com.viaversion.viaversion.api.connection.UserConnection;
|
|||||||
import com.viaversion.viaversion.api.data.MappingData;
|
import com.viaversion.viaversion.api.data.MappingData;
|
||||||
import com.viaversion.viaversion.api.data.MappingDataBase;
|
import com.viaversion.viaversion.api.data.MappingDataBase;
|
||||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||||
import com.viaversion.viaversion.api.protocol.Protocol;
|
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||||
@ -39,7 +39,7 @@ import com.viaversion.viaversion.rewriter.RegistryType;
|
|||||||
import com.viaversion.viaversion.rewriter.StatisticsRewriter;
|
import com.viaversion.viaversion.rewriter.StatisticsRewriter;
|
||||||
import com.viaversion.viaversion.rewriter.TagRewriter;
|
import com.viaversion.viaversion.rewriter.TagRewriter;
|
||||||
|
|
||||||
public class Protocol1_13_1To1_13 extends Protocol<ClientboundPackets1_13, ClientboundPackets1_13, ServerboundPackets1_13, ServerboundPackets1_13> {
|
public class Protocol1_13_1To1_13 extends AbstractProtocol<ClientboundPackets1_13, ClientboundPackets1_13, ServerboundPackets1_13, ServerboundPackets1_13> {
|
||||||
|
|
||||||
public static final MappingData MAPPINGS = new MappingDataBase("1.13", "1.13.2", true);
|
public static final MappingData MAPPINGS = new MappingDataBase("1.13", "1.13.2", true);
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
package com.viaversion.viaversion.protocols.protocol1_13_2to1_13_1;
|
package com.viaversion.viaversion.protocols.protocol1_13_2to1_13_1;
|
||||||
|
|
||||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||||
import com.viaversion.viaversion.api.protocol.Protocol;
|
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||||
@ -29,7 +29,7 @@ import com.viaversion.viaversion.protocols.protocol1_13_2to1_13_1.packets.WorldP
|
|||||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
|
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ServerboundPackets1_13;
|
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ServerboundPackets1_13;
|
||||||
|
|
||||||
public class Protocol1_13_2To1_13_1 extends Protocol<ClientboundPackets1_13, ClientboundPackets1_13, ServerboundPackets1_13, ServerboundPackets1_13> {
|
public class Protocol1_13_2To1_13_1 extends AbstractProtocol<ClientboundPackets1_13, ClientboundPackets1_13, ServerboundPackets1_13, ServerboundPackets1_13> {
|
||||||
|
|
||||||
public Protocol1_13_2To1_13_1() {
|
public Protocol1_13_2To1_13_1() {
|
||||||
super(ClientboundPackets1_13.class, ClientboundPackets1_13.class, ServerboundPackets1_13.class, ServerboundPackets1_13.class);
|
super(ClientboundPackets1_13.class, ClientboundPackets1_13.class, ServerboundPackets1_13.class, ServerboundPackets1_13.class);
|
||||||
|
@ -27,7 +27,7 @@ import com.viaversion.viaversion.api.minecraft.Position;
|
|||||||
import com.viaversion.viaversion.api.minecraft.entities.Entity1_13Types;
|
import com.viaversion.viaversion.api.minecraft.entities.Entity1_13Types;
|
||||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||||
import com.viaversion.viaversion.api.platform.providers.ViaProviders;
|
import com.viaversion.viaversion.api.platform.providers.ViaProviders;
|
||||||
import com.viaversion.viaversion.api.protocol.Protocol;
|
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.State;
|
import com.viaversion.viaversion.api.protocol.packet.State;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||||
@ -67,7 +67,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public class Protocol1_13To1_12_2 extends Protocol<ClientboundPackets1_12_1, ClientboundPackets1_13, ServerboundPackets1_12_1, ServerboundPackets1_13> {
|
public class Protocol1_13To1_12_2 extends AbstractProtocol<ClientboundPackets1_12_1, ClientboundPackets1_13, ServerboundPackets1_12_1, ServerboundPackets1_13> {
|
||||||
|
|
||||||
public static final MappingData MAPPINGS = new MappingData();
|
public static final MappingData MAPPINGS = new MappingData();
|
||||||
// These are arbitrary rewrite values, it just needs an invalid color code character.
|
// These are arbitrary rewrite values, it just needs an invalid color code character.
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
package com.viaversion.viaversion.protocols.protocol1_14_1to1_14;
|
package com.viaversion.viaversion.protocols.protocol1_14_1to1_14;
|
||||||
|
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||||
import com.viaversion.viaversion.api.protocol.Protocol;
|
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_14_1to1_14.metadata.MetadataRewriter1_14_1To1_14;
|
import com.viaversion.viaversion.protocols.protocol1_14_1to1_14.metadata.MetadataRewriter1_14_1To1_14;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_14_1to1_14.packets.EntityPackets;
|
import com.viaversion.viaversion.protocols.protocol1_14_1to1_14.packets.EntityPackets;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_14_1to1_14.storage.EntityTracker1_14_1;
|
import com.viaversion.viaversion.protocols.protocol1_14_1to1_14.storage.EntityTracker1_14_1;
|
||||||
@ -26,7 +26,7 @@ import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ClientboundPacke
|
|||||||
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14;
|
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14;
|
||||||
import com.viaversion.viaversion.rewriter.MetadataRewriter;
|
import com.viaversion.viaversion.rewriter.MetadataRewriter;
|
||||||
|
|
||||||
public class Protocol1_14_1To1_14 extends Protocol<ClientboundPackets1_14, ClientboundPackets1_14, ServerboundPackets1_14, ServerboundPackets1_14> {
|
public class Protocol1_14_1To1_14 extends AbstractProtocol<ClientboundPackets1_14, ClientboundPackets1_14, ServerboundPackets1_14, ServerboundPackets1_14> {
|
||||||
|
|
||||||
public Protocol1_14_1To1_14() {
|
public Protocol1_14_1To1_14() {
|
||||||
super(ClientboundPackets1_14.class, ClientboundPackets1_14.class, ServerboundPackets1_14.class, ServerboundPackets1_14.class);
|
super(ClientboundPackets1_14.class, ClientboundPackets1_14.class, ServerboundPackets1_14.class, ServerboundPackets1_14.class);
|
||||||
|
@ -17,9 +17,9 @@
|
|||||||
*/
|
*/
|
||||||
package com.viaversion.viaversion.protocols.protocol1_14_2to1_14_1;
|
package com.viaversion.viaversion.protocols.protocol1_14_2to1_14_1;
|
||||||
|
|
||||||
import com.viaversion.viaversion.api.protocol.Protocol;
|
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14;
|
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14;
|
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14;
|
||||||
|
|
||||||
public class Protocol1_14_2To1_14_1 extends Protocol<ClientboundPackets1_14, ClientboundPackets1_14, ServerboundPackets1_14, ServerboundPackets1_14> {
|
public class Protocol1_14_2To1_14_1 extends AbstractProtocol<ClientboundPackets1_14, ClientboundPackets1_14, ServerboundPackets1_14, ServerboundPackets1_14> {
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.viaversion.viaversion.protocols.protocol1_14_3to1_14_2;
|
package com.viaversion.viaversion.protocols.protocol1_14_3to1_14_2;
|
||||||
|
|
||||||
import com.viaversion.viaversion.api.protocol.Protocol;
|
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||||
@ -25,7 +25,7 @@ import com.viaversion.viaversion.api.type.Type;
|
|||||||
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14;
|
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14;
|
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14;
|
||||||
|
|
||||||
public class Protocol1_14_3To1_14_2 extends Protocol<ClientboundPackets1_14, ClientboundPackets1_14, ServerboundPackets1_14, ServerboundPackets1_14> {
|
public class Protocol1_14_3To1_14_2 extends AbstractProtocol<ClientboundPackets1_14, ClientboundPackets1_14, ServerboundPackets1_14, ServerboundPackets1_14> {
|
||||||
|
|
||||||
public Protocol1_14_3To1_14_2() {
|
public Protocol1_14_3To1_14_2() {
|
||||||
super(ClientboundPackets1_14.class, ClientboundPackets1_14.class, null, null);
|
super(ClientboundPackets1_14.class, ClientboundPackets1_14.class, null, null);
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.viaversion.viaversion.protocols.protocol1_14_4to1_14_3;
|
package com.viaversion.viaversion.protocols.protocol1_14_4to1_14_3;
|
||||||
|
|
||||||
import com.viaversion.viaversion.api.protocol.Protocol;
|
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||||
@ -25,7 +25,7 @@ import com.viaversion.viaversion.api.type.Type;
|
|||||||
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14;
|
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14;
|
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14;
|
||||||
|
|
||||||
public class Protocol1_14_4To1_14_3 extends Protocol<ClientboundPackets1_14, ClientboundPackets1_14, ServerboundPackets1_14, ServerboundPackets1_14> {
|
public class Protocol1_14_4To1_14_3 extends AbstractProtocol<ClientboundPackets1_14, ClientboundPackets1_14, ServerboundPackets1_14, ServerboundPackets1_14> {
|
||||||
|
|
||||||
public Protocol1_14_4To1_14_3() {
|
public Protocol1_14_4To1_14_3() {
|
||||||
super(ClientboundPackets1_14.class, ClientboundPackets1_14.class, null, null);
|
super(ClientboundPackets1_14.class, ClientboundPackets1_14.class, null, null);
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
package com.viaversion.viaversion.protocols.protocol1_14to1_13_2;
|
package com.viaversion.viaversion.protocols.protocol1_14to1_13_2;
|
||||||
|
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||||
import com.viaversion.viaversion.api.protocol.Protocol;
|
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||||
@ -40,7 +40,7 @@ import com.viaversion.viaversion.rewriter.MetadataRewriter;
|
|||||||
import com.viaversion.viaversion.rewriter.SoundRewriter;
|
import com.viaversion.viaversion.rewriter.SoundRewriter;
|
||||||
import com.viaversion.viaversion.rewriter.StatisticsRewriter;
|
import com.viaversion.viaversion.rewriter.StatisticsRewriter;
|
||||||
|
|
||||||
public class Protocol1_14To1_13_2 extends Protocol<ClientboundPackets1_13, ClientboundPackets1_14, ServerboundPackets1_13, ServerboundPackets1_14> {
|
public class Protocol1_14To1_13_2 extends AbstractProtocol<ClientboundPackets1_13, ClientboundPackets1_14, ServerboundPackets1_13, ServerboundPackets1_14> {
|
||||||
|
|
||||||
public static final MappingData MAPPINGS = new MappingData();
|
public static final MappingData MAPPINGS = new MappingData();
|
||||||
|
|
||||||
|
@ -17,9 +17,9 @@
|
|||||||
*/
|
*/
|
||||||
package com.viaversion.viaversion.protocols.protocol1_15_1to1_15;
|
package com.viaversion.viaversion.protocols.protocol1_15_1to1_15;
|
||||||
|
|
||||||
import com.viaversion.viaversion.api.protocol.Protocol;
|
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14;
|
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_15to1_14_4.ClientboundPackets1_15;
|
import com.viaversion.viaversion.protocols.protocol1_15to1_14_4.ClientboundPackets1_15;
|
||||||
|
|
||||||
public class Protocol1_15_1To1_15 extends Protocol<ClientboundPackets1_15, ClientboundPackets1_15, ServerboundPackets1_14, ServerboundPackets1_14> {
|
public class Protocol1_15_1To1_15 extends AbstractProtocol<ClientboundPackets1_15, ClientboundPackets1_15, ServerboundPackets1_14, ServerboundPackets1_14> {
|
||||||
}
|
}
|
||||||
|
@ -17,9 +17,9 @@
|
|||||||
*/
|
*/
|
||||||
package com.viaversion.viaversion.protocols.protocol1_15_2to1_15_1;
|
package com.viaversion.viaversion.protocols.protocol1_15_2to1_15_1;
|
||||||
|
|
||||||
import com.viaversion.viaversion.api.protocol.Protocol;
|
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14;
|
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_15to1_14_4.ClientboundPackets1_15;
|
import com.viaversion.viaversion.protocols.protocol1_15to1_14_4.ClientboundPackets1_15;
|
||||||
|
|
||||||
public class Protocol1_15_2To1_15_1 extends Protocol<ClientboundPackets1_15, ClientboundPackets1_15, ServerboundPackets1_14, ServerboundPackets1_14> {
|
public class Protocol1_15_2To1_15_1 extends AbstractProtocol<ClientboundPackets1_15, ClientboundPackets1_15, ServerboundPackets1_14, ServerboundPackets1_14> {
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
package com.viaversion.viaversion.protocols.protocol1_15to1_14_4;
|
package com.viaversion.viaversion.protocols.protocol1_15to1_14_4;
|
||||||
|
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||||
import com.viaversion.viaversion.api.protocol.Protocol;
|
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14;
|
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14;
|
||||||
@ -36,7 +36,7 @@ import com.viaversion.viaversion.rewriter.SoundRewriter;
|
|||||||
import com.viaversion.viaversion.rewriter.StatisticsRewriter;
|
import com.viaversion.viaversion.rewriter.StatisticsRewriter;
|
||||||
import com.viaversion.viaversion.rewriter.TagRewriter;
|
import com.viaversion.viaversion.rewriter.TagRewriter;
|
||||||
|
|
||||||
public class Protocol1_15To1_14_4 extends Protocol<ClientboundPackets1_14, ClientboundPackets1_15, ServerboundPackets1_14, ServerboundPackets1_14> {
|
public class Protocol1_15To1_14_4 extends AbstractProtocol<ClientboundPackets1_14, ClientboundPackets1_15, ServerboundPackets1_14, ServerboundPackets1_14> {
|
||||||
|
|
||||||
public static final MappingData MAPPINGS = new MappingData();
|
public static final MappingData MAPPINGS = new MappingData();
|
||||||
private TagRewriter tagRewriter;
|
private TagRewriter tagRewriter;
|
||||||
|
@ -17,9 +17,9 @@
|
|||||||
*/
|
*/
|
||||||
package com.viaversion.viaversion.protocols.protocol1_16_1to1_16;
|
package com.viaversion.viaversion.protocols.protocol1_16_1to1_16;
|
||||||
|
|
||||||
import com.viaversion.viaversion.api.protocol.Protocol;
|
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.ClientboundPackets1_16;
|
import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.ClientboundPackets1_16;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.ServerboundPackets1_16;
|
import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.ServerboundPackets1_16;
|
||||||
|
|
||||||
public class Protocol1_16_1To1_16 extends Protocol<ClientboundPackets1_16, ClientboundPackets1_16, ServerboundPackets1_16, ServerboundPackets1_16> {
|
public class Protocol1_16_1To1_16 extends AbstractProtocol<ClientboundPackets1_16, ClientboundPackets1_16, ServerboundPackets1_16, ServerboundPackets1_16> {
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
package com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1;
|
package com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1;
|
||||||
|
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||||
import com.viaversion.viaversion.api.protocol.Protocol;
|
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.data.MappingData;
|
import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.data.MappingData;
|
||||||
@ -35,7 +35,7 @@ import com.viaversion.viaversion.rewriter.SoundRewriter;
|
|||||||
import com.viaversion.viaversion.rewriter.StatisticsRewriter;
|
import com.viaversion.viaversion.rewriter.StatisticsRewriter;
|
||||||
import com.viaversion.viaversion.rewriter.TagRewriter;
|
import com.viaversion.viaversion.rewriter.TagRewriter;
|
||||||
|
|
||||||
public class Protocol1_16_2To1_16_1 extends Protocol<ClientboundPackets1_16, ClientboundPackets1_16_2, ServerboundPackets1_16, ServerboundPackets1_16_2> {
|
public class Protocol1_16_2To1_16_1 extends AbstractProtocol<ClientboundPackets1_16, ClientboundPackets1_16_2, ServerboundPackets1_16, ServerboundPackets1_16_2> {
|
||||||
|
|
||||||
public static final MappingData MAPPINGS = new MappingData();
|
public static final MappingData MAPPINGS = new MappingData();
|
||||||
private TagRewriter tagRewriter;
|
private TagRewriter tagRewriter;
|
||||||
|
@ -17,9 +17,9 @@
|
|||||||
*/
|
*/
|
||||||
package com.viaversion.viaversion.protocols.protocol1_16_3to1_16_2;
|
package com.viaversion.viaversion.protocols.protocol1_16_3to1_16_2;
|
||||||
|
|
||||||
import com.viaversion.viaversion.api.protocol.Protocol;
|
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.ClientboundPackets1_16_2;
|
import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.ClientboundPackets1_16_2;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.ServerboundPackets1_16_2;
|
import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.ServerboundPackets1_16_2;
|
||||||
|
|
||||||
public class Protocol1_16_3To1_16_2 extends Protocol<ClientboundPackets1_16_2, ClientboundPackets1_16_2, ServerboundPackets1_16_2, ServerboundPackets1_16_2> {
|
public class Protocol1_16_3To1_16_2 extends AbstractProtocol<ClientboundPackets1_16_2, ClientboundPackets1_16_2, ServerboundPackets1_16_2, ServerboundPackets1_16_2> {
|
||||||
}
|
}
|
||||||
|
@ -17,13 +17,13 @@
|
|||||||
*/
|
*/
|
||||||
package com.viaversion.viaversion.protocols.protocol1_16_4to1_16_3;
|
package com.viaversion.viaversion.protocols.protocol1_16_4to1_16_3;
|
||||||
|
|
||||||
import com.viaversion.viaversion.api.protocol.Protocol;
|
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.ClientboundPackets1_16_2;
|
import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.ClientboundPackets1_16_2;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.ServerboundPackets1_16_2;
|
import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.ServerboundPackets1_16_2;
|
||||||
|
|
||||||
public class Protocol1_16_4To1_16_3 extends Protocol<ClientboundPackets1_16_2, ClientboundPackets1_16_2, ServerboundPackets1_16_2, ServerboundPackets1_16_2> {
|
public class Protocol1_16_4To1_16_3 extends AbstractProtocol<ClientboundPackets1_16_2, ClientboundPackets1_16_2, ServerboundPackets1_16_2, ServerboundPackets1_16_2> {
|
||||||
|
|
||||||
public Protocol1_16_4To1_16_3() {
|
public Protocol1_16_4To1_16_3() {
|
||||||
super(ClientboundPackets1_16_2.class, ClientboundPackets1_16_2.class, ServerboundPackets1_16_2.class, ServerboundPackets1_16_2.class);
|
super(ClientboundPackets1_16_2.class, ClientboundPackets1_16_2.class, ServerboundPackets1_16_2.class, ServerboundPackets1_16_2.class);
|
||||||
|
@ -23,7 +23,7 @@ import com.google.gson.JsonElement;
|
|||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import com.viaversion.viaversion.api.Via;
|
import com.viaversion.viaversion.api.Via;
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||||
import com.viaversion.viaversion.api.protocol.Protocol;
|
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.State;
|
import com.viaversion.viaversion.api.protocol.packet.State;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
@ -50,7 +50,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class Protocol1_16To1_15_2 extends Protocol<ClientboundPackets1_15, ClientboundPackets1_16, ServerboundPackets1_14, ServerboundPackets1_16> {
|
public class Protocol1_16To1_15_2 extends AbstractProtocol<ClientboundPackets1_15, ClientboundPackets1_16, ServerboundPackets1_14, ServerboundPackets1_16> {
|
||||||
|
|
||||||
private static final UUID ZERO_UUID = new UUID(0, 0);
|
private static final UUID ZERO_UUID = new UUID(0, 0);
|
||||||
public static final MappingData MAPPINGS = new MappingData();
|
public static final MappingData MAPPINGS = new MappingData();
|
||||||
|
@ -21,7 +21,7 @@ import com.viaversion.viaversion.api.Via;
|
|||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||||
import com.viaversion.viaversion.api.data.MappingData;
|
import com.viaversion.viaversion.api.data.MappingData;
|
||||||
import com.viaversion.viaversion.api.data.MappingDataBase;
|
import com.viaversion.viaversion.api.data.MappingDataBase;
|
||||||
import com.viaversion.viaversion.api.protocol.Protocol;
|
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
|
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
@ -39,7 +39,7 @@ import com.viaversion.viaversion.rewriter.SoundRewriter;
|
|||||||
import com.viaversion.viaversion.rewriter.StatisticsRewriter;
|
import com.viaversion.viaversion.rewriter.StatisticsRewriter;
|
||||||
import com.viaversion.viaversion.rewriter.TagRewriter;
|
import com.viaversion.viaversion.rewriter.TagRewriter;
|
||||||
|
|
||||||
public class Protocol1_17To1_16_4 extends Protocol<ClientboundPackets1_16_2, ClientboundPackets1_17, ServerboundPackets1_16_2, ServerboundPackets1_17> {
|
public class Protocol1_17To1_16_4 extends AbstractProtocol<ClientboundPackets1_16_2, ClientboundPackets1_17, ServerboundPackets1_16_2, ServerboundPackets1_17> {
|
||||||
|
|
||||||
public static final MappingData MAPPINGS = new MappingDataBase("1.16.2", "1.17", true);
|
public static final MappingData MAPPINGS = new MappingDataBase("1.16.2", "1.17", true);
|
||||||
private static final String[] NEW_GAME_EVENT_TAGS = {"minecraft:ignore_vibrations_sneaking", "minecraft:vibrations"};
|
private static final String[] NEW_GAME_EVENT_TAGS = {"minecraft:ignore_vibrations_sneaking", "minecraft:vibrations"};
|
||||||
|
@ -21,7 +21,7 @@ import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
|||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||||
import com.viaversion.viaversion.api.minecraft.Position;
|
import com.viaversion.viaversion.api.minecraft.Position;
|
||||||
import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
|
import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
|
||||||
import com.viaversion.viaversion.api.protocol.Protocol;
|
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||||
@ -36,7 +36,7 @@ import com.viaversion.viaversion.protocols.protocol1_9to1_8.ClientboundPackets1_
|
|||||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.ServerboundPackets1_9;
|
import com.viaversion.viaversion.protocols.protocol1_9to1_8.ServerboundPackets1_9;
|
||||||
|
|
||||||
// Goes BACKWARDS from 1.9.3/4 to 1.9.1/2
|
// Goes BACKWARDS from 1.9.3/4 to 1.9.1/2
|
||||||
public class Protocol1_9_1_2To1_9_3_4 extends Protocol<ClientboundPackets1_9_3, ClientboundPackets1_9, ServerboundPackets1_9_3, ServerboundPackets1_9> {
|
public class Protocol1_9_1_2To1_9_3_4 extends AbstractProtocol<ClientboundPackets1_9_3, ClientboundPackets1_9, ServerboundPackets1_9_3, ServerboundPackets1_9> {
|
||||||
|
|
||||||
public Protocol1_9_1_2To1_9_3_4() {
|
public Protocol1_9_1_2To1_9_3_4() {
|
||||||
super(ClientboundPackets1_9_3.class, ClientboundPackets1_9.class, ServerboundPackets1_9_3.class, ServerboundPackets1_9.class);
|
super(ClientboundPackets1_9_3.class, ClientboundPackets1_9.class, ServerboundPackets1_9_3.class, ServerboundPackets1_9.class);
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.viaversion.viaversion.protocols.protocol1_9_1to1_9;
|
package com.viaversion.viaversion.protocols.protocol1_9_1to1_9;
|
||||||
|
|
||||||
import com.viaversion.viaversion.api.protocol.Protocol;
|
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||||
@ -25,7 +25,7 @@ import com.viaversion.viaversion.api.type.Type;
|
|||||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.ClientboundPackets1_9;
|
import com.viaversion.viaversion.protocols.protocol1_9to1_8.ClientboundPackets1_9;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.ServerboundPackets1_9;
|
import com.viaversion.viaversion.protocols.protocol1_9to1_8.ServerboundPackets1_9;
|
||||||
|
|
||||||
public class Protocol1_9_1To1_9 extends Protocol<ClientboundPackets1_9, ClientboundPackets1_9, ServerboundPackets1_9, ServerboundPackets1_9> {
|
public class Protocol1_9_1To1_9 extends AbstractProtocol<ClientboundPackets1_9, ClientboundPackets1_9, ServerboundPackets1_9, ServerboundPackets1_9> {
|
||||||
|
|
||||||
public Protocol1_9_1To1_9() {
|
public Protocol1_9_1To1_9() {
|
||||||
super(ClientboundPackets1_9.class, ClientboundPackets1_9.class, ServerboundPackets1_9.class, ServerboundPackets1_9.class);
|
super(ClientboundPackets1_9.class, ClientboundPackets1_9.class, ServerboundPackets1_9.class, ServerboundPackets1_9.class);
|
||||||
|
@ -25,7 +25,7 @@ import com.viaversion.viaversion.api.connection.UserConnection;
|
|||||||
import com.viaversion.viaversion.api.minecraft.Position;
|
import com.viaversion.viaversion.api.minecraft.Position;
|
||||||
import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
|
import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
|
||||||
import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection;
|
import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection;
|
||||||
import com.viaversion.viaversion.api.protocol.Protocol;
|
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||||
@ -39,7 +39,7 @@ import com.viaversion.viaversion.protocols.protocol1_9to1_8.ServerboundPackets1_
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class Protocol1_9_3To1_9_1_2 extends Protocol<ClientboundPackets1_9, ClientboundPackets1_9_3, ServerboundPackets1_9, ServerboundPackets1_9_3> {
|
public class Protocol1_9_3To1_9_1_2 extends AbstractProtocol<ClientboundPackets1_9, ClientboundPackets1_9_3, ServerboundPackets1_9, ServerboundPackets1_9_3> {
|
||||||
|
|
||||||
public static final ValueTransformer<Short, Short> ADJUST_PITCH = new ValueTransformer<Short, Short>(Type.UNSIGNED_BYTE, Type.UNSIGNED_BYTE) {
|
public static final ValueTransformer<Short, Short> ADJUST_PITCH = new ValueTransformer<Short, Short>(Type.UNSIGNED_BYTE, Type.UNSIGNED_BYTE) {
|
||||||
@Override
|
@Override
|
||||||
|
@ -23,7 +23,7 @@ import com.viaversion.viaversion.api.Via;
|
|||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||||
import com.viaversion.viaversion.api.platform.providers.ViaProviders;
|
import com.viaversion.viaversion.api.platform.providers.ViaProviders;
|
||||||
import com.viaversion.viaversion.api.protocol.Protocol;
|
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.State;
|
import com.viaversion.viaversion.api.protocol.packet.State;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||||
@ -54,7 +54,7 @@ import com.viaversion.viaversion.util.GsonUtil;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class Protocol1_9To1_8 extends Protocol<ClientboundPackets1_8, ClientboundPackets1_9, ServerboundPackets1_8, ServerboundPackets1_9> {
|
public class Protocol1_9To1_8 extends AbstractProtocol<ClientboundPackets1_8, ClientboundPackets1_9, ServerboundPackets1_8, ServerboundPackets1_9> {
|
||||||
public static final ValueTransformer<String, JsonElement> FIX_JSON = new ValueTransformer<String, JsonElement>(Type.COMPONENT) {
|
public static final ValueTransformer<String, JsonElement> FIX_JSON = new ValueTransformer<String, JsonElement>(Type.COMPONENT) {
|
||||||
@Override
|
@Override
|
||||||
public JsonElement transform(PacketWrapper wrapper, String line) {
|
public JsonElement transform(PacketWrapper wrapper, String line) {
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.viaversion.viaversion.protocols.protocol1_9to1_9_1;
|
package com.viaversion.viaversion.protocols.protocol1_9to1_9_1;
|
||||||
|
|
||||||
import com.viaversion.viaversion.api.protocol.Protocol;
|
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||||
@ -25,7 +25,7 @@ import com.viaversion.viaversion.api.type.Type;
|
|||||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.ClientboundPackets1_9;
|
import com.viaversion.viaversion.protocols.protocol1_9to1_8.ClientboundPackets1_9;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.ServerboundPackets1_9;
|
import com.viaversion.viaversion.protocols.protocol1_9to1_8.ServerboundPackets1_9;
|
||||||
|
|
||||||
public class Protocol1_9To1_9_1 extends Protocol<ClientboundPackets1_9, ClientboundPackets1_9, ServerboundPackets1_9, ServerboundPackets1_9> {
|
public class Protocol1_9To1_9_1 extends AbstractProtocol<ClientboundPackets1_9, ClientboundPackets1_9, ServerboundPackets1_9, ServerboundPackets1_9> {
|
||||||
|
|
||||||
public Protocol1_9To1_9_1() {
|
public Protocol1_9To1_9_1() {
|
||||||
super(ClientboundPackets1_9.class, ClientboundPackets1_9.class, ServerboundPackets1_9.class, ServerboundPackets1_9.class);
|
super(ClientboundPackets1_9.class, ClientboundPackets1_9.class, ServerboundPackets1_9.class, ServerboundPackets1_9.class);
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren