Skip to content

Commit 689c35f

Browse files
Mickey42302JRoy
andauthored
Add bypass permission node for the whitelist. (#6232)
I would like to suggest adding an "essentials.whitelist.bypass" permission node. This permission node allows users to bypass the whitelist requirement on servers that have the whitelist enabled, similar to how the "essentials.joinfullserver" permission node allows users to bypass the player limit. --------- Co-authored-by: JRoy <[email protected]>
1 parent 03d8938 commit 689c35f

File tree

6 files changed

+26
-1
lines changed

6 files changed

+26
-1
lines changed

Essentials/src/main/java/com/earth2me/essentials/EssentialsPlayerListener.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,17 @@ public void onPlayerLogin(final PlayerLoginEvent event) {
574574
event.disallow(Result.KICK_FULL, tlLiteral("serverFull"));
575575
}
576576
}
577+
if (event.getResult() == Result.KICK_WHITELIST) {
578+
final User kfuser = ess.getUser(event.getPlayer());
579+
kfuser.update(event.getPlayer());
580+
if (kfuser.isAuthorized("essentials.whitelist.bypass")) {
581+
event.allow();
582+
return;
583+
}
584+
if (ess.getSettings().isCustomWhitelistMessage()) {
585+
event.disallow(Result.KICK_WHITELIST, tlLiteral("whitelistKick"));
586+
}
587+
}
577588
}
578589

579590
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)

Essentials/src/main/java/com/earth2me/essentials/ISettings.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,8 @@ public interface ISettings extends IConf {
318318

319319
boolean isCustomServerFullMessage();
320320

321+
boolean isCustomWhitelistMessage();
322+
321323
boolean isNotifyNoNewMail();
322324

323325
boolean isDropItemsIfFull();

Essentials/src/main/java/com/earth2me/essentials/Settings.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1634,6 +1634,11 @@ public boolean isCustomServerFullMessage() {
16341634
return config.getBoolean("use-custom-server-full-message", true);
16351635
}
16361636

1637+
@Override
1638+
public boolean isCustomWhitelistMessage() {
1639+
return config.getBoolean("use-custom-whitelist-message", true);
1640+
}
1641+
16371642
@Override
16381643
public int getJoinQuitMessagePlayerCount() {
16391644
return config.getInt("hide-join-quit-messages-above", -1);
@@ -2139,7 +2144,7 @@ public boolean showZeroBaltop() {
21392144
public String getNickRegex() {
21402145
return config.getString("allowed-nicks-regex", "^[a-zA-Z_0-9§]+$");
21412146
}
2142-
2147+
21432148
@Override
21442149
public BigDecimal getMultiplier(final User user) {
21452150
BigDecimal multiplier = defaultMultiplier;

Essentials/src/main/resources/config.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -597,6 +597,10 @@ custom-new-username-message: "none"
597597
# Set to false to keep the vanilla message.
598598
use-custom-server-full-message: true
599599

600+
# Should Essentials override the vanilla "You are not whitelisted on this server" message with its own from the language file?
601+
# Set to false to keep the vanilla message.
602+
use-custom-whitelist-message: true
603+
600604
# You can disable join and quit messages when the player count reaches a certain limit.
601605
# When the player count is below this number, join/quit messages will always be shown.
602606
# Set this to -1 to always show join and quit messages regardless of player count.

Essentials/src/main/resources/messages.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1131,6 +1131,7 @@ sellCommandUsage4=/<command> blocks [amount]
11311131
sellCommandUsage4Description=Sells all (or the given amount, if specified) of blocks in your inventory
11321132
sellHandPermission=<primary>You do not have permission to hand sell.
11331133
serverFull=Server is full\!
1134+
whitelistKick=Whitelist enabled\!
11341135
serverReloading=There's a good chance you're reloading your server right now. If that's the case, why do you hate yourself? Expect no support from the EssentialsX team when using /reload.
11351136
serverTotal=<primary>Server Total\:<secondary> {0}
11361137
serverUnsupported=You are running an unsupported server version\!

Essentials/src/main/resources/plugin.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -968,6 +968,8 @@ permissions:
968968
description: Allows the user to keep their exp on death, instead of dropping it.
969969
essentials.joinfullserver:
970970
description: Allows the to join the server even if it is full
971+
essentials.whitelist.bypass:
972+
description: Allows a player to join the server even if they are not whitelisted.
971973
essentials.kick:
972974
description: Allows access to the /kick command
973975
essentials.kick.exempt:

0 commit comments

Comments
 (0)