Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent /editsign on waxed signs #5492

Merged
merged 4 commits into from
Aug 28, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,11 @@ protected void run(final Server server, final User user, final String commandLab
user.sendMessage(tl("editsignCommandClearLine", line + 1));
}
} else if (args[0].equalsIgnoreCase("copy")) {
final int line = args.length == 1 ? -1 : Integer.parseInt(args[1]) - 1;
if (callSignEvent(sign, user.getBase(), sign.getLines())) {
return;
}
SrBedrock marked this conversation as resolved.
Show resolved Hide resolved

final int line = args.length == 1 ? -1 : Integer.parseInt(args[1]) - 1;
if (line == -1) {
for (int i = 0; i < 4; i++) {
// We use unformat here to prevent players from copying signs with colors that they do not have permission to use.
Expand Down Expand Up @@ -119,6 +122,9 @@ protected void run(final Server server, final User user, final String commandLab
private boolean callSignEvent(final ModifiableSign sign, final Player player, final String[] lines) {
final SignChangeEvent event;
if (VersionUtil.getServerBukkitVersion().isHigherThanOrEqualTo(VersionUtil.v1_20_1_R01)) {
if (sign.isWaxed() && !player.hasPermission("essentials.editsign.waxed.exempt")) {
return true;
}
event = new SignChangeEvent(sign.getBlock(), player, lines, sign.isFront() ? Side.FRONT : Side.BACK);
} else {
//noinspection deprecation
Expand Down Expand Up @@ -199,6 +205,11 @@ void setLine(int line, String text) {
boolean isFront() {
return side == Side.FRONT;
}

@Override
boolean isWaxed() {
return sign.isWaxed();
}
};
}
return new ModifiableSign(sign) {
Expand All @@ -221,6 +232,11 @@ void setLine(int line, String text) {
boolean isFront() {
return true;
}

@Override
boolean isWaxed() {
return false;
}
};
}

Expand All @@ -239,6 +255,8 @@ protected ModifiableSign(final Sign sign) {

abstract boolean isFront();

abstract boolean isWaxed();

Block getBlock() {
return sign.getBlock();
}
Expand Down
1 change: 1 addition & 0 deletions Essentials/src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,7 @@ permissions:
essentials.sudo.exempt: true
essentials.tempban.exempt: true
essentials.exempt.protect: true
essentials.editsign.waxed.exempt: true
essentials.nick.hideprefix:
default: false
description: Players with this permission will not have the nickname prefix applied to them