3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-12-24 23:30:15 +01:00

Merge branch 'master' into abstraction

Dieser Commit ist enthalten in:
Myles 2019-05-27 17:29:04 +01:00
Commit 3027490256
19 geänderte Dateien mit 109 neuen und 62 gelöschten Zeilen

Datei anzeigen

@ -1,4 +1,4 @@
# ViaVersion 2.0.1 - Spigot, Sponge, BungeeCord, Velocity # ViaVersion 2.1.1 - Spigot, Sponge, BungeeCord, Velocity
[![Build Status](https://travis-ci.com/ViaVersion/ViaVersion.svg?branch=master)](https://travis-ci.com/ViaVersion/ViaVersion) [![Build Status](https://travis-ci.com/ViaVersion/ViaVersion.svg?branch=master)](https://travis-ci.com/ViaVersion/ViaVersion)
[![Discord](https://img.shields.io/badge/chat-on%20discord-blue.svg)](https://viaversion.com/discord) [![Discord](https://img.shields.io/badge/chat-on%20discord-blue.svg)](https://viaversion.com/discord)

Datei anzeigen

@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>viaversion-parent</artifactId> <artifactId>viaversion-parent</artifactId>
<groupId>us.myles</groupId> <groupId>us.myles</groupId>
<version>2.1.0</version> <version>2.1.2-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

Datei anzeigen

@ -1,7 +1,9 @@
package us.myles.ViaVersion.bukkit.listeners.multiversion; package us.myles.ViaVersion.bukkit.listeners.multiversion;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerToggleSneakEvent; import org.bukkit.event.player.PlayerToggleSneakEvent;
import us.myles.ViaVersion.ViaVersionPlugin; import us.myles.ViaVersion.ViaVersionPlugin;
@ -9,13 +11,11 @@ import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.protocol.ProtocolRegistry; import us.myles.ViaVersion.api.protocol.ProtocolRegistry;
import us.myles.ViaVersion.api.protocol.ProtocolVersion; import us.myles.ViaVersion.api.protocol.ProtocolVersion;
import us.myles.ViaVersion.bukkit.listeners.ViaBukkitListener; import us.myles.ViaVersion.bukkit.listeners.ViaBukkitListener;
import us.myles.ViaVersion.bukkit.platform.BukkitViaLoader;
import us.myles.ViaVersion.protocols.base.ProtocolInfo; import us.myles.ViaVersion.protocols.base.ProtocolInfo;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.HashMap; import java.util.*;
import java.util.Map;
public class PlayerSneakListener extends ViaBukkitListener { public class PlayerSneakListener extends ViaBukkitListener {
private static final float STANDING_HEIGHT = 1.8F; private static final float STANDING_HEIGHT = 1.8F;
@ -24,13 +24,14 @@ public class PlayerSneakListener extends ViaBukkitListener {
private static final float DEFAULT_WIDTH = 0.6F; private static final float DEFAULT_WIDTH = 0.6F;
private Map<Player, Boolean> sneaking; // true = 1.14+, else false private Map<Player, Boolean> sneaking; // true = 1.14+, else false
private Set<UUID> sneakingUuids;
private Method getHandle; private Method getHandle;
private Method setSize; private Method setSize;
private boolean is1_9Fix; private boolean is1_9Fix;
private boolean is1_14Fix; private boolean is1_14Fix;
private boolean useCache; private boolean useCache;
public PlayerSneakListener(ViaVersionPlugin plugin, BukkitViaLoader viaLoader, boolean is1_9Fix, boolean is1_14Fix) { public PlayerSneakListener(ViaVersionPlugin plugin, boolean is1_9Fix, boolean is1_14Fix) {
super(plugin, null); super(plugin, null);
this.is1_9Fix = is1_9Fix; this.is1_9Fix = is1_9Fix;
this.is1_14Fix = is1_14Fix; this.is1_14Fix = is1_14Fix;
@ -41,16 +42,11 @@ public class PlayerSneakListener extends ViaBukkitListener {
} catch (ClassNotFoundException | NoSuchMethodException e) { } catch (ClassNotFoundException | NoSuchMethodException e) {
e.printStackTrace(); e.printStackTrace();
} }
// From 1.9 upwards the server hitbox is set in every entity tick, so we have to reset it everytime // From 1.9 upwards the server hitbox is set in every entity tick, so we have to reset it everytime
if (ProtocolRegistry.SERVER_PROTOCOL >= ProtocolVersion.v1_9.getId()) { if (ProtocolRegistry.SERVER_PROTOCOL >= ProtocolVersion.v1_9.getId()) {
sneaking = new HashMap<>(); sneaking = new WeakHashMap<>();
useCache = true; useCache = true;
viaLoader.storeListener(new ViaBukkitListener(plugin, null) {
@EventHandler
public void playerQuit(PlayerQuitEvent event) {
sneaking.remove(event.getPlayer());
}
}).register();
plugin.getServer().getScheduler().runTaskTimer(plugin, new Runnable() { plugin.getServer().getScheduler().runTaskTimer(plugin, new Runnable() {
@Override @Override
public void run() { public void run() {
@ -60,6 +56,11 @@ public class PlayerSneakListener extends ViaBukkitListener {
} }
}, 1, 1); }, 1, 1);
} }
// Suffocation removal only required for 1.14+ clients.
if (is1_14Fix) {
sneakingUuids = new HashSet<>();
}
} }
@EventHandler(ignoreCancelled = true) @EventHandler(ignoreCancelled = true)
@ -73,6 +74,11 @@ public class PlayerSneakListener extends ViaBukkitListener {
int protocolVersion = info.getProtocolVersion(); int protocolVersion = info.getProtocolVersion();
if (is1_14Fix && protocolVersion >= ProtocolVersion.v1_14.getId()) { if (is1_14Fix && protocolVersion >= ProtocolVersion.v1_14.getId()) {
setHeight(player, event.isSneaking() ? HEIGHT_1_14 : STANDING_HEIGHT); setHeight(player, event.isSneaking() ? HEIGHT_1_14 : STANDING_HEIGHT);
if (event.isSneaking())
sneakingUuids.add(player.getUniqueId());
else
sneakingUuids.remove(player.getUniqueId());
if (!useCache) return; if (!useCache) return;
if (event.isSneaking()) if (event.isSneaking())
sneaking.put(player, true); sneaking.put(player, true);
@ -88,6 +94,32 @@ public class PlayerSneakListener extends ViaBukkitListener {
} }
} }
@EventHandler(ignoreCancelled = true)
public void playerDamage(EntityDamageEvent event) {
if (!is1_14Fix) return;
if (event.getCause() != EntityDamageEvent.DamageCause.SUFFOCATION) return;
if (event.getEntityType() != EntityType.PLAYER) return;
Player player = (Player) event.getEntity();
if (!sneakingUuids.contains(player.getUniqueId())) return;
// Don't cancel when they should actually be suffocating; Essentially cancel when the head is in the top block only ever so slightly
// ~0.041 should suffice, but gotta stay be safe
double y = player.getEyeLocation().getY() + 0.045;
y -= (int) y;
if (y < 0.09) {
event.setCancelled(true);
}
}
@EventHandler
public void playerQuit(PlayerQuitEvent event) {
if (sneaking != null)
sneaking.remove(event.getPlayer());
if (sneakingUuids != null)
sneakingUuids.remove(event.getPlayer().getUniqueId());
}
private void setHeight(Player player, float height) { private void setHeight(Player player, float height) {
try { try {
setSize.invoke(getHandle.invoke(player), DEFAULT_WIDTH, height); setSize.invoke(getHandle.invoke(player), DEFAULT_WIDTH, height);
@ -95,4 +127,4 @@ public class PlayerSneakListener extends ViaBukkitListener {
e.printStackTrace(); e.printStackTrace();
} }
} }
} }

Datei anzeigen

@ -82,7 +82,7 @@ public class BukkitViaLoader implements ViaPlatformLoader {
if (ProtocolRegistry.SERVER_PROTOCOL < ProtocolVersion.v1_14.getId()) { if (ProtocolRegistry.SERVER_PROTOCOL < ProtocolVersion.v1_14.getId()) {
boolean use1_9Fix = plugin.getConf().is1_9HitboxFix() && ProtocolRegistry.SERVER_PROTOCOL < ProtocolVersion.v1_9.getId(); boolean use1_9Fix = plugin.getConf().is1_9HitboxFix() && ProtocolRegistry.SERVER_PROTOCOL < ProtocolVersion.v1_9.getId();
if (use1_9Fix || plugin.getConf().is1_14HitboxFix()) { if (use1_9Fix || plugin.getConf().is1_14HitboxFix()) {
storeListener(new PlayerSneakListener(plugin, this, use1_9Fix, plugin.getConf().is1_14HitboxFix())).register(); storeListener(new PlayerSneakListener(plugin, use1_9Fix, plugin.getConf().is1_14HitboxFix())).register();
} }
} }

Datei anzeigen

@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>viaversion-parent</artifactId> <artifactId>viaversion-parent</artifactId>
<groupId>us.myles</groupId> <groupId>us.myles</groupId>
<version>2.1.0</version> <version>2.1.2-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

Datei anzeigen

@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>viaversion-parent</artifactId> <artifactId>viaversion-parent</artifactId>
<groupId>us.myles</groupId> <groupId>us.myles</groupId>
<version>2.1.0</version> <version>2.1.2-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

Datei anzeigen

@ -77,7 +77,6 @@ public class Entity1_13Types {
ABSTRACT_PARROT(-1, ABSTRACT_TAMEABLE_ANIMAL), // agr ABSTRACT_PARROT(-1, ABSTRACT_TAMEABLE_ANIMAL), // agr
PARROT(50, ABSTRACT_PARROT), // agk PARROT(50, ABSTRACT_PARROT), // agk
// Horses // Horses
ABSTRACT_HORSE(-1, ABSTRACT_ANIMAL), // aha ABSTRACT_HORSE(-1, ABSTRACT_ANIMAL), // aha
CHESTED_HORSE(-1, ABSTRACT_HORSE), // agz CHESTED_HORSE(-1, ABSTRACT_HORSE), // agz
@ -152,6 +151,7 @@ public class Entity1_13Types {
ABSTRACT_WATERMOB(-1, ABSTRACT_INSENTIENT), // agx ABSTRACT_WATERMOB(-1, ABSTRACT_INSENTIENT), // agx
SQUID(70, ABSTRACT_WATERMOB), // agt SQUID(70, ABSTRACT_WATERMOB), // agt
DOLPHIN(12, ABSTRACT_WATERMOB),
// Slimes // Slimes
SLIME(64, ABSTRACT_INSENTIENT), // aka SLIME(64, ABSTRACT_INSENTIENT), // aka

Datei anzeigen

@ -61,6 +61,7 @@ public class Entity1_14Types {
CHICKEN(8, ABSTRACT_ANIMAL), CHICKEN(8, ABSTRACT_ANIMAL),
COW(10, ABSTRACT_ANIMAL), COW(10, ABSTRACT_ANIMAL),
MOOSHROOM(49, COW), MOOSHROOM(49, COW),
PANDA(52, ABSTRACT_INSENTIENT),
PIG(54, ABSTRACT_ANIMAL), PIG(54, ABSTRACT_ANIMAL),
POLAR_BEAR(57, ABSTRACT_ANIMAL), POLAR_BEAR(57, ABSTRACT_ANIMAL),
RABBIT(59, ABSTRACT_ANIMAL), RABBIT(59, ABSTRACT_ANIMAL),

Datei anzeigen

@ -16,6 +16,7 @@ import us.myles.ViaVersion.protocols.protocol1_12to1_11_1.Protocol1_12To1_11_1;
import us.myles.ViaVersion.protocols.protocol1_13_2to1_13_1.Protocol1_13_2To1_13_1; import us.myles.ViaVersion.protocols.protocol1_13_2to1_13_1.Protocol1_13_2To1_13_1;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.Protocol1_13To1_12_2; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.Protocol1_13To1_12_2;
import us.myles.ViaVersion.protocols.protocol1_14_1to1_14.Protocol1_14_1To1_14; import us.myles.ViaVersion.protocols.protocol1_14_1to1_14.Protocol1_14_1To1_14;
import us.myles.ViaVersion.protocols.protocol1_14_2to1_14_1.Protocol1_14_2To1_14_1;
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.Protocol1_14To1_13_2; import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.Protocol1_14To1_13_2;
import us.myles.ViaVersion.protocols.protocol1_9_1_2to1_9_3_4.Protocol1_9_1_2To1_9_3_4; import us.myles.ViaVersion.protocols.protocol1_9_1_2to1_9_3_4.Protocol1_9_1_2To1_9_3_4;
import us.myles.ViaVersion.protocols.protocol1_9_1to1_9.Protocol1_9_1To1_9; import us.myles.ViaVersion.protocols.protocol1_9_1to1_9.Protocol1_9_1To1_9;
@ -64,6 +65,7 @@ public class ProtocolRegistry {
registerProtocol(new Protocol1_14To1_13_2(), Arrays.asList(ProtocolVersion.v1_14.getId()), ProtocolVersion.v1_13_2.getId()); registerProtocol(new Protocol1_14To1_13_2(), Arrays.asList(ProtocolVersion.v1_14.getId()), ProtocolVersion.v1_13_2.getId());
registerProtocol(new Protocol1_14_1To1_14(), Arrays.asList(ProtocolVersion.v1_14_1.getId()), ProtocolVersion.v1_14.getId()); registerProtocol(new Protocol1_14_1To1_14(), Arrays.asList(ProtocolVersion.v1_14_1.getId()), ProtocolVersion.v1_14.getId());
registerProtocol(new Protocol1_14_2To1_14_1(), Arrays.asList(ProtocolVersion.v1_14_2.getId()), ProtocolVersion.v1_14_1.getId());
} }
/** /**

Datei anzeigen

@ -37,6 +37,7 @@ public class ProtocolVersion {
public static final ProtocolVersion v1_13_2; public static final ProtocolVersion v1_13_2;
public static final ProtocolVersion v1_14; public static final ProtocolVersion v1_14;
public static final ProtocolVersion v1_14_1; public static final ProtocolVersion v1_14_1;
public static final ProtocolVersion v1_14_2;
public static final ProtocolVersion unknown; public static final ProtocolVersion unknown;
private final int id; private final int id;
@ -70,6 +71,7 @@ public class ProtocolVersion {
register(v1_13_2 = new ProtocolVersion(404, "1.13.2")); register(v1_13_2 = new ProtocolVersion(404, "1.13.2"));
register(v1_14 = new ProtocolVersion(477, "1.14")); register(v1_14 = new ProtocolVersion(477, "1.14"));
register(v1_14_1 = new ProtocolVersion(480, "1.14.1")); register(v1_14_1 = new ProtocolVersion(480, "1.14.1"));
register(v1_14_2 = new ProtocolVersion(485, "1.14.2"));
register(unknown = new ProtocolVersion(-1, "UNKNOWN")); register(unknown = new ProtocolVersion(-1, "UNKNOWN"));
} }

Datei anzeigen

@ -178,7 +178,12 @@ public class InventoryPackets {
Via.getPlatform().getLogger().warning("Ignoring plugin channel in outgoing REGISTER: " + channels[i]); Via.getPlatform().getLogger().warning("Ignoring plugin channel in outgoing REGISTER: " + channels[i]);
} }
} }
wrapper.write(Type.REMAINING_BYTES, Joiner.on('\0').join(rewrittenChannels).getBytes(StandardCharsets.UTF_8)); if (!rewrittenChannels.isEmpty()) {
wrapper.write(Type.REMAINING_BYTES, Joiner.on('\0').join(rewrittenChannels).getBytes(StandardCharsets.UTF_8));
} else {
wrapper.cancel();
return;
}
} }
} }
wrapper.set(Type.STRING, 0, channel); wrapper.set(Type.STRING, 0, channel);

Datei anzeigen

@ -0,0 +1,17 @@
package us.myles.ViaVersion.protocols.protocol1_14_2to1_14_1;
import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.protocol.Protocol;
public class Protocol1_14_2To1_14_1 extends Protocol {
@Override
protected void registerPackets() {
}
@Override
public void init(UserConnection userConnection) {
}
}

Datei anzeigen

@ -47,6 +47,7 @@ public class EntityTypeRewriter {
regEnt(41, 43); // command_block_minecart regEnt(41, 43); // command_block_minecart
regEnt(42, 44); // furnace_minecart regEnt(42, 44); // furnace_minecart
regEnt(43, 45); // hopper_minecart regEnt(43, 45); // hopper_minecart
regEnt(44, 46); // spawner_minecart
regEnt(45, 47); // tnt_minecart regEnt(45, 47); // tnt_minecart
regEnt(46, 48); // mule regEnt(46, 48); // mule
regEnt(47, 49); // mooshroom regEnt(47, 49); // mooshroom

Datei anzeigen

@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>viaversion-parent</artifactId> <artifactId>viaversion-parent</artifactId>
<groupId>us.myles</groupId> <groupId>us.myles</groupId>
<version>2.1.0</version> <version>2.1.2-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<name>viaversion-jar</name> <name>viaversion-jar</name>

Datei anzeigen

@ -6,7 +6,7 @@
<groupId>us.myles</groupId> <groupId>us.myles</groupId>
<artifactId>viaversion-parent</artifactId> <artifactId>viaversion-parent</artifactId>
<version>2.1.0</version> <version>2.1.2-SNAPSHOT</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<name>viaversion-parent</name> <name>viaversion-parent</name>

Datei anzeigen

@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>viaversion-parent</artifactId> <artifactId>viaversion-parent</artifactId>
<groupId>us.myles</groupId> <groupId>us.myles</groupId>
<version>2.1.0</version> <version>2.1.2-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

Datei anzeigen

@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>viaversion-parent</artifactId> <artifactId>viaversion-parent</artifactId>
<groupId>us.myles</groupId> <groupId>us.myles</groupId>
<version>2.1.0</version> <version>2.1.2-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

Datei anzeigen

@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>viaversion-parent</artifactId> <artifactId>viaversion-parent</artifactId>
<groupId>us.myles</groupId> <groupId>us.myles</groupId>
<version>2.1.0</version> <version>2.1.2-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

Datei anzeigen

@ -16,15 +16,14 @@ import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.protocols.base.ProtocolInfo; import us.myles.ViaVersion.protocols.base.ProtocolInfo;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.packets.InventoryPackets; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.packets.InventoryPackets;
import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9To1_8; import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9To1_8;
import us.myles.ViaVersion.util.ReflectionUtil;
import us.myles.ViaVersion.velocity.service.ProtocolDetectorService; import us.myles.ViaVersion.velocity.service.ProtocolDetectorService;
import us.myles.ViaVersion.velocity.storage.VelocityStorage; import us.myles.ViaVersion.velocity.storage.VelocityStorage;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Set;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.Semaphore; import java.util.concurrent.Semaphore;
@ -34,7 +33,6 @@ public class VelocityServerHandler {
private static Method getMinecraftConnection; private static Method getMinecraftConnection;
private static Method getNextProtocolVersion; private static Method getNextProtocolVersion;
private static Method getKnownChannels; private static Method getKnownChannels;
private static Class<?> clientPlaySessionHandler;
static { static {
try { try {
@ -42,13 +40,11 @@ public class VelocityServerHandler {
.getDeclaredMethod("setProtocolVersion", ProtocolVersion.class); .getDeclaredMethod("setProtocolVersion", ProtocolVersion.class);
setNextProtocolVersion = Class.forName("com.velocitypowered.proxy.connection.MinecraftConnection") setNextProtocolVersion = Class.forName("com.velocitypowered.proxy.connection.MinecraftConnection")
.getDeclaredMethod("setNextProtocolVersion", ProtocolVersion.class); .getDeclaredMethod("setNextProtocolVersion", ProtocolVersion.class);
getMinecraftConnection = Class.forName("com.velocitypowered.proxy.connection.client.ConnectedPlayer") Class<?> connectedPlayer = Class.forName("com.velocitypowered.proxy.connection.client.ConnectedPlayer");
.getDeclaredMethod("getMinecraftConnection"); getMinecraftConnection = connectedPlayer.getDeclaredMethod("getMinecraftConnection");
getNextProtocolVersion = Class.forName("com.velocitypowered.proxy.connection.MinecraftConnection") getNextProtocolVersion = Class.forName("com.velocitypowered.proxy.connection.MinecraftConnection")
.getDeclaredMethod("getNextProtocolVersion"); .getDeclaredMethod("getNextProtocolVersion");
clientPlaySessionHandler = Class.forName("com.velocitypowered.proxy.connection.client.ClientPlaySessionHandler"); getKnownChannels = connectedPlayer.getDeclaredMethod("getKnownChannels");
getKnownChannels = clientPlaySessionHandler
.getDeclaredMethod("getKnownChannels");
} catch (NoSuchMethodException | ClassNotFoundException e) { } catch (NoSuchMethodException | ClassNotFoundException e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -79,7 +75,6 @@ public class VelocityServerHandler {
@Subscribe(order = PostOrder.LATE) @Subscribe(order = PostOrder.LATE)
public void connectedEvent(ServerConnectedEvent e) { public void connectedEvent(ServerConnectedEvent e) {
UserConnection user = Via.getManager().getConnection(e.getPlayer().getUniqueId());
try { try {
checkServerChange(e, Via.getManager().getConnection(e.getPlayer().getUniqueId())); checkServerChange(e, Via.getManager().getConnection(e.getPlayer().getUniqueId()));
} catch (Exception e1) { } catch (Exception e1) {
@ -144,37 +139,29 @@ public class VelocityServerHandler {
// Add version-specific base Protocol // Add version-specific base Protocol
pipeline.add(ProtocolRegistry.getBaseProtocol(protocolId)); pipeline.add(ProtocolRegistry.getBaseProtocol(protocolId));
// Workaround 1.13 server change Collection<String> knownChannels = (Collection<String>) getKnownChannels.invoke(e.getPlayer());
Object sessionHandler = ReflectionUtil.invoke( if (previousServerProtocol != -1) {
getMinecraftConnection.invoke(e.getPlayer()), int id1_13 = ProtocolVersion.MINECRAFT_1_13.getProtocol();
"getSessionHandler" if (previousServerProtocol < id1_13 && protocolId >= id1_13) {
); List<String> newChannels = new ArrayList<>();
for (String oldChannel : knownChannels) {
if (clientPlaySessionHandler.isInstance(sessionHandler)) { // It may be InitialConnectSessionHandler on the first server connection String transformed = InventoryPackets.getNewPluginChannelId(oldChannel);
Set<String> knownChannels = (Set<String>) getKnownChannels.invoke(sessionHandler); if (transformed != null) {
if (previousServerProtocol != -1) { newChannels.add(transformed);
int id1_13 = ProtocolVersion.MINECRAFT_1_13.getProtocol();
if (previousServerProtocol < id1_13 && protocolId >= id1_13) {
ArrayList<String> newChannels = new ArrayList<>();
for (String oldChannel : knownChannels) {
String transformed = InventoryPackets.getNewPluginChannelId(oldChannel);
if (transformed != null) {
newChannels.add(transformed);
}
} }
knownChannels.clear();
knownChannels.addAll(newChannels);
} else if (previousServerProtocol >= id1_13 && protocolId < id1_13) {
ArrayList<String> newChannels = new ArrayList<>();
for (String oldChannel : knownChannels) {
String transformed = InventoryPackets.getOldPluginChannelId(oldChannel);
if (transformed != null) {
newChannels.add(transformed);
}
}
knownChannels.clear();
knownChannels.addAll(newChannels);
} }
knownChannels.clear();
knownChannels.addAll(newChannels);
} else if (previousServerProtocol >= id1_13 && protocolId < id1_13) {
List<String> newChannels = new ArrayList<>();
for (String oldChannel : knownChannels) {
String transformed = InventoryPackets.getOldPluginChannelId(oldChannel);
if (transformed != null) {
newChannels.add(transformed);
}
}
knownChannels.clear();
knownChannels.addAll(newChannels);
} }
} }