Skip to content

Commit d51ef11

Browse files
authored
Merge pull request #390 from BentoBoxWorld/develop
Version 1.5.2
2 parents 45692bf + d7e4283 commit d51ef11

File tree

7 files changed

+140
-17
lines changed

7 files changed

+140
-17
lines changed

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,14 @@
4444
<!-- More visible way how to change dependency versions -->
4545
<spigot.version>1.21.3-R0.1-SNAPSHOT</spigot.version>
4646
<spigot-annotations.version>1.2.3-SNAPSHOT</spigot-annotations.version>
47-
<bentobox.version>3.2.4-SNAPSHOT</bentobox.version>
47+
<bentobox.version>3.4.0</bentobox.version>
4848
<level.version>2.6.3</level.version>
4949
<vault.version>1.7</vault.version>
5050
<panelutils.version>1.2.0</panelutils.version>
5151
<!-- Revision variable removes warning about dynamic version -->
5252
<revision>${build.version}-SNAPSHOT</revision>
5353
<!-- This allows to change between versions and snapshots. -->
54-
<build.version>1.5.1</build.version>
54+
<build.version>1.5.2</build.version>
5555
<build.number>-LOCAL</build.number>
5656
<!-- Sonar Cloud -->
5757
<sonar.projectKey>BentoBoxWorld_Challenges</sonar.projectKey>

src/main/java/world/bentobox/challenges/config/Settings.java

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,12 @@ public class Settings implements ConfigObject
101101
@ConfigEntry(path = "gui-settings.add-completed-glow")
102102
private boolean addCompletedGlow = true;
103103

104+
105+
@ConfigComment("")
106+
@ConfigComment("Add enchanted glow to completed levels")
107+
@ConfigEntry(path = "gui-settings.add-completed-level-glow")
108+
private boolean addCompletedLevelGlow = true;
109+
104110
@ConfigComment("")
105111
@ConfigComment("This variable allows to choose which Challenges users can see in Challenges GUI.")
106112
@ConfigComment("Valid values are:")
@@ -117,6 +123,20 @@ public class Settings implements ConfigObject
117123
@ConfigEntry(path = "gui-settings.locked-level-icon")
118124
private ItemStack lockedLevelIcon = new ItemStack(Material.BOOK);
119125

126+
127+
@ConfigComment("")
128+
@ConfigComment("This allows to change default completed level icon. If this option is set")
129+
@ConfigComment("to null, the level icon will not be overwritten.")
130+
@ConfigEntry(path = "gui-settings.completed-level-icon")
131+
private ItemStack completedLevelIcon = null;
132+
133+
134+
@ConfigComment("")
135+
@ConfigComment("This allows to change default selected level icon. If this option is set")
136+
@ConfigComment("to null, the level icon will not be overwritten.")
137+
@ConfigEntry(path = "gui-settings.selected-level-icon")
138+
private ItemStack selectedLevelIcon = null;
139+
120140
@ConfigComment("")
121141
@ConfigComment("This indicate if challenges data will be stored per island (true) or per player (false).")
122142
@ConfigEntry(path = "store-island-data")
@@ -224,6 +244,15 @@ public boolean isAddCompletedGlow()
224244
}
225245

226246

247+
/**
248+
* @return addCompletedLevelGlow value.
249+
*/
250+
public boolean isAddCompletedLevelGlow()
251+
{
252+
return this.addCompletedLevelGlow;
253+
}
254+
255+
227256
/**
228257
* @return disabledGameModes value.
229258
*/
@@ -346,6 +375,34 @@ public ItemStack getLockedLevelIcon()
346375
}
347376

348377

