Skip to content

Commit

Permalink
Fix double-prefix sending on alts notification
Browse files Browse the repository at this point in the history
  • Loading branch information
A248 committed Mar 19, 2024
1 parent dc18139 commit 97ddc62
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,6 @@ public void notifyFoundAlts(UUID uuid, String name, NetworkAddress address, List
}
Component notification = altCheckFormatter.formatMessage(
configs.getMessagesConfig().alts().autoShow().header(), name, alts);
envEnforcer.sendToThoseWithPermission("libertybans.alts.autoshow", notification);
envEnforcer.sendToThoseWithPermissionNoPrefix("libertybans.alts.autoshow", notification);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,15 @@ protected CentralisedFuture<Void> completedVoid() {

@Override
public final CentralisedFuture<Void> sendToThoseWithPermission(String permission, ComponentLike message) {
return sendToThoseWithPermissionNoPrefix(permission, formatter.prefix(message).asComponent());
return sendToThoseWithPermissionNoPrefix(permission, formatter.prefix(message));
}

private CentralisedFuture<Void> sendToThoseWithPermissionNoPrefix(String permission, Component message) {
@Override
public final CentralisedFuture<Void> sendToThoseWithPermissionNoPrefix(String permission, ComponentLike message) {
return sendToThoseWithPermissionNoPrefixComponent(permission, message.asComponent());
}

private CentralisedFuture<Void> sendToThoseWithPermissionNoPrefixComponent(String permission, Component message) {
Consumer<P> callback;
if (interlocutor.shouldFilterIpAddresses()) {
Component stripped = interlocutor.stripIpAddresses(message);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,15 @@ public interface EnvEnforcer<@PlatformPlayer P> {
*/
CentralisedFuture<Void> sendToThoseWithPermission(String permission, ComponentLike message);

/**
* For all players with the specified permission, sends the message.
*
* @param permission the permission
* @param message the message
* @return a future completed when the operation is done
*/
CentralisedFuture<Void> sendToThoseWithPermissionNoPrefix(String permission, ComponentLike message);

/**
* Searches for a player with the given uuid, if found, invokes the callback
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ public CentralisedFuture<Void> sendToThoseWithPermission(String permission, Comp
return completedVoid();
}

@Override
public CentralisedFuture<Void> sendToThoseWithPermissionNoPrefix(String permission, ComponentLike message) {
return completedVoid();
}

@Override
public CentralisedFuture<Void> doForPlayerIfOnline(UUID uuid, Consumer<Void> callback) {
return completedVoid();
Expand Down

0 comments on commit 97ddc62

Please sign in to comment.