From abf964ce57b488c2dbb5f94ec6ca56a153a6ec9d Mon Sep 17 00:00:00 2001 From: Des Herriott Date: Tue, 16 Jul 2024 08:22:21 +0100 Subject: [PATCH 1/5] fix: crash when ReplayMod is installed https://github.com/FTBTeam/FTB-Mods-Issues/issues/1276 --- .../src/main/java/dev/ftb/mods/ftbquests/quest/TeamData.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/common/src/main/java/dev/ftb/mods/ftbquests/quest/TeamData.java b/common/src/main/java/dev/ftb/mods/ftbquests/quest/TeamData.java index 17cab9d3..57f5213b 100644 --- a/common/src/main/java/dev/ftb/mods/ftbquests/quest/TeamData.java +++ b/common/src/main/java/dev/ftb/mods/ftbquests/quest/TeamData.java @@ -718,6 +718,11 @@ public void copyData(TeamData from) { * @return the player's per-player data, or {@code Optional.empty()} if the player isn't in this team */ private Optional getOrCreatePlayerData(Player player) { + if (file == null) { + // shouldn't normally be the base, but can happen if ReplayMod is installed + // https://github.com/FTBTeam/FTB-Mods-Issues/issues/1276 + return Optional.empty(); + } if (!perPlayerData.containsKey(player.getUUID()) && file.isPlayerOnTeam(player, this)) { perPlayerData.put(player.getUUID(), new PerPlayerData()); } From 23f4e3f6bf1a10f62363a25677cf85e84469d686 Mon Sep 17 00:00:00 2001 From: Des Herriott Date: Tue, 16 Jul 2024 10:12:39 +0100 Subject: [PATCH 2/5] fix: image components now use left/center/right instead of 0/1/2 Requires FTB Library 2001.2.3 Old quest data will convert correctly https://github.com/FTBTeam/FTB-Mods-Issues/issues/1263 --- .../ftbquests/client/gui/MultilineTextEditorScreen.java | 2 +- .../mods/ftbquests/client/gui/quests/ViewQuestPanel.java | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/common/src/main/java/dev/ftb/mods/ftbquests/client/gui/MultilineTextEditorScreen.java b/common/src/main/java/dev/ftb/mods/ftbquests/client/gui/MultilineTextEditorScreen.java index 03ba2b2b..0487cef1 100644 --- a/common/src/main/java/dev/ftb/mods/ftbquests/client/gui/MultilineTextEditorScreen.java +++ b/common/src/main/java/dev/ftb/mods/ftbquests/client/gui/MultilineTextEditorScreen.java @@ -254,7 +254,7 @@ private void openImageSelector() { v -> component.image = Icon.getIcon(v), ImageResourceConfig.NONE); group.addInt("width", component.width, v -> component.width = v, 0, 1, 1000); group.addInt("height", component.height, v -> component.height = v, 0, 1, 1000); - group.addInt("align", component.align, v -> component.align = v, 0, 1, 2); + group.addEnum("align", component.align, v -> component.align = v, ImageComponent.ImageAlign.NAME_MAP, ImageComponent.ImageAlign.CENTER); group.addBool("fit", component.fit, v -> component.fit = v, false); new EditConfigScreen(group).openGui(); diff --git a/common/src/main/java/dev/ftb/mods/ftbquests/client/gui/quests/ViewQuestPanel.java b/common/src/main/java/dev/ftb/mods/ftbquests/client/gui/quests/ViewQuestPanel.java index 73709b92..685845a1 100644 --- a/common/src/main/java/dev/ftb/mods/ftbquests/client/gui/quests/ViewQuestPanel.java +++ b/common/src/main/java/dev/ftb/mods/ftbquests/client/gui/quests/ViewQuestPanel.java @@ -17,6 +17,7 @@ import dev.ftb.mods.ftblibrary.ui.misc.CompactGridLayout; import dev.ftb.mods.ftblibrary.util.TooltipList; import dev.ftb.mods.ftblibrary.util.client.ImageComponent; +import dev.ftb.mods.ftblibrary.util.client.ImageComponent.ImageAlign; import dev.ftb.mods.ftbquests.api.FTBQuestsAPI; import dev.ftb.mods.ftbquests.client.ClientQuestFile; import dev.ftb.mods.ftbquests.client.gui.ImageComponentWidget; @@ -404,9 +405,9 @@ private void addDescriptionText(boolean canEdit, Component subtitle) { if (cw.getComponent().fit) { double scale = panelText.width / (double) cw.width; cw.setSize((int) (cw.width * scale), (int) (cw.height * scale)); - } else if (cw.getComponent().align == 1) { + } else if (cw.getComponent().align == ImageAlign.CENTER) { cw.setX((panelText.width - cw.width) / 2); - } else if (cw.getComponent().align == 2) { + } else if (cw.getComponent().align == ImageAlign.RIGHT) { cw.setX(panelText.width - cw.width); } else { cw.setX(0); @@ -736,7 +737,7 @@ private void editImage(int line, ImageComponent component) { v -> component.image = Icon.getIcon(v), ImageResourceConfig.NONE); group.addInt("width", component.width, v -> component.width = v, 0, 1, 1000); group.addInt("height", component.height, v -> component.height = v, 0, 1, 1000); - group.addInt("align", component.align, v -> component.align = v, 0, 0, 2); + group.addEnum("align", component.align, v -> component.align = v, ImageAlign.NAME_MAP, ImageAlign.CENTER); group.addBool("fit", component.fit, v -> component.fit = v, false); new EditConfigScreen(group).openGui(); From cebbc4852866a9cfe1cbc0b42473e87c2a52f399 Mon Sep 17 00:00:00 2001 From: Des Herriott Date: Tue, 16 Jul 2024 10:13:09 +0100 Subject: [PATCH 3/5] build: version -> 2001.4.8 Using snapshot FTB Lib version for now --- gradle.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gradle.properties b/gradle.properties index afb39f4c..7e9e50c8 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,7 +5,7 @@ mod_id=ftbquests archives_base_name=ftb-quests minecraft_version=1.20.1 # Build time -mod_version=2001.4.7 +mod_version=2001.4.8 maven_group=dev.ftb.mods mod_author=FTB Team # Curse release @@ -18,7 +18,7 @@ fabric_loader_version=0.14.21 fabric_api_version=0.83.1+1.20.1 forge_version=47.2.19 # Deps -ftb_library_version=2001.2.1 +ftb_library_version=2001.2.3-SNAPSHOT ftb_teams_version=2001.3.0 # Optional deps teamreborn_energy_version=3.0.0 From e215e5bee4727a8250ebbc8117b2fb18fb17ed9d Mon Sep 17 00:00:00 2001 From: Des Herriott Date: Mon, 15 Jul 2024 11:56:10 +0100 Subject: [PATCH 4/5] feat: support {team} as a substitution in command rewards Also added a tooltip listing supported substitutions https://github.com/FTBTeam/FTB-Mods-Issues/issues/1270 --- .../mods/ftbquests/quest/reward/CommandReward.java | 11 +++++++++-- .../main/resources/assets/ftbquests/lang/en_us.json | 1 + 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/common/src/main/java/dev/ftb/mods/ftbquests/quest/reward/CommandReward.java b/common/src/main/java/dev/ftb/mods/ftbquests/quest/reward/CommandReward.java index 8a0af01b..c7a1f3f3 100644 --- a/common/src/main/java/dev/ftb/mods/ftbquests/quest/reward/CommandReward.java +++ b/common/src/main/java/dev/ftb/mods/ftbquests/quest/reward/CommandReward.java @@ -2,6 +2,7 @@ import dev.ftb.mods.ftblibrary.config.ConfigGroup; import dev.ftb.mods.ftbquests.quest.Quest; +import dev.ftb.mods.ftbteams.api.FTBTeamsAPI; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.ChatFormatting; @@ -17,13 +18,15 @@ import java.util.Map; public class CommandReward extends Reward { + private static final String DEFAULT_COMMAND = "/say Hi, @p!"; + private String command; private boolean elevatePerms; private boolean silent; public CommandReward(long id, Quest quest) { super(id, quest); - command = "/say Hi, @p!"; + command = DEFAULT_COMMAND; } @Override @@ -69,7 +72,7 @@ public void readNetData(FriendlyByteBuf buffer) { @Environment(EnvType.CLIENT) public void fillConfigGroup(ConfigGroup config) { super.fillConfigGroup(config); - config.addString("command", command, v -> command = v, "/say Hi, @team!").setNameKey("ftbquests.reward.ftbquests.command"); + config.addString("command", command, v -> command = v, DEFAULT_COMMAND).setNameKey("ftbquests.reward.ftbquests.command"); config.addBool("elevate", elevatePerms, v -> elevatePerms = v, false); config.addBool("silent", silent, v -> silent = v, false); } @@ -89,6 +92,10 @@ public void claim(ServerPlayer player, boolean notify) { } overrides.put("quest", quest); + overrides.put("team", FTBTeamsAPI.api().getManager().getTeamForPlayer(player) + .map(team -> team.getName().getString()) + .orElse(player.getGameProfile().getName()) + ); String cmd = command; for (Map.Entry entry : overrides.entrySet()) { diff --git a/common/src/main/resources/assets/ftbquests/lang/en_us.json b/common/src/main/resources/assets/ftbquests/lang/en_us.json index a0d15004..dbd2cca3 100644 --- a/common/src/main/resources/assets/ftbquests/lang/en_us.json +++ b/common/src/main/resources/assets/ftbquests/lang/en_us.json @@ -436,6 +436,7 @@ "ftbquests.reward.ftbquests.xp": "XP", "ftbquests.reward.ftbquests.xp_levels": "XP Levels", "ftbquests.reward.ftbquests.command": "Command", + "ftbquests.reward.ftbquests.command.tooltip": "Vanilla substitutions, e.g. @p, are supported\nSpecial substitutions:\n{x} / {y} / {z} - player's current X/Y/Z pos\n{quest} - ID of this quest\n{chapter} - ID of this chapter\n{team} - short name of player's team", "ftbquests.reward.ftbquests.command.elevate": "Run with Elevated Permission", "ftbquests.reward.ftbquests.command.elevate.tooltip": "Run the command as if the player had permission level 2", "ftbquests.reward.ftbquests.command.silent": "Silent", From be11e46bed0aa75e0543e008185732c427f27d88 Mon Sep 17 00:00:00 2001 From: Des Herriott Date: Thu, 18 Jul 2024 19:34:37 +0100 Subject: [PATCH 5/5] build: updated ftb lib dep version, changelog updated --- CHANGELOG.md | 11 +++++++++++ gradle.properties | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ebd07a82..1723f757 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,17 @@ 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). +## [2001.4.8] + +### Fixed +* Fixed image component alignment settings other than centered getting ignored + * Image alignment now uses 'left', 'center' & 'right' instead of 0, 1 & 2 (previous quest book data will be imported correctly) +* Fixed crash when ReplayMod is also installed + +### Added +* Command rewards now support a {team} substitution in the executed command, which is replaced with the player's short team name + * The command setting in the reward properties screen now has a tooltip listing all available substitutions + ## [2001.4.7] ### Fixed diff --git a/gradle.properties b/gradle.properties index 7e9e50c8..f1dedc47 100644 --- a/gradle.properties +++ b/gradle.properties @@ -18,7 +18,7 @@ fabric_loader_version=0.14.21 fabric_api_version=0.83.1+1.20.1 forge_version=47.2.19 # Deps -ftb_library_version=2001.2.3-SNAPSHOT +ftb_library_version=2001.2.3 ftb_teams_version=2001.3.0 # Optional deps teamreborn_energy_version=3.0.0