Skip to content

Commit

Permalink
Separate all enums from Settings class into SettingsUtils.
Browse files Browse the repository at this point in the history
  • Loading branch information
BONNe authored and BuildTools committed Sep 1, 2019
1 parent 235da81 commit 0026cb7
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
import world.bentobox.bentobox.api.addons.GameModeAddon;
import world.bentobox.bentobox.api.commands.CompositeCommand;
import world.bentobox.bentobox.api.user.User;

import world.bentobox.challenges.ChallengesAddon;
import world.bentobox.challenges.config.Settings;
import world.bentobox.challenges.config.SettingsUtils.GuiMode;
import world.bentobox.challenges.panel.GameModesGUI;


Expand Down Expand Up @@ -59,7 +60,7 @@ public boolean execute(User user, String label, List<String> args)
user.performCommand(compositeCommand.getTopLabel() + " challenges"));
return true;
}
else if (this.addon.getChallengesSettings().getUserGuiMode() == Settings.GuiMode.CURRENT_WORLD)
else if (this.addon.getChallengesSettings().getUserGuiMode() == GuiMode.CURRENT_WORLD)
{
// Find GameMode and run command
for (GameModeAddon addon : this.gameModeAddons)
Expand All @@ -73,7 +74,7 @@ else if (this.addon.getChallengesSettings().getUserGuiMode() == Settings.GuiMode
}
}
}
else if (this.addon.getChallengesSettings().getUserGuiMode() == Settings.GuiMode.GAMEMODE_LIST)
else if (this.addon.getChallengesSettings().getUserGuiMode() == GuiMode.GAMEMODE_LIST)
{
new GameModesGUI(this.addon,
this.getWorld(),
Expand Down
23 changes: 2 additions & 21 deletions src/main/java/world/bentobox/challenges/config/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
import world.bentobox.bentobox.api.configuration.ConfigObject;
import world.bentobox.bentobox.api.configuration.StoreAt;

import world.bentobox.challenges.config.SettingsUtils.GuiMode;


@StoreAt(filename="config.yml", path="addons/Challenges")
@ConfigComment("Challenges [version] Configuration")
Expand Down Expand Up @@ -592,25 +594,4 @@ public void setLifeSpan(int lifeSpan)
{
this.lifeSpan = lifeSpan;
}


// ---------------------------------------------------------------------
// Section: Enums
// ---------------------------------------------------------------------


/**
* This enum holds all possible values for Gui Opening for users.
*/
public enum GuiMode
{
/**
* Opens user GUI with list of all GameModes.
*/
GAMEMODE_LIST,
/**
* Opens user GUI with challenges in given world.
*/
CURRENT_WORLD
}
}
29 changes: 29 additions & 0 deletions src/main/java/world/bentobox/challenges/config/SettingsUtils.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//
// Created by BONNe
// Copyright - 2019
//


package world.bentobox.challenges.config;


/**
* This class holds all enums that are used in Settings class.
*/
public class SettingsUtils
{
/**
* This enum holds all possible values for Gui Opening for users.
*/
public enum GuiMode
{
/**
* Opens user GUI with list of all GameModes.
*/
GAMEMODE_LIST,
/**
* Opens user GUI with challenges in given world.
*/
CURRENT_WORLD
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import world.bentobox.bentobox.api.user.User;
import world.bentobox.challenges.ChallengesAddon;
import world.bentobox.challenges.config.Settings;
import world.bentobox.challenges.config.SettingsUtils.GuiMode;
import world.bentobox.challenges.panel.CommonGUI;
import world.bentobox.challenges.panel.util.NumberGUI;
import world.bentobox.challenges.panel.util.SelectBlocksGUI;
Expand Down Expand Up @@ -327,26 +328,26 @@ private PanelItem getSettingsButton(Button button)
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.settings.getUserGuiMode().equals(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.STONE_BUTTON);
clickHandler = (panel, user1, clickType, i) -> {

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

panel.getInventory().setItem(i, this.getSettingsButton(button).getItem());
return true;
};
glow = this.settings.getUserGuiMode().equals(Settings.GuiMode.GAMEMODE_LIST);
glow = this.settings.getUserGuiMode().equals(GuiMode.GAMEMODE_LIST);
break;
}
case GAMEMODE_GUI:
Expand Down

0 comments on commit 0026cb7

Please sign in to comment.