Skip to content

Commit

Permalink
fix issue when not all item lore showing up
Browse files Browse the repository at this point in the history
  • Loading branch information
NONPLAYT committed Jul 23, 2024
1 parent 8b9a6ec commit 51d785b
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions src/main/java/space/bxteam/ndailyrewards/managers/MenuManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import space.bxteam.ndailyrewards.utils.ItemBuilder;
import space.bxteam.ndailyrewards.utils.TextUtils;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

Expand Down Expand Up @@ -75,11 +76,13 @@ private void updateRewardsMenu(Player player) {
String material = NDailyRewards.getInstance().getConfig().getString("gui.reward.display.next.material");
String name = NDailyRewards.getInstance().getConfig().getString("gui.reward.display.next.name").replace("<dayNum>", String.valueOf(day));
int customModelData = NDailyRewards.getInstance().getConfig().getInt("gui.reward.display.next.custom-model-data");
String lore = daySection.getStringList("lore").stream()
List<String> rewardLore = daySection.getStringList("lore").stream()
.map(TextUtils::applyColor)
.collect(Collectors.joining("\n"));
.collect(Collectors.toList());
String rewardLoreJoined = String.join("\n", rewardLore);
List<String> loreFormatted = NDailyRewards.getInstance().getConfig().getStringList("gui.reward.display.next.lore").stream()
.map(s -> s.replace("<reward-lore>", lore).replace("<time-left>", timeLeftFormatted))
.map(s -> s.replace("<reward-lore>", rewardLoreJoined).replace("<time-left>", timeLeftFormatted))
.flatMap(s -> Arrays.stream(s.split("\n")))
.collect(Collectors.toList());

rewardItem = new ItemBuilder(new ItemStack(Material.valueOf(material)))
Expand Down Expand Up @@ -133,15 +136,11 @@ private ItemStack createItemStack(String type, int day, ConfigurationSection day
List<String> rewardLore = daySection.getStringList("lore").stream()
.map(TextUtils::applyColor)
.collect(Collectors.toList());
String rewardLoreJoined = String.join("\n", rewardLore);

List<String> loreFormatted = NDailyRewards.getInstance().getConfig().getStringList("gui.reward.display." + type + ".lore").stream()
.map(s -> {
StringBuilder replacedLore = new StringBuilder();
for (String loreLine : rewardLore) {
replacedLore.append(s.replace("<reward-lore>", loreLine)).append("\n");
}
return replacedLore.toString().trim();
})
.map(s -> s.replace("<reward-lore>", rewardLoreJoined))
.flatMap(s -> Arrays.stream(s.split("\n")))
.collect(Collectors.toList());

return new ItemBuilder(new ItemStack(Material.valueOf(material)))
Expand Down

0 comments on commit 51d785b

Please sign in to comment.