used correct server event for redirect
This commit is contained in:
parent
56d8254cc7
commit
59495d01e9
@ -5,6 +5,7 @@ import com.google.inject.Inject;
|
|||||||
import com.google.inject.name.Named;
|
import com.google.inject.name.Named;
|
||||||
import com.velocitypowered.api.event.Subscribe;
|
import com.velocitypowered.api.event.Subscribe;
|
||||||
import com.velocitypowered.api.event.connection.LoginEvent;
|
import com.velocitypowered.api.event.connection.LoginEvent;
|
||||||
|
import com.velocitypowered.api.event.player.PlayerChooseInitialServerEvent;
|
||||||
import com.velocitypowered.api.event.player.ServerConnectedEvent;
|
import com.velocitypowered.api.event.player.ServerConnectedEvent;
|
||||||
import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
|
import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
|
||||||
import com.velocitypowered.api.plugin.Dependency;
|
import com.velocitypowered.api.plugin.Dependency;
|
||||||
@ -65,14 +66,12 @@ public class RememberMe {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onLoginEvent(LoginEvent loginEvent) {
|
public void onServerChooseEvent(PlayerChooseInitialServerEvent chooseServerEvent) {
|
||||||
// Ignore plugin when user has notransfer permission
|
// Ignore plugin when user has notransfer permission
|
||||||
if (!loginEvent.getPlayer().hasPermission("rememberme.notransfer")) {
|
if (!chooseServerEvent.getPlayer().hasPermission("rememberme.notransfer")) {
|
||||||
handler.getLastServerName(loginEvent.getPlayer().getUniqueId()).thenAcceptAsync(lastServerName -> {
|
handler.getLastServerName(chooseServerEvent.getPlayer().getUniqueId()).thenAcceptAsync(lastServerName -> {
|
||||||
if (lastServerName != null) {
|
if (lastServerName != null) {
|
||||||
getServer().getServer(lastServerName).ifPresent(lastServer -> {
|
getServer().getServer(lastServerName).ifPresent(chooseServerEvent::setInitialServer);
|
||||||
loginEvent.getPlayer().createConnectionRequest(lastServer).connectWithIndication();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}).join();
|
}).join();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user