Skip to content

Commit

Permalink
feat: allow rewards to be excluded from "claim all rewards"
Browse files Browse the repository at this point in the history
Thanks @MasterOfBob777 and @Darkmega18

FTBTeam/FTB-Mods-Issues#81
  • Loading branch information
desht committed Oct 14, 2022
1 parent 3e04438 commit 46ee5f7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,7 @@
import dev.ftb.mods.ftbquests.gui.quests.QuestScreen;
import dev.ftb.mods.ftbquests.integration.FTBQuestsJEIHelper;
import dev.ftb.mods.ftbquests.net.ClaimRewardMessage;
import dev.ftb.mods.ftbquests.quest.Chapter;
import dev.ftb.mods.ftbquests.quest.Quest;
import dev.ftb.mods.ftbquests.quest.QuestFile;
import dev.ftb.mods.ftbquests.quest.QuestObjectBase;
import dev.ftb.mods.ftbquests.quest.QuestObjectType;
import dev.ftb.mods.ftbquests.quest.TeamData;
import dev.ftb.mods.ftbquests.quest.*;
import dev.ftb.mods.ftbquests.util.ProgressChange;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
Expand All @@ -35,17 +30,17 @@
* @author LatvianModder
*/
public abstract class Reward extends QuestObjectBase {
public Quest quest;
public final Quest quest;

public Tristate team;
public RewardAutoClaim autoclaim;
public boolean optional;
private Tristate team;
protected RewardAutoClaim autoclaim;
private boolean excludeFromClaimAll;

public Reward(Quest q) {
quest = q;
team = Tristate.DEFAULT;
autoclaim = RewardAutoClaim.DEFAULT;
optional = getType().getExcludeFromListRewards();
excludeFromClaimAll = getType().getExcludeFromListRewards();
}

@Override
Expand Down Expand Up @@ -83,31 +78,31 @@ public void writeData(CompoundTag nbt) {
nbt.putString("auto", autoclaim.id);
}

if (optional) nbt.putBoolean("optional", optional);
if (excludeFromClaimAll) nbt.putBoolean("exclude_from_claim_all", excludeFromClaimAll);
}

@Override
public void readData(CompoundTag nbt) {
super.readData(nbt);
team = Tristate.read(nbt, "team_reward");
autoclaim = RewardAutoClaim.NAME_MAP.get(nbt.getString("auto"));
optional = nbt.getBoolean("optional");
excludeFromClaimAll = nbt.getBoolean("exclude_from_claim_all");
}

@Override
public void writeNetData(FriendlyByteBuf buffer) {
super.writeNetData(buffer);
Tristate.NAME_MAP.write(buffer, team);
RewardAutoClaim.NAME_MAP.write(buffer, autoclaim);
buffer.writeBoolean(optional);
buffer.writeBoolean(excludeFromClaimAll);
}

@Override
public void readNetData(FriendlyByteBuf buffer) {
super.readNetData(buffer);
team = Tristate.NAME_MAP.read(buffer);
autoclaim = RewardAutoClaim.NAME_MAP.read(buffer);
optional = buffer.readBoolean();
excludeFromClaimAll = buffer.readBoolean();
}

@Override
Expand All @@ -116,7 +111,7 @@ public void getConfig(ConfigGroup config) {
super.getConfig(config);
config.addEnum("team", team, v -> team = v, Tristate.NAME_MAP).setNameKey("ftbquests.reward.team_reward");
config.addEnum("autoclaim", autoclaim, v -> autoclaim = v, RewardAutoClaim.NAME_MAP).setNameKey("ftbquests.reward.autoclaim");
config.addBool("optional", optional, v -> optional = v, optional).setNameKey("ftbquests.reward.optional");
config.addBool("exclude_from_claim_all", excludeFromClaimAll, v -> excludeFromClaimAll = v, excludeFromClaimAll).setNameKey("ftbquests.reward.exclude_from_claim_all");
}

public abstract void claim(ServerPlayer player, boolean notify);
Expand Down Expand Up @@ -246,7 +241,7 @@ public void onButtonClicked(Button button, boolean canClick) {
}

public boolean getExcludeFromClaimAll() {
return optional;
return excludeFromClaimAll;
}

@Nullable
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 @@ -312,6 +312,7 @@
"ftbquests.reward.autoclaim.invisible": "Enabled, Invisible",
"ftbquests.reward.claim_all": "Claim All Rewards",
"ftbquests.reward.collected": "Reward Collected!",
"ftbquests.reward.exclude_from_claim_all": "Exclude from Claim All",
"ftbquests.reward.random_bonus": "Random Bonus",
"ftbquests.reward.ftbquests.item": "Item",
"ftbquests.reward.ftbquests.item.count": "Count",
Expand Down

0 comments on commit 46ee5f7

Please sign in to comment.