378+
/**
379+
* This method returns the selectedLevelIcon value.
380+
* @return the value of selectedLevelIcon.
381+
*/
382+
public ItemStack getSelectedLevelIcon()
383+
{
384+
if (selectedLevelIcon != null)
385+
{
386+
return selectedLevelIcon.clone();
387+
}
388+
return null;
389+
}
390+
391+
392+
/**
393+
* This method returns the completedLevelIcon value.
394+
* @return the value of completedLevelIcon.
395+
*/
396+
public ItemStack getCompletedLevelIcon()
397+
{
398+
if (completedLevelIcon != null)
399+
{
400+
return completedLevelIcon.clone();
401+
}
402+
return null;
403+
}
404+
405+
349406
/**
350407
* This method returns the showCompletionTitle object.
351408
* @return the showCompletionTitle object.
@@ -435,6 +492,28 @@ public void setLockedLevelIcon(ItemStack lockedLevelIcon)
435492
}
436493

437494

495+
/**
496+
* This method sets the selectedLevelIcon value.
497+
* @param selectedLevelIcon the selectedLevelIcon new value.
498+
*
499+
*/
500+
public void setSelectedLevelIcon(ItemStack selectedLevelIcon)
501+
{
502+
this.selectedLevelIcon = selectedLevelIcon;
503+
}
504+
505+
506+
/**
507+
* This method sets the completedLevelIcon value.
508+
* @param completedLevelIcon the completedLevelIcon new value.
509+
*
510+
*/
511+
public void setCompletedLevelIcon(ItemStack completedLevelIcon)
512+
{
513+
this.completedLevelIcon = completedLevelIcon;
514+
}
515+
516+
438517
/**
439518
* This method sets the userGuiMode value.
440519
* @param userGuiMode the userGuiMode new value.
@@ -490,6 +569,14 @@ public void setAddCompletedGlow(boolean addCompletedGlow)
490569
this.addCompletedGlow = addCompletedGlow;
491570
}
492571

572+
/**
573+
* @param addCompletedLevelGlow new addCompletedLevelGlow value.
574+
*/
575+
public void setAddCompletedLevelGlow(boolean addCompletedLevelGlow)
576+
{
577+
this.addCompletedLevelGlow = addCompletedLevelGlow;
578+
}
579+
493580

