Files
CustomNPC-Plus/src/main/java/noppes/npcs/config/ConfigMain.java
T

272 lines
11 KiB
Java
Raw Normal View History

2023-01-07 00:21:08 -05:00
package noppes.npcs.config;
import cpw.mods.fml.common.FMLLog;
import net.minecraftforge.common.config.Configuration;
2023-01-07 18:07:23 -05:00
import net.minecraftforge.common.config.Property;
import noppes.npcs.CustomNpcs;
import noppes.npcs.config.legacy.LegacyConfig;
2023-01-07 00:21:08 -05:00
import org.apache.logging.log4j.Level;
import java.io.File;
public class ConfigMain
{
public static Configuration config;
2023-02-28 03:35:44 -05:00
public final static String GENERAL = "General";
2023-01-07 18:07:23 -05:00
public final static String NPC = "NPC";
public final static String UPDATE = "Update";
2023-01-07 18:07:23 -05:00
/**
* General Main Properties
**/
public static Property EnableUpdateCheckerProperty;
2023-01-07 00:21:08 -05:00
public static boolean EnableUpdateChecker = true;
2023-01-07 18:07:23 -05:00
public static Property DisableExtraBlockProperty;
2023-01-07 00:21:08 -05:00
public static boolean DisableExtraBlock = false;
2023-01-07 18:07:23 -05:00
public static Property DisableExtraItemsProperty;
2023-01-07 00:21:08 -05:00
public static boolean DisableExtraItems = false;
2023-01-07 18:07:23 -05:00
public static Property DisableEnchantsProperty;
2023-01-07 00:21:08 -05:00
public static boolean DisableEnchants = false;
2023-01-07 18:07:23 -05:00
public static Property GunsEnabledProperty;
2023-01-07 00:21:08 -05:00
public static boolean GunsEnabled = true;
2023-01-07 18:07:23 -05:00
public static Property EnchantStartIdProperty;
2023-01-07 00:21:08 -05:00
public static int EnchantStartId = 100;
2023-01-07 18:07:23 -05:00
public static Property LeavesDecayEnabledProperty;
2023-01-07 00:21:08 -05:00
public static boolean LeavesDecayEnabled = true;
2023-01-07 18:07:23 -05:00
public static Property VineGrowthEnabledProperty;
2023-01-07 00:21:08 -05:00
public static boolean VineGrowthEnabled = true;
2023-01-07 18:07:23 -05:00
public static Property IceMeltsEnabledProperty;
2023-01-07 00:21:08 -05:00
public static boolean IceMeltsEnabled = true;
2023-01-07 18:07:23 -05:00
public static Property SoulStoneAnimalsProperty;
2023-01-07 00:21:08 -05:00
public static boolean SoulStoneAnimals = true;
2023-01-07 18:07:23 -05:00
public static Property SoulStoneVillagersProperty;
2023-01-07 00:21:08 -05:00
public static boolean SoulStoneVillagers = false;
2023-01-07 18:07:23 -05:00
public static Property SoulStoneNPCsProperty;
2023-01-07 00:21:08 -05:00
public static boolean SoulStoneNPCs = false;
2023-01-07 18:07:23 -05:00
public static Property SoulStoneFriendlyNPCsProperty;
2023-01-07 00:21:08 -05:00
public static boolean SoulStoneFriendlyNPCs = false;
2023-01-07 18:07:23 -05:00
/**
* General NPC Properties
**/
public static Property OpsOnlyProperty;
2023-01-07 00:21:08 -05:00
public static boolean OpsOnly = false;
2023-01-07 18:07:23 -05:00
public static Property NpcNavRangeProperty;
2023-01-07 00:21:08 -05:00
public static int NpcNavRange = 32;
2023-01-07 18:07:23 -05:00
public static Property NpcSizeLimitProperty;
2023-01-07 00:21:08 -05:00
public static int NpcSizeLimit = 100;
2023-01-07 18:07:23 -05:00
public static Property DefaultInteractLineProperty;
2023-01-07 00:21:08 -05:00
public static String DefaultInteractLine = "Hello @p";
2023-01-07 18:07:23 -05:00
public static Property ChunkLoadersProperty;
2023-01-07 00:21:08 -05:00
public static int ChunkLoaders = 20;
2023-01-07 18:07:23 -05:00
public static Property DialogImageLimitProperty;
2023-01-07 00:21:08 -05:00
public static int DialogImageLimit = 10;
2023-01-07 18:07:23 -05:00
public static Property SkinOverlayLimitProperty;
2023-01-07 00:21:08 -05:00
public static int SkinOverlayLimit = 10;
2023-01-07 18:07:23 -05:00
public static Property NpcUseOpCommandsProperty;
2023-01-07 00:21:08 -05:00
public static boolean NpcUseOpCommands = false;
/**
* Update Properties
**/
public static Property TrackedQuestUpdateFrequencyProperty;
public static int TrackedQuestUpdateFrequency = 5;
2023-01-07 00:21:08 -05:00
public static void init(File configFile)
{
config = new Configuration(configFile);
try
{
config.load();
2023-01-07 18:07:23 -05:00
// General
EnableUpdateCheckerProperty = config.get(GENERAL, "Enables Update Checker", true);
EnableUpdateChecker = EnableUpdateCheckerProperty.getBoolean(true);
DisableExtraBlockProperty = config.get(GENERAL, "Disable Extra Blocks", false);
DisableExtraBlock = DisableExtraBlockProperty.getBoolean(false);
DisableExtraItemsProperty = config.get(GENERAL, "Disable Extra Items", false);
DisableExtraItems = DisableExtraItemsProperty.getBoolean(false);
GunsEnabledProperty = config.get(GENERAL, "Guns Enabled", true, "Set to false if you want to disable guns");
GunsEnabled = GunsEnabledProperty.getBoolean(true);
DisableEnchantsProperty = config.get(GENERAL, "Disable Enchants", false);
DisableEnchants = DisableEnchantsProperty.getBoolean(false);
EnchantStartIdProperty = config.get(GENERAL, "Enchant Start ID", 100, "Start ID for enchants. IDs can only range from 0-256");
EnchantStartId = EnchantStartIdProperty.getInt(100);
LeavesDecayEnabledProperty = config.get(GENERAL, "Leaves Decay Enabled", true);
LeavesDecayEnabled = LeavesDecayEnabledProperty.getBoolean(true);
VineGrowthEnabledProperty = config.get(GENERAL, "Vine Growth Enabled", true);
VineGrowthEnabled = VineGrowthEnabledProperty.getBoolean(true);
IceMeltsEnabledProperty = config.get(GENERAL, "Ice Melt Enabled", true);
IceMeltsEnabled = IceMeltsEnabledProperty.getBoolean(true);
SoulStoneAnimalsProperty = config.get(GENERAL, "Normal playes can use soulstone on Animals", true);
SoulStoneAnimals = SoulStoneAnimalsProperty.getBoolean(true);
SoulStoneVillagersProperty = config.get(GENERAL, "Normal playes can use soulstone on Villagers", true);
SoulStoneVillagers = SoulStoneVillagersProperty.getBoolean(true);
SoulStoneNPCsProperty = config.get(GENERAL, "Normal playes can use soulstone on NPCs", false);
SoulStoneNPCs = SoulStoneNPCsProperty.getBoolean(false);
SoulStoneFriendlyNPCsProperty = config.get(GENERAL, "Normal playes can use soulstone on Friendly NPCs", false);
SoulStoneFriendlyNPCs = SoulStoneFriendlyNPCsProperty.getBoolean(false);
// NPC
NpcNavRangeProperty = config.get(NPC, "NPC Navigation Range", 32, "Navigation search range for NPCs. Not recommended to increase if you have a slow pc or on a server. Minimum of 16, maximum of 96.");
NpcNavRange = NpcNavRangeProperty.getInt(32);
OpsOnlyProperty = config.get(NPC, "Only Ops Edit NPCs", false, "Only ops can create and edit npcs");
OpsOnly = OpsOnlyProperty.getBoolean(false);
NpcUseOpCommandsProperty = config.get(NPC, "NPC Use Op Commands", false, "Set to true if you want the dialog command option to be able to use op commands like tp etc");
NpcUseOpCommands = NpcUseOpCommandsProperty.getBoolean(false);
DefaultInteractLineProperty = config.get(NPC, "Default Interaction Line", "Hello @p", "Default interact line. Leave empty to not have one");
DefaultInteractLine = DefaultInteractLineProperty.getString();
ChunkLoadersProperty = config.get(NPC, "Chunk Loader Limit", 20, "Number of chunk loading npcs that can be active at the same time");
ChunkLoaders = ChunkLoadersProperty.getInt(20);
DialogImageLimitProperty = config.get(NPC, "Dialog Image Limit", 10, "The maximum number of images any dialog can hold.");
DialogImageLimit = DialogImageLimitProperty.getInt(10);
NpcSizeLimitProperty = config.get(NPC, "NPC Size Limit", 100, "Size limit for NPCs. Default 100, larger sizes may cause lag on clients and servers that can't take it!");
NpcSizeLimit = NpcSizeLimitProperty.getInt(100);
SkinOverlayLimitProperty = config.get(NPC, "Skin Overlay Limit", 10, "The maximum number of overlays any npc/player can hold.");
SkinOverlayLimit = SkinOverlayLimitProperty.getInt(10);
// Update
TrackedQuestUpdateFrequencyProperty = config.get(UPDATE, "Tracked Quest Update Frequency", 5, "How often in seconds to update a players tracked quest. [Only applies to Item Quest currently]");
TrackedQuestUpdateFrequency = TrackedQuestUpdateFrequencyProperty.getInt(5);
2023-01-07 18:07:23 -05:00
// Convert to Legacy
if(CustomNpcs.legacyExist){
EnableUpdateChecker = LegacyConfig.EnableUpdateChecker;
EnableUpdateCheckerProperty.set(EnableUpdateChecker);
DisableExtraBlock = LegacyConfig.DisableExtraBlock;
DisableExtraBlockProperty.set(DisableExtraBlock);
DisableExtraItems = LegacyConfig.DisableExtraItems;
DisableExtraItemsProperty.set(DisableExtraItems);
DisableEnchants = LegacyConfig.DisableEnchants;
DisableEnchantsProperty.set(DisableEnchants);
GunsEnabled = LegacyConfig.GunsEnabled;
GunsEnabledProperty.set(GunsEnabled);
EnchantStartId = LegacyConfig.EnchantStartId;
EnchantStartIdProperty.set(EnchantStartId);
LeavesDecayEnabled = LegacyConfig.LeavesDecayEnabled;
LeavesDecayEnabledProperty.set(LeavesDecayEnabled);
VineGrowthEnabled = LegacyConfig.VineGrowthEnabled;
VineGrowthEnabledProperty.set(VineGrowthEnabled);
IceMeltsEnabled = LegacyConfig.IceMeltsEnabled;
IceMeltsEnabledProperty.set(IceMeltsEnabled);
SoulStoneAnimals = LegacyConfig.SoulStoneAnimals;
SoulStoneAnimalsProperty.set(SoulStoneAnimals);
SoulStoneVillagers = LegacyConfig.SoulStoneVillagers;
SoulStoneVillagersProperty.set(SoulStoneVillagers);
SoulStoneNPCs = LegacyConfig.SoulStoneNPCs;
SoulStoneNPCsProperty.set(SoulStoneNPCs);
SoulStoneFriendlyNPCs = LegacyConfig.SoulStoneFriendlyNPCs;
SoulStoneFriendlyNPCsProperty.set(SoulStoneFriendlyNPCs);
OpsOnly = LegacyConfig.OpsOnly;
OpsOnlyProperty.set(OpsOnly);
NpcNavRange = LegacyConfig.NpcNavRange;
NpcNavRangeProperty.set(NpcNavRange);
NpcSizeLimit = LegacyConfig.NpcSizeLimit;
NpcSizeLimitProperty.set(NpcSizeLimit);
DefaultInteractLine = LegacyConfig.DefaultInteractLine;
DefaultInteractLineProperty.set(DefaultInteractLine);
ChunkLoaders = LegacyConfig.ChunkLoaders;
ChunkLoadersProperty.set(ChunkLoaders);
DialogImageLimit = LegacyConfig.DialogImageLimit;
DialogImageLimitProperty.set(DialogImageLimit);
SkinOverlayLimit = LegacyConfig.SkinOverlayLimit;
SkinOverlayLimitProperty.set(SkinOverlayLimit);
NpcUseOpCommands = LegacyConfig.NpcUseOpCommands;
NpcUseOpCommandsProperty.set(NpcUseOpCommands);
}
2023-01-07 00:21:08 -05:00
if (NpcNavRange < 16) {
NpcNavRange = 16;
}
if (NpcNavRange > 96) {
NpcNavRange = 96;
}
2023-01-07 18:07:23 -05:00
if(NpcSizeLimit < 1){
2023-01-07 00:21:08 -05:00
NpcSizeLimit = 1;
2023-01-07 18:07:23 -05:00
}
2023-01-07 00:21:08 -05:00
if (DialogImageLimit < 0) {
DialogImageLimit = 0;
}
if (SkinOverlayLimit < 0) {
SkinOverlayLimit = 0;
}
}
catch (Exception e)
{
FMLLog.log(Level.ERROR, e, "CNPC+ has had a problem loading its main configuration");
}
finally
{
if (config.hasChanged()) {
config.save();
}
}
}
}