2019-09-11 16:37:45 +02:00
package com.songoda.epicfarming.settings ;
2018-05-06 18:56:17 +02:00
2019-09-11 17:05:58 +02:00
import com.songoda.core.compatibility.CompatibleMaterial ;
2019-09-11 20:11:34 +02:00
import com.songoda.core.compatibility.ServerVersion ;
2019-09-11 17:05:58 +02:00
import com.songoda.core.configuration.Config ;
import com.songoda.core.configuration.ConfigSetting ;
import com.songoda.core.hooks.EconomyManager ;
2019-09-11 16:37:45 +02:00
import com.songoda.epicfarming.EpicFarming ;
2018-05-06 18:56:17 +02:00
2022-07-03 22:24:32 +02:00
import java.util.Arrays ;
2019-09-11 17:05:58 +02:00
import java.util.stream.Collectors ;
2018-05-06 18:56:17 +02:00
2019-10-02 16:25:44 +02:00
public class Settings {
2023-06-25 14:56:37 +02:00
static final Config CONFIG = EpicFarming . getPlugin ( EpicFarming . class ) . getCoreConfig ( ) ;
2018-08-07 17:07:43 +02:00
2023-06-25 14:56:37 +02:00
public static final ConfigSetting UPGRADE_WITH_ECONOMY = new ConfigSetting ( CONFIG , " Main.Upgrade With Economy " , true ,
2019-09-11 17:05:58 +02:00
" Should you be able to upgrade farmses with economy? " ) ;
2018-05-06 18:56:17 +02:00
2023-06-25 14:56:37 +02:00
public static final ConfigSetting UPGRADE_WITH_XP = new ConfigSetting ( CONFIG , " Main.Upgrade With XP " , true ,
2019-09-11 17:05:58 +02:00
" Should you be able to upgrade farms with experience? " ) ;
2018-05-06 18:56:17 +02:00
2023-06-25 14:56:37 +02:00
public static final ConfigSetting PARTICLE_TYPE = new ConfigSetting ( CONFIG , " Main.Upgrade Particle Type " , " SPELL_WITCH " ,
2019-09-11 17:05:58 +02:00
" The type of particle shown when a furnace is upgraded. " ) ;
2018-05-06 18:56:17 +02:00
2023-06-25 14:56:37 +02:00
public static final ConfigSetting FARM_TICK_SPEED = new ConfigSetting ( CONFIG , " Main.Farm Tick Speed " , 20 ,
2019-09-11 17:05:58 +02:00
" The delay in ticks between each farm growth event. " ) ;
2018-05-06 18:56:17 +02:00
2023-06-25 14:56:37 +02:00
public static final ConfigSetting GROWTH_TICK_SPEED = new ConfigSetting ( CONFIG , " Main.Growth Tick Speed " , 70 ,
2019-09-11 17:05:58 +02:00
" The delay in ticks between each farm entity event. " ) ;
2018-05-06 18:56:17 +02:00
2023-06-25 14:56:37 +02:00
public static final ConfigSetting FARM_BLOCK_MATERIAL = new ConfigSetting ( CONFIG , " Main.Farm Block Material " , ServerVersion . isServerVersionAtLeast ( ServerVersion . V1_9 ) ? " END_ROD " : " TORCH " ,
2019-09-11 17:05:58 +02:00
" What material should be used as a farm item? " ) ;
2018-05-06 18:56:17 +02:00
2023-06-25 14:56:37 +02:00
public static final ConfigSetting NON_COMMAND_FARMS = new ConfigSetting ( CONFIG , " Main.Allow Non Command Issued Farm Items " , false ,
2019-09-11 17:05:58 +02:00
" Should farm item materials found in the wild work as farms? " ) ;
2018-05-06 18:56:17 +02:00
2023-06-25 14:56:37 +02:00
public static final ConfigSetting ANIMATE = new ConfigSetting ( CONFIG , " Main.Animate " , true ,
2019-09-11 17:05:58 +02:00
" Should the processed farm item be animated above the farm item? " ) ;
2018-08-07 17:07:43 +02:00
2023-06-25 14:56:37 +02:00
public static final ConfigSetting DISABLE_AUTO_TIL_LAND = new ConfigSetting ( CONFIG , " Main.Disable Auto Til Land " , false ,
2019-09-11 18:21:55 +02:00
" Should farms not auto til land around them? " ) ;
2018-05-06 18:56:17 +02:00
2023-06-25 14:56:37 +02:00
public static final ConfigSetting USE_PROTECTION_PLUGINS = new ConfigSetting ( CONFIG , " Main.Use Protection Plugins " , true ,
2021-01-26 04:03:37 +01:00
" Should we use protection plugins? " ) ;
2023-06-25 14:56:37 +02:00
public static final ConfigSetting BREAKABLE_BLOCKS = new ConfigSetting ( CONFIG , " Main.Breakable Blocks " , Arrays . asList (
2022-07-03 22:24:32 +02:00
" TALL_GRASS " , " GRASS " , " BLUE_ORCHID " , " AZURE_BLUET " ,
" ALLIUM " , " POPPY " , " DANDELION " , " SNOW " ,
" CORNFLOWER " , " FERN " , " LARGE_FERN " , " SUNFLOWER " ,
" ROSE_BUSH " , " OXEYE_DAISY " , " LILY_OF_THE_VALLEY " , " PEONY " ,
" LILAC " , " WITHER_ROSE " , " PINK_TULIP " , " RED_TULIP " ,
" WHITE_TULIP " , " ORANGE_TULIP " , " NETHER_SPROUTS " , " GLOW_LICHEN " ) ,
" Which blocks should farms be allowed to break when they til the land? " ) ;
2023-06-25 14:56:37 +02:00
public static final ConfigSetting ECONOMY_PLUGIN = new ConfigSetting ( CONFIG , " Main.Economy " , EconomyManager . getEconomy ( ) = = null ? " Vault " : EconomyManager . getEconomy ( ) . getName ( ) ,
2019-09-11 17:05:58 +02:00
" Which economy plugin should be used? " ,
" Supported plugins you have installed: \" " + EconomyManager . getManager ( ) . getRegisteredPlugins ( ) . stream ( ) . collect ( Collectors . joining ( " \" , \" " ) ) + " \" . " ) ;
2018-05-06 18:56:17 +02:00
2023-06-25 14:56:37 +02:00
public static final ConfigSetting ECO_ICON = new ConfigSetting ( CONFIG , " Interfaces.Economy Icon " , " SUNFLOWER " ) ;
public static final ConfigSetting XP_ICON = new ConfigSetting ( CONFIG , " Interfaces.XP Icon " , " EXPERIENCE_BOTTLE " ) ;
2018-08-07 17:07:43 +02:00
2023-06-25 14:56:37 +02:00
public static final ConfigSetting GLASS_TYPE_1 = new ConfigSetting ( CONFIG , " Interfaces.Glass Type 1 " , " GRAY_STAINED_GLASS_PANE " ) ;
public static final ConfigSetting GLASS_TYPE_2 = new ConfigSetting ( CONFIG , " Interfaces.Glass Type 2 " , " BLUE_STAINED_GLASS_PANE " ) ;
public static final ConfigSetting GLASS_TYPE_3 = new ConfigSetting ( CONFIG , " Interfaces.Glass Type 3 " , " LIGHT_BLUE_STAINED_GLASS_PANE " ) ;
2018-05-06 18:56:17 +02:00
2023-06-25 14:56:37 +02:00
public static final ConfigSetting LANGUGE_MODE = new ConfigSetting ( CONFIG , " System.Language Mode " , " en_US " ,
2019-09-11 17:05:58 +02:00
" The enabled language file. " ,
" More language files (if available) can be found in the plugins data folder. " ) ;
2018-08-07 17:07:43 +02:00
2023-06-25 14:56:37 +02:00
public static final ConfigSetting MYSQL_ENABLED = new ConfigSetting ( CONFIG , " MySQL.Enabled " , false , " Set to 'true' to use MySQL instead of SQLite for data storage. " ) ;
public static final ConfigSetting MYSQL_HOSTNAME = new ConfigSetting ( CONFIG , " MySQL.Hostname " , " localhost " ) ;
public static final ConfigSetting MYSQL_PORT = new ConfigSetting ( CONFIG , " MySQL.Port " , 3306 ) ;
public static final ConfigSetting MYSQL_DATABASE = new ConfigSetting ( CONFIG , " MySQL.Database " , " your-database " ) ;
public static final ConfigSetting MYSQL_USERNAME = new ConfigSetting ( CONFIG , " MySQL.Username " , " user " ) ;
public static final ConfigSetting MYSQL_PASSWORD = new ConfigSetting ( CONFIG , " MySQL.Password " , " pass " ) ;
public static final ConfigSetting MYSQL_USE_SSL = new ConfigSetting ( CONFIG , " MySQL.Use SSL " , false ) ;
public static final ConfigSetting MYSQL_POOL_SIZE = new ConfigSetting ( CONFIG , " MySQL.Pool Size " , 3 , " Determines the number of connections the pool is using. Increase this value if you are getting timeout errors when more players online. " ) ;
2022-08-14 17:56:50 +02:00
2019-09-11 17:05:58 +02:00
/ * *
* In order to set dynamic economy comment correctly , this needs to be
* called after EconomyManager load
* /
public static void setupConfig ( ) {
2023-06-25 14:56:37 +02:00
CONFIG . load ( ) ;
CONFIG . setAutoremove ( true ) . setAutosave ( true ) ;
2018-05-06 18:56:17 +02:00
2019-09-11 17:05:58 +02:00
// convert glass pane settings
int color ;
if ( ( color = GLASS_TYPE_1 . getInt ( - 1 ) ) ! = - 1 ) {
2023-06-25 14:56:37 +02:00
CONFIG . set ( GLASS_TYPE_1 . getKey ( ) , CompatibleMaterial . getGlassPaneColor ( color ) . name ( ) ) ;
2018-05-06 18:56:17 +02:00
}
2019-09-11 17:05:58 +02:00
if ( ( color = GLASS_TYPE_2 . getInt ( - 1 ) ) ! = - 1 ) {
2023-06-25 14:56:37 +02:00
CONFIG . set ( GLASS_TYPE_2 . getKey ( ) , CompatibleMaterial . getGlassPaneColor ( color ) . name ( ) ) ;
2019-09-11 17:05:58 +02:00
}
if ( ( color = GLASS_TYPE_3 . getInt ( - 1 ) ) ! = - 1 ) {
2023-06-25 14:56:37 +02:00
CONFIG . set ( GLASS_TYPE_3 . getKey ( ) , CompatibleMaterial . getGlassPaneColor ( color ) . name ( ) ) ;
2018-05-06 18:56:17 +02:00
}
2023-06-25 14:56:37 +02:00
if ( Settings . FARM_TICK_SPEED . getInt ( ) = = 70 ) {
CONFIG . set ( FARM_TICK_SPEED . getKey ( ) , 20 ) ;
}
CONFIG . saveChanges ( ) ;
2018-05-06 18:56:17 +02:00
}
2023-06-25 14:56:37 +02:00
}