Skip to content

chore: don't prepend FAWE prefix to WorldGuard messages #3111

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 1 commit into
base: main
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ public class BukkitPlayer extends AbstractPlayerActor {
private final WorldEditPlugin plugin;
//FAWE start
private final PermissionAttachment permAttachment;
// We require the StackWalker to show hidden frames, due to the usage of the c.sk89q.we...AsyncCommandBuilder in WorldGuard
// (in that case, all WG references are hidden in lambdas and not shown in the default walker)
private final StackWalker stackWalker = StackWalker.getInstance(StackWalker.Option.SHOW_HIDDEN_FRAMES);

/**
* This constructs a new {@link BukkitPlayer} for the given {@link Player}.
Expand Down Expand Up @@ -222,7 +225,14 @@ public void printError(String msg) {
@Override
public void print(Component component) {
//FAWE start - Add FAWE prefix to all messages
component = Caption.color(TranslatableComponent.of("prefix", component), getLocale());
final boolean isWorldGuardCaller = stackWalker.walk(frames -> frames
.dropWhile(frame -> frame.getClassName().startsWith("com.sk89q.worldedit"))
.takeWhile(frame -> !frame.getClassName().startsWith("org.bukkit"))
.filter(frame -> frame.getClassName().startsWith("com.sk89q.worldguard"))
.findFirst()).isPresent();
if (!isWorldGuardCaller) {
component = Caption.color(TranslatableComponent.of("prefix", component), getLocale());
}
//FAWE end
TextAdapter.sendMessage(player, WorldEditText.format(component, getLocale()));
}
Expand Down
Loading