Skip to content

Commit

Permalink
Add new Buttons to settings GUI
Browse files Browse the repository at this point in the history
  • Loading branch information
BONNe committed Feb 22, 2019
1 parent 0bb3171 commit f77c141
Show file tree
Hide file tree
Showing 2 changed files with 130 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,26 @@ public void build()
GuiUtils.fillBorder(panelBuilder);

panelBuilder.item(19, this.getSettingsButton(Button.RESET_CHALLENGES));
panelBuilder.item(28, this.getSettingsButton(Button.REMOVE_COMPLETED));

panelBuilder.item(20, this.getSettingsButton(Button.BROADCAST));
panelBuilder.item(21, this.getSettingsButton(Button.REMOVE_COMPLETED));
panelBuilder.item(22, this.getSettingsButton(Button.GLOW_COMPLETED));
panelBuilder.item(23, this.getSettingsButton(Button.FREE_AT_TOP));
panelBuilder.item(24, this.getSettingsButton(Button.CHALLENGE_LORE));
panelBuilder.item(33, this.getSettingsButton(Button.LEVEL_LORE));
panelBuilder.item(25, this.getSettingsButton(Button.LORE_LENGTH));
panelBuilder.item(29, this.getSettingsButton(Button.GLOW_COMPLETED));

panelBuilder.item(22, this.getSettingsButton(Button.FREE_AT_TOP));
panelBuilder.item(31, this.getSettingsButton(Button.GAMEMODE_GUI));

panelBuilder.item(14, this.getSettingsButton(Button.LORE_LENGTH));
panelBuilder.item(23, this.getSettingsButton(Button.CHALLENGE_LORE));
panelBuilder.item(32, this.getSettingsButton(Button.LEVEL_LORE));

panelBuilder.item(24, this.getSettingsButton(Button.HISTORY));

if (this.settings.isStoreHistory())
{
panelBuilder.item(33, this.getSettingsButton(Button.PURGE_HISTORY));
}

panelBuilder.item(25, this.getSettingsButton(Button.STORE_MODE));

// Return Button
panelBuilder.item(44, this.returnButton);
Expand Down Expand Up @@ -265,7 +278,7 @@ private PanelItem getSettingsButton(Button button)
description.add(this.user.getTranslation("challenges.gui.descriptions.admin.glow"));
description.add(this.user.getTranslation("challenges.gui.descriptions.current-value",
"[value]",
this.addon.getChallengesSettings().isAddCompletedGlow() ?
this.settings.isAddCompletedGlow() ?
this.user.getTranslation("challenges.gui.descriptions.enabled") :
this.user.getTranslation("challenges.gui.descriptions.disabled")));

