diff --git a/src/main/java/world/bentobox/challenges/panel/admin/EditChallengeGUI.java b/src/main/java/world/bentobox/challenges/panel/admin/EditChallengeGUI.java index f77951f..812b58f 100644 --- a/src/main/java/world/bentobox/challenges/panel/admin/EditChallengeGUI.java +++ b/src/main/java/world/bentobox/challenges/panel/admin/EditChallengeGUI.java @@ -280,7 +280,7 @@ public class EditChallengeGUI extends CommonGUI return null; } - return new PanelItem(icon, name, description, glow, clickHandler, false); + return new PanelItem(icon, name, GuiUtils.stringSplit(description), glow, clickHandler, false); } @@ -305,11 +305,12 @@ public class EditChallengeGUI extends CommonGUI for (Challenge.ChallengeType type : Challenge.ChallengeType.values()) { - values.add((this.challenge.getChallengeType().equals(type) ? "§2" : "§c") + + values.add((this.challenge.getChallengeType().equals(type) ? "&2" : "&c") + this.user.getTranslation("challenges.gui.admin.descriptions." + type.name().toLowerCase())); } - name = this.user.getTranslation("challenges.gui.admin.buttons.type"); + name = this.user.getTranslation("challenges.gui.admin.buttons.type", + "[value]", this.challenge.getChallengeType().name()); description = values; if (this.challenge.getChallengeType().equals(Challenge.ChallengeType.ISLAND)) @@ -450,7 +451,7 @@ public class EditChallengeGUI extends CommonGUI for (World.Environment environment : World.Environment.values()) { - values.add((this.challenge.getEnvironment().contains(environment.name()) ? "§2" : "§c") + + values.add((this.challenge.getEnvironment().contains(environment.name()) ? "&2" : "&c") + this.user.getTranslation("challenges.gui.admin.descriptions." + environment.name().toLowerCase())); } @@ -1153,7 +1154,7 @@ public class EditChallengeGUI extends CommonGUI return null; } - return new PanelItem(icon, name, description, glow, clickHandler, false); + return new PanelItem(icon, name, GuiUtils.stringSplit(description), glow, clickHandler, false); } diff --git a/src/main/java/world/bentobox/challenges/panel/admin/EditLevelGUI.java b/src/main/java/world/bentobox/challenges/panel/admin/EditLevelGUI.java index e3113a5..75c7159 100644 --- a/src/main/java/world/bentobox/challenges/panel/admin/EditLevelGUI.java +++ b/src/main/java/world/bentobox/challenges/panel/admin/EditLevelGUI.java @@ -13,11 +13,10 @@ import world.bentobox.bentobox.api.panels.PanelItem; import world.bentobox.bentobox.api.panels.builders.PanelBuilder; import world.bentobox.bentobox.api.panels.builders.PanelItemBuilder; import world.bentobox.bentobox.api.user.User; -import world.bentobox.bentobox.util.ItemParser; import world.bentobox.challenges.ChallengesAddon; import world.bentobox.challenges.ChallengesManager; -import world.bentobox.challenges.database.object.ChallengeLevel; import world.bentobox.challenges.database.object.Challenge; +import world.bentobox.challenges.database.object.ChallengeLevel; import world.bentobox.challenges.panel.CommonGUI; import world.bentobox.challenges.panel.util.ItemSwitchGUI; import world.bentobox.challenges.panel.util.NumberGUI; @@ -253,7 +252,7 @@ public class EditLevelGUI extends CommonGUI return null; } - return new PanelItem(icon, name, description, glow, clickHandler, false); + return new PanelItem(icon, name, GuiUtils.stringSplit(description), glow, clickHandler, false); } @@ -266,7 +265,7 @@ public class EditLevelGUI extends CommonGUI { return new PanelItemBuilder(). name(challenge.getFriendlyName()). - description(challenge.getDescription()). + description(GuiUtils.stringSplit(challenge.getDescription())). icon(challenge.getIcon()). clickHandler((panel, user1, clickType, slot) -> { // Open challenges edit screen. @@ -591,7 +590,7 @@ public class EditLevelGUI extends CommonGUI return null; } - return new PanelItem(icon, name, description, glow, clickHandler, false); + return new PanelItem(icon, name, GuiUtils.stringSplit(description), glow, clickHandler, false); } diff --git a/src/main/java/world/bentobox/challenges/panel/admin/EditSettingsGUI.java b/src/main/java/world/bentobox/challenges/panel/admin/EditSettingsGUI.java index 16625d6..1617f76 100644 --- a/src/main/java/world/bentobox/challenges/panel/admin/EditSettingsGUI.java +++ b/src/main/java/world/bentobox/challenges/panel/admin/EditSettingsGUI.java @@ -66,7 +66,7 @@ public class EditSettingsGUI extends CommonGUI // resetChallenges panelBuilder.item(19, new PanelItemBuilder(). name(this.user.getTranslation("challenges.gui.admin.buttons.reset")). - description(this.user.getTranslation("challenges.gui.admin.descriptions.reset")). + description(GuiUtils.stringSplit(this.user.getTranslation("challenges.gui.admin.descriptions.reset"))). icon(Material.LAVA_BUCKET). clickHandler((panel, user1, clickType, i) -> { this.addon.getChallengesSettings().setResetChallenges( @@ -79,7 +79,7 @@ public class EditSettingsGUI extends CommonGUI // broadcastMessages panelBuilder.item(20, new PanelItemBuilder(). name(this.user.getTranslation("challenges.gui.admin.buttons.broadcast")). - description(this.user.getTranslation("challenges.gui.admin.descriptions.broadcast")). + description(GuiUtils.stringSplit(this.user.getTranslation("challenges.gui.admin.descriptions.broadcast"))). icon(Material.JUKEBOX). clickHandler((panel, user1, clickType, i) -> { this.addon.getChallengesSettings().setBroadcastMessages( @@ -92,7 +92,7 @@ public class EditSettingsGUI extends CommonGUI // removeCompleteOneTimeChallenges panelBuilder.item(21, new PanelItemBuilder(). name(this.user.getTranslation("challenges.gui.admin.buttons.remove-on-complete")). - description(this.user.getTranslation("challenges.gui.admin.descriptions.remove-on-complete")). + description(GuiUtils.stringSplit(this.user.getTranslation("challenges.gui.admin.descriptions.remove-on-complete"))). icon(Material.MAGMA_BLOCK). clickHandler((panel, user1, clickType, i) -> { this.addon.getChallengesSettings().setRemoveCompleteOneTimeChallenges( @@ -105,7 +105,7 @@ public class EditSettingsGUI extends CommonGUI // addCompletedGlow panelBuilder.item(22, new PanelItemBuilder(). name(this.user.getTranslation("challenges.gui.admin.buttons.glow")). - description(this.user.getTranslation("challenges.gui.admin.descriptions.glow")). + description(GuiUtils.stringSplit(this.user.getTranslation("challenges.gui.admin.descriptions.glow"))). icon(Material.GLOWSTONE). clickHandler((panel, user1, clickType, i) -> { this.addon.getChallengesSettings().setAddCompletedGlow( @@ -118,7 +118,7 @@ public class EditSettingsGUI extends CommonGUI // freeChallengesAtTheTop panelBuilder.item(23, new PanelItemBuilder(). name(this.user.getTranslation("challenges.gui.admin.buttons.free-challenges")). - description(this.user.getTranslation("challenges.gui.admin.descriptions.free-challenges")). + description(GuiUtils.stringSplit(this.user.getTranslation("challenges.gui.admin.descriptions.free-challenges"))). icon(Material.FILLED_MAP). clickHandler((panel, user1, clickType, i) -> { this.addon.getChallengesSettings().setFreeChallengesFirst( diff --git a/src/main/java/world/bentobox/challenges/panel/admin/ListChallengesGUI.java b/src/main/java/world/bentobox/challenges/panel/admin/ListChallengesGUI.java index 77e98f8..ad76912 100644 --- a/src/main/java/world/bentobox/challenges/panel/admin/ListChallengesGUI.java +++ b/src/main/java/world/bentobox/challenges/panel/admin/ListChallengesGUI.java @@ -134,7 +134,7 @@ public class ListChallengesGUI extends CommonGUI { PanelItemBuilder itemBuilder = new PanelItemBuilder(). name(challenge.getFriendlyName()). - description(challenge.getDescription()). + description(GuiUtils.stringSplit(challenge.getDescription())). icon(challenge.getIcon()). glow(challenge.isDeployed()); diff --git a/src/main/java/world/bentobox/challenges/panel/admin/ListLevelsGUI.java b/src/main/java/world/bentobox/challenges/panel/admin/ListLevelsGUI.java index 6a9b967..5267d10 100644 --- a/src/main/java/world/bentobox/challenges/panel/admin/ListLevelsGUI.java +++ b/src/main/java/world/bentobox/challenges/panel/admin/ListLevelsGUI.java @@ -134,7 +134,7 @@ public class ListLevelsGUI extends CommonGUI { PanelItemBuilder itemBuilder = new PanelItemBuilder(). name(challengeLevel.getFriendlyName()). - description(challengeLevel.getUnlockMessage()). + description(GuiUtils.stringSplit(challengeLevel.getUnlockMessage())). icon(challengeLevel.getIcon()). glow(false); diff --git a/src/main/java/world/bentobox/challenges/panel/admin/ListUsersGUI.java b/src/main/java/world/bentobox/challenges/panel/admin/ListUsersGUI.java index d00503c..c7c5461 100644 --- a/src/main/java/world/bentobox/challenges/panel/admin/ListUsersGUI.java +++ b/src/main/java/world/bentobox/challenges/panel/admin/ListUsersGUI.java @@ -216,7 +216,7 @@ public class ListUsersGUI extends CommonGUI return new PanelItemBuilder(). name(player.getName()). icon(Material.BARRIER). - description(this.user.getTranslation("general.errors.player-has-no-island")). + description(GuiUtils.stringSplit(this.user.getTranslation("general.errors.player-has-no-island"))). clickHandler((panel, user1, clickType, slot) -> false). build(); } @@ -258,7 +258,7 @@ public class ListUsersGUI extends CommonGUI for (int i = 0; i < ViewMode.values().length; i++) { - values.add((this.modeIndex == i ? "§2" : "§c") + + values.add((this.modeIndex == i ? "&2" : "&c") + this.user.getTranslation("challenges.gui.admin.descriptions." + ViewMode.values()[i].name().toLowerCase())); } @@ -267,7 +267,7 @@ public class ListUsersGUI extends CommonGUI name(this.user.getTranslation("challenges.gui.admin.buttons.toggle-users", "[value]", this.user.getTranslation("challenges.gui.admin.descriptions." + ViewMode.values()[this.modeIndex].name().toLowerCase()))). - description(values). + description(GuiUtils.stringSplit(values)). icon(Material.STONE_BUTTON). clickHandler( (panel, user1, clickType, slot) -> { diff --git a/src/main/java/world/bentobox/challenges/panel/user/ChallengesGUI.java b/src/main/java/world/bentobox/challenges/panel/user/ChallengesGUI.java index b5f2a51..a1913f5 100644 --- a/src/main/java/world/bentobox/challenges/panel/user/ChallengesGUI.java +++ b/src/main/java/world/bentobox/challenges/panel/user/ChallengesGUI.java @@ -5,7 +5,6 @@ import org.bukkit.Material; import org.bukkit.World; import org.bukkit.inventory.ItemStack; import java.util.ArrayList; -import java.util.Collections; import java.util.List; import world.bentobox.bentobox.api.panels.PanelItem; @@ -17,6 +16,7 @@ import world.bentobox.challenges.ChallengesManager; import world.bentobox.challenges.database.object.Challenge; import world.bentobox.challenges.panel.CommonGUI; import world.bentobox.challenges.panel.TryToComplete; +import world.bentobox.challenges.utils.GuiUtils; import world.bentobox.challenges.utils.LevelStatus; @@ -320,7 +320,7 @@ public class ChallengesGUI extends CommonGUI return new PanelItemBuilder(). icon(challenge.getIcon()). name(challenge.getFriendlyName().isEmpty() ? challenge.getUniqueId() : challenge.getFriendlyName()). - description(this.createChallengeDescription(challenge)). + description(GuiUtils.stringSplit(this.createChallengeDescription(challenge))). clickHandler((panel, user1, clickType, slot) -> { new TryToComplete(this.addon, this.user, @@ -496,8 +496,7 @@ public class ChallengesGUI extends CommonGUI if (level.isUnlocked()) { icon = level.getLevel().getIcon(); - description = Collections.singletonList( - this.user.getTranslation("challenges.navigation", "[level]", name)); + description = GuiUtils.stringSplit(this.user.getTranslation("challenges.navigation", "[level]", name)); clickHandler = (panel, user1, clickType, slot) -> { this.lastSelectedLevel = level; @@ -514,7 +513,7 @@ public class ChallengesGUI extends CommonGUI { icon = new ItemStack(Material.BOOK); - description = Collections.singletonList( + description = GuiUtils.stringSplit( this.user.getTranslation("challenges.to-complete", "[challengesToDo]", Integer.toString(level.getNumberOfChallengesStillToDo()), "[thisLevel]", level.getPreviousLevel().getFriendlyName())); diff --git a/src/main/java/world/bentobox/challenges/panel/util/ItemSwitchGUI.java b/src/main/java/world/bentobox/challenges/panel/util/ItemSwitchGUI.java index 1188ec5..2d44739 100644 --- a/src/main/java/world/bentobox/challenges/panel/util/ItemSwitchGUI.java +++ b/src/main/java/world/bentobox/challenges/panel/util/ItemSwitchGUI.java @@ -14,6 +14,7 @@ import world.bentobox.bentobox.api.panels.PanelItem; import world.bentobox.bentobox.api.panels.PanelListener; import world.bentobox.bentobox.api.panels.builders.PanelBuilder; import world.bentobox.bentobox.api.user.User; +import world.bentobox.challenges.utils.GuiUtils; /** @@ -123,7 +124,7 @@ public class ItemSwitchGUI return null; } - return new PanelItem(icon, name, description, false, clickHandler, false); + return new PanelItem(icon, name, GuiUtils.stringSplit(description), false, clickHandler, false); } diff --git a/src/main/java/world/bentobox/challenges/panel/util/NumberGUI.java b/src/main/java/world/bentobox/challenges/panel/util/NumberGUI.java index 8917303..6eb0376 100644 --- a/src/main/java/world/bentobox/challenges/panel/util/NumberGUI.java +++ b/src/main/java/world/bentobox/challenges/panel/util/NumberGUI.java @@ -238,7 +238,7 @@ public class NumberGUI return null; } - return new PanelItem(icon, name, description, glow, clickHandler, false); + return new PanelItem(icon, name, GuiUtils.stringSplit(description), glow, clickHandler, false); } diff --git a/src/main/java/world/bentobox/challenges/panel/util/SelectChallengeGUI.java b/src/main/java/world/bentobox/challenges/panel/util/SelectChallengeGUI.java index aa01327..ab6bdab 100644 --- a/src/main/java/world/bentobox/challenges/panel/util/SelectChallengeGUI.java +++ b/src/main/java/world/bentobox/challenges/panel/util/SelectChallengeGUI.java @@ -127,7 +127,7 @@ public class SelectChallengeGUI { return new PanelItemBuilder(). name(challenge.getFriendlyName()). - description(challenge.getDescription()). + description(GuiUtils.stringSplit(challenge.getDescription())). icon(challenge.getIcon()). clickHandler((panel, user1, clickType, slot) -> { this.consumer.accept(true, challenge); diff --git a/src/main/java/world/bentobox/challenges/panel/util/StringListGUI.java b/src/main/java/world/bentobox/challenges/panel/util/StringListGUI.java index 2a7c169..964d531 100644 --- a/src/main/java/world/bentobox/challenges/panel/util/StringListGUI.java +++ b/src/main/java/world/bentobox/challenges/panel/util/StringListGUI.java @@ -3,7 +3,10 @@ package world.bentobox.challenges.panel.util; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; -import java.util.*; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.List; import java.util.function.BiConsumer; import net.wesjd.anvilgui.AnvilGUI; @@ -174,7 +177,7 @@ public class StringListGUI return null; } - return new PanelItem(icon, name, description, false, clickHandler, false); + return new PanelItem(icon, name, GuiUtils.stringSplit(description), false, clickHandler, false); } diff --git a/src/main/java/world/bentobox/challenges/utils/GuiUtils.java b/src/main/java/world/bentobox/challenges/utils/GuiUtils.java index ecde0d0..da5eebe 100644 --- a/src/main/java/world/bentobox/challenges/utils/GuiUtils.java +++ b/src/main/java/world/bentobox/challenges/utils/GuiUtils.java @@ -6,7 +6,6 @@ import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.entity.EntityType; import org.bukkit.inventory.ItemStack; - import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -385,4 +384,22 @@ public class GuiUtils return result; } + + + /** + * Simple splitter for all strings in list. + * @param stringList - list of string to be split + * @return list of split strings + */ + public static List stringSplit(List stringList) + { + if (stringList.isEmpty()) + { + return stringList; + } + + List newList = new ArrayList<>(stringList.size()); + stringList.stream().map(GuiUtils::stringSplit).forEach(newList::addAll); + return newList; + } } \ No newline at end of file diff --git a/src/main/resources/locales/en-US.yml b/src/main/resources/locales/en-US.yml index 95631ef..fff97b6 100755 --- a/src/main/resources/locales/en-US.yml +++ b/src/main/resources/locales/en-US.yml @@ -134,7 +134,7 @@ challenges: search-radius: Search radius settings: Settings toggle-users: Choose players - type: Challenge Type + type: 'Challenge Type: [value]' waiver-amount: Waiver Amount import: Import choose-challenge-title: Challenges List