Revert changes to SeverConnectedEvent
This commit is contained in:
parent
f083e27649
commit
db5a147491
@ -3,9 +3,9 @@ package net.md_5.bungee.api.event;
|
|||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
import net.md_5.bungee.api.Callback;
|
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
import net.md_5.bungee.api.connection.Server;
|
import net.md_5.bungee.api.connection.Server;
|
||||||
|
import net.md_5.bungee.api.plugin.Event;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Not to be confused with {@link ServerConnectEvent}, this event is called once
|
* Not to be confused with {@link ServerConnectEvent}, this event is called once
|
||||||
@ -16,7 +16,7 @@ import net.md_5.bungee.api.connection.Server;
|
|||||||
@Data
|
@Data
|
||||||
@ToString(callSuper = false)
|
@ToString(callSuper = false)
|
||||||
@EqualsAndHashCode(callSuper = false)
|
@EqualsAndHashCode(callSuper = false)
|
||||||
public class ServerConnectedEvent extends AsyncEvent<ServerConnectedEvent>
|
public class ServerConnectedEvent extends Event
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -27,11 +27,4 @@ public class ServerConnectedEvent extends AsyncEvent<ServerConnectedEvent>
|
|||||||
* The server itself.
|
* The server itself.
|
||||||
*/
|
*/
|
||||||
private final Server server;
|
private final Server server;
|
||||||
|
|
||||||
public ServerConnectedEvent(ProxiedPlayer player, Server server, Callback<ServerConnectedEvent> done)
|
|
||||||
{
|
|
||||||
super( done );
|
|
||||||
this.player = player;
|
|
||||||
this.server = server;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,6 @@ import java.util.Queue;
|
|||||||
import javax.crypto.Cipher;
|
import javax.crypto.Cipher;
|
||||||
import javax.crypto.SecretKey;
|
import javax.crypto.SecretKey;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import net.md_5.bungee.api.Callback;
|
|
||||||
import net.md_5.bungee.api.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
import net.md_5.bungee.api.ProxyServer;
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
import net.md_5.bungee.api.config.ServerInfo;
|
import net.md_5.bungee.api.config.ServerInfo;
|
||||||
@ -100,27 +99,13 @@ public class ServerConnector extends PacketHandler
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handle(final Packet1Login login) throws Exception
|
public void handle(Packet1Login login) throws Exception
|
||||||
{
|
{
|
||||||
Preconditions.checkState( thisState == State.LOGIN, "Not exepcting LOGIN" );
|
Preconditions.checkState( thisState == State.LOGIN, "Not exepcting LOGIN" );
|
||||||
|
|
||||||
synchronized ( user.getSwitchMutex() )
|
ServerConnection server = new ServerConnection( ch, target );
|
||||||
{
|
ServerConnectedEvent event = new ServerConnectedEvent( user, server );
|
||||||
if ( user.getServer() != null )
|
bungee.getPluginManager().callEvent( event );
|
||||||
{
|
|
||||||
user.sendDimensionSwitch();
|
|
||||||
// Remove from old servers
|
|
||||||
user.getServer().setObsolete( true );
|
|
||||||
user.getServer().disconnect( "Quitting" );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
final ServerConnection server = new ServerConnection( ch, target );
|
|
||||||
Callback<ServerConnectedEvent> callback = new Callback<ServerConnectedEvent>()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void done(ServerConnectedEvent result, Throwable error)
|
|
||||||
{
|
|
||||||
|
|
||||||
ch.write( BungeeCord.getInstance().registerChannels() );
|
ch.write( BungeeCord.getInstance().registerChannels() );
|
||||||
Queue<DefinedPacket> packetQueue = target.getPacketQueue();
|
Queue<DefinedPacket> packetQueue = target.getPacketQueue();
|
||||||
@ -188,8 +173,14 @@ public class ServerConnector extends PacketHandler
|
|||||||
}
|
}
|
||||||
serverScoreboard.clear();
|
serverScoreboard.clear();
|
||||||
|
|
||||||
|
user.sendDimensionSwitch();
|
||||||
|
|
||||||
user.setServerEntityId( login.getEntityId() );
|
user.setServerEntityId( login.getEntityId() );
|
||||||
user.unsafe().sendPacket( new Packet9Respawn( login.getDimension(), login.getDifficulty(), login.getGameMode(), (short) 256, login.getLevelType() ) );
|
user.unsafe().sendPacket( new Packet9Respawn( login.getDimension(), login.getDifficulty(), login.getGameMode(), (short) 256, login.getLevelType() ) );
|
||||||
|
|
||||||
|
// Remove from old servers
|
||||||
|
user.getServer().setObsolete( true );
|
||||||
|
user.getServer().disconnect( "Quitting" );
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Fix this?
|
// TODO: Fix this?
|
||||||
@ -213,11 +204,6 @@ public class ServerConnector extends PacketHandler
|
|||||||
bungee.getPluginManager().callEvent( new ServerSwitchEvent( user ) );
|
bungee.getPluginManager().callEvent( new ServerSwitchEvent( user ) );
|
||||||
|
|
||||||
thisState = State.FINISHED;
|
thisState = State.FINISHED;
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
ServerConnectedEvent event = new ServerConnectedEvent( user, server, callback );
|
|
||||||
bungee.getPluginManager().callEvent( event );
|
|
||||||
|
|
||||||
throw new CancelSendSignal();
|
throw new CancelSendSignal();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user