mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-07-31 11:35:28 +02:00
Fixed a bug where party members didn't have properly colored names, added some optimization and removed some unnecessary API
This commit is contained in:
@@ -29,6 +29,7 @@ public class AdminChatMailer extends AbstractChatMailer {
|
||||
|
||||
/**
|
||||
* Constructs an audience of admins
|
||||
*
|
||||
* @return an audience of admins
|
||||
*/
|
||||
public @NotNull Audience constructAudience() {
|
||||
@@ -37,6 +38,7 @@ public class AdminChatMailer extends AbstractChatMailer {
|
||||
|
||||
/**
|
||||
* Predicate used to filter the audience
|
||||
*
|
||||
* @return admin chat audience predicate
|
||||
*/
|
||||
public @NotNull Predicate<CommandSender> predicate() {
|
||||
@@ -47,6 +49,7 @@ public class AdminChatMailer extends AbstractChatMailer {
|
||||
|
||||
/**
|
||||
* Styles a string using a locale entry
|
||||
*
|
||||
* @param author message author
|
||||
* @param message message contents
|
||||
* @param canColor whether to replace colors codes with colors in the raw message
|
||||
@@ -54,7 +57,7 @@ public class AdminChatMailer extends AbstractChatMailer {
|
||||
*/
|
||||
public @NotNull TextComponent addStyle(@NotNull Author author, @NotNull String message, boolean canColor) {
|
||||
if(canColor) {
|
||||
return LocaleLoader.getTextComponent("Chat.Style.Admin", TextUtils.sanitizeAuthorName(author, ChatChannel.ADMIN), message);
|
||||
return LocaleLoader.getTextComponent("Chat.Style.Admin", author.getAuthoredName(ChatChannel.ADMIN), message);
|
||||
} else {
|
||||
return TextUtils.ofLegacyTextRaw(LocaleLoader.getString("Chat.Style.Admin", author.getAuthoredName(ChatChannel.ADMIN), message));
|
||||
}
|
||||
@@ -65,6 +68,14 @@ public class AdminChatMailer extends AbstractChatMailer {
|
||||
chatMessage.sendMessage();
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes a chat message from an author to an audience of admins
|
||||
*
|
||||
* @param author the author
|
||||
* @param rawString the raw message as the author typed it before any styling
|
||||
* @param isAsync whether or not this is being processed asynchronously
|
||||
* @param canColor whether or not the author can use colors in chat
|
||||
*/
|
||||
public void processChatMessage(@NotNull Author author, @NotNull String rawString, boolean isAsync, boolean canColor) {
|
||||
AdminChatMessage chatMessage = new AdminChatMessage(pluginRef, author, constructAudience(), rawString, addStyle(author, rawString, canColor));
|
||||
|
||||
@@ -77,4 +88,4 @@ public class AdminChatMailer extends AbstractChatMailer {
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
@@ -22,6 +22,14 @@ public class PartyChatMailer extends AbstractChatMailer {
|
||||
super(pluginRef);
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes a chat message from an author to an audience of party members
|
||||
*
|
||||
* @param author the author
|
||||
* @param rawString the raw message as the author typed it before any styling
|
||||
* @param isAsync whether or not this is being processed asynchronously
|
||||
* @param canColor whether or not the author can use colors in chat
|
||||
*/
|
||||
public void processChatMessage(@NotNull Author author, @NotNull String rawString, @NotNull Party party, boolean isAsync, boolean canColor, boolean isLeader) {
|
||||
PartyChatMessage chatMessage = new PartyChatMessage(pluginRef, author, constructPartyAudience(party), rawString, addStyle(author, rawString, canColor, isLeader), party);
|
||||
|
||||
@@ -33,12 +41,19 @@ public class PartyChatMailer extends AbstractChatMailer {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs an {@link Audience} of party members
|
||||
*
|
||||
* @param party target party
|
||||
* @return an {@link Audience} of party members
|
||||
*/
|
||||
public @NotNull Audience constructPartyAudience(@NotNull Party party) {
|
||||
return mcMMO.getAudiences().filter(party.getSamePartyPredicate());
|
||||
}
|
||||
|
||||
/**
|
||||
* Styles a string using a locale entry
|
||||
*
|
||||
* @param author message author
|
||||
* @param message message contents
|
||||
* @param canColor whether to replace colors codes with colors in the raw message
|
||||
@@ -47,7 +62,7 @@ public class PartyChatMailer extends AbstractChatMailer {
|
||||
public @NotNull TextComponent addStyle(@NotNull Author author, @NotNull String message, boolean canColor, boolean isLeader) {
|
||||
if(canColor) {
|
||||
if(isLeader) {
|
||||
return LocaleLoader.getTextComponent("Chat.Style.Party.Leader", TextUtils.sanitizeAuthorName(author, ChatChannel.PARTY), message);
|
||||
return LocaleLoader.getTextComponent("Chat.Style.Party.Leader", author.getAuthoredName(ChatChannel.PARTY), message);
|
||||
} else {
|
||||
return LocaleLoader.getTextComponent("Chat.Style.Party", author.getAuthoredName(ChatChannel.PARTY), message);
|
||||
}
|
||||
|
Reference in New Issue
Block a user