Skip to content

Commit

Permalink
fix mini message support
Browse files Browse the repository at this point in the history
  • Loading branch information
ProdPreva1l committed Jul 25, 2024
1 parent 2bfc492 commit 83d12ad
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import info.preva1l.fadah.config.Config;
import info.preva1l.fadah.config.Lang;
import info.preva1l.fadah.multiserver.CacheSync;
import info.preva1l.fadah.utils.StringUtils;
import info.preva1l.fadah.utils.logging.TransactionLogger;
import net.milkbowl.vault.economy.Economy;
import org.bukkit.Bukkit;
Expand Down Expand Up @@ -90,10 +89,10 @@ public boolean cancel(@NotNull Player canceller) {
if (ListingCache.getListing(this.getId()) == null
|| (Config.STRICT_CHECKS.toBoolean()
&& Fadah.getINSTANCE().getDatabase().getListing(this.getId()) == null)) {
canceller.sendMessage(StringUtils.colorize(Lang.PREFIX.toFormattedString() + Lang.DOES_NOT_EXIST.toFormattedString()));
canceller.sendMessage(Lang.PREFIX.toFormattedString() + Lang.DOES_NOT_EXIST.toFormattedString());
return false;
}
canceller.sendMessage(StringUtils.colorize(Lang.PREFIX.toFormattedString() + Lang.CANCELLED.toFormattedString()));
canceller.sendMessage(Lang.PREFIX.toFormattedString() + Lang.CANCELLED.toFormattedString());
if (Fadah.getINSTANCE().getCacheSync() == null) {
ListingCache.removeListing(this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,17 @@ public String miniMessageToLegacy(String message) {
message = message.replace("<dark_gray>", "&8");
message = message.replace("<black>", "&0");
message = message.replace("<b>", "&l");
message = message.replace("<bold>", "&l");
message = message.replace("<obf>", "&k");
message = message.replace("<obfuscated>", "&k");
message = message.replace("<st>", "&m");
message = message.replace("<strikethrough>", "&m");
message = message.replace("<u>", "&n");
message = message.replace("<underline>", "&n");
message = message.replace("<i>", "&o");
message = message.replace("<italic>", "&o");
message = message.replace("<reset>", "&r");
message = message.replace("<r>", "&r");


Pattern pattern = Pattern.compile("<#[a-fA-F0-9]{6}>");
Expand All @@ -77,6 +83,7 @@ public String miniMessageToLegacy(String message) {
* @return Colorized String
*/
public String colorize(String text) {
text = miniMessageToLegacy(text);
Matcher matcher = HEX_PATTERN.matcher(text);
StringBuilder buffer = new StringBuilder();

Expand Down Expand Up @@ -107,7 +114,7 @@ public String removeColorCodes(String str) {
public String message(String message, Object... args) {
message = formatPlaceholders(message, args);

return colorize(miniMessageToLegacy(message));
return colorize(message);
}

/**
Expand Down

0 comments on commit 83d12ad

Please sign in to comment.