494581
/**
495582
* @param disabledGameModes new disabledGameModes value.

src/main/java/world/bentobox/challenges/panel/admin/EditSettingsPanel.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ protected void build()
117117
panelBuilder.item(28, this.getSettingsButton(Button.BROADCAST));
118118

119119
panelBuilder.item(11, this.getSettingsButton(Button.GLOW_COMPLETED));
120+
panelBuilder.item(12, this.getSettingsButton(Button.GLOW_COMPLETED_LEVELS));
120121
panelBuilder.item(20, this.getSettingsButton(Button.REMOVE_COMPLETED));
121122
panelBuilder.item(29, this.getSettingsButton(Button.VISIBILITY_MODE));
122123
panelBuilder.item(30, this.getSettingsButton(Button.INCLUDE_UNDEPLOYED));
@@ -331,6 +332,22 @@ private PanelItem getSettingsButton(Button button)
331332
description.add("");
332333
description.add(this.user.getTranslation(Constants.TIPS + "click-to-toggle"));
333334
}
335+
case GLOW_COMPLETED_LEVELS -> {
336+
description.add(this.user.getTranslation(reference +
337+
(this.settings.isAddCompletedLevelGlow() ? "enabled" : "disabled")));
338+
339+
icon = new ItemStack(Material.GLOWSTONE);
340+
clickHandler = (panel, user1, clickType, i) -> {
341+
this.settings.setAddCompletedLevelGlow(!this.settings.isAddCompletedLevelGlow());
342+
panel.getInventory().setItem(i, this.getSettingsButton(button).getItem());
343+
this.addon.saveSettings();
344+
return true;
345+
};
346+
glow = this.settings.isAddCompletedLevelGlow();
347+
348+
description.add("");
349+
description.add(this.user.getTranslation(Constants.TIPS + "click-to-toggle"));
350+
}
334351
case LOCKED_LEVEL_ICON -> {
335352
icon = this.settings.getLockedLevelIcon();
336353

@@ -568,6 +585,7 @@ private enum Button
568585
PURGE_HISTORY,
569586
DATA_PER_ISLAND,
570587
GLOW_COMPLETED,
588+
GLOW_COMPLETED_LEVELS,
571589
LOCKED_LEVEL_ICON,
572590
SHOW_TITLE,
573591
TITLE_SHOWTIME,

src/main/java/world/bentobox/challenges/panel/user/ChallengesPanel.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -551,9 +551,23 @@ else if (level.getLevel().getLockedIcon() != null)
551551
// Glow the icon.
552552
builder.glow(level == this.lastSelectedLevel ||
553553
level.isUnlocked() &&
554-
this.addon.getChallengesSettings().isAddCompletedGlow() &&
554+
this.addon.getChallengesSettings().isAddCompletedLevelGlow() &&
555555
this.manager.isLevelCompleted(this.user, this.world, level.getLevel()));
556556

557+
// Change icon for completed level
558+
if( level.isUnlocked() &&
559+
this.manager.isLevelCompleted(this.user, this.world, level.getLevel()) &&
560+
this.addon.getChallengesSettings().getCompletedLevelIcon() != null
561+
) {
562+
builder.icon(this.addon.getChallengesSettings().getCompletedLevelIcon().clone());
563+
}
564+
565+
// Change icon for selected level
566+
if(level == this.lastSelectedLevel &&
567+
this.addon.getChallengesSettings().getSelectedLevelIcon() != null){
568+
builder.icon(this.addon.getChallengesSettings().getSelectedLevelIcon().clone());
569+
}
570+
557571
// Click Handlers are managed by custom addon buttons.
558572
return builder.build();
559573
}

src/main/java/world/bentobox/challenges/utils/Utils.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import java.util.Set;
99

1010
import org.bukkit.Bukkit;
11-
import org.bukkit.ChatColor;
1211
import org.bukkit.Material;
1312
import org.bukkit.Statistic;
1413
import org.bukkit.Tag;
@@ -183,7 +182,7 @@ public static <T> T getPreviousValue(T[] values, T currentValue)
183182
*/
184183
public static String sanitizeInput(String input)
185184
{
186-
return ChatColor.stripColor(
185+
return Util.stripColor(
187186
Util.translateColorCodes(input.toLowerCase(Locale.ENGLISH).
188187
replace(" ", "_").
189188
replace("-", "_")));
@@ -776,7 +775,6 @@ public static String prettifyObject(ItemStack item, @Nullable PotionMeta potionM
776775
String meta = user.getTranslationOrNothing(metaReference + "potion-meta",
777776
"[type]", type,
778777
"[upgraded]", "", "[extended]", "");
779-
BentoBox.getInstance().logDebug("Generic ref: " + Constants.ITEM_STACKS + "generic");
780778
specific = user.getTranslationOrNothing(Constants.ITEM_STACKS + "generic",
781779
"[type]", prettifyObject(itemType, user),
782780
"[meta]", meta);
@@ -785,7 +783,6 @@ public static String prettifyObject(ItemStack item, @Nullable PotionMeta potionM
785783
// Last ditch
786784
specific = prettifyObject(itemType, user) + ": " + type;
787785
}
788-
BentoBox.getInstance().logDebug(specific);
789786
return specific;
790787
}
791788

src/main/resources/locales/en-US.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -635,12 +635,19 @@ challenges:
635635
enabled: "&2 Enabled"
636636
disabled: "&c Disabled"
637637
glow_completed:
638-
name: "&f&l Glow Completed"
638+
name: "&f&l Glow Completed Challenges"
639639
description: |-
640640
&7 Applies an enchantment glow
641641
&7 to completed challenges.
642642
enabled: "&2 Enabled"
643643
disabled: "&c Disabled"
644+
glow_completed_levels:
645+
name: "&f&l Glow Completed Levels"
646+
description: |-
647+
&7 Applies an enchantment glow
648+
&7 to completed levels.
649+
enabled: "&2 Enabled"
650+
disabled: "&c Disabled"
644651
store_history:
645652
name: "&f&l Store History"
646653
description: |-

src/main/resources/locales/pl.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ challenges:
6363
&7 lub wyjście z GUI
6464
previous:
6565
name: "&f&l Poprzednia strona"
66-
description: "&7 Przełącz na &e [numer] &7 stronę"
66+
description: "&7 Przełącz na &e [number] &7 stronę"
6767
next:
6868
name: "&f&l Następna strona"
6969
description: "&7 Przełącz na &e [number] &7 stronę"
@@ -367,7 +367,7 @@ challenges:
367367
description: |-
368368
&7 Pozwala na zmianę
369369
&7 statystyk bloku docelowego.
370-
value: "&7 Bieżący blok: &e [blok]"
370+
value: "&7 Bieżący blok: &e [block]"
371371
statistic_items:
372372
name: "&f&l Element docelowy"
373373
description: |-
@@ -709,7 +709,7 @@ challenges:
709709
name: "&f&l [statistic]"
710710
description: "[description]\t\n"
711711
environment_element:
712-
name: "&f&l [enviroment]"
712+
name: "&f&l [environment]"
713713
description: "[description]"
714714
search:
715715
name: "&f&l Szukaj"
@@ -777,7 +777,7 @@ challenges:
777777
status:
778778
completed: "&2&l Zakończono"
779779
completed-times: "&2 Ukończono &7&l [number] &r&2 raz(-y)"
780-
completed-times-of: "&2 Zakończono &7&l [number] &r&2 z &7&l [maks.] &r&2
780+
completed-times-of: "&2 Zakończono &7&l [number] &r&2 z &7&l [max] &r&2
781781
razy"
782782
completed-times-reached: "&2&l Ukończono wszystkie &7 [max] &2 razy"
783783
cooldown:
@@ -798,9 +798,9 @@ challenges:
798798
environment-single: "&7 Ograniczone do [environment]"
799799
environment-title: "&7 Ograniczone do:"
800800
environment-list: "&7 - &e [environment]\t\n"
801-
permission-single: "&c Wymaga uprawnień [permissions]"
801+
permission-single: "&c Wymaga uprawnień [permission]"
802802
permissions-title: "&c Wymaga uprawnień:"
803-
permissions-list: " &c - [permissions]"
803+
permissions-list: " &c - [permission]"
804804
island:
805805
lore: |-
806806
[blocks]
@@ -823,7 +823,7 @@ challenges:
823823
[warning]
824824
item-title: "&7&l Wymagane pozycje:"
825825
item-value: " &7 - &e [item]"
826-
items-value: " &7 - &e [numer] x [item]"
826+
items-value: " &7 - &e [number] x [item]"
827827
warning: "&e Przedmiot(y) zostaną &c usunięte"
828828
other:
829829
lore: |-
@@ -836,7 +836,7 @@ challenges:
836836
experience-warning: "&e Doświadczenie zostanie &c usunięte"
837837
money: "&7&l Wymagane pieniądze: &r&e [number]"
838838
money-warning: "&e Pieniądze zostaną &c usunięte"
839-
level: "&7&l Wymagany poziom wyspy: &r&e [liczba]"
839+
level: "&7&l Wymagany poziom wyspy: &r&e [number]"
840840
statistic:
841841
lore: |-
842842
[statistic]
@@ -996,7 +996,7 @@ challenges:
996996
unknown-challenge: "&cNieznane wyzwanie"
997997
not-valid-integer: |-
998998
&c Podana liczba całkowita "[value]" jest nieprawidłowa!
999-
Wartość powinna mieścić się w zakresie od [min] do [maks].
999+
Wartość powinna mieścić się w zakresie od [min] do [max].
10001000
not-deployed: "&c Challenge nie został wdrożony!"
10011001
not-on-island: "&cMusisz być na swojej wyspie by to zrobic!"
10021002
challenge-level-not-available: "&c Nie odblokowałeś wymaganego poziomu, aby ukończyć

0 commit comments

Comments
 (0)