Expand All @@ -280,6 +293,102 @@ private PanelItem getSettingsButton(Button button)
glow = this.settings.isAddCompletedGlow();
break;
}
case GAMEMODE_GUI:
{
description = new ArrayList<>(2);
description.add(this.user.getTranslation("challenges.gui.descriptions.admin.gui-view-mode"));
description.add(this.user.getTranslation("challenges.gui.descriptions.current-value",
"[value]",
this.settings.getUserGuiMode().equals(Settings.GuiMode.GAMEMODE_LIST) ?
this.user.getTranslation("challenges.gui.descriptions.enabled") :
this.user.getTranslation("challenges.gui.descriptions.disabled")));
name = this.user.getTranslation("challenges.gui.buttons.admin.gui-view-mode");
icon = new ItemStack(Material.GLOWSTONE);
clickHandler = (panel, user1, clickType, i) -> {

if (this.settings.getUserGuiMode().equals(Settings.GuiMode.GAMEMODE_LIST))
{
this.settings.setUserGuiMode(Settings.GuiMode.CURRENT_WORLD);
}
else
{
this.settings.setUserGuiMode(Settings.GuiMode.GAMEMODE_LIST);
}

panel.getInventory().setItem(i, this.getSettingsButton(button).getItem());
return true;
};
glow = this.settings.getUserGuiMode().equals(Settings.GuiMode.GAMEMODE_LIST);
break;
}
case HISTORY:
{
description = new ArrayList<>(2);
description.add(this.user.getTranslation("challenges.gui.descriptions.admin.history-store"));
description.add(this.user.getTranslation("challenges.gui.descriptions.current-value",
"[value]",
this.settings.isStoreHistory() ?
this.user.getTranslation("challenges.gui.descriptions.enabled") :
this.user.getTranslation("challenges.gui.descriptions.disabled")));
name = this.user.getTranslation("challenges.gui.buttons.admin.history-store");
icon = new ItemStack(Material.GLOWSTONE);
clickHandler = (panel, user1, clickType, i) -> {
this.settings.setStoreHistory(!this.settings.isStoreHistory());

// Need to rebuild all as new buttons will show up.
this.build();
return true;
};
glow = this.settings.isStoreHistory();
break;
}
case PURGE_HISTORY:
{
description = new ArrayList<>(2);
description.add(this.user.getTranslation("challenges.gui.descriptions.admin.history-lifespan"));
description.add(this.user.getTranslation("challenges.gui.descriptions.current-value",
"[value]", Integer.toString(this.settings.getLifeSpan())));
name = this.user.getTranslation("challenges.gui.buttons.admin.history-lifespan");
icon = new ItemStack(Material.ANVIL);
clickHandler = (panel, user1, clickType, i) -> {
new NumberGUI(this.user,
this.settings.getLifeSpan(),
0,
this.settings.getLoreLineLength(),
(status, value) -> {
if (status)
{
this.settings.setLifeSpan(value);
}

panel.getInventory().setItem(i, this.getSettingsButton(button).getItem());
});

return true;
};
glow = false;
break;
}
case STORE_MODE:
{
description = new ArrayList<>(2);
description.add(this.user.getTranslation("challenges.gui.descriptions.admin.island-store"));
description.add(this.user.getTranslation("challenges.gui.descriptions.current-value",
"[value]",
this.settings.isStoreAsIslandData() ?
this.user.getTranslation("challenges.gui.descriptions.enabled") :
this.user.getTranslation("challenges.gui.descriptions.disabled")));
name = this.user.getTranslation("challenges.gui.buttons.admin.island-store");
icon = new ItemStack(Material.GLOWSTONE);
clickHandler = (panel, user1, clickType, i) -> {
this.settings.setStoreAsIslandData(!this.settings.isStoreAsIslandData());
// TODO: Data Migration must be added here.
panel.getInventory().setItem(i, this.getSettingsButton(button).getItem());
return true;
};
glow = this.settings.isStoreAsIslandData();
break;
}
default:
return new PanelItemBuilder().build();
}
Expand All @@ -304,7 +413,11 @@ private enum Button
LORE_LENGTH,
LEVEL_LORE,
CHALLENGE_LORE,
FREE_AT_TOP,
FREE_AT_TOP,
GAMEMODE_GUI,
HISTORY,
PURGE_HISTORY,
STORE_MODE,
GLOW_COMPLETED
}

Expand Down
10 changes: 9 additions & 1 deletion src/main/resources/locales/en-US.yml
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ challenges:
number: '[number]'
level-lore: 'Level Description'
challenge-lore: 'Challenge Description'
gui-view-mode: 'Display All GameModes'
history-store: 'Challenges History'
history-lifespan: 'History LifeSpan'
island-store: 'Store per Island'
next: 'Next'
previous: 'Previous'
return: 'Return'
Expand Down Expand Up @@ -218,6 +222,10 @@ challenges:
show-eggs: 'Switch entity view between Egg mode or Head mode.'
level-lore: 'Allows to modify which elements of level description should be visible.'
challenge-lore: 'Allows to modify which elements of challenge description should be visible.'
gui-view-mode: 'Allows to set if /challenges GUI should show GameModes or challenges in players world.'
history-store: 'Allows to enable/disable challenges history storage.'
history-lifespan: 'Allows to modify how many days history data will be saved.|0 means forever.'
island-store: 'Allows to enable/disable challenges data string per island. This means that challenges will be the same on whole team, if this is enabled.|Will convert data on click.'
current-value: '|&6Current value: [value].'
enabled: 'Active'
disabled: 'Disabled'
Expand Down Expand Up @@ -307,4 +315,4 @@ challenges:
import-no-file: '&cCould not find challenges.yml file to import!'
no-load: '&cError: Could not load challenges.yml. [message]'
load-error: '&cError: Cannot load [value].'
version: 6
version: 7

0 comments on commit f77c141

Please sign in to comment.