3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-12-25 15:50:10 +01:00

Fix getting connection twice

Dieser Commit ist enthalten in:
Myles 2016-11-15 08:17:15 +00:00
Ursprung bee260e2b4
Commit bf01c9ea0e

Datei anzeigen

@ -76,7 +76,7 @@ public class BungeeServerHandler implements Listener {
} }
public void checkServerChange(ServerConnectedEvent e, UserConnection user) throws Exception { public void checkServerChange(ServerConnectedEvent e, UserConnection user) throws Exception {
if(user == null) return; if (user == null) return;
if (user.has(BungeeStorage.class)) { if (user.has(BungeeStorage.class)) {
BungeeStorage storage = user.get(BungeeStorage.class); BungeeStorage storage = user.get(BungeeStorage.class);
ProxiedPlayer player = storage.getPlayer(); ProxiedPlayer player = storage.getPlayer();
@ -89,12 +89,11 @@ public class BungeeServerHandler implements Listener {
int protocolId = ProtocolDetectorService.getProtocolId(serverName); int protocolId = ProtocolDetectorService.getProtocolId(serverName);
UserConnection viaConnection = Via.getManager().getConnection(player.getUniqueId()); ProtocolInfo info = user.get(ProtocolInfo.class);
ProtocolInfo info = viaConnection.get(ProtocolInfo.class);
// 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 = viaConnection.get(ProtocolInfo.class).getPipeline(); ProtocolPipeline pipeline = user.get(ProtocolInfo.class).getPipeline();
viaConnection.clearStoredObjects(); user.clearStoredObjects();
pipeline.cleanPipes(); pipeline.cleanPipes();
if (protocols == null) { if (protocols == null) {
// TODO Check Bungee Supported Protocols? *shrugs* // TODO Check Bungee Supported Protocols? *shrugs*
@ -105,14 +104,14 @@ public class BungeeServerHandler implements Listener {
} }
} }
viaConnection.put(info); user.put(info);
viaConnection.put(storage); user.put(storage);
viaConnection.setActive(protocols != null); user.setActive(protocols != null);
// Init all protocols TODO check if this can get moved up to the previous for loop, and doesn't require the pipeline to already exist. // Init all protocols TODO check if this can get moved up to the previous for loop, and doesn't require the pipeline to already exist.
for (Protocol protocol : pipeline.pipes()) { for (Protocol protocol : pipeline.pipes()) {
protocol.init(viaConnection); protocol.init(user);
} }
Object wrapper = channelWrapper.get(player); Object wrapper = channelWrapper.get(player);