Add ability to require permission to send-on-login

This commit is contained in:
Triassic 2023-10-09 16:08:42 +03:00
parent 0f9c3f053c
commit 5849f05a69
2 changed files with 10 additions and 0 deletions

View File

@ -80,6 +80,12 @@ public class ProxyConfiguration {
return this.sendOnLogin; return this.sendOnLogin;
} }
@Comment("Require players to have the authmevelocity.send-on-login permission?")
private boolean requirePermission = false;
public boolean isRequirePermission() {
return this.requirePermission;
}
@Comment(""" @Comment("""
List of servers to send List of servers to send
One of these servers will be chosen at random""") One of these servers will be chosen at random""")

View File

@ -134,6 +134,10 @@ public final class PluginMessageListener implements Listener<PluginMessageEvent>
return; return;
} }
if (plugin.config().get().sendOnLogin().isRequirePermission() && !player.hasPermission("authmevelocity.send-on-login")) {
return;
}
eventManager.fire(new PreSendOnLoginEvent(player, loginServer, toSend.object())) eventManager.fire(new PreSendOnLoginEvent(player, loginServer, toSend.object()))
.thenAccept(event -> { .thenAccept(event -> {
if (!event.getResult().isAllowed()) { if (!event.getResult().isAllowed()) {