Skip to content

Commit

Permalink
Add "server switch prevention" message.
Browse files Browse the repository at this point in the history
  • Loading branch information
frafol committed Dec 9, 2024
1 parent ebbba62 commit 958c0b6
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public enum BungeeMessages {
BUTTON_EXECUTION("messages.staff_message.execution"),

COMMAND_BLOCKED("messages.control.command_blocked"),
CANT_SWITCH("messages.control.cant_switch"),

CONTROL_CLEAN_NAME("messages.staff_message.clean.name"),
CONTROL_CLEAN_COMMAND("messages.staff_message.clean.command"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ public void onPlayerChange(ServerConnectEvent event) {
}

event.setCancelled(true);
if (event.getReason().equals(ServerConnectEvent.Reason.COMMAND)) {
player.sendMessage(TextComponent.fromLegacyText(BungeeMessages.CANT_SWITCH.color()
.replace("%prefix%", BungeeMessages.PREFIX.color())));
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public enum VelocityMessages {
NOT_ONLINE("messages.not_online"),
NOT_VALID("messages.server_not_valid"),
COMMAND_BLOCKED("messages.control.command_blocked"),
CANT_SWITCH("messages.control.cant_switch"),

PLAYER_MISSING("messages.player_missing"),
NO_PERMISSION("messages.no_permission"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,13 @@ public void onPlayerConnect(ServerPreConnectEvent event) {
if (PlayerCache.getSuspicious().contains(player.getUniqueId())
|| PlayerCache.getAdministrator().contains(player.getUniqueId())) {

if (Utils.isInControlServer(server) || instance.useLimbo) {
if (!Utils.isInControlServer(server) || instance.useLimbo) {
return;
}

event.setResult(ServerPreConnectEvent.ServerResult.denied());
player.sendMessage(LegacyComponentSerializer.legacy('§').deserialize(VelocityMessages.CANT_SWITCH.color()
.replace("%prefix%", VelocityMessages.PREFIX.color())));
}
}

Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/messages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ messages:
# This message will appear when a player tries to execute a command during a hack control.
command_blocked: "%prefix% &7You can't use commands during a &dhack control&7."

# This message will appear when an administrator tries to change server during a hack control without terminating it.
cant_switch: "%prefix% &7You can't switch your server during a &dhack control&7."

info:

# If you're using LuckPerms, you can also use %playerprefix% and %playersuffix% here.
Expand Down

0 comments on commit 958c0b6

Please sign in to comment.