Skip to content

Commit

Permalink
Merge pull request #741 from FTBTeam/1.20.4/dev
Browse files Browse the repository at this point in the history
1.20.4/dev
  • Loading branch information
MichaelHillcox authored Jul 2, 2024
2 parents 575c6ea + 759bee6 commit 2662cdb
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 20 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

# [2004.2.3]

### Fixed
* Fixed raw json text in quest descriptions not always being recognised
* Fixed chapter and chapter group creation popups moving in and out with the chapter panel when it's not pinned

# [2004.2.2]

### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ public void onClicked(MouseButton button) {
List<ContextMenuItem> contextMenu = new ArrayList<>();
contextMenu.add(new ContextMenuItem(Component.translatable("ftbquests.chapter"), ThemeProperties.ADD_ICON.get(), b -> {
StringConfig c = new StringConfig(Pattern.compile("^.+$"));
EditStringConfigOverlay<String> overlay = new EditStringConfigOverlay<>(parent, c, accepted -> {
EditStringConfigOverlay<String> overlay = new EditStringConfigOverlay<>(parent.getParent(), c, accepted -> {
chapterPanel.questScreen.openGui();

if (accepted && !c.getValue().isEmpty()) {
Expand All @@ -209,7 +209,7 @@ public void onClicked(MouseButton button) {

contextMenu.add(new ContextMenuItem(Component.translatable("ftbquests.chapter_group"), ThemeProperties.ADD_ICON.get(), b -> {
StringConfig c = new StringConfig(Pattern.compile("^.+$"));
EditStringConfigOverlay<String> overlay = new EditStringConfigOverlay<>(parent, c, accepted -> {
EditStringConfigOverlay<String> overlay = new EditStringConfigOverlay<>(parent.getParent(), c, accepted -> {
chapterPanel.questScreen.openGui();

if (accepted) {
Expand Down Expand Up @@ -286,7 +286,7 @@ public void onClicked(MouseButton button) {
playClickSound();

StringConfig c = new StringConfig(Pattern.compile("^.+$"));
EditStringConfigOverlay<String> overlay = new EditStringConfigOverlay<>(parent, c, accepted -> {
EditStringConfigOverlay<String> overlay = new EditStringConfigOverlay<>(parent.getParent(), c, accepted -> {
chapterPanel.questScreen.openGui();

if (accepted && !c.getValue().isEmpty()) {
Expand Down
29 changes: 13 additions & 16 deletions common/src/main/java/dev/ftb/mods/ftbquests/util/TextUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,29 @@

import com.google.gson.JsonParseException;
import dev.ftb.mods.ftblibrary.util.client.ClientTextComponentUtils;
import net.minecraft.ChatFormatting;
import net.minecraft.network.chat.Component;

import java.util.regex.Pattern;
import net.minecraft.network.chat.MutableComponent;

public class TextUtils {
private static final Pattern JSON_TEXT_PATTERN = Pattern.compile("^[{\\[]\\s*\"");

/**
* Parse some rich text into a Component. Use vanilla-style raw JSON if possible, fall back to old-style FTB
* Parse some rich text into a Component. Use vanilla-style raw JSON if applicable, fall back to old-style FTB
* Quests rich text otherwise. (FTB Quests rich text is more concise, raw JSON is much more powerful)
*
* @param str the raw string to parse
* @return a component, which could be the error message if parsing failed
*/
public static Component parseRawText(String str) {
return JSON_TEXT_PATTERN.matcher(str).find() ?
deserializeRawJsonText(str) :
ClientTextComponentUtils.parse(str);
}

private static Component deserializeRawJsonText(String raw) {
try {
return Component.Serializer.fromJson(raw);
} catch (JsonParseException e) {
return Component.literal("ERROR: " + e.getMessage()).withStyle(ChatFormatting.RED);
String str2 = str.trim();
if (str2.startsWith("[") && str2.endsWith("]") || str2.startsWith("{") && str2.endsWith("}")) {
// could be JSON raw text, but not for definite...
try {
MutableComponent res = Component.Serializer.fromJson(str2);
if (res != null) {
return res;
}
} catch (JsonParseException ignored) {
}
}
return ClientTextComponentUtils.parse(str);
}
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ archives_base_name=ftb-quests
minecraft_version=1.20.4

# Build time
mod_version=2004.2.2
mod_version=2004.2.3
maven_group=dev.ftb.mods
mod_author=FTB Team

Expand Down

0 comments on commit 2662cdb

Please sign in to comment.