Skip to content

Commit

Permalink
chore: don't prepend FAWE prefix to WorldGuard messages
Browse files Browse the repository at this point in the history
  • Loading branch information
PierreSchwang committed Feb 13, 2025
1 parent 61f4a48 commit f81d82d
Showing 1 changed file with 11 additions and 1 deletion.
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

0 comments on commit f81d82d

Please sign in to comment.