diff --git a/pom.xml b/pom.xml index f5e9035c..8bb1c350 100644 --- a/pom.xml +++ b/pom.xml @@ -44,14 +44,14 @@ 1.21.3-R0.1-SNAPSHOT 1.2.3-SNAPSHOT - 3.2.4-SNAPSHOT + 3.4.0 2.6.3 1.7 1.2.0 ${build.version}-SNAPSHOT - 1.5.1 + 1.5.2 -LOCAL BentoBoxWorld_Challenges diff --git a/src/main/java/world/bentobox/challenges/config/Settings.java b/src/main/java/world/bentobox/challenges/config/Settings.java index a859403d..1822c133 100644 --- a/src/main/java/world/bentobox/challenges/config/Settings.java +++ b/src/main/java/world/bentobox/challenges/config/Settings.java @@ -101,6 +101,12 @@ public class Settings implements ConfigObject @ConfigEntry(path = "gui-settings.add-completed-glow") private boolean addCompletedGlow = true; + + @ConfigComment("") + @ConfigComment("Add enchanted glow to completed levels") + @ConfigEntry(path = "gui-settings.add-completed-level-glow") + private boolean addCompletedLevelGlow = true; + @ConfigComment("") @ConfigComment("This variable allows to choose which Challenges users can see in Challenges GUI.") @ConfigComment("Valid values are:") @@ -117,6 +123,20 @@ public class Settings implements ConfigObject @ConfigEntry(path = "gui-settings.locked-level-icon") private ItemStack lockedLevelIcon = new ItemStack(Material.BOOK); + + @ConfigComment("") + @ConfigComment("This allows to change default completed level icon. If this option is set") + @ConfigComment("to null, the level icon will not be overwritten.") + @ConfigEntry(path = "gui-settings.completed-level-icon") + private ItemStack completedLevelIcon = null; + + + @ConfigComment("") + @ConfigComment("This allows to change default selected level icon. If this option is set") + @ConfigComment("to null, the level icon will not be overwritten.") + @ConfigEntry(path = "gui-settings.selected-level-icon") + private ItemStack selectedLevelIcon = null; + @ConfigComment("") @ConfigComment("This indicate if challenges data will be stored per island (true) or per player (false).") @ConfigEntry(path = "store-island-data") @@ -224,6 +244,15 @@ public boolean isAddCompletedGlow() } + /** + * @return addCompletedLevelGlow value. + */ + public boolean isAddCompletedLevelGlow() + { + return this.addCompletedLevelGlow; + } + + /** * @return disabledGameModes value. */ @@ -346,6 +375,34 @@ public ItemStack getLockedLevelIcon() } + /** + * This method returns the selectedLevelIcon value. + * @return the value of selectedLevelIcon. + */ + public ItemStack getSelectedLevelIcon() + { + if (selectedLevelIcon != null) + { + return selectedLevelIcon.clone(); + } + return null; + } + + + /** + * This method returns the completedLevelIcon value. + * @return the value of completedLevelIcon. + */ + public ItemStack getCompletedLevelIcon() + { + if (completedLevelIcon != null) + { + return completedLevelIcon.clone(); + } + return null; + } + + /** * This method returns the showCompletionTitle object. * @return the showCompletionTitle object. @@ -435,6 +492,28 @@ public void setLockedLevelIcon(ItemStack lockedLevelIcon) } + /** + * This method sets the selectedLevelIcon value. + * @param selectedLevelIcon the selectedLevelIcon new value. + * + */ + public void setSelectedLevelIcon(ItemStack selectedLevelIcon) + { + this.selectedLevelIcon = selectedLevelIcon; + } + + + /** + * This method sets the completedLevelIcon value. + * @param completedLevelIcon the completedLevelIcon new value. + * + */ + public void setCompletedLevelIcon(ItemStack completedLevelIcon) + { + this.completedLevelIcon = completedLevelIcon; + } + + /** * This method sets the userGuiMode value. * @param userGuiMode the userGuiMode new value. @@ -490,6 +569,14 @@ public void setAddCompletedGlow(boolean addCompletedGlow) this.addCompletedGlow = addCompletedGlow; } + /** + * @param addCompletedLevelGlow new addCompletedLevelGlow value. + */ + public void setAddCompletedLevelGlow(boolean addCompletedLevelGlow) + { + this.addCompletedLevelGlow = addCompletedLevelGlow; + } + /** * @param disabledGameModes new disabledGameModes value. diff --git a/src/main/java/world/bentobox/challenges/panel/admin/EditSettingsPanel.java b/src/main/java/world/bentobox/challenges/panel/admin/EditSettingsPanel.java index 840a8761..e4df5f5b 100644 --- a/src/main/java/world/bentobox/challenges/panel/admin/EditSettingsPanel.java +++ b/src/main/java/world/bentobox/challenges/panel/admin/EditSettingsPanel.java @@ -117,6 +117,7 @@ protected void build() panelBuilder.item(28, this.getSettingsButton(Button.BROADCAST)); panelBuilder.item(11, this.getSettingsButton(Button.GLOW_COMPLETED)); + panelBuilder.item(12, this.getSettingsButton(Button.GLOW_COMPLETED_LEVELS)); panelBuilder.item(20, this.getSettingsButton(Button.REMOVE_COMPLETED)); panelBuilder.item(29, this.getSettingsButton(Button.VISIBILITY_MODE)); panelBuilder.item(30, this.getSettingsButton(Button.INCLUDE_UNDEPLOYED)); @@ -331,6 +332,22 @@ private PanelItem getSettingsButton(Button button) description.add(""); description.add(this.user.getTranslation(Constants.TIPS + "click-to-toggle")); } + case GLOW_COMPLETED_LEVELS -> { + description.add(this.user.getTranslation(reference + + (this.settings.isAddCompletedLevelGlow() ? "enabled" : "disabled"))); + + icon = new ItemStack(Material.GLOWSTONE); + clickHandler = (panel, user1, clickType, i) -> { + this.settings.setAddCompletedLevelGlow(!this.settings.isAddCompletedLevelGlow()); + panel.getInventory().setItem(i, this.getSettingsButton(button).getItem()); + this.addon.saveSettings(); + return true; + }; + glow = this.settings.isAddCompletedLevelGlow(); + + description.add(""); + description.add(this.user.getTranslation(Constants.TIPS + "click-to-toggle")); + } case LOCKED_LEVEL_ICON -> { icon = this.settings.getLockedLevelIcon(); @@ -568,6 +585,7 @@ private enum Button PURGE_HISTORY, DATA_PER_ISLAND, GLOW_COMPLETED, + GLOW_COMPLETED_LEVELS, LOCKED_LEVEL_ICON, SHOW_TITLE, TITLE_SHOWTIME, diff --git a/src/main/java/world/bentobox/challenges/panel/user/ChallengesPanel.java b/src/main/java/world/bentobox/challenges/panel/user/ChallengesPanel.java index 7b8b7e1d..cd49402a 100644 --- a/src/main/java/world/bentobox/challenges/panel/user/ChallengesPanel.java +++ b/src/main/java/world/bentobox/challenges/panel/user/ChallengesPanel.java @@ -551,9 +551,23 @@ else if (level.getLevel().getLockedIcon() != null) // Glow the icon. builder.glow(level == this.lastSelectedLevel || level.isUnlocked() && - this.addon.getChallengesSettings().isAddCompletedGlow() && + this.addon.getChallengesSettings().isAddCompletedLevelGlow() && this.manager.isLevelCompleted(this.user, this.world, level.getLevel())); + // Change icon for completed level + if( level.isUnlocked() && + this.manager.isLevelCompleted(this.user, this.world, level.getLevel()) && + this.addon.getChallengesSettings().getCompletedLevelIcon() != null + ) { + builder.icon(this.addon.getChallengesSettings().getCompletedLevelIcon().clone()); + } + + // Change icon for selected level + if(level == this.lastSelectedLevel && + this.addon.getChallengesSettings().getSelectedLevelIcon() != null){ + builder.icon(this.addon.getChallengesSettings().getSelectedLevelIcon().clone()); + } + // Click Handlers are managed by custom addon buttons. return builder.build(); } diff --git a/src/main/java/world/bentobox/challenges/utils/Utils.java b/src/main/java/world/bentobox/challenges/utils/Utils.java index 6374d447..8245b6d0 100644 --- a/src/main/java/world/bentobox/challenges/utils/Utils.java +++ b/src/main/java/world/bentobox/challenges/utils/Utils.java @@ -8,7 +8,6 @@ import java.util.Set; import org.bukkit.Bukkit; -import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.Statistic; import org.bukkit.Tag; @@ -183,7 +182,7 @@ public static T getPreviousValue(T[] values, T currentValue) */ public static String sanitizeInput(String input) { - return ChatColor.stripColor( + return Util.stripColor( Util.translateColorCodes(input.toLowerCase(Locale.ENGLISH). replace(" ", "_"). replace("-", "_"))); @@ -776,7 +775,6 @@ public static String prettifyObject(ItemStack item, @Nullable PotionMeta potionM String meta = user.getTranslationOrNothing(metaReference + "potion-meta", "[type]", type, "[upgraded]", "", "[extended]", ""); - BentoBox.getInstance().logDebug("Generic ref: " + Constants.ITEM_STACKS + "generic"); specific = user.getTranslationOrNothing(Constants.ITEM_STACKS + "generic", "[type]", prettifyObject(itemType, user), "[meta]", meta); @@ -785,7 +783,6 @@ public static String prettifyObject(ItemStack item, @Nullable PotionMeta potionM // Last ditch specific = prettifyObject(itemType, user) + ": " + type; } - BentoBox.getInstance().logDebug(specific); return specific; } diff --git a/src/main/resources/locales/en-US.yml b/src/main/resources/locales/en-US.yml index 197e5c44..cc5b2ad9 100755 --- a/src/main/resources/locales/en-US.yml +++ b/src/main/resources/locales/en-US.yml @@ -635,12 +635,19 @@ challenges: enabled: "&2 Enabled" disabled: "&c Disabled" glow_completed: - name: "&f&l Glow Completed" + name: "&f&l Glow Completed Challenges" description: |- &7 Applies an enchantment glow &7 to completed challenges. enabled: "&2 Enabled" disabled: "&c Disabled" + glow_completed_levels: + name: "&f&l Glow Completed Levels" + description: |- + &7 Applies an enchantment glow + &7 to completed levels. + enabled: "&2 Enabled" + disabled: "&c Disabled" store_history: name: "&f&l Store History" description: |- diff --git a/src/main/resources/locales/pl.yml b/src/main/resources/locales/pl.yml index 3450cd04..169cd1b6 100644 --- a/src/main/resources/locales/pl.yml +++ b/src/main/resources/locales/pl.yml @@ -63,7 +63,7 @@ challenges: &7 lub wyjście z GUI previous: name: "&f&l Poprzednia strona" - description: "&7 Przełącz na &e [numer] &7 stronę" + description: "&7 Przełącz na &e [number] &7 stronę" next: name: "&f&l Następna strona" description: "&7 Przełącz na &e [number] &7 stronę" @@ -367,7 +367,7 @@ challenges: description: |- &7 Pozwala na zmianę &7 statystyk bloku docelowego. - value: "&7 Bieżący blok: &e [blok]" + value: "&7 Bieżący blok: &e [block]" statistic_items: name: "&f&l Element docelowy" description: |- @@ -709,7 +709,7 @@ challenges: name: "&f&l [statistic]" description: "[description]\t\n" environment_element: - name: "&f&l [enviroment]" + name: "&f&l [environment]" description: "[description]" search: name: "&f&l Szukaj" @@ -777,7 +777,7 @@ challenges: status: completed: "&2&l Zakończono" completed-times: "&2 Ukończono &7&l [number] &r&2 raz(-y)" - completed-times-of: "&2 Zakończono &7&l [number] &r&2 z &7&l [maks.] &r&2 + completed-times-of: "&2 Zakończono &7&l [number] &r&2 z &7&l [max] &r&2 razy" completed-times-reached: "&2&l Ukończono wszystkie &7 [max] &2 razy" cooldown: @@ -798,9 +798,9 @@ challenges: environment-single: "&7 Ograniczone do [environment]" environment-title: "&7 Ograniczone do:" environment-list: "&7 - &e [environment]\t\n" - permission-single: "&c Wymaga uprawnień [permissions]" + permission-single: "&c Wymaga uprawnień [permission]" permissions-title: "&c Wymaga uprawnień:" - permissions-list: " &c - [permissions]" + permissions-list: " &c - [permission]" island: lore: |- [blocks] @@ -823,7 +823,7 @@ challenges: [warning] item-title: "&7&l Wymagane pozycje:" item-value: " &7 - &e [item]" - items-value: " &7 - &e [numer] x [item]" + items-value: " &7 - &e [number] x [item]" warning: "&e Przedmiot(y) zostaną &c usunięte" other: lore: |- @@ -836,7 +836,7 @@ challenges: experience-warning: "&e Doświadczenie zostanie &c usunięte" money: "&7&l Wymagane pieniądze: &r&e [number]" money-warning: "&e Pieniądze zostaną &c usunięte" - level: "&7&l Wymagany poziom wyspy: &r&e [liczba]" + level: "&7&l Wymagany poziom wyspy: &r&e [number]" statistic: lore: |- [statistic] @@ -996,7 +996,7 @@ challenges: unknown-challenge: "&cNieznane wyzwanie" not-valid-integer: |- &c Podana liczba całkowita "[value]" jest nieprawidłowa! - Wartość powinna mieścić się w zakresie od [min] do [maks]. + Wartość powinna mieścić się w zakresie od [min] do [max]. not-deployed: "&c Challenge nie został wdrożony!" not-on-island: "&cMusisz być na swojej wyspie by to zrobic!" challenge-level-not-available: "&c Nie odblokowałeś wymaganego poziomu, aby ukończyć