Continuations use in AwatingsEvents
This commit is contained in:
parent
b94c664101
commit
5fead6090c
@ -4,6 +4,7 @@ import com.glyart.authmevelocity.proxy.AuthmeVelocityAPI;
|
|||||||
import com.glyart.authmevelocity.proxy.config.AuthMeConfig;
|
import com.glyart.authmevelocity.proxy.config.AuthMeConfig;
|
||||||
import com.glyart.authmevelocity.proxy.config.ConfigUtils;
|
import com.glyart.authmevelocity.proxy.config.ConfigUtils;
|
||||||
import com.glyart.authmevelocity.proxy.utils.AuthmeUtils;
|
import com.glyart.authmevelocity.proxy.utils.AuthmeUtils;
|
||||||
|
import com.velocitypowered.api.event.Continuation;
|
||||||
import com.velocitypowered.api.event.EventTask;
|
import com.velocitypowered.api.event.EventTask;
|
||||||
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;
|
||||||
@ -28,9 +29,18 @@ public class ProxyListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onCommandExecute(final CommandExecuteEvent event) {
|
public void onCommandExecute(final CommandExecuteEvent event, Continuation continuation) {
|
||||||
if (!(event.getCommandSource() instanceof Player player) || AuthmeVelocityAPI.isLogged(player))
|
if (!(event.getCommandSource() instanceof Player)){
|
||||||
|
continuation.resume();
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Player player = ((Player)event.getCommandSource());
|
||||||
|
|
||||||
|
if(AuthmeVelocityAPI.isLogged(player)){
|
||||||
|
continuation.resume();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if(AuthmeVelocityAPI.isInAuthServer(player)){
|
if(AuthmeVelocityAPI.isInAuthServer(player)){
|
||||||
String command = AuthmeUtils.getFirstArgument(event.getCommand());
|
String command = AuthmeUtils.getFirstArgument(event.getCommand());
|
||||||
@ -42,6 +52,7 @@ public class ProxyListener {
|
|||||||
ConfigUtils.sendBlockedMessage(player);
|
ConfigUtils.sendBlockedMessage(player);
|
||||||
event.setResult(CommandExecuteEvent.CommandResult.denied());
|
event.setResult(CommandExecuteEvent.CommandResult.denied());
|
||||||
}
|
}
|
||||||
|
continuation.resume();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
@ -52,14 +63,18 @@ public class ProxyListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onServerPreConnect(ServerPreConnectEvent event) {
|
public void onServerPreConnect(ServerPreConnectEvent event, Continuation continuation) {
|
||||||
if (AuthmeVelocityAPI.isLogged(event.getPlayer())) return;
|
if (AuthmeVelocityAPI.isLogged(event.getPlayer())){
|
||||||
|
continuation.resume();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
event.getResult().getServer().ifPresent(server -> {
|
event.getResult().getServer().ifPresent(server -> {
|
||||||
if(!AuthmeVelocityAPI.isAuthServer(server)){
|
if(!AuthmeVelocityAPI.isAuthServer(server)){
|
||||||
event.setResult(ServerPreConnectEvent.ServerResult.denied());
|
event.setResult(ServerPreConnectEvent.ServerResult.denied());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
continuation.resume();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
|
Loading…
x
Reference in New Issue
Block a user