Skip to content

Commit

Permalink
Fix double-prefix sending on alts notification
Browse files Browse the repository at this point in the history
Reported by fuzz over Discord. Thanks fuzz
  • Loading branch information
A248 committed Mar 19, 2024
1 parent dc18139 commit f0dfc41
Show file tree
Hide file tree
Showing 5 changed files with 23 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
1 change: 1 addition & 0 deletions bans-core/src/main/resources/contributors
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Dejay
Deactivation
Folas1337
Franciscoyt94
fuzz
hawkfalcon
Healthy
Kaludi
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

1 comment on commit f0dfc41

@fuzz5566
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for fixing this and adding me to the plugin's commended users. keep improving on this amazing plugin. ❤️

Please sign in to comment.