Cleanup userconnection constructor
This commit is contained in:
parent
9f8ad518e8
commit
6efba44e5a
@ -17,6 +17,7 @@ import java.util.Objects;
|
|||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import lombok.AccessLevel;
|
import lombok.AccessLevel;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import lombok.Synchronized;
|
import lombok.Synchronized;
|
||||||
import net.md_5.bungee.api.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
@ -32,16 +33,19 @@ import net.md_5.bungee.netty.ChannelWrapper;
|
|||||||
import net.md_5.bungee.netty.PipelineUtils;
|
import net.md_5.bungee.netty.PipelineUtils;
|
||||||
import net.md_5.bungee.packet.*;
|
import net.md_5.bungee.packet.*;
|
||||||
|
|
||||||
|
@RequiredArgsConstructor
|
||||||
public final class UserConnection implements ProxiedPlayer
|
public final class UserConnection implements ProxiedPlayer
|
||||||
{
|
{
|
||||||
|
|
||||||
public final Packet2Handshake handshake;
|
/*========================================================================*/
|
||||||
private final ProxyServer bungee;
|
private final ProxyServer bungee;
|
||||||
public final ChannelWrapper ch;
|
public final ChannelWrapper ch;
|
||||||
final Packet1Login forgeLogin;
|
|
||||||
final List<PacketFAPluginMessage> loginMessages;
|
|
||||||
@Getter
|
@Getter
|
||||||
private final PendingConnection pendingConnection;
|
private final PendingConnection pendingConnection;
|
||||||
|
public final Packet2Handshake handshake;
|
||||||
|
final Packet1Login forgeLogin;
|
||||||
|
final List<PacketFAPluginMessage> loginMessages;
|
||||||
|
/*========================================================================*/
|
||||||
@Getter
|
@Getter
|
||||||
@Setter(AccessLevel.PACKAGE)
|
@Setter(AccessLevel.PACKAGE)
|
||||||
private ServerConnection server;
|
private ServerConnection server;
|
||||||
@ -68,15 +72,8 @@ public final class UserConnection implements ProxiedPlayer
|
|||||||
public final Scoreboard serverSentScoreboard = new Scoreboard();
|
public final Scoreboard serverSentScoreboard = new Scoreboard();
|
||||||
public final Collection<ServerInfo> pendingConnects = new HashSet<>();
|
public final Collection<ServerInfo> pendingConnects = new HashSet<>();
|
||||||
|
|
||||||
public UserConnection(BungeeCord bungee, ChannelWrapper channel, PendingConnection pendingConnection, Packet2Handshake handshake, Packet1Login forgeLogin, List<PacketFAPluginMessage> loginMessages)
|
public void init()
|
||||||
{
|
{
|
||||||
this.bungee = bungee;
|
|
||||||
this.ch = channel;
|
|
||||||
this.handshake = handshake;
|
|
||||||
this.pendingConnection = pendingConnection;
|
|
||||||
this.forgeLogin = forgeLogin;
|
|
||||||
this.loginMessages = loginMessages;
|
|
||||||
this.name = handshake.username;
|
|
||||||
this.displayName = name;
|
this.displayName = name;
|
||||||
|
|
||||||
Collection<String> g = bungee.getConfigurationAdapter().getGroups( name );
|
Collection<String> g = bungee.getConfigurationAdapter().getGroups( name );
|
||||||
@ -94,6 +91,7 @@ public final class UserConnection implements ProxiedPlayer
|
|||||||
@Override
|
@Override
|
||||||
public void setDisplayName(String name)
|
public void setDisplayName(String name)
|
||||||
{
|
{
|
||||||
|
Preconditions.checkNotNull( name, "displayName" );
|
||||||
Preconditions.checkArgument( name.length() <= 16, "Display name cannot be longer than 16 characters" );
|
Preconditions.checkArgument( name.length() <= 16, "Display name cannot be longer than 16 characters" );
|
||||||
bungee.getTabListHandler().onDisconnect( this );
|
bungee.getTabListHandler().onDisconnect( this );
|
||||||
displayName = name;
|
displayName = name;
|
||||||
|
@ -224,6 +224,8 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
|||||||
Preconditions.checkState( thisState == State.LOGIN, "Not expecting LOGIN" );
|
Preconditions.checkState( thisState == State.LOGIN, "Not expecting LOGIN" );
|
||||||
|
|
||||||
UserConnection userCon = new UserConnection( (BungeeCord) bungee, ch, this, handshake, forgeLogin, loginMessages );
|
UserConnection userCon = new UserConnection( (BungeeCord) bungee, ch, this, handshake, forgeLogin, loginMessages );
|
||||||
|
userCon.init();
|
||||||
|
|
||||||
bungee.getPluginManager().callEvent( new PostLoginEvent( userCon ) );
|
bungee.getPluginManager().callEvent( new PostLoginEvent( userCon ) );
|
||||||
|
|
||||||
ch.getHandle().pipeline().get( HandlerBoss.class ).setHandler( new UpstreamBridge( bungee, userCon ) );
|
ch.getHandle().pipeline().get( HandlerBoss.class ).setHandler( new UpstreamBridge( bungee, userCon ) );
|
||||||
|
Loading…
Reference in New Issue
Block a user