Skip to content

[WIP] Command + Permission Data Extraction #6083

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

Open
wants to merge 20 commits into
base: 2.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
# Build files
.gradle/
/jars/
generated/
out/
build/
target/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import org.bukkit.block.data.type.WallHangingSign;
import org.bukkit.block.data.type.WallSign;
import org.bukkit.block.sign.Side;
import org.bukkit.entity.Player;
import org.bukkit.event.block.SignChangeEvent;
import org.bukkit.util.Vector;

Expand Down Expand Up @@ -49,7 +48,7 @@ protected void run(final Server server, final User user, final String commandLab
throw new TranslatableException("editsignCommandLimit");
}
existingLines[line] = text;
if (callSignEvent(sign, user.getBase(), existingLines)) {
if (callSignEvent(sign, user, existingLines)) {
return;
}

Expand All @@ -61,7 +60,7 @@ protected void run(final Server server, final User user, final String commandLab
existingLines[i] = "";
}

if (callSignEvent(sign, user.getBase(), existingLines)) {
if (callSignEvent(sign, user, existingLines)) {
return;
}

Expand All @@ -71,7 +70,7 @@ protected void run(final Server server, final User user, final String commandLab
final int line = Integer.parseInt(args[1]) - 1;
existingLines[line] = "";

if (callSignEvent(sign, user.getBase(), existingLines)) {
if (callSignEvent(sign, user, existingLines)) {
return;
}

Expand Down Expand Up @@ -106,7 +105,7 @@ protected void run(final Server server, final User user, final String commandLab
user.sendTl("editsignPasteLine", line + 1, commandLabel);
}

callSignEvent(sign, user.getBase(), existingLines);
callSignEvent(sign, user, existingLines);
} else {
throw new NotEnoughArgumentsException();
}
Expand All @@ -115,22 +114,22 @@ protected void run(final Server server, final User user, final String commandLab
}
}

private boolean callSignEvent(final ModifiableSign sign, final Player player, final String[] lines) {
private boolean callSignEvent(final ModifiableSign sign, final User user, final String[] lines) {
final SignChangeEvent event;
if (VersionUtil.getServerBukkitVersion().isHigherThanOrEqualTo(VersionUtil.v1_20_1_R01)) {
if (sign.isWaxed() && !player.hasPermission("essentials.editsign.waxed.exempt")) {
if (sign.isWaxed() && !user.isAuthorized("essentials.editsign.waxed.exempt")) {
return true;
}
event = new SignChangeEvent(sign.getBlock(), player, lines, sign.isFront() ? Side.FRONT : Side.BACK);
event = new SignChangeEvent(sign.getBlock(), user.getBase(), lines, sign.isFront() ? Side.FRONT : Side.BACK);
} else {
//noinspection deprecation
event = new SignChangeEvent(sign.getBlock(), player, lines);
event = new SignChangeEvent(sign.getBlock(), user.getBase(), lines);
}

Bukkit.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
if (ess.getSettings().isDebug()) {
ess.getLogger().info("SignChangeEvent canceled for /editsign execution by " + player.getName());
ess.getLogger().info("SignChangeEvent canceled for /editsign execution by " + user.getName());
}
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ private void sendMessage(final IMessageRecipient from, final String[] args) thro

final List<IUser> recipients = new ArrayList<>();
for (IUser user : ess.getOnlineUsers()) {
if (user.getBase().hasPermission("essentials.helpop.receive")) {
if (user.isAuthorized("essentials.helpop.receive")) {
recipients.add(user);
}
}
Expand Down
Loading
Loading