|
15 | 15 | import world.bentobox.challenges.ChallengesAddon;
|
16 | 16 | import world.bentobox.challenges.config.Settings;
|
17 | 17 | import world.bentobox.challenges.config.SettingsUtils.GuiMode;
|
| 18 | +import world.bentobox.challenges.config.SettingsUtils.VisibilityMode; |
18 | 19 | import world.bentobox.challenges.panel.CommonGUI;
|
19 | 20 | import world.bentobox.challenges.panel.util.NumberGUI;
|
20 | 21 | import world.bentobox.challenges.panel.util.SelectBlocksGUI;
|
21 | 22 | import world.bentobox.challenges.utils.GuiUtils;
|
| 23 | +import world.bentobox.challenges.utils.Utils; |
22 | 24 |
|
23 | 25 |
|
24 | 26 | /**
|
@@ -90,8 +92,9 @@ public void build()
|
90 | 92 |
|
91 | 93 | panelBuilder.item(28, this.getSettingsButton(Button.BROADCAST));
|
92 | 94 |
|
93 |
| - panelBuilder.item(20, this.getSettingsButton(Button.GLOW_COMPLETED)); |
94 |
| - panelBuilder.item(29, this.getSettingsButton(Button.REMOVE_COMPLETED)); |
| 95 | + panelBuilder.item(11, this.getSettingsButton(Button.GLOW_COMPLETED)); |
| 96 | + panelBuilder.item(20, this.getSettingsButton(Button.REMOVE_COMPLETED)); |
| 97 | + panelBuilder.item(29, this.getSettingsButton(Button.VISIBILITY_MODE)); |
95 | 98 |
|
96 | 99 | panelBuilder.item(21, this.getSettingsButton(Button.LOCKED_LEVEL_ICON));
|
97 | 100 | panelBuilder.item(30, this.getSettingsButton(Button.FREE_AT_TOP));
|
@@ -490,6 +493,61 @@ private PanelItem getSettingsButton(Button button)
|
490 | 493 | glow = false;
|
491 | 494 | break;
|
492 | 495 | }
|
| 496 | + case VISIBILITY_MODE: |
| 497 | + { |
| 498 | + name = this.user.getTranslation("challenges.gui.buttons.admin.visibility-mode"); |
| 499 | + |
| 500 | + List<String> values = new ArrayList<>(5); |
| 501 | + values.add(this.user.getTranslation("challenges.gui.descriptions.admin.visibility-mode")); |
| 502 | + |
| 503 | + values.add((this.settings.getVisibilityMode().equals(VisibilityMode.VISIBLE) ? "&2" : "&c") + |
| 504 | + this.user.getTranslation("challenges.gui.descriptions.visibility.visible")); |
| 505 | + values.add((this.settings.getVisibilityMode().equals(VisibilityMode.HIDDEN) ? "&2" : "&c") + |
| 506 | + this.user.getTranslation("challenges.gui.descriptions.visibility.hidden")); |
| 507 | + values.add((this.settings.getVisibilityMode().equals(VisibilityMode.TOGGLEABLE) ? "&2" : "&c") + |
| 508 | + this.user.getTranslation("challenges.gui.descriptions.visibility.toggleable")); |
| 509 | + |
| 510 | + values.add(this.user.getTranslation("challenges.gui.descriptions.current-value", |
| 511 | + "[value]",this.settings.getVisibilityMode().name())); |
| 512 | + |
| 513 | + description = values; |
| 514 | + |
| 515 | + if (this.settings.getVisibilityMode().equals(VisibilityMode.VISIBLE)) |
| 516 | + { |
| 517 | + icon = new ItemStack(Material.OAK_PLANKS); |
| 518 | + } |
| 519 | + else if (this.settings.getVisibilityMode().equals(VisibilityMode.HIDDEN)) |
| 520 | + { |
| 521 | + icon = new ItemStack(Material.OAK_SLAB); |
| 522 | + } |
| 523 | + else |
| 524 | + { |
| 525 | + icon = new ItemStack(Material.OAK_BUTTON); |
| 526 | + } |
| 527 | + |
| 528 | + clickHandler = (panel, user, clickType, slot) -> { |
| 529 | + if (clickType.isRightClick()) |
| 530 | + { |
| 531 | + this.settings.setVisibilityMode( |
| 532 | + Utils.getPreviousValue(VisibilityMode.values(), |
| 533 | + this.settings.getVisibilityMode())); |
| 534 | + } |
| 535 | + else |
| 536 | + { |
| 537 | + this.settings.setVisibilityMode( |
| 538 | + Utils.getNextValue(VisibilityMode.values(), |
| 539 | + this.settings.getVisibilityMode())); |
| 540 | + } |
| 541 | + |
| 542 | + // Rebuild just this icon |
| 543 | + panel.getInventory().setItem(slot, |
| 544 | + this.getSettingsButton(button).getItem()); |
| 545 | + |
| 546 | + return true; |
| 547 | + }; |
| 548 | + glow = false; |
| 549 | + break; |
| 550 | + } |
493 | 551 | default:
|
494 | 552 | return new PanelItemBuilder().build();
|
495 | 553 | }
|
@@ -529,7 +587,12 @@ private enum Button
|
529 | 587 | GLOW_COMPLETED,
|
530 | 588 | LOCKED_LEVEL_ICON,
|
531 | 589 | ENABLE_TITLE,
|
532 |
| - TITLE_SHOWTIME |
| 590 | + TITLE_SHOWTIME, |
| 591 | + |
| 592 | + /** |
| 593 | + * This allows to switch between different challenges visibility modes. |
| 594 | + */ |
| 595 | + VISIBILITY_MODE |
533 | 596 | }
|
534 | 597 |
|
535 | 598 |
|
|
0 commit comments