Implement ProxyLoginEvent
This commit is contained in:
parent
89a5740051
commit
4c4550f440
@ -0,0 +1,31 @@
|
|||||||
|
package com.glyart.authmevelocity.proxy.event;
|
||||||
|
|
||||||
|
import com.velocitypowered.api.proxy.Player;
|
||||||
|
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
||||||
|
|
||||||
|
public class ProxyLoginEvent {
|
||||||
|
|
||||||
|
private final Player player;
|
||||||
|
private final RegisteredServer server;
|
||||||
|
|
||||||
|
public ProxyLoginEvent(Player player, RegisteredServer server){
|
||||||
|
this.player = player;
|
||||||
|
this.server = server;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the player who has logged in
|
||||||
|
* @return the login player
|
||||||
|
*/
|
||||||
|
public Player getPlayer(){
|
||||||
|
return this.player;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Obtain the server to which the user is logged in.
|
||||||
|
* @return the login server
|
||||||
|
*/
|
||||||
|
public RegisteredServer getServer(){
|
||||||
|
return this.server;
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,7 @@
|
|||||||
package com.glyart.authmevelocity.proxy.listener;
|
package com.glyart.authmevelocity.proxy.listener;
|
||||||
|
|
||||||
import com.glyart.authmevelocity.proxy.AuthMeVelocityPlugin;
|
import com.glyart.authmevelocity.proxy.AuthMeVelocityPlugin;
|
||||||
|
import com.glyart.authmevelocity.proxy.event.ProxyLoginEvent;
|
||||||
import com.google.common.io.ByteArrayDataInput;
|
import com.google.common.io.ByteArrayDataInput;
|
||||||
import com.velocitypowered.api.event.Subscribe;
|
import com.velocitypowered.api.event.Subscribe;
|
||||||
import com.velocitypowered.api.event.command.CommandExecuteEvent;
|
import com.velocitypowered.api.event.command.CommandExecuteEvent;
|
||||||
@ -39,7 +40,11 @@ public class ProxyListener {
|
|||||||
Optional<Player> player = server.getPlayer(UUID.fromString(user));
|
Optional<Player> player = server.getPlayer(UUID.fromString(user));
|
||||||
if (!player.isPresent()) return;
|
if (!player.isPresent()) return;
|
||||||
|
|
||||||
plugin.loggedPlayers.add(player.get().getUniqueId());
|
Player loggedPlayer = player.get();
|
||||||
|
plugin.loggedPlayers.add(loggedPlayer.getUniqueId());
|
||||||
|
|
||||||
|
RegisteredServer loginServer = player.get().getCurrentServer().get().getServer();
|
||||||
|
server.getEventManager().fireAndForget(new ProxyLoginEvent(loggedPlayer, loginServer));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
@ -66,7 +71,7 @@ public class ProxyListener {
|
|||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onPlayerChat(final PlayerChatEvent event) {
|
public void onPlayerChat(final PlayerChatEvent event) {
|
||||||
Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
if (plugin.loggedPlayers.contains(player.getUniqueId())) return;
|
if (plugin.loggedPlayers.contains(player.getUniqueId())) return;
|
||||||
|
|
||||||
Optional<ServerConnection> server = player.getCurrentServer();
|
Optional<ServerConnection> server = player.getCurrentServer();
|
||||||
@ -79,7 +84,7 @@ public class ProxyListener {
|
|||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onServerPreConnect(ServerPreConnectEvent event) {
|
public void onServerPreConnect(ServerPreConnectEvent event) {
|
||||||
Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
if (plugin.loggedPlayers.contains(player.getUniqueId())) return;
|
if (plugin.loggedPlayers.contains(player.getUniqueId())) return;
|
||||||
|
|
||||||
Optional<RegisteredServer> server = event.getResult().getServer();
|
Optional<RegisteredServer> server = event.getResult().getServer();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user