Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-27 08:30:09 +01:00
Move ProtocolInfo into its own field
Dieser Commit ist enthalten in:
Ursprung
f2d6691af7
Commit
529da10615
@ -17,7 +17,7 @@ public class BukkitBlockConnectionProvider extends BlockConnectionProvider {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getWorldBlockData(UserConnection user, int bx, int by, int bz) {
|
public int getWorldBlockData(UserConnection user, int bx, int by, int bz) {
|
||||||
UUID uuid = user.get(ProtocolInfo.class).getUuid();
|
UUID uuid = user.getProtocolInfo().getUuid();
|
||||||
Player player = Bukkit.getPlayer(uuid);
|
Player player = Bukkit.getPlayer(uuid);
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
World world = player.getWorld();
|
World world = player.getWorld();
|
||||||
|
@ -24,7 +24,7 @@ public class BukkitPacketHandler extends MessageToMessageEncoder {
|
|||||||
info.setLastPacket(o);
|
info.setLastPacket(o);
|
||||||
/* This transformer is more for fixing issues which we find hard at packet level :) */
|
/* This transformer is more for fixing issues which we find hard at packet level :) */
|
||||||
if (info.isActive()) {
|
if (info.isActive()) {
|
||||||
if (info.get(ProtocolInfo.class).getPipeline().filter(o, list)) {
|
if (info.getProtocolInfo().getPipeline().filter(o, list)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -75,7 +75,7 @@ public class PlayerSneakListener extends ViaBukkitListener {
|
|||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
UserConnection userConnection = getUserConnection(player);
|
UserConnection userConnection = getUserConnection(player);
|
||||||
if (userConnection == null) return;
|
if (userConnection == null) return;
|
||||||
ProtocolInfo info = userConnection.get(ProtocolInfo.class);
|
ProtocolInfo info = userConnection.getProtocolInfo();
|
||||||
if (info == null) return;
|
if (info == null) return;
|
||||||
|
|
||||||
int protocolVersion = info.getProtocolVersion();
|
int protocolVersion = info.getProtocolVersion();
|
||||||
|
@ -35,7 +35,7 @@ public class BukkitViaAPI implements ViaAPI<Player> {
|
|||||||
public int getPlayerVersion(UUID uuid) {
|
public int getPlayerVersion(UUID uuid) {
|
||||||
if (!isInjected(uuid))
|
if (!isInjected(uuid))
|
||||||
return getExternalVersion(Bukkit.getPlayer(uuid));
|
return getExternalVersion(Bukkit.getPlayer(uuid));
|
||||||
return Via.getManager().getConnection(uuid).get(ProtocolInfo.class).getProtocolVersion();
|
return Via.getManager().getConnection(uuid).getProtocolInfo().getProtocolVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getExternalVersion(Player player) {
|
private int getExternalVersion(Player player) {
|
||||||
|
@ -120,11 +120,11 @@ public class BukkitViaLoader implements ViaPlatformLoader {
|
|||||||
@Override
|
@Override
|
||||||
public Item getHandItem(final UserConnection info) {
|
public Item getHandItem(final UserConnection info) {
|
||||||
if (handItemCache != null) {
|
if (handItemCache != null) {
|
||||||
return handItemCache.getHandItem(info.get(ProtocolInfo.class).getUuid());
|
return handItemCache.getHandItem(info.getProtocolInfo().getUuid());
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
return Bukkit.getScheduler().callSyncMethod(Bukkit.getPluginManager().getPlugin("ViaVersion"), () -> {
|
return Bukkit.getScheduler().callSyncMethod(Bukkit.getPluginManager().getPlugin("ViaVersion"), () -> {
|
||||||
UUID playerUUID = info.get(ProtocolInfo.class).getUuid();
|
UUID playerUUID = info.getProtocolInfo().getUuid();
|
||||||
Player player = Bukkit.getPlayer(playerUUID);
|
Player player = Bukkit.getPlayer(playerUUID);
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
return HandItemCache.convert(player.getItemInHand());
|
return HandItemCache.convert(player.getItemInHand());
|
||||||
|
@ -63,7 +63,7 @@ public class BukkitInventoryQuickMoveProvider extends InventoryQuickMoveProvider
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ProtocolInfo info = userConnection.get(ProtocolInfo.class);
|
ProtocolInfo info = userConnection.getProtocolInfo();
|
||||||
UUID uuid = info.getUuid();
|
UUID uuid = info.getUuid();
|
||||||
BukkitInventoryUpdateTask updateTask = updateTasks.get(uuid);
|
BukkitInventoryUpdateTask updateTask = updateTasks.get(uuid);
|
||||||
final boolean registered = updateTask != null;
|
final boolean registered = updateTask != null;
|
||||||
|
@ -81,7 +81,7 @@ public class BukkitViaMovementTransmitter extends MovementTransmitterProvider {
|
|||||||
@Override
|
@Override
|
||||||
public void sendPlayer(UserConnection info) {
|
public void sendPlayer(UserConnection info) {
|
||||||
if (USE_NMS) {
|
if (USE_NMS) {
|
||||||
Player player = Bukkit.getPlayer(info.get(ProtocolInfo.class).getUuid());
|
Player player = Bukkit.getPlayer(info.getProtocolInfo().getUuid());
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
try {
|
try {
|
||||||
// Tick player
|
// Tick player
|
||||||
|
@ -77,13 +77,13 @@ public class BungeeServerHandler implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int protocolId = ProtocolDetectorService.getProtocolId(e.getTarget().getName());
|
int protocolId = ProtocolDetectorService.getProtocolId(e.getTarget().getName());
|
||||||
List<Pair<Integer, Protocol>> protocols = ProtocolRegistry.getProtocolPath(user.get(ProtocolInfo.class).getProtocolVersion(), protocolId);
|
List<Pair<Integer, Protocol>> protocols = ProtocolRegistry.getProtocolPath(user.getProtocolInfo().getProtocolVersion(), protocolId);
|
||||||
|
|
||||||
// Check if ViaVersion can support that version
|
// Check if ViaVersion can support that version
|
||||||
try {
|
try {
|
||||||
//Object pendingConnection = getPendingConnection.invoke(e.getPlayer());
|
//Object pendingConnection = getPendingConnection.invoke(e.getPlayer());
|
||||||
Object handshake = getHandshake.invoke(e.getPlayer().getPendingConnection());
|
Object handshake = getHandshake.invoke(e.getPlayer().getPendingConnection());
|
||||||
setProtocol.invoke(handshake, protocols == null ? user.get(ProtocolInfo.class).getProtocolVersion() : protocolId);
|
setProtocol.invoke(handshake, protocols == null ? user.getProtocolInfo().getProtocolVersion() : protocolId);
|
||||||
} catch (InvocationTargetException | IllegalAccessException e1) {
|
} catch (InvocationTargetException | IllegalAccessException e1) {
|
||||||
e1.printStackTrace();
|
e1.printStackTrace();
|
||||||
}
|
}
|
||||||
@ -145,7 +145,7 @@ public class BungeeServerHandler implements Listener {
|
|||||||
if (storage.getBossbar() != null) {
|
if (storage.getBossbar() != null) {
|
||||||
// TODO: Verify whether this packet needs to be sent when 1.8 -> 1.9 protocol isn't present in the pipeline
|
// TODO: Verify whether this packet needs to be sent when 1.8 -> 1.9 protocol isn't present in the pipeline
|
||||||
// This ensures we can encode it properly as only the 1.9 protocol is currently implemented.
|
// This ensures we can encode it properly as only the 1.9 protocol is currently implemented.
|
||||||
if (user.get(ProtocolInfo.class).getPipeline().contains(Protocol1_9To1_8.class)) {
|
if (user.getProtocolInfo().getPipeline().contains(Protocol1_9To1_8.class)) {
|
||||||
for (UUID uuid : storage.getBossbar()) {
|
for (UUID uuid : storage.getBossbar()) {
|
||||||
PacketWrapper wrapper = new PacketWrapper(0x0C, null, user);
|
PacketWrapper wrapper = new PacketWrapper(0x0C, null, user);
|
||||||
wrapper.write(Type.UUID, uuid);
|
wrapper.write(Type.UUID, uuid);
|
||||||
@ -157,12 +157,12 @@ public class BungeeServerHandler implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ProtocolInfo info = user.get(ProtocolInfo.class);
|
ProtocolInfo info = user.getProtocolInfo();
|
||||||
int previousServerProtocol = info.getServerProtocolVersion();
|
int previousServerProtocol = info.getServerProtocolVersion();
|
||||||
|
|
||||||
// Refresh the pipes
|
// Refresh the pipes
|
||||||
List<Pair<Integer, Protocol>> protocols = ProtocolRegistry.getProtocolPath(info.getProtocolVersion(), protocolId);
|
List<Pair<Integer, Protocol>> protocols = ProtocolRegistry.getProtocolPath(info.getProtocolVersion(), protocolId);
|
||||||
ProtocolPipeline pipeline = user.get(ProtocolInfo.class).getPipeline();
|
ProtocolPipeline pipeline = user.getProtocolInfo().getPipeline();
|
||||||
user.clearStoredObjects();
|
user.clearStoredObjects();
|
||||||
pipeline.cleanPipes();
|
pipeline.cleanPipes();
|
||||||
if (protocols == null) {
|
if (protocols == null) {
|
||||||
|
@ -28,7 +28,7 @@ public class ElytraPatch implements Listener {
|
|||||||
if (user == null) return;
|
if (user == null) return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (user.get(ProtocolInfo.class).getPipeline().contains(Protocol1_9To1_8.class)) {
|
if (user.getProtocolInfo().getPipeline().contains(Protocol1_9To1_8.class)) {
|
||||||
int entityId = user.get(EntityTracker1_9.class).getProvidedEntityId();
|
int entityId = user.get(EntityTracker1_9.class).getProvidedEntityId();
|
||||||
|
|
||||||
PacketWrapper wrapper = new PacketWrapper(0x39, null, user);
|
PacketWrapper wrapper = new PacketWrapper(0x39, null, user);
|
||||||
|
@ -26,7 +26,7 @@ public class BungeeViaAPI implements ViaAPI<ProxiedPlayer> {
|
|||||||
if (conn == null) {
|
if (conn == null) {
|
||||||
return player.getPendingConnection().getVersion();
|
return player.getPendingConnection().getVersion();
|
||||||
}
|
}
|
||||||
return conn.get(ProtocolInfo.class).getProtocolVersion();
|
return conn.getProtocolInfo().getProtocolVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -26,7 +26,7 @@ public class BungeeMainHandProvider extends MainHandProvider {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setMainHand(UserConnection user, int hand) {
|
public void setMainHand(UserConnection user, int hand) {
|
||||||
ProtocolInfo info = user.get(ProtocolInfo.class);
|
ProtocolInfo info = user.getProtocolInfo();
|
||||||
if (info == null || info.getUuid() == null) return;
|
if (info == null || info.getUuid() == null) return;
|
||||||
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(info.getUuid());
|
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(info.getUuid());
|
||||||
if (player == null) return;
|
if (player == null) return;
|
||||||
|
@ -21,7 +21,7 @@ public class BungeeMovementTransmitter extends MovementTransmitterProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void sendPlayer(UserConnection userConnection) {
|
public void sendPlayer(UserConnection userConnection) {
|
||||||
if (userConnection.get(ProtocolInfo.class).getState() == State.PLAY) {
|
if (userConnection.getProtocolInfo().getState() == State.PLAY) {
|
||||||
PacketWrapper wrapper = new PacketWrapper(0x03, null, userConnection);
|
PacketWrapper wrapper = new PacketWrapper(0x03, null, userConnection);
|
||||||
wrapper.write(Type.BOOLEAN, userConnection.get(MovementTracker.class).isGround());
|
wrapper.write(Type.BOOLEAN, userConnection.get(MovementTracker.class).isGround());
|
||||||
try {
|
try {
|
||||||
|
@ -34,7 +34,7 @@ public class BungeeVersionProvider extends VersionProvider {
|
|||||||
List<Integer> sorted = new ArrayList<>(list);
|
List<Integer> sorted = new ArrayList<>(list);
|
||||||
Collections.sort(sorted);
|
Collections.sort(sorted);
|
||||||
|
|
||||||
ProtocolInfo info = user.get(ProtocolInfo.class);
|
ProtocolInfo info = user.getProtocolInfo();
|
||||||
|
|
||||||
// Bungee supports it
|
// Bungee supports it
|
||||||
if (sorted.contains(info.getProtocolVersion()))
|
if (sorted.contains(info.getProtocolVersion()))
|
||||||
|
@ -319,7 +319,7 @@ public class PacketWrapper {
|
|||||||
*/
|
*/
|
||||||
private ByteBuf constructPacket(Class<? extends Protocol> packetProtocol, boolean skipCurrentPipeline, Direction direction) throws Exception {
|
private ByteBuf constructPacket(Class<? extends Protocol> packetProtocol, boolean skipCurrentPipeline, Direction direction) throws Exception {
|
||||||
// Apply current pipeline
|
// Apply current pipeline
|
||||||
List<Protocol> protocols = new ArrayList<>(user().get(ProtocolInfo.class).getPipeline().pipes());
|
List<Protocol> protocols = new ArrayList<>(user().getProtocolInfo().getPipeline().pipes());
|
||||||
if (direction == Direction.OUTGOING) {
|
if (direction == Direction.OUTGOING) {
|
||||||
// Other way if outgoing
|
// Other way if outgoing
|
||||||
Collections.reverse(protocols);
|
Collections.reverse(protocols);
|
||||||
@ -337,7 +337,7 @@ public class PacketWrapper {
|
|||||||
resetReader();
|
resetReader();
|
||||||
|
|
||||||
// Apply other protocols
|
// Apply other protocols
|
||||||
apply(direction, user().get(ProtocolInfo.class).getState(), index, protocols);
|
apply(direction, user().getProtocolInfo().getState(), index, protocols);
|
||||||
// Send
|
// Send
|
||||||
ByteBuf output = inputBuffer == null ? user().getChannel().alloc().buffer() : inputBuffer.alloc().buffer();
|
ByteBuf output = inputBuffer == null ? user().getChannel().alloc().buffer() : inputBuffer.alloc().buffer();
|
||||||
writeToBuffer(output);
|
writeToBuffer(output);
|
||||||
|
@ -35,7 +35,7 @@ public abstract class ViaListener {
|
|||||||
protected boolean isOnPipe(UUID uuid) {
|
protected boolean isOnPipe(UUID uuid) {
|
||||||
UserConnection userConnection = getUserConnection(uuid);
|
UserConnection userConnection = getUserConnection(uuid);
|
||||||
return userConnection != null &&
|
return userConnection != null &&
|
||||||
(requiredPipeline == null || userConnection.get(ProtocolInfo.class).getPipeline().contains(requiredPipeline));
|
(requiredPipeline == null || userConnection.getProtocolInfo().getPipeline().contains(requiredPipeline));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -26,6 +26,7 @@ public class UserConnection {
|
|||||||
private static final AtomicLong IDS = new AtomicLong();
|
private static final AtomicLong IDS = new AtomicLong();
|
||||||
private final long id = IDS.incrementAndGet();
|
private final long id = IDS.incrementAndGet();
|
||||||
private final Channel channel;
|
private final Channel channel;
|
||||||
|
private ProtocolInfo protocolInfo;
|
||||||
Map<Class, StoredObject> storedObjects = new ConcurrentHashMap<>();
|
Map<Class, StoredObject> storedObjects = new ConcurrentHashMap<>();
|
||||||
private boolean active = true;
|
private boolean active = true;
|
||||||
private boolean pendingDisconnect;
|
private boolean pendingDisconnect;
|
||||||
@ -193,7 +194,7 @@ public class UserConnection {
|
|||||||
if (!channel.isOpen() || pendingDisconnect) return;
|
if (!channel.isOpen() || pendingDisconnect) return;
|
||||||
|
|
||||||
pendingDisconnect = true;
|
pendingDisconnect = true;
|
||||||
UUID uuid = get(ProtocolInfo.class).getUuid();
|
UUID uuid = protocolInfo.getUuid();
|
||||||
if (uuid == null) {
|
if (uuid == null) {
|
||||||
channel.close(); // Just disconnect, we don't know what the connection is
|
channel.close(); // Just disconnect, we don't know what the connection is
|
||||||
return;
|
return;
|
||||||
@ -318,9 +319,8 @@ public class UserConnection {
|
|||||||
if (id == PacketWrapper.PASSTHROUGH_ID) return;
|
if (id == PacketWrapper.PASSTHROUGH_ID) return;
|
||||||
|
|
||||||
PacketWrapper wrapper = new PacketWrapper(id, draft, this);
|
PacketWrapper wrapper = new PacketWrapper(id, draft, this);
|
||||||
ProtocolInfo protInfo = get(ProtocolInfo.class);
|
|
||||||
try {
|
try {
|
||||||
protInfo.getPipeline().transform(direction, protInfo.getState(), wrapper);
|
protocolInfo.getPipeline().transform(direction, protocolInfo.getState(), wrapper);
|
||||||
} catch (CancelException ex) {
|
} catch (CancelException ex) {
|
||||||
throw cancelSupplier.apply(ex);
|
throw cancelSupplier.apply(ex);
|
||||||
}
|
}
|
||||||
@ -343,6 +343,20 @@ public class UserConnection {
|
|||||||
return channel;
|
return channel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public ProtocolInfo getProtocolInfo() {
|
||||||
|
return protocolInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProtocolInfo(@Nullable ProtocolInfo protocolInfo) {
|
||||||
|
this.protocolInfo = protocolInfo;
|
||||||
|
if (protocolInfo != null) {
|
||||||
|
storedObjects.put(ProtocolInfo.class, protocolInfo);
|
||||||
|
} else {
|
||||||
|
storedObjects.remove(ProtocolInfo.class);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public Map<Class, StoredObject> getStoredObjects() {
|
public Map<Class, StoredObject> getStoredObjects() {
|
||||||
return storedObjects;
|
return storedObjects;
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ public class ViaConnectionManager {
|
|||||||
|
|
||||||
public void onLoginSuccess(UserConnection connection) {
|
public void onLoginSuccess(UserConnection connection) {
|
||||||
Objects.requireNonNull(connection, "connection is null!");
|
Objects.requireNonNull(connection, "connection is null!");
|
||||||
UUID id = connection.get(ProtocolInfo.class).getUuid();
|
UUID id = connection.getProtocolInfo().getUuid();
|
||||||
connections.add(connection);
|
connections.add(connection);
|
||||||
clients.put(id, connection);
|
clients.put(id, connection);
|
||||||
|
|
||||||
@ -28,7 +28,7 @@ public class ViaConnectionManager {
|
|||||||
|
|
||||||
public void onDisconnect(UserConnection connection) {
|
public void onDisconnect(UserConnection connection) {
|
||||||
Objects.requireNonNull(connection, "connection is null!");
|
Objects.requireNonNull(connection, "connection is null!");
|
||||||
UUID id = connection.get(ProtocolInfo.class).getUuid();
|
UUID id = connection.getProtocolInfo().getUuid();
|
||||||
connections.remove(connection);
|
connections.remove(connection);
|
||||||
clients.remove(id);
|
clients.remove(id);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package us.myles.ViaVersion.api.protocol;
|
package us.myles.ViaVersion.api.protocol;
|
||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
|
import jdk.nashorn.internal.ir.CallNode;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import us.myles.ViaVersion.api.PacketWrapper;
|
import us.myles.ViaVersion.api.PacketWrapper;
|
||||||
import us.myles.ViaVersion.api.Via;
|
import us.myles.ViaVersion.api.Via;
|
||||||
@ -422,14 +423,14 @@ public abstract class Protocol<C1 extends ClientboundPacketType, C2 extends Clie
|
|||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
||||||
Class<? extends PacketType> packetTypeClass = direction == Direction.OUTGOING ? oldClientboundPacketEnum : newServerboundPacketEnum;
|
Class<? extends PacketType> packetTypeClass = state == State.PLAY ? (direction == Direction.OUTGOING ? oldClientboundPacketEnum : newServerboundPacketEnum) : null;
|
||||||
if (packetTypeClass != null) {
|
if (packetTypeClass != null) {
|
||||||
PacketType[] enumConstants = packetTypeClass.getEnumConstants();
|
PacketType[] enumConstants = packetTypeClass.getEnumConstants();
|
||||||
PacketType packetType = oldId < enumConstants.length && oldId >= 0 ? enumConstants[oldId] : null;
|
PacketType packetType = oldId < enumConstants.length && oldId >= 0 ? enumConstants[oldId] : null;
|
||||||
Via.getPlatform().getLogger().warning("ERROR IN " + getClass().getSimpleName() + " IN REMAP OF " + packetType + " (" + oldId + ")");
|
Via.getPlatform().getLogger().warning("ERROR IN " + getClass().getSimpleName() + " IN REMAP OF " + packetType + " (" + toNiceHex(oldId) + ")");
|
||||||
} else {
|
} else {
|
||||||
Via.getPlatform().getLogger().warning("ERROR IN " + getClass().getSimpleName()
|
Via.getPlatform().getLogger().warning("ERROR IN " + getClass().getSimpleName()
|
||||||
+ " IN REMAP OF 0x" + Integer.toHexString(oldId) + "->0x" + Integer.toHexString(newId));
|
+ " IN REMAP OF 0x" + toNiceHex(oldId) + "->0x" + toNiceHex(newId));
|
||||||
}
|
}
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
@ -439,6 +440,11 @@ public abstract class Protocol<C1 extends ClientboundPacketType, C2 extends Clie
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String toNiceHex(int id) {
|
||||||
|
String hex = Integer.toHexString(id).toUpperCase();
|
||||||
|
return (hex.length() == 1 ? "0x0" : "0x") + hex;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param packetType packet type
|
* @param packetType packet type
|
||||||
* @param isValid expression to check the packet's validity
|
* @param isValid expression to check the packet's validity
|
||||||
|
@ -37,7 +37,7 @@ public class ProtocolPipeline extends SimpleProtocol {
|
|||||||
ProtocolInfo protocolInfo = new ProtocolInfo(userConnection);
|
ProtocolInfo protocolInfo = new ProtocolInfo(userConnection);
|
||||||
protocolInfo.setPipeline(this);
|
protocolInfo.setPipeline(this);
|
||||||
|
|
||||||
userConnection.put(protocolInfo);
|
userConnection.setProtocolInfo(protocolInfo);
|
||||||
|
|
||||||
/* Init through all our pipes */
|
/* Init through all our pipes */
|
||||||
for (Protocol protocol : protocolList) {
|
for (Protocol protocol : protocolList) {
|
||||||
@ -83,11 +83,11 @@ public class ProtocolPipeline extends SimpleProtocol {
|
|||||||
|
|
||||||
if (Via.getManager().isDebug()) {
|
if (Via.getManager().isDebug()) {
|
||||||
// Debug packet
|
// Debug packet
|
||||||
int serverProtocol = userConnection.get(ProtocolInfo.class).getServerProtocolVersion();
|
int serverProtocol = userConnection.getProtocolInfo().getServerProtocolVersion();
|
||||||
int clientProtocol = userConnection.get(ProtocolInfo.class).getProtocolVersion();
|
int clientProtocol = userConnection.getProtocolInfo().getProtocolVersion();
|
||||||
ViaPlatform platform = Via.getPlatform();
|
ViaPlatform platform = Via.getPlatform();
|
||||||
|
|
||||||
String actualUsername = packetWrapper.user().get(ProtocolInfo.class).getUsername();
|
String actualUsername = packetWrapper.user().getProtocolInfo().getUsername();
|
||||||
String username = actualUsername != null ? actualUsername + " " : "";
|
String username = actualUsername != null ? actualUsername + " " : "";
|
||||||
|
|
||||||
platform.getLogger().log(Level.INFO, "{0}{1} {2}: {3} (0x{4}) -> {5} (0x{6}) [{7}] {8}",
|
platform.getLogger().log(Level.INFO, "{0}{1} {2}: {3} (0x{4}) -> {5} (0x{6}) [{7}] {8}",
|
||||||
|
@ -38,7 +38,7 @@ public class BaseProtocol extends SimpleProtocol {
|
|||||||
int protVer = wrapper.get(Type.VAR_INT, 0);
|
int protVer = wrapper.get(Type.VAR_INT, 0);
|
||||||
int state = wrapper.get(Type.VAR_INT, 1);
|
int state = wrapper.get(Type.VAR_INT, 1);
|
||||||
|
|
||||||
ProtocolInfo info = wrapper.user().get(ProtocolInfo.class);
|
ProtocolInfo info = wrapper.user().getProtocolInfo();
|
||||||
info.setProtocolVersion(protVer);
|
info.setProtocolVersion(protVer);
|
||||||
// Ensure the server has a version provider
|
// Ensure the server has a version provider
|
||||||
if (Via.getManager().getProviders().get(VersionProvider.class) == null) {
|
if (Via.getManager().getProviders().get(VersionProvider.class) == null) {
|
||||||
@ -55,7 +55,7 @@ public class BaseProtocol extends SimpleProtocol {
|
|||||||
protocols = ProtocolRegistry.getProtocolPath(info.getProtocolVersion(), protocol);
|
protocols = ProtocolRegistry.getProtocolPath(info.getProtocolVersion(), protocol);
|
||||||
}
|
}
|
||||||
|
|
||||||
ProtocolPipeline pipeline = wrapper.user().get(ProtocolInfo.class).getPipeline();
|
ProtocolPipeline pipeline = wrapper.user().getProtocolInfo().getPipeline();
|
||||||
if (protocols != null) {
|
if (protocols != null) {
|
||||||
for (Pair<Integer, Protocol> prot : protocols) {
|
for (Pair<Integer, Protocol> prot : protocols) {
|
||||||
pipeline.add(prot.getValue());
|
pipeline.add(prot.getValue());
|
||||||
|
@ -38,7 +38,7 @@ public class BaseProtocol1_7 extends SimpleProtocol {
|
|||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
ProtocolInfo info = wrapper.user().get(ProtocolInfo.class);
|
ProtocolInfo info = wrapper.user().getProtocolInfo();
|
||||||
String originalStatus = wrapper.get(Type.STRING, 0);
|
String originalStatus = wrapper.get(Type.STRING, 0);
|
||||||
try {
|
try {
|
||||||
JsonElement json = GsonUtil.getGson().fromJson(originalStatus, JsonElement.class);
|
JsonElement json = GsonUtil.getGson().fromJson(originalStatus, JsonElement.class);
|
||||||
@ -113,7 +113,7 @@ public class BaseProtocol1_7 extends SimpleProtocol {
|
|||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
ProtocolInfo info = wrapper.user().get(ProtocolInfo.class);
|
ProtocolInfo info = wrapper.user().getProtocolInfo();
|
||||||
info.setState(State.PLAY);
|
info.setState(State.PLAY);
|
||||||
|
|
||||||
if (info.getServerProtocolVersion() >= ProtocolVersion.v1_16.getId()) {
|
if (info.getServerProtocolVersion() >= ProtocolVersion.v1_16.getId()) {
|
||||||
@ -170,7 +170,7 @@ public class BaseProtocol1_7 extends SimpleProtocol {
|
|||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void handle(final PacketWrapper wrapper) throws Exception {
|
public void handle(final PacketWrapper wrapper) throws Exception {
|
||||||
int protocol = wrapper.user().get(ProtocolInfo.class).getProtocolVersion();
|
int protocol = wrapper.user().getProtocolInfo().getProtocolVersion();
|
||||||
if (Via.getConfig().getBlockedProtocols().contains(protocol)) {
|
if (Via.getConfig().getBlockedProtocols().contains(protocol)) {
|
||||||
if (!wrapper.user().getChannel().isOpen()) return;
|
if (!wrapper.user().getChannel().isOpen()) return;
|
||||||
|
|
||||||
|
@ -2,14 +2,14 @@ package us.myles.ViaVersion.protocols.protocol1_13to1_12_2;
|
|||||||
|
|
||||||
import us.myles.ViaVersion.api.Via;
|
import us.myles.ViaVersion.api.Via;
|
||||||
import us.myles.ViaVersion.api.data.UserConnection;
|
import us.myles.ViaVersion.api.data.UserConnection;
|
||||||
import us.myles.ViaVersion.protocols.base.ProtocolInfo;
|
|
||||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.storage.TabCompleteTracker;
|
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.storage.TabCompleteTracker;
|
||||||
|
|
||||||
public class TabCompleteThread implements Runnable {
|
public class TabCompleteThread implements Runnable {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
for (UserConnection info : Via.getManager().getConnections()) {
|
for (UserConnection info : Via.getManager().getConnections()) {
|
||||||
if (info.has(ProtocolInfo.class) && info.get(ProtocolInfo.class).getPipeline().contains(Protocol1_13To1_12_2.class)) {
|
if (info.getProtocolInfo() == null) continue;
|
||||||
|
if (info.getProtocolInfo().getPipeline().contains(Protocol1_13To1_12_2.class)) {
|
||||||
if (info.getChannel().isOpen()) {
|
if (info.getChannel().isOpen()) {
|
||||||
info.get(TabCompleteTracker.class).sendPacketToServer();
|
info.get(TabCompleteTracker.class).sendPacketToServer();
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ public abstract class AbstractFenceConnectionHandler extends ConnectionHandler {
|
|||||||
|
|
||||||
protected byte getStates(UserConnection user, Position position, int blockState) {
|
protected byte getStates(UserConnection user, Position position, int blockState) {
|
||||||
byte states = 0;
|
byte states = 0;
|
||||||
boolean pre1_12 = user.get(ProtocolInfo.class).getServerProtocolVersion() < ProtocolVersion.v1_12.getId();
|
boolean pre1_12 = user.getProtocolInfo().getServerProtocolVersion() < ProtocolVersion.v1_12.getId();
|
||||||
if (connects(BlockFace.EAST, getBlockData(user, position.getRelative(BlockFace.EAST)), pre1_12)) states |= 1;
|
if (connects(BlockFace.EAST, getBlockData(user, position.getRelative(BlockFace.EAST)), pre1_12)) states |= 1;
|
||||||
if (connects(BlockFace.NORTH, getBlockData(user, position.getRelative(BlockFace.NORTH)), pre1_12)) states |= 2;
|
if (connects(BlockFace.NORTH, getBlockData(user, position.getRelative(BlockFace.NORTH)), pre1_12)) states |= 2;
|
||||||
if (connects(BlockFace.SOUTH, getBlockData(user, position.getRelative(BlockFace.SOUTH)), pre1_12)) states |= 4;
|
if (connects(BlockFace.SOUTH, getBlockData(user, position.getRelative(BlockFace.SOUTH)), pre1_12)) states |= 4;
|
||||||
|
@ -41,7 +41,7 @@ public class GlassConnectionHandler extends AbstractFenceConnectionHandler {
|
|||||||
byte states = super.getStates(user, position, blockState);
|
byte states = super.getStates(user, position, blockState);
|
||||||
if (states != 0) return states;
|
if (states != 0) return states;
|
||||||
|
|
||||||
ProtocolInfo protocolInfo = user.get(ProtocolInfo.class);
|
ProtocolInfo protocolInfo = user.getProtocolInfo();
|
||||||
return protocolInfo.getServerProtocolVersion() <= 47
|
return protocolInfo.getServerProtocolVersion() <= 47
|
||||||
&& protocolInfo.getServerProtocolVersion() != -1 ? 0xF : states;
|
&& protocolInfo.getServerProtocolVersion() != -1 ? 0xF : states;
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,6 @@ import us.myles.ViaVersion.api.type.PartialType;
|
|||||||
import us.myles.ViaVersion.api.type.Type;
|
import us.myles.ViaVersion.api.type.Type;
|
||||||
import us.myles.ViaVersion.api.type.types.minecraft.BaseChunkType;
|
import us.myles.ViaVersion.api.type.types.minecraft.BaseChunkType;
|
||||||
import us.myles.ViaVersion.api.type.types.version.Types1_9;
|
import us.myles.ViaVersion.api.type.types.version.Types1_9;
|
||||||
import us.myles.ViaVersion.protocols.base.ProtocolInfo;
|
|
||||||
import us.myles.ViaVersion.protocols.protocol1_10to1_9_3.Protocol1_10To1_9_3_4;
|
import us.myles.ViaVersion.protocols.protocol1_10to1_9_3.Protocol1_10To1_9_3_4;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||||
|
|
||||||
@ -26,7 +25,7 @@ public class Chunk1_9_1_2Type extends PartialType<Chunk, ClientWorld> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Chunk read(ByteBuf input, ClientWorld world) throws Exception {
|
public Chunk read(ByteBuf input, ClientWorld world) throws Exception {
|
||||||
boolean replacePistons = world.getUser().get(ProtocolInfo.class).getPipeline().contains(Protocol1_10To1_9_3_4.class) && Via.getConfig().isReplacePistons();
|
boolean replacePistons = world.getUser().getProtocolInfo().getPipeline().contains(Protocol1_10To1_9_3_4.class) && Via.getConfig().isReplacePistons();
|
||||||
int replacementId = Via.getConfig().getPistonReplacementId();
|
int replacementId = Via.getConfig().getPistonReplacementId();
|
||||||
|
|
||||||
int chunkX = input.readInt();
|
int chunkX = input.readInt();
|
||||||
|
@ -10,7 +10,7 @@ public class ViaIdleThread implements Runnable {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
for (UserConnection info : Via.getManager().getConnections()) {
|
for (UserConnection info : Via.getManager().getConnections()) {
|
||||||
ProtocolInfo protocolInfo = info.get(ProtocolInfo.class);
|
ProtocolInfo protocolInfo = info.getProtocolInfo();
|
||||||
if (protocolInfo != null && protocolInfo.getPipeline().contains(Protocol1_9To1_8.class)) {
|
if (protocolInfo != null && protocolInfo.getPipeline().contains(Protocol1_9To1_8.class)) {
|
||||||
long nextIdleUpdate = info.get(MovementTracker.class).getNextIdlePacket();
|
long nextIdleUpdate = info.get(MovementTracker.class).getNextIdlePacket();
|
||||||
if (nextIdleUpdate <= System.currentTimeMillis()) {
|
if (nextIdleUpdate <= System.currentTimeMillis()) {
|
||||||
|
@ -126,7 +126,7 @@ public class PlayerPackets {
|
|||||||
if (mode == 0 || mode == 3 || mode == 4) {
|
if (mode == 0 || mode == 3 || mode == 4) {
|
||||||
String[] players = wrapper.passthrough(Type.STRING_ARRAY); // Players
|
String[] players = wrapper.passthrough(Type.STRING_ARRAY); // Players
|
||||||
final EntityTracker1_9 entityTracker = wrapper.user().get(EntityTracker1_9.class);
|
final EntityTracker1_9 entityTracker = wrapper.user().get(EntityTracker1_9.class);
|
||||||
String myName = wrapper.user().get(ProtocolInfo.class).getUsername();
|
String myName = wrapper.user().getProtocolInfo().getUsername();
|
||||||
String teamName = wrapper.get(Type.STRING, 0);
|
String teamName = wrapper.get(Type.STRING, 0);
|
||||||
for (String player : players) {
|
for (String player : players) {
|
||||||
if (entityTracker.isAutoTeam() && player.equalsIgnoreCase(myName)) {
|
if (entityTracker.isAutoTeam() && player.equalsIgnoreCase(myName)) {
|
||||||
|
@ -191,7 +191,7 @@ public class EntityTracker1_9 extends EntityTracker {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
UUID uuid = getUser().get(ProtocolInfo.class).getUuid();
|
UUID uuid = getUser().getProtocolInfo().getUuid();
|
||||||
// Boss bar
|
// Boss bar
|
||||||
if (Via.getConfig().isBossbarPatch()) {
|
if (Via.getConfig().isBossbarPatch()) {
|
||||||
if (type == EntityType.ENDER_DRAGON || type == EntityType.WITHER) {
|
if (type == EntityType.ENDER_DRAGON || type == EntityType.WITHER) {
|
||||||
@ -256,7 +256,7 @@ public class EntityTracker1_9 extends EntityTracker {
|
|||||||
} else {
|
} else {
|
||||||
wrapper.write(Type.BYTE, (byte) 3);
|
wrapper.write(Type.BYTE, (byte) 3);
|
||||||
}
|
}
|
||||||
wrapper.write(Type.STRING_ARRAY, new String[]{getUser().get(ProtocolInfo.class).getUsername()});
|
wrapper.write(Type.STRING_ARRAY, new String[]{getUser().getProtocolInfo().getUsername()});
|
||||||
} else {
|
} else {
|
||||||
wrapper.write(Type.BYTE, (byte) 1); // remove team
|
wrapper.write(Type.BYTE, (byte) 1); // remove team
|
||||||
}
|
}
|
||||||
@ -283,7 +283,7 @@ public class EntityTracker1_9 extends EntityTracker {
|
|||||||
PacketWrapper wrapper = new PacketWrapper(0x39, null, getUser());
|
PacketWrapper wrapper = new PacketWrapper(0x39, null, getUser());
|
||||||
wrapper.write(Type.VAR_INT, entityId);
|
wrapper.write(Type.VAR_INT, entityId);
|
||||||
wrapper.write(Types1_9.METADATA_LIST, metadataList);
|
wrapper.write(Types1_9.METADATA_LIST, metadataList);
|
||||||
getUser().get(ProtocolInfo.class).getPipeline().getProtocol(Protocol1_9To1_8.class).get(MetadataRewriter1_9To1_8.class)
|
getUser().getProtocolInfo().getPipeline().getProtocol(Protocol1_9To1_8.class).get(MetadataRewriter1_9To1_8.class)
|
||||||
.handleMetadata(entityId, metadataList, getUser());
|
.handleMetadata(entityId, metadataList, getUser());
|
||||||
handleMetadata(entityId, metadataList);
|
handleMetadata(entityId, metadataList);
|
||||||
if (!metadataList.isEmpty()) {
|
if (!metadataList.isEmpty()) {
|
||||||
|
@ -48,7 +48,7 @@ public class Chunk1_9to1_8Type extends PartialType<Chunk, ClientChunks> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Chunk read(ByteBuf input, ClientChunks param) throws Exception {
|
public Chunk read(ByteBuf input, ClientChunks param) throws Exception {
|
||||||
boolean replacePistons = param.getUser().get(ProtocolInfo.class).getPipeline().contains(Protocol1_10To1_9_3_4.class) && Via.getConfig().isReplacePistons();
|
boolean replacePistons = param.getUser().getProtocolInfo().getPipeline().contains(Protocol1_10To1_9_3_4.class) && Via.getConfig().isReplacePistons();
|
||||||
int replacementId = Via.getConfig().getPistonReplacementId();
|
int replacementId = Via.getConfig().getPistonReplacementId();
|
||||||
|
|
||||||
int chunkX = input.readInt();
|
int chunkX = input.readInt();
|
||||||
|
@ -24,7 +24,7 @@ public class SpongePacketHandler extends MessageToMessageEncoder {
|
|||||||
info.setLastPacket(o);
|
info.setLastPacket(o);
|
||||||
/* This transformer is more for fixing issues which we find hard at packet level :) */
|
/* This transformer is more for fixing issues which we find hard at packet level :) */
|
||||||
if (info.isActive()) {
|
if (info.isActive()) {
|
||||||
if (info.get(ProtocolInfo.class).getPipeline().filter(o, list)) {
|
if (info.getProtocolInfo().getPipeline().filter(o, list)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ public class SpongeViaAPI implements ViaAPI<Player> {
|
|||||||
public int getPlayerVersion(UUID uuid) {
|
public int getPlayerVersion(UUID uuid) {
|
||||||
if (!isInjected(uuid))
|
if (!isInjected(uuid))
|
||||||
return ProtocolRegistry.SERVER_PROTOCOL;
|
return ProtocolRegistry.SERVER_PROTOCOL;
|
||||||
return Via.getManager().getConnection(uuid).get(ProtocolInfo.class).getProtocolVersion();
|
return Via.getManager().getConnection(uuid).getProtocolInfo().getProtocolVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -76,7 +76,7 @@ public class SpongeViaLoader implements ViaPlatformLoader {
|
|||||||
@Override
|
@Override
|
||||||
public Item getHandItem(final UserConnection info) {
|
public Item getHandItem(final UserConnection info) {
|
||||||
if (HandItemCache.CACHE) {
|
if (HandItemCache.CACHE) {
|
||||||
return HandItemCache.getHandItem(info.get(ProtocolInfo.class).getUuid());
|
return HandItemCache.getHandItem(info.getProtocolInfo().getUuid());
|
||||||
} else {
|
} else {
|
||||||
return super.getHandItem(info);
|
return super.getHandItem(info);
|
||||||
}
|
}
|
||||||
|
@ -26,8 +26,6 @@ import java.util.Collection;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.concurrent.Semaphore;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
public class VelocityServerHandler {
|
public class VelocityServerHandler {
|
||||||
private static Method setProtocolVersion;
|
private static Method setProtocolVersion;
|
||||||
@ -62,12 +60,12 @@ public class VelocityServerHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int protocolId = ProtocolDetectorService.getProtocolId(e.getOriginalServer().getServerInfo().getName());
|
int protocolId = ProtocolDetectorService.getProtocolId(e.getOriginalServer().getServerInfo().getName());
|
||||||
List<Pair<Integer, Protocol>> protocols = ProtocolRegistry.getProtocolPath(user.get(ProtocolInfo.class).getProtocolVersion(), protocolId);
|
List<Pair<Integer, Protocol>> protocols = ProtocolRegistry.getProtocolPath(user.getProtocolInfo().getProtocolVersion(), protocolId);
|
||||||
|
|
||||||
// Check if ViaVersion can support that version
|
// Check if ViaVersion can support that version
|
||||||
Object connection = getMinecraftConnection.invoke(e.getPlayer());
|
Object connection = getMinecraftConnection.invoke(e.getPlayer());
|
||||||
setNextProtocolVersion.invoke(connection, ProtocolVersion.getProtocolVersion(protocols == null
|
setNextProtocolVersion.invoke(connection, ProtocolVersion.getProtocolVersion(protocols == null
|
||||||
? user.get(ProtocolInfo.class).getProtocolVersion()
|
? user.getProtocolInfo().getProtocolVersion()
|
||||||
: protocolId));
|
: protocolId));
|
||||||
|
|
||||||
} catch (IllegalAccessException | InvocationTargetException e1) {
|
} catch (IllegalAccessException | InvocationTargetException e1) {
|
||||||
@ -105,7 +103,7 @@ public class VelocityServerHandler {
|
|||||||
if (storage.getBossbar() != null) {
|
if (storage.getBossbar() != null) {
|
||||||
// TODO: Verify whether this packet needs to be sent when 1.8 -> 1.9 protocol isn't present in the pipeline
|
// TODO: Verify whether this packet needs to be sent when 1.8 -> 1.9 protocol isn't present in the pipeline
|
||||||
// This ensures we can encode it properly as only the 1.9 protocol is currently implemented.
|
// This ensures we can encode it properly as only the 1.9 protocol is currently implemented.
|
||||||
if (user.get(ProtocolInfo.class).getPipeline().contains(Protocol1_9To1_8.class)) {
|
if (user.getProtocolInfo().getPipeline().contains(Protocol1_9To1_8.class)) {
|
||||||
for (UUID uuid : storage.getBossbar()) {
|
for (UUID uuid : storage.getBossbar()) {
|
||||||
PacketWrapper wrapper = new PacketWrapper(0x0C, null, user);
|
PacketWrapper wrapper = new PacketWrapper(0x0C, null, user);
|
||||||
wrapper.write(Type.UUID, uuid);
|
wrapper.write(Type.UUID, uuid);
|
||||||
@ -117,12 +115,12 @@ public class VelocityServerHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ProtocolInfo info = user.get(ProtocolInfo.class);
|
ProtocolInfo info = user.getProtocolInfo();
|
||||||
int previousServerProtocol = info.getServerProtocolVersion();
|
int previousServerProtocol = info.getServerProtocolVersion();
|
||||||
|
|
||||||
// Refresh the pipes
|
// Refresh the pipes
|
||||||
List<Pair<Integer, Protocol>> protocols = ProtocolRegistry.getProtocolPath(info.getProtocolVersion(), protocolId);
|
List<Pair<Integer, Protocol>> protocols = ProtocolRegistry.getProtocolPath(info.getProtocolVersion(), protocolId);
|
||||||
ProtocolPipeline pipeline = user.get(ProtocolInfo.class).getPipeline();
|
ProtocolPipeline pipeline = info.getPipeline();
|
||||||
user.clearStoredObjects();
|
user.clearStoredObjects();
|
||||||
pipeline.cleanPipes();
|
pipeline.cleanPipes();
|
||||||
if (protocols == null) {
|
if (protocols == null) {
|
||||||
|
@ -27,7 +27,7 @@ public class ElytraPatch {
|
|||||||
if (user == null) return;
|
if (user == null) return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (user.get(ProtocolInfo.class).getPipeline().contains(Protocol1_9To1_8.class)) {
|
if (user.getProtocolInfo().getPipeline().contains(Protocol1_9To1_8.class)) {
|
||||||
int entityId = user.get(EntityTracker1_9.class).getProvidedEntityId();
|
int entityId = user.get(EntityTracker1_9.class).getProvidedEntityId();
|
||||||
|
|
||||||
PacketWrapper wrapper = new PacketWrapper(0x39, null, user);
|
PacketWrapper wrapper = new PacketWrapper(0x39, null, user);
|
||||||
|
@ -22,7 +22,7 @@ public class VelocityViaAPI implements ViaAPI<Player> {
|
|||||||
public int getPlayerVersion(Player player) {
|
public int getPlayerVersion(Player player) {
|
||||||
if (!isInjected(player.getUniqueId()))
|
if (!isInjected(player.getUniqueId()))
|
||||||
return player.getProtocolVersion().getProtocol();
|
return player.getProtocolVersion().getProtocol();
|
||||||
return Via.getManager().getConnection(player.getUniqueId()).get(ProtocolInfo.class).getProtocolVersion();
|
return Via.getManager().getConnection(player.getUniqueId()).getProtocolInfo().getProtocolVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -4,7 +4,6 @@ import us.myles.ViaVersion.api.PacketWrapper;
|
|||||||
import us.myles.ViaVersion.api.data.UserConnection;
|
import us.myles.ViaVersion.api.data.UserConnection;
|
||||||
import us.myles.ViaVersion.api.type.Type;
|
import us.myles.ViaVersion.api.type.Type;
|
||||||
import us.myles.ViaVersion.packets.State;
|
import us.myles.ViaVersion.packets.State;
|
||||||
import us.myles.ViaVersion.protocols.base.ProtocolInfo;
|
|
||||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9To1_8;
|
import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9To1_8;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.providers.MovementTransmitterProvider;
|
import us.myles.ViaVersion.protocols.protocol1_9to1_8.providers.MovementTransmitterProvider;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.storage.MovementTracker;
|
import us.myles.ViaVersion.protocols.protocol1_9to1_8.storage.MovementTracker;
|
||||||
@ -21,7 +20,7 @@ public class VelocityMovementTransmitter extends MovementTransmitterProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void sendPlayer(UserConnection userConnection) {
|
public void sendPlayer(UserConnection userConnection) {
|
||||||
if (userConnection.get(ProtocolInfo.class).getState() == State.PLAY) {
|
if (userConnection.getProtocolInfo().getState() == State.PLAY) {
|
||||||
PacketWrapper wrapper = new PacketWrapper(0x03, null, userConnection);
|
PacketWrapper wrapper = new PacketWrapper(0x03, null, userConnection);
|
||||||
wrapper.write(Type.BOOLEAN, userConnection.get(MovementTracker.class).isGround());
|
wrapper.write(Type.BOOLEAN, userConnection.get(MovementTracker.class).isGround());
|
||||||
try {
|
try {
|
||||||
|
@ -4,7 +4,6 @@ import us.myles.ViaVersion.VelocityPlugin;
|
|||||||
import us.myles.ViaVersion.api.Via;
|
import us.myles.ViaVersion.api.Via;
|
||||||
import us.myles.ViaVersion.api.data.UserConnection;
|
import us.myles.ViaVersion.api.data.UserConnection;
|
||||||
import us.myles.ViaVersion.api.protocol.ProtocolVersion;
|
import us.myles.ViaVersion.api.protocol.ProtocolVersion;
|
||||||
import us.myles.ViaVersion.protocols.base.ProtocolInfo;
|
|
||||||
import us.myles.ViaVersion.protocols.base.VersionProvider;
|
import us.myles.ViaVersion.protocols.base.VersionProvider;
|
||||||
import us.myles.ViaVersion.velocity.platform.VelocityViaInjector;
|
import us.myles.ViaVersion.velocity.platform.VelocityViaInjector;
|
||||||
|
|
||||||
@ -15,7 +14,7 @@ public class VelocityVersionProvider extends VersionProvider {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getServerProtocol(UserConnection user) throws Exception {
|
public int getServerProtocol(UserConnection user) throws Exception {
|
||||||
int playerVersion = user.get(ProtocolInfo.class).getProtocolVersion();
|
int playerVersion = user.getProtocolInfo().getProtocolVersion();
|
||||||
|
|
||||||
IntStream versions = com.velocitypowered.api.network.ProtocolVersion.SUPPORTED_VERSIONS.stream()
|
IntStream versions = com.velocitypowered.api.network.ProtocolVersion.SUPPORTED_VERSIONS.stream()
|
||||||
.mapToInt(com.velocitypowered.api.network.ProtocolVersion::getProtocol);
|
.mapToInt(com.velocitypowered.api.network.ProtocolVersion::getProtocol);
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren