Separate all enums from Settings class into SettingsUtils.

This commit is contained in:
BONNe 2019-09-01 15:17:34 +03:00 committed by BuildTools
parent 235da81ba0
commit 0026cb7404
4 changed files with 41 additions and 29 deletions

View File

@ -6,8 +6,9 @@ import java.util.List;
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;
@ -59,7 +60,7 @@ public class ChallengesUserCommand extends CompositeCommand
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)
@ -73,7 +74,7 @@ public class ChallengesUserCommand extends CompositeCommand
}
}
}
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(),

View File

@ -12,6 +12,8 @@ import world.bentobox.bentobox.api.configuration.ConfigEntry;
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")
@ -592,25 +594,4 @@ public class Settings implements ConfigObject
{
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
}
}

View File

@ -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
}
}

View File

@ -14,6 +14,7 @@ import world.bentobox.bentobox.api.panels.builders.PanelItemBuilder;
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;
@ -327,26 +328,26 @@ public class EditSettingsGUI extends CommonGUI
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: