Skip to content

Commit

Permalink
Merge pull request #745 from FTBTeam/1.20.1/dev
Browse files Browse the repository at this point in the history
1.20.1/dev
  • Loading branch information
desht authored Jul 18, 2024
2 parents c78001d + be11e46 commit 6a3dc8f
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 8 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<PerPlayerData> 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());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -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);
}
Expand All @@ -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<String, Object> entry : overrides.entrySet()) {
Expand Down
1 change: 1 addition & 0 deletions common/src/main/resources/assets/ftbquests/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
ftb_teams_version=2001.3.0
# Optional deps
teamreborn_energy_version=3.0.0

0 comments on commit 6a3dc8f

Please sign in to comment.