Skip to content

Commit

Permalink
added minimessage integration
Browse files Browse the repository at this point in the history
  • Loading branch information
firef1a committed Jun 3, 2024
1 parent 450f37b commit fcc2132
Show file tree
Hide file tree
Showing 6 changed files with 373 additions and 246 deletions.
26 changes: 21 additions & 5 deletions src/main/java/dev/fire/TextUtil.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package dev.fire;

import dev.fire.config.ChatTag;
import dev.fire.config.MiniMessageChatTag;
import net.minecraft.network.message.SentMessage;
import net.minecraft.text.*;
import dev.fire.config.Config;
Expand Down Expand Up @@ -159,27 +160,40 @@ public static Text replaceTags(Text text, boolean isTabList) {
for (Map.Entry<String, ChatTag> entry : DefaultConfig.oldChatTags.entrySet()) {
String key = entry.getKey();
ChatTag chattag = entry.getValue();
ChatTag custom = c.chatTags.get(key);
MiniMessageChatTag custom = c.chatTags.get(key);
ChatTag replacetag = DefaultConfig.newChatTags.get(key);

if (!Objects.equals(key, "vip")) {

text = replaceTextInternal(text, getCustomTag(replacetag, false, false), getCustomTag(custom, false, false), false);
text = replaceTextInternal(text, getCustomTag(replacetag, false, true), getCustomTag(custom, false, false), false);
text = replaceTextInternal(text, getCustomTag(replacetag, false, false), custom.getAsFormatted(), false);
text = replaceTextInternal(text, getCustomTag(replacetag, false, true), custom.getAsFormatted(), false);


// replace shortened chat tags and tab list for normal tags
boolean return_empty = !c.ShortenedChatTags && !isTabList;
text = replaceTextInternal(text, getShortCustomTag(replacetag, isTabList, false), getShortCustomTag(custom, isTabList, return_empty), false);
Text replace;
if (return_empty) {
replace = Text.empty();
} else {
replace = custom.getAsShortFormatted();
if (isTabList) replace = replace.copy().append(Text.literal(" "));
}
text = replaceTextInternal(text, getShortCustomTag(replacetag, isTabList, false), replace, false);



// check if its the tab list and if its a staff tag (staff tags in the tab list are displayed fully but with an add_space, different from above)
if (isTabList) {
if (DefaultConfig.staffList.contains(key)) {
text = replaceTextInternal(text, getCustomTag(replacetag, true, false), getCustomTag(custom, true, false), false);
text = replaceTextInternal(text, getCustomTag(replacetag, true, false), custom.getAsFormatted().copy().append(Text.literal(" ")), false);
}
}



}
}
/*
// replace profile line and arrow colors
for (String key : DefaultConfig.normalList) {
Expand Down Expand Up @@ -217,6 +231,8 @@ public static Text replaceTags(Text text, boolean isTabList) {
.withColor(custom_vip.SymbolColor))))
, false);
}
*/
return text;
}

Expand Down
Loading

0 comments on commit fcc2132

Please sign in to comment.