Skip to content

Commit

Permalink
patch text format reparsing reliability
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Dec 22, 2020
1 parent 41448a7 commit 6012618
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.denizenscript.denizen.objects.EntityTag;
import com.denizenscript.denizen.objects.ItemTag;
import com.denizenscript.denizencore.utilities.CoreUtilities;
import com.denizenscript.denizencore.utilities.debugging.Debug;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.chat.*;

Expand Down Expand Up @@ -179,7 +180,7 @@ public static BaseComponent[] parse(String str, ChatColor baseColor, boolean cle
base.addExtra(new TextComponent(str)); // This is for compat with how Spigot does parsing of plaintext.
return new BaseComponent[] { base };
}
TextComponent root = new TextComponent(str.substring(0, firstChar));
TextComponent root = new TextComponent();
TextComponent base = new TextComponent();
if (cleanBase) {
base.setBold(false);
Expand All @@ -188,6 +189,10 @@ public static BaseComponent[] parse(String str, ChatColor baseColor, boolean cle
base.setUnderlined(false);
base.setObfuscated(false);
base.setColor(baseColor);
root.setText(str.substring(0, firstChar));
}
else {
base.setText(str.substring(0, firstChar));
}
root.addExtra(base);
str = str.substring(firstChar);
Expand Down Expand Up @@ -353,6 +358,11 @@ else if (colorChar.length() == 7) {
else if (innardType.equals("font")) {
nextText.setFont(innardBase.get(1));
}
else {
if (Debug.verbose) {
Debug.echoError("Text parse issue: cannot interpret type '" + innardType + "' with " + innardParts.size() + " parts.");
}
}
}
i = endBracket;
started = endBracket + 1;
Expand Down

0 comments on commit 6012618

Please sign in to comment.