2019-09-01 14:10:05 +02:00
package world.bentobox.challenges.config ;
2019-01-10 10:30:54 +01:00
2019-09-03 08:03:21 +02:00
import java.util.ArrayList ;
2019-01-10 10:30:54 +01:00
import java.util.HashSet ;
2019-09-03 08:03:21 +02:00
import java.util.List ;
2019-01-10 10:30:54 +01:00
import java.util.Set ;
2019-05-09 15:24:01 +02:00
import org.bukkit.Material ;
import org.bukkit.inventory.ItemStack ;
2019-01-10 10:30:54 +01:00
import world.bentobox.bentobox.api.configuration.ConfigComment ;
import world.bentobox.bentobox.api.configuration.ConfigEntry ;
2019-05-09 15:24:01 +02:00
import world.bentobox.bentobox.api.configuration.ConfigObject ;
2019-01-10 10:30:54 +01:00
import world.bentobox.bentobox.api.configuration.StoreAt ;
2019-09-03 08:03:21 +02:00
import world.bentobox.bentobox.database.objects.adapters.Adapter ;
2019-09-01 14:17:34 +02:00
import world.bentobox.challenges.config.SettingsUtils.GuiMode ;
2019-09-03 08:03:21 +02:00
import world.bentobox.challenges.config.SettingsUtils.ChallengeLore ;
import world.bentobox.challenges.config.SettingsUtils.LevelLore ;
2019-09-05 14:52:14 +02:00
import world.bentobox.challenges.config.SettingsUtils.VisibilityMode ;
2019-09-03 08:03:21 +02:00
import world.bentobox.challenges.database.object.adapters.ChallengeLoreAdapter ;
import world.bentobox.challenges.database.object.adapters.LevelLoreAdapter ;
2019-09-01 14:17:34 +02:00
2019-01-10 10:30:54 +01:00
@StoreAt ( filename = " config.yml " , path = " addons/Challenges " )
2019-02-12 11:24:00 +01:00
@ConfigComment ( " Challenges [version] Configuration " )
2019-01-10 10:30:54 +01:00
@ConfigComment ( " This config file is dynamic and saved when the server is shutdown. " )
@ConfigComment ( " You cannot edit it while the server is running because changes will " )
@ConfigComment ( " be lost! Use in-game settings GUI or edit when server is offline. " )
@ConfigComment ( " " )
2019-05-09 15:24:01 +02:00
public class Settings implements ConfigObject
2019-01-10 10:30:54 +01:00
{
2019-05-09 15:24:01 +02:00
@ConfigComment ( " " )
@ConfigComment ( " Allows to define common challenges command that will open User GUI " )
@ConfigComment ( " with all GameMode selection or Challenges from user world. " )
@ConfigComment ( " This will not affect /{gamemode_user} challenges command. " )
@ConfigEntry ( path = " commands.user " , needsReset = true )
private String userCommand = " challenges c " ;
@ConfigComment ( " " )
@ConfigComment ( " Allows to define common challenges command that will open Admin GUI " )
@ConfigComment ( " with all GameMode selection. " )
@ConfigComment ( " This will not affect /{gamemode_admin} challenges command. " )
@ConfigEntry ( path = " commands.admin " , needsReset = true )
private String adminCommand = " challengesadmin chadmin " ;
@ConfigComment ( " " )
@ConfigComment ( " This enables/disables common command that will be independent from " )
@ConfigComment ( " all GameModes. For admins it will open selection with all GameModes " )
@ConfigComment ( " (unless there is one), but for users it will open GUI that corresponds " )
@ConfigComment ( " to their world (unless it is specified other way in Admin GUI). " )
@ConfigEntry ( path = " commands.single-gui " , needsReset = true )
private boolean useCommonGUI = false ;
@ConfigComment ( " " )
@ConfigComment ( " This allows for admins to define which GUI will be opened for admins " )
@ConfigComment ( " when users calls single-gui command. " )
@ConfigComment ( " Acceptable values: " )
@ConfigComment ( " - CURRENT_WORLD - will open GUI that corresponds to user location. " )
@ConfigComment ( " - GAMEMODE_LIST - will open GUI with all installed game modes. " )
@ConfigEntry ( path = " commands.single-gamemode " )
private GuiMode userGuiMode = GuiMode . CURRENT_WORLD ;
@ConfigComment ( " " )
@ConfigComment ( " This indicate if player challenges data history will be stored or not. " )
@ConfigEntry ( path = " history.store-history-data " )
private boolean storeHistory = false ;
@ConfigComment ( " " )
@ConfigComment ( " This allows to specify an amount of time in days when history data will " )
@ConfigComment ( " be removed. 0 means that data will not be removed. " )
@ConfigEntry ( path = " history.lifespan " )
private int lifeSpan = 14 ;
@ConfigComment ( " " )
@ConfigComment ( " Remove non-repeatable challenges from the challenge GUI when complete. " )
@ConfigEntry ( path = " gui-settings.remove-complete-one-time-challenges " )
private boolean removeCompleteOneTimeChallenges = false ;
@ConfigComment ( " " )
@ConfigComment ( " Add enchanted glow to completed challenges " )
@ConfigEntry ( path = " gui-settings.add-completed-glow " )
private boolean addCompletedGlow = true ;
2019-09-05 14:52:14 +02:00
@ConfigComment ( " " )
@ConfigComment ( " This variable allows to choose which Challenges users can see in Challenges GUI. " )
@ConfigComment ( " Valid values are: " )
@ConfigComment ( " 'VISIBLE' - there will be no hidden challenges. All challenges will be viewable in GUI. " )
@ConfigComment ( " 'HIDDEN' - shows only deployed challenges. " )
@ConfigComment ( " 'TOGGLEABLE' - there will be button in GUI that allows users to switch from ALL modes. " )
@ConfigComment ( " TOGGLEABLE - Currently not implemented. " )
@ConfigEntry ( path = " gui-settings.undeployed-view-mode " )
private VisibilityMode visibilityMode = VisibilityMode . VISIBLE ;
2019-05-09 15:24:01 +02:00
@ConfigComment ( " " )
@ConfigComment ( " This allows to change default locked level icon. This option may be " )
@ConfigComment ( " overwritten by each challenge level. If challenge level has specified " )
@ConfigComment ( " their locked level icon, then it will be used, instead of this one. " )
@ConfigEntry ( path = " gui-settings.locked-level-icon " )
private ItemStack lockedLevelIcon = new ItemStack ( Material . BOOK ) ;
@ConfigComment ( " " )
@ConfigComment ( " This indicate if free challenges must be at the start (true) or at the end (false) of list. " )
@ConfigEntry ( path = " gui-settings.free-challenges-first " )
private boolean freeChallengesFirst = true ;
@ConfigComment ( " " )
@ConfigComment ( " This allows to change lore description line length. By default it is 25, but some server " )
@ConfigComment ( " owners may like it to be larger. " )
@ConfigEntry ( path = " gui-settings.lore-length " )
private int loreLineLength = 25 ;
@ConfigComment ( " " )
@ConfigComment ( " This string allows to change element order in Challenge description. Each letter represents " )
@ConfigComment ( " one object from challenge description. If letter is not used, then its represented part " )
@ConfigComment ( " will not be in description. If use any letter that is not recognized, then it will be " )
@ConfigComment ( " ignored. Some strings can be customized via lang file under 'challenges.gui.challenge-description'. " )
2019-09-03 08:03:21 +02:00
@ConfigComment ( " List of values and their meaning: " )
@ConfigComment ( " - LEVEL - Level String: '*.level' " )
@ConfigComment ( " - STATUS - Status String: '*.completed' " )
@ConfigComment ( " - COUNT - Times String: '*.completed-times', '*.completed-times-of' or '*.maxed-reached' " )
@ConfigComment ( " - DESCRIPTION - Description String: defined in challenge object - challenge.description " )
@ConfigComment ( " - WARNINGS - Warning String: '*.warning-items-take', '*.objects-close-by', '*.warning-entities-kill', '*.warning-blocks-remove' " )
@ConfigComment ( " - ENVIRONMENT - Environment String: defined in challenge object - challenge.environment " )
@ConfigComment ( " - REQUIREMENTS - Requirement String: '*.required-level', '*.required-money', '*.required-experience' and items, blocks or entities " )
@ConfigComment ( " - REWARD_TEXT - Reward String: message that is defined in challenge.rewardTest and challenge.repeatRewardText " )
@ConfigComment ( " - REWARD_OTHER - Reward extra String: '*.experience-reward', '*.money-reward', '*.not-repeatable' " )
@ConfigComment ( " - REWARD_ITEMS - Reward Items: List of items that will be rewarded. " )
@ConfigComment ( " - REWARD_COMMANDS - Reward Commands: List of commands that will be rewarded. " )
@ConfigComment ( " Requirement and reward items, blocks and entities that are defined in challenge and can be customized under 'challenges.gui.item-description.*' " )
@ConfigEntry ( path = " gui-settings.challenge-lore " )
@Adapter ( ChallengeLoreAdapter . class )
private List < ChallengeLore > challengeLoreMessage = new ArrayList < > ( ) ;
2019-05-09 15:24:01 +02:00
@ConfigComment ( " " )
@ConfigComment ( " This string allows to change element order in Level description. Each letter represents " )
@ConfigComment ( " one object from level description. If letter is not used, then its represented part " )
@ConfigComment ( " will not be in description. If use any letter that is not recognized, then it will be " )
@ConfigComment ( " ignored. Some strings can be customized via lang file under 'challenges.gui.level-description'. " )
2019-09-03 08:03:21 +02:00
@ConfigComment ( " List of values and their meaning: " )
@ConfigComment ( " - LEVEL_STATUS - Status String: '*.completed' " )
@ConfigComment ( " - CHALLENGE_COUNT - Count of completed challenges String: '*.completed-challenges-of' " )
@ConfigComment ( " - UNLOCK_MESSAGE - Description String: defined in level object - challengeLevel.unlockMessage " )
@ConfigComment ( " - WAIVER_AMOUNT - WaiverAmount String: '*.waver-amount' " )
@ConfigComment ( " - LEVEL_REWARD_TEXT - Reward String: message that is defined in challengeLevel.rewardText. " )
@ConfigComment ( " - LEVEL_REWARD_OTHER - Reward extra String: '*.experience-reward', '*.money-reward' " )
@ConfigComment ( " - LEVEL_REWARD_ITEMS - Reward Items: List of items that will be rewarded. " )
@ConfigComment ( " - LEVEL_REWARD_COMMANDS - Reward Commands: List of commands that will be rewarded. " )
@ConfigComment ( " Reward items that are defined in challenge level and can be customized under 'challenges.gui.item-description.*' " )
@ConfigEntry ( path = " gui-settings.level-lore " )
@Adapter ( LevelLoreAdapter . class )
private List < LevelLore > levelLoreMessage = new ArrayList < > ( ) ;
2019-05-09 15:24:01 +02:00
@ConfigComment ( " " )
@ConfigComment ( " This indicate if challenges data will be stored per island (true) or per player (false). " )
@ConfigEntry ( path = " store-island-data " )
private boolean storeAsIslandData = false ;
@ConfigComment ( " " )
@ConfigComment ( " Reset Challenges - if this is true, player's challenges will reset when users " )
@ConfigComment ( " reset an island or if users are kicked or leave a team. Prevents exploiting the " )
@ConfigComment ( " challenges by doing them repeatedly. " )
@ConfigEntry ( path = " reset-challenges " )
private boolean resetChallenges = true ;
@ConfigComment ( " " )
@ConfigComment ( " Broadcast 1st time challenge completion messages to all players. " )
@ConfigComment ( " Change to false if the spam becomes too much. " )
@ConfigEntry ( path = " broadcast-messages " )
private boolean broadcastMessages = true ;
@ConfigComment ( " " )
@ConfigComment ( " Shows a title screen for player after completion a challenge or level. " )
@ConfigComment ( " Message can be edited via language settings. " )
@ConfigEntry ( path = " title.show-title " )
private boolean showCompletionTitle = true ;
@ConfigComment ( " " )
@ConfigComment ( " Integer that represents how long title will be visible for player. " )
@ConfigEntry ( path = " title.title-showtime " )
private int titleShowtime = 70 ;
2019-06-12 21:56:52 +02:00
@ConfigComment ( " " )
@ConfigComment ( " Long that represents how frequently (in minutes) challenges addon will save data to database. " )
@ConfigComment ( " If this is set to 0, saving will not happen. " )
@ConfigEntry ( path = " auto-saver " )
private long autoSaveTimer = 30 ;
2019-05-09 15:24:01 +02:00
@ConfigComment ( " " )
@ConfigComment ( " This list stores GameModes in which Challenges addon should not work. " )
@ConfigComment ( " To disable addon it is necessary to write its name in new line that starts with -. Example: " )
@ConfigComment ( " disabled-gamemodes: " )
@ConfigComment ( " - BSkyBlock " )
@ConfigEntry ( path = " disabled-gamemodes " )
private Set < String > disabledGameModes = new HashSet < > ( ) ;
/ * *
* Configuration version
* /
@ConfigComment ( " " )
private String configVersion = " v3 " ;
2019-09-05 14:52:14 +02:00
// ---------------------------------------------------------------------
// Section: Getters
// ---------------------------------------------------------------------
2019-05-09 15:24:01 +02:00
/ * *
* This method returns the challengeLoreMessage object .
* @return the challengeLoreMessage object .
* /
2019-09-03 08:03:21 +02:00
public List < ChallengeLore > getChallengeLoreMessage ( )
2019-05-09 15:24:01 +02:00
{
return challengeLoreMessage ;
}
/ * *
* This method returns the configVersion object .
* @return the configVersion object .
* /
public String getConfigVersion ( )
{
return configVersion ;
}
/ * *
* @return resetChallenges value .
* /
public boolean isResetChallenges ( )
{
return this . resetChallenges ;
}
/ * *
* @return broadcastMessages value .
* /
public boolean isBroadcastMessages ( )
{
return this . broadcastMessages ;
}
/ * *
* @return removeCompleteOneTimeChallenges value .
* /
public boolean isRemoveCompleteOneTimeChallenges ( )
{
return this . removeCompleteOneTimeChallenges ;
}
/ * *
* @return addCompletedGlow value .
* /
public boolean isAddCompletedGlow ( )
{
return this . addCompletedGlow ;
}
/ * *
* @return disabledGameModes value .
* /
public Set < String > getDisabledGameModes ( )
{
return this . disabledGameModes ;
}
/ * *
* @return freeChallengesFirst value .
* /
public boolean isFreeChallengesFirst ( )
{
return this . freeChallengesFirst ;
}
/ * *
* This method returns the loreLineLength object .
* @return the loreLineLength object .
* /
public int getLoreLineLength ( )
{
return loreLineLength ;
}
/ * *
* This method returns the levelLoreMessage object .
* @return the levelLoreMessage object .
* /
2019-09-03 08:03:21 +02:00
public List < LevelLore > getLevelLoreMessage ( )
2019-05-09 15:24:01 +02:00
{
return levelLoreMessage ;
}
/ * *
* This method returns the storeAsIslandData object .
* @return the storeAsIslandData object .
* /
public boolean isStoreAsIslandData ( )
{
return storeAsIslandData ;
}
/ * *
* This method returns the storeHistory object .
* @return the storeHistory object .
* /
public boolean isStoreHistory ( )
{
return storeHistory ;
}
/ * *
* This method returns the userCommand value .
* @return the value of userCommand .
* /
public String getUserCommand ( )
{
return userCommand ;
}
/ * *
* This method returns the adminCommand value .
* @return the value of adminCommand .
* /
public String getAdminCommand ( )
{
return adminCommand ;
}
/ * *
* This method returns the useCommonGUI value .
* @return the value of useCommonGUI .
* /
public boolean isUseCommonGUI ( )
{
return useCommonGUI ;
}
/ * *
* This method returns the userGuiMode value .
* @return the value of userGuiMode .
* /
public GuiMode getUserGuiMode ( )
{
return userGuiMode ;
}
/ * *
* This method returns the lifeSpan value .
* @return the value of lifeSpan .
* /
public int getLifeSpan ( )
{
return lifeSpan ;
}
/ * *
* This method returns the lockedLevelIcon value .
* @return the value of lockedLevelIcon .
* /
public ItemStack getLockedLevelIcon ( )
{
return lockedLevelIcon . clone ( ) ;
}
/ * *
* This method returns the showCompletionTitle object .
* @return the showCompletionTitle object .
* /
public boolean isShowCompletionTitle ( )
{
return this . showCompletionTitle ;
}
/ * *
* This method returns the titleShowtime object .
* @return the titleShowtime object .
* /
public int getTitleShowtime ( )
{
return this . titleShowtime ;
}
2019-06-12 21:56:52 +02:00
/ * *
* This method returns the autoSaveTimer object .
* @return the autoSaveTimer object .
* /
public long getAutoSaveTimer ( )
{
return autoSaveTimer ;
}
2019-09-05 14:52:14 +02:00
/ * *
* This method returns the visibilityMode value .
* @return the value of visibilityMode .
* /
public VisibilityMode getVisibilityMode ( )
{
return this . visibilityMode ;
}
// ---------------------------------------------------------------------
// Section: Setters
// ---------------------------------------------------------------------
2019-06-12 21:56:52 +02:00
/ * *
* This method sets the autoSaveTimer object value .
* @param autoSaveTimer the autoSaveTimer object new value .
*
* /
public void setAutoSaveTimer ( long autoSaveTimer )
{
this . autoSaveTimer = autoSaveTimer ;
}
2019-05-09 15:24:01 +02:00
/ * *
* This method sets the titleShowtime object value .
* @param titleShowtime the titleShowtime object new value .
*
* /
public void setTitleShowtime ( int titleShowtime )
{
this . titleShowtime = titleShowtime ;
}
/ * *
* This method sets the showCompletionTitle object value .
* @param showCompletionTitle the showCompletionTitle object new value .
*
* /
public void setShowCompletionTitle ( boolean showCompletionTitle )
{
this . showCompletionTitle = showCompletionTitle ;
}
/ * *
* This method sets the lockedLevelIcon value .
* @param lockedLevelIcon the lockedLevelIcon new value .
*
* /
public void setLockedLevelIcon ( ItemStack lockedLevelIcon )
{
this . lockedLevelIcon = lockedLevelIcon ;
}
/ * *
* This method sets the userGuiMode value .
* @param userGuiMode the userGuiMode new value .
* /
public void setUserGuiMode ( GuiMode userGuiMode )
{
this . userGuiMode = userGuiMode ;
}
/ * *
* This method sets the configVersion object value .
* @param configVersion the configVersion object new value .
* /
public void setConfigVersion ( String configVersion )
{
this . configVersion = configVersion ;
}
/ * *
* This method sets the challengeLoreMessage object value .
* @param challengeLoreMessage the challengeLoreMessage object new value .
* /
2019-09-03 08:03:21 +02:00
public void setChallengeLoreMessage ( List < ChallengeLore > challengeLoreMessage )
2019-05-09 15:24:01 +02:00
{
this . challengeLoreMessage = challengeLoreMessage ;
}
/ * *
* This method sets the levelLoreMessage object value .
* @param levelLoreMessage the levelLoreMessage object new value .
* /
2019-09-03 08:03:21 +02:00
public void setLevelLoreMessage ( List < LevelLore > levelLoreMessage )
2019-05-09 15:24:01 +02:00
{
this . levelLoreMessage = levelLoreMessage ;
}
/ * *
* @param resetChallenges new resetChallenges value .
* /
public void setResetChallenges ( boolean resetChallenges )
{
this . resetChallenges = resetChallenges ;
}
/ * *
* @param broadcastMessages new broadcastMessages value .
* /
public void setBroadcastMessages ( boolean broadcastMessages )
{
this . broadcastMessages = broadcastMessages ;
}
/ * *
* @param removeCompleteOneTimeChallenges new removeCompleteOneTimeChallenges value .
* /
public void setRemoveCompleteOneTimeChallenges ( boolean removeCompleteOneTimeChallenges )
{
this . removeCompleteOneTimeChallenges = removeCompleteOneTimeChallenges ;
}
/ * *
* @param addCompletedGlow new addCompletedGlow value .
* /
public void setAddCompletedGlow ( boolean addCompletedGlow )
{
this . addCompletedGlow = addCompletedGlow ;
}
/ * *
* @param disabledGameModes new disabledGameModes value .
* /
public void setDisabledGameModes ( Set < String > disabledGameModes )
{
this . disabledGameModes = disabledGameModes ;
}
/ * *
* @param freeChallengesFirst new freeChallengesFirst value .
* /
public void setFreeChallengesFirst ( boolean freeChallengesFirst )
{
this . freeChallengesFirst = freeChallengesFirst ;
}
/ * *
* This method sets the loreLineLength object value .
* @param loreLineLength the loreLineLength object new value .
* /
public void setLoreLineLength ( int loreLineLength )
{
this . loreLineLength = loreLineLength ;
}
/ * *
* This method sets the storeAsIslandData object value .
* @param storeAsIslandData the storeAsIslandData object new value .
* /
public void setStoreAsIslandData ( boolean storeAsIslandData )
{
this . storeAsIslandData = storeAsIslandData ;
}
/ * *
* This method sets the storeHistory object value .
* @param storeHistory the storeHistory object new value .
* /
public void setStoreHistory ( boolean storeHistory )
{
this . storeHistory = storeHistory ;
}
/ * *
* This method sets the userCommand value .
* @param userCommand the userCommand new value .
* /
public void setUserCommand ( String userCommand )
{
this . userCommand = userCommand ;
}
/ * *
* This method sets the adminCommand value .
* @param adminCommand the adminCommand new value .
* /
public void setAdminCommand ( String adminCommand )
{
this . adminCommand = adminCommand ;
}
/ * *
* This method sets the useCommonGUI value .
* @param useCommonGUI the useCommonGUI new value .
* /
public void setUseCommonGUI ( boolean useCommonGUI )
{
this . useCommonGUI = useCommonGUI ;
}
/ * *
* This method sets the lifeSpan value .
* @param lifeSpan the lifeSpan new value .
*
* /
public void setLifeSpan ( int lifeSpan )
{
this . lifeSpan = lifeSpan ;
}
2019-09-05 14:52:14 +02:00
/ * *
* This method sets the visibilityMode value .
* @param visibilityMode the visibilityMode new value .
*
* /
public void setVisibilityMode ( VisibilityMode visibilityMode )
{
this . visibilityMode = visibilityMode ;
}
2019-01-10 10:30:54 +01:00
}