fix(velocity): Implement ignoreSignedPlayer configuration
Workaround for #48
This commit is contained in:
parent
97b9bcd87a
commit
0d8630452f
@ -47,8 +47,7 @@ public class ProxyConfiguration {
|
|||||||
Selection Mode of the player's initial server
|
Selection Mode of the player's initial server
|
||||||
TO_FIRST | Send to the first valid server configured
|
TO_FIRST | Send to the first valid server configured
|
||||||
TO_EMPTIEST_SERVER | Send to the server with the lowest number of players
|
TO_EMPTIEST_SERVER | Send to the server with the lowest number of players
|
||||||
RANDOM | Send to a random server
|
RANDOM | Send to a random server""")
|
||||||
""")
|
|
||||||
private SendMode sendMode = SendMode.RANDOM;
|
private SendMode sendMode = SendMode.RANDOM;
|
||||||
public SendMode sendMode() {
|
public SendMode sendMode() {
|
||||||
return this.sendMode;
|
return this.sendMode;
|
||||||
@ -65,8 +64,7 @@ public class ProxyConfiguration {
|
|||||||
|
|
||||||
@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""")
|
||||||
""")
|
|
||||||
private List<String> teleportServers = List.of("lobby1", "lobby2");
|
private List<String> teleportServers = List.of("lobby1", "lobby2");
|
||||||
public List<String> teleportServers() {
|
public List<String> teleportServers() {
|
||||||
return this.teleportServers;
|
return this.teleportServers;
|
||||||
@ -76,8 +74,7 @@ public class ProxyConfiguration {
|
|||||||
Selection Mode of the server to which the player will be sent
|
Selection Mode of the server to which the player will be sent
|
||||||
TO_FIRST | Send to the first valid server configured
|
TO_FIRST | Send to the first valid server configured
|
||||||
TO_EMPTIEST_SERVER | Send to the server with the lowest number of players
|
TO_EMPTIEST_SERVER | Send to the server with the lowest number of players
|
||||||
RANDOM | Send to a random server
|
RANDOM | Send to a random server""")
|
||||||
""")
|
|
||||||
private SendMode sendMode = SendMode.RANDOM;
|
private SendMode sendMode = SendMode.RANDOM;
|
||||||
public SendMode sendMode() {
|
public SendMode sendMode() {
|
||||||
return this.sendMode;
|
return this.sendMode;
|
||||||
@ -94,8 +91,7 @@ public class ProxyConfiguration {
|
|||||||
|
|
||||||
@Comment("""
|
@Comment("""
|
||||||
Sets the message to send in case a non-logged-in player executes an unauthorized command
|
Sets the message to send in case a non-logged-in player executes an unauthorized command
|
||||||
To deactivate the message, leave it empty
|
To deactivate the message, leave it empty""")
|
||||||
""")
|
|
||||||
private String blockedMessage = "<red>You cannot execute commands if you are not logged in yet";
|
private String blockedMessage = "<red>You cannot execute commands if you are not logged in yet";
|
||||||
public String blockedCommandMessage() {
|
public String blockedCommandMessage() {
|
||||||
return this.blockedMessage;
|
return this.blockedMessage;
|
||||||
@ -115,6 +111,16 @@ public class ProxyConfiguration {
|
|||||||
public int randomAttempts() {
|
public int randomAttempts() {
|
||||||
return this.randomAttempts;
|
return this.randomAttempts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Comment("""
|
||||||
|
Ignore blocking of commands and chat messages to 1.19.1 clients with a valid signed key
|
||||||
|
When trying to block these executions, the proxy will kick the player out.
|
||||||
|
This option allows you to prevent the plugin from trying to block these executions,
|
||||||
|
avoiding the player to be kicked out""")
|
||||||
|
private boolean ignoreSignedPlayers = false;
|
||||||
|
public boolean ignoreSignedPlayers() {
|
||||||
|
return this.ignoreSignedPlayers;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@ import com.velocitypowered.api.event.command.CommandExecuteEvent;
|
|||||||
import com.velocitypowered.api.event.connection.DisconnectEvent;
|
import com.velocitypowered.api.event.connection.DisconnectEvent;
|
||||||
import com.velocitypowered.api.event.player.PlayerChatEvent;
|
import com.velocitypowered.api.event.player.PlayerChatEvent;
|
||||||
import com.velocitypowered.api.event.player.TabCompleteEvent;
|
import com.velocitypowered.api.event.player.TabCompleteEvent;
|
||||||
|
import com.velocitypowered.api.network.ProtocolVersion;
|
||||||
import com.velocitypowered.api.proxy.Player;
|
import com.velocitypowered.api.proxy.Player;
|
||||||
|
|
||||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||||
@ -35,7 +36,13 @@ public final class ProxyListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.isLogged(player)) {
|
if (plugin.isLogged(player)) {
|
||||||
plugin.logDebug("CommandExecuteEvent | Player is not logged");
|
plugin.logDebug("CommandExecuteEvent | Player is already logged");
|
||||||
|
continuation.resume();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (canBeIgnored(player)) {
|
||||||
|
plugin.logDebug("CommandexecuteEvent | Ignored signed player");
|
||||||
continuation.resume();
|
continuation.resume();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -57,11 +64,23 @@ public final class ProxyListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe(order = PostOrder.FIRST)
|
@Subscribe(order = PostOrder.FIRST)
|
||||||
public void onPlayerChat(final PlayerChatEvent event) {
|
public void onPlayerChat(final PlayerChatEvent event, Continuation continuation) {
|
||||||
if (plugin.isNotLogged(event.getPlayer())) {
|
if (plugin.isLogged(event.getPlayer())) {
|
||||||
plugin.logDebug("PlayerChatEvent | Player is not logged");
|
plugin.logDebug("PlayerChatEvent | Player is already logged");
|
||||||
event.setResult(PlayerChatEvent.ChatResult.denied());
|
continuation.resume();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
plugin.logDebug("PlayerChatEvent | Player is not logged");
|
||||||
|
|
||||||
|
if (canBeIgnored(event.getPlayer())) {
|
||||||
|
plugin.logDebug("PlayerChatEvent | Ignored signed player");
|
||||||
|
continuation.resume();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
event.setResult(PlayerChatEvent.ChatResult.denied());
|
||||||
|
continuation.resume();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe(order = PostOrder.FIRST)
|
@Subscribe(order = PostOrder.FIRST)
|
||||||
@ -88,5 +107,11 @@ public final class ProxyListener {
|
|||||||
player.sendMessage(MiniMessage.miniMessage().deserialize(blockedMessage));
|
player.sendMessage(MiniMessage.miniMessage().deserialize(blockedMessage));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean canBeIgnored(Player player) {
|
||||||
|
return player.getIdentifiedKey() != null
|
||||||
|
&& player.getProtocolVersion().compareTo(ProtocolVersion.MINECRAFT_1_19_1) >= 0
|
||||||
|
&& plugin.config().get().advanced().ignoreSignedPlayers();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user