mirror of
				https://github.com/mcMMO-Dev/mcMMO.git
				synced 2025-10-31 17:23:42 +01:00 
			
		
		
		
	new config pt 10 - All configs are now managed by ConfigManager (WIP)
This commit is contained in:
		
							
								
								
									
										4
									
								
								pom.xml
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								pom.xml
									
									
									
									
									
								
							| @@ -125,10 +125,10 @@ | |||||||
|                             <pattern>com.flowpowered</pattern> |                             <pattern>com.flowpowered</pattern> | ||||||
|                             <shadedPattern>com.gmail.nossr50.flow</shadedPattern> |                             <shadedPattern>com.gmail.nossr50.flow</shadedPattern> | ||||||
|                         </relocation>--> |                         </relocation>--> | ||||||
|                         <relocation> |                         <!--<relocation> | ||||||
|                             <pattern>ninja.leaping</pattern> |                             <pattern>ninja.leaping</pattern> | ||||||
|                             <shadedPattern>com.gmail.nossr50.configurable</shadedPattern> |                             <shadedPattern>com.gmail.nossr50.configurable</shadedPattern> | ||||||
|                         </relocation> |                         </relocation>--> | ||||||
|                     </relocations> |                     </relocations> | ||||||
|                 </configuration> |                 </configuration> | ||||||
|                 <executions> |                 <executions> | ||||||
|   | |||||||
| @@ -122,20 +122,22 @@ public class AdvancedConfig extends ConfigValidated { | |||||||
|     public static final String SEND_COPY_OF_MESSAGE_TO_CHAT = "SendCopyOfMessageToChat"; |     public static final String SEND_COPY_OF_MESSAGE_TO_CHAT = "SendCopyOfMessageToChat"; | ||||||
|     public static final String EVENTS = "Events"; |     public static final String EVENTS = "Events"; | ||||||
|     public static final String SEND_TITLES = "SendTitles"; |     public static final String SEND_TITLES = "SendTitles"; | ||||||
|     private static AdvancedConfig instance; |     //private static AdvancedConfig instance; | ||||||
|  |  | ||||||
|     private AdvancedConfig() { |     public AdvancedConfig() { | ||||||
|         //super(McmmoCore.getDataFolderPath().getAbsoluteFile(), "advanced.yml", true); |         //super(McmmoCore.getDataFolderPath().getAbsoluteFile(), "advanced.yml", true); | ||||||
|         super(mcMMO.p.getDataFolder().getAbsoluteFile(), "advanced.yml", true); |         super(mcMMO.p.getDataFolder().getAbsoluteFile(), "advanced.yml", true); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public static AdvancedConfig getInstance() { |  | ||||||
|  |  | ||||||
|  |     /*public static AdvancedConfig getInstance() { | ||||||
|         if (instance == null) { |         if (instance == null) { | ||||||
|             instance = new AdvancedConfig(); |             instance = new AdvancedConfig(); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         return instance; |         return instance; | ||||||
|     } |     }*/ | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * The version of this config |      * The version of this config | ||||||
|   | |||||||
| @@ -7,13 +7,13 @@ import org.bukkit.configuration.file.YamlConfiguration; | |||||||
|  |  | ||||||
| import java.util.EnumSet; | import java.util.EnumSet; | ||||||
|  |  | ||||||
| public class ChildConfig extends ConfigCollections { | public class ChildConfig extends ConfigCollection { | ||||||
|     public ChildConfig() { |     public ChildConfig() { | ||||||
|         super("child.yml"); |         super("child.yml"); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     protected void loadKeys() { |     protected void register() { | ||||||
|         config.setDefaults(YamlConfiguration.loadConfiguration(plugin.getResourceAsReader("child.yml"))); |         config.setDefaults(YamlConfiguration.loadConfiguration(plugin.getResourceAsReader("child.yml"))); | ||||||
|  |  | ||||||
|         FamilyTree.clearRegistrations(); // when reloading, need to clear statics |         FamilyTree.clearRegistrations(); // when reloading, need to clear statics | ||||||
|   | |||||||
| @@ -1,7 +1,49 @@ | |||||||
| package com.gmail.nossr50.config; | package com.gmail.nossr50.config; | ||||||
|  |  | ||||||
|  | import java.io.File; | ||||||
|  | import java.util.ArrayList; | ||||||
| import java.util.Collection; | import java.util.Collection; | ||||||
|  |  | ||||||
| public interface ConfigCollection<T> { | /** | ||||||
|     Collection<T> getLoadedCollection(); |  * Represents a config file that registers keys after its initialized | ||||||
|  |  */ | ||||||
|  | public abstract class ConfigCollection<T> extends Config implements Registers, GenericCollectionContainer { | ||||||
|  |  | ||||||
|  |     //The collection held by this class | ||||||
|  |     protected Collection<T> genericCollection; | ||||||
|  |  | ||||||
|  |     public ConfigCollection(String pathToParentFolder, String relativePath, boolean mergeNewKeys) { | ||||||
|  |         super(pathToParentFolder, relativePath, mergeNewKeys); | ||||||
|  |  | ||||||
|  |         //init | ||||||
|  |         initCollection(); | ||||||
|  |  | ||||||
|  |         //load | ||||||
|  |         register(); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     private void initCollection() { | ||||||
|  |         if (genericCollection == null) | ||||||
|  |             genericCollection = new ArrayList<>(); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public ConfigCollection(File pathToParentFolder, String relativePath, boolean mergeNewKeys) { | ||||||
|  |         super(pathToParentFolder, relativePath, mergeNewKeys); | ||||||
|  |  | ||||||
|  |         //init | ||||||
|  |         initCollection(); | ||||||
|  |  | ||||||
|  |         //load | ||||||
|  |         register(); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|  |     public Collection<T> getLoadedCollection() { | ||||||
|  |         return this.genericCollection; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|  |     public void unload() { | ||||||
|  |         genericCollection.clear(); | ||||||
|  |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -1,19 +0,0 @@ | |||||||
| package com.gmail.nossr50.config; |  | ||||||
|  |  | ||||||
| import java.io.File; |  | ||||||
|  |  | ||||||
| /** |  | ||||||
|  * Represents a config file that registers keys after its initialized |  | ||||||
|  */ |  | ||||||
| public abstract class ConfigCollections extends Config implements RegistersKeys, ConfigCollection { |  | ||||||
|  |  | ||||||
|     public ConfigCollections(String pathToParentFolder, String relativePath, boolean mergeNewKeys) { |  | ||||||
|         super(pathToParentFolder, relativePath, mergeNewKeys); |  | ||||||
|         loadKeys(); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     public ConfigCollections(File pathToParentFolder, String relativePath, boolean mergeNewKeys) { |  | ||||||
|         super(pathToParentFolder, relativePath, mergeNewKeys); |  | ||||||
|         loadKeys(); |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @@ -6,19 +6,19 @@ import com.gmail.nossr50.mcMMO; | |||||||
| import com.gmail.nossr50.util.StringUtils; | import com.gmail.nossr50.util.StringUtils; | ||||||
|  |  | ||||||
| public class CoreSkillsConfig extends Config { | public class CoreSkillsConfig extends Config { | ||||||
|     private static CoreSkillsConfig instance; |     //private static CoreSkillsConfig instance; | ||||||
|  |  | ||||||
|     public CoreSkillsConfig() { |     public CoreSkillsConfig() { | ||||||
|         //super(McmmoCore.getDataFolderPath().getAbsoluteFile(),"coreskills.yml", true); |         //super(McmmoCore.getDataFolderPath().getAbsoluteFile(),"coreskills.yml", true); | ||||||
|         super(mcMMO.p.getDataFolder().getAbsoluteFile(),"coreskills.yml", true); |         super(mcMMO.p.getDataFolder().getAbsoluteFile(),"coreskills.yml", true); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public static CoreSkillsConfig getInstance() { |     /*public static CoreSkillsConfig getInstance() { | ||||||
|         if (instance == null) |         if (instance == null) | ||||||
|             return new CoreSkillsConfig(); |             return new CoreSkillsConfig(); | ||||||
|  |  | ||||||
|         return instance; |         return instance; | ||||||
|     } |     }*/ | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * The version of this config |      * The version of this config | ||||||
|   | |||||||
| @@ -0,0 +1,15 @@ | |||||||
|  | package com.gmail.nossr50.config; | ||||||
|  |  | ||||||
|  | import java.util.Collection; | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |  * Represents a class that contains a generic collection | ||||||
|  |  * @param <T> | ||||||
|  |  */ | ||||||
|  | public interface GenericCollectionContainer<T> { | ||||||
|  |     /** | ||||||
|  |      * Grab the collection held by this class | ||||||
|  |      * @return the collection held by this class | ||||||
|  |      */ | ||||||
|  |     Collection<T> getLoadedCollection(); | ||||||
|  | } | ||||||
| @@ -8,20 +8,20 @@ import java.util.ArrayList; | |||||||
| import java.util.List; | import java.util.List; | ||||||
|  |  | ||||||
| public class RankConfig extends ConfigValidated { | public class RankConfig extends ConfigValidated { | ||||||
|     private static RankConfig instance; |     //private static RankConfig instance; | ||||||
|  |  | ||||||
|     public RankConfig() { |     public RankConfig() { | ||||||
|         //super(McmmoCore.getDataFolderPath().getAbsoluteFile(),"skillranks.yml", true); |         //super(McmmoCore.getDataFolderPath().getAbsoluteFile(),"skillranks.yml", true); | ||||||
|         super(mcMMO.p.getDataFolder().getAbsoluteFile(),"skillranks.yml", true); |         super(mcMMO.p.getDataFolder().getAbsoluteFile(),"skillranks.yml", true); | ||||||
|         this.instance = this; |         //this.instance = this; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public static RankConfig getInstance() { |     /*public static RankConfig getInstance() { | ||||||
|         if (instance == null) |         if (instance == null) | ||||||
|             return new RankConfig(); |             return new RankConfig(); | ||||||
|  |  | ||||||
|         return instance; |         return instance; | ||||||
|     } |     }*/ | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public void unload() { |     public void unload() { | ||||||
|   | |||||||
							
								
								
									
										11
									
								
								src/main/java/com/gmail/nossr50/config/Registers.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								src/main/java/com/gmail/nossr50/config/Registers.java
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,11 @@ | |||||||
|  | package com.gmail.nossr50.config; | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |  * A class that is expected to register one thing into another thing | ||||||
|  |  */ | ||||||
|  | public interface Registers { | ||||||
|  |     /** | ||||||
|  |      * Register stuff | ||||||
|  |      */ | ||||||
|  |     void register(); | ||||||
|  | } | ||||||
| @@ -1,11 +0,0 @@ | |||||||
| package com.gmail.nossr50.config; |  | ||||||
|  |  | ||||||
| /** |  | ||||||
|  * A class that registers keys |  | ||||||
|  */ |  | ||||||
| public interface RegistersKeys { |  | ||||||
|     /** |  | ||||||
|      * Loads up keys |  | ||||||
|      */ |  | ||||||
|     void loadKeys(); |  | ||||||
| } |  | ||||||
| @@ -7,7 +7,7 @@ import java.util.ArrayList; | |||||||
| import java.util.List; | import java.util.List; | ||||||
|  |  | ||||||
| public class SoundConfig extends ConfigValidated { | public class SoundConfig extends ConfigValidated { | ||||||
|     private static SoundConfig instance; |     //private static SoundConfig instance; | ||||||
|  |  | ||||||
|     public SoundConfig() { |     public SoundConfig() { | ||||||
|         //super(McmmoCore.getDataFolderPath().getAbsoluteFile(), "sounds.yml", true); |         //super(McmmoCore.getDataFolderPath().getAbsoluteFile(), "sounds.yml", true); | ||||||
| @@ -15,12 +15,12 @@ public class SoundConfig extends ConfigValidated { | |||||||
|         this.instance = this; |         this.instance = this; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public static SoundConfig getInstance() { |     /*public static SoundConfig getInstance() { | ||||||
|         if (instance == null) |         if (instance == null) | ||||||
|             return new SoundConfig(); |             return new SoundConfig(); | ||||||
|  |  | ||||||
|         return instance; |         return instance; | ||||||
|     } |     }*/ | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public void unload() { |     public void unload() { | ||||||
|   | |||||||
| @@ -0,0 +1,166 @@ | |||||||
|  | package com.gmail.nossr50.config.collectionconfigs; | ||||||
|  |  | ||||||
|  | import com.gmail.nossr50.config.*; | ||||||
|  | import com.gmail.nossr50.config.mods.ArmorConfigManager; | ||||||
|  | import com.gmail.nossr50.config.mods.BlockConfigManager; | ||||||
|  | import com.gmail.nossr50.config.mods.EntityConfigManager; | ||||||
|  | import com.gmail.nossr50.config.mods.ToolConfigManager; | ||||||
|  | import com.gmail.nossr50.config.skills.alchemy.PotionConfig; | ||||||
|  | import com.gmail.nossr50.config.treasure.TreasureConfig; | ||||||
|  | import com.gmail.nossr50.skills.child.ChildConfig; | ||||||
|  | import com.gmail.nossr50.skills.repair.repairables.Repairable; | ||||||
|  | import com.gmail.nossr50.skills.repair.repairables.SimpleRepairableManager; | ||||||
|  | import com.gmail.nossr50.skills.salvage.salvageables.Salvageable; | ||||||
|  | import com.gmail.nossr50.skills.salvage.salvageables.SimpleSalvageableManager; | ||||||
|  |  | ||||||
|  | import java.util.ArrayList; | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |  * | ||||||
|  |  * The Config Manager handles initializing, loading, and unloading registers for all configs that mcMMO uses | ||||||
|  |  * This makes sure that mcMMO properly loads and unloads its values on reload | ||||||
|  |  * | ||||||
|  |  * Config Manager also holds all of our MultiConfigContainers | ||||||
|  |  * | ||||||
|  |  * MultiConfigContainers | ||||||
|  |  *      Represents a collection of config files that serve a similar purpose | ||||||
|  |  *      As an example, with Repair you can have an unlimited number of files named repair.*.yml and each one will be treated the same and have its collections registered | ||||||
|  |  *      The master file is always named x.vanilla.yml, for example "repair.vanilla.yml" | ||||||
|  |  *          To be honest I'm not sure how many people make use of this system, but I'm keeping it since its been in mcMMO for like 6+ years | ||||||
|  |  */ | ||||||
|  | public final class ConfigManager { | ||||||
|  |  | ||||||
|  |     /* UNLOAD REGISTER */ | ||||||
|  |  | ||||||
|  |     private ArrayList<Unload> unloadables; | ||||||
|  |  | ||||||
|  |     /* MULTI CONFIG INSTANCES */ | ||||||
|  |  | ||||||
|  |     private MultiConfigContainer<Repairable> repairableMultiConfigContainer; | ||||||
|  |     private MultiConfigContainer<Salvageable> salvageableMultiConfigContainer; | ||||||
|  |  | ||||||
|  |     /* COLLECTION MANAGERS */ | ||||||
|  |  | ||||||
|  |     private SimpleRepairableManager simpleRepairableManager; | ||||||
|  |     private SimpleSalvageableManager simpleSalvageableManager; | ||||||
|  |  | ||||||
|  |     /* CONFIG INSTANCES */ | ||||||
|  |  | ||||||
|  |     private TreasureConfig treasureConfig; | ||||||
|  |     private AdvancedConfig advancedConfig; | ||||||
|  |     private PotionConfig potionConfig; | ||||||
|  |     private CoreSkillsConfig coreSkillsConfig; | ||||||
|  |     private SoundConfig soundConfig; | ||||||
|  |     private RankConfig rankConfig; | ||||||
|  |  | ||||||
|  |     public ConfigManager() | ||||||
|  |     { | ||||||
|  |         unloadables = new ArrayList<>(); | ||||||
|  |  | ||||||
|  |         // Load Config Files | ||||||
|  |         // I'm pretty these are supposed to be done in a specific order, so don't rearrange them willy nilly | ||||||
|  |         treasureConfig = new TreasureConfig(); | ||||||
|  |         unloadables.add(treasureConfig); | ||||||
|  |  | ||||||
|  |         advancedConfig = new AdvancedConfig(); | ||||||
|  |         unloadables.add(advancedConfig); | ||||||
|  |  | ||||||
|  |         potionConfig = new PotionConfig(); | ||||||
|  |         unloadables.add(potionConfig); | ||||||
|  |  | ||||||
|  |         coreSkillsConfig = new CoreSkillsConfig(); | ||||||
|  |         unloadables.add(coreSkillsConfig); | ||||||
|  |  | ||||||
|  |         soundConfig = new SoundConfig(); | ||||||
|  |         unloadables.add(soundConfig); | ||||||
|  |  | ||||||
|  |         rankConfig = new RankConfig(); | ||||||
|  |         unloadables.add(rankConfig); | ||||||
|  |  | ||||||
|  |         //TODO: This config serves no purpose so its getting removed | ||||||
|  |         new ChildConfig(); | ||||||
|  |  | ||||||
|  |         if (MainConfig.getInstance().getToolModsEnabled()) { | ||||||
|  |             new ToolConfigManager(); | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         if (MainConfig.getInstance().getArmorModsEnabled()) { | ||||||
|  |             new ArmorConfigManager(); | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         if (MainConfig.getInstance().getBlockModsEnabled()) { | ||||||
|  |             new BlockConfigManager(); | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         if (MainConfig.getInstance().getEntityModsEnabled()) { | ||||||
|  |             new EntityConfigManager(); | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         // Multi Config Containers | ||||||
|  |         initMultiConfigContainers(); | ||||||
|  |  | ||||||
|  |         // Register Managers | ||||||
|  |         initCollectionManagers(); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * Initializes all of our Multi Config Containers | ||||||
|  |      */ | ||||||
|  |     private void initMultiConfigContainers() | ||||||
|  |     { | ||||||
|  |         //Repair | ||||||
|  |         repairableMultiConfigContainer = new MultiConfigContainer<>("repair", CollectionClassType.REPAIR); | ||||||
|  |         unloadables.add(repairableMultiConfigContainer); | ||||||
|  |  | ||||||
|  |         //Salvage | ||||||
|  |         salvageableMultiConfigContainer = new MultiConfigContainer<>("salvage", CollectionClassType.SALVAGE); | ||||||
|  |         unloadables.add(salvageableMultiConfigContainer); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * Initializes any managers related to config collections | ||||||
|  |      */ | ||||||
|  |     private void initCollectionManagers() | ||||||
|  |     { | ||||||
|  |         // Handles registration of repairables | ||||||
|  |         simpleRepairableManager = new SimpleRepairableManager(getRepairables()); | ||||||
|  |         unloadables.add(simpleRepairableManager); | ||||||
|  |  | ||||||
|  |         // Handles registration of salvageables | ||||||
|  |         simpleSalvageableManager = new SimpleSalvageableManager(getSalvageables()); | ||||||
|  |         unloadables.add(simpleSalvageableManager); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * Get all loaded repairables (loaded from all repairable configs) | ||||||
|  |      * @return the currently loaded repairables | ||||||
|  |      */ | ||||||
|  |     public ArrayList<Repairable> getRepairables() | ||||||
|  |     { | ||||||
|  |         return (ArrayList<Repairable>) repairableMultiConfigContainer.getCollection(); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * Get all loaded salvageables (loaded from all salvageable configs) | ||||||
|  |      * @return the currently loaded salvageables | ||||||
|  |      */ | ||||||
|  |     public ArrayList<Salvageable> getSalvageables() | ||||||
|  |     { | ||||||
|  |         return (ArrayList<Salvageable>) salvageableMultiConfigContainer.getCollection(); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * Unloads all config options (prepares for reload) | ||||||
|  |      */ | ||||||
|  |     public void unloadAllConfigsAndRegisters() | ||||||
|  |     { | ||||||
|  |         //Unload | ||||||
|  |         for(Unload unloadable : unloadables) | ||||||
|  |         { | ||||||
|  |             unloadable.unload(); | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         //Clear | ||||||
|  |         unloadables.clear(); | ||||||
|  |     } | ||||||
|  | } | ||||||
| @@ -0,0 +1,155 @@ | |||||||
|  | package com.gmail.nossr50.config.collectionconfigs; | ||||||
|  |  | ||||||
|  | import com.gmail.nossr50.config.ConfigCollection; | ||||||
|  | import com.gmail.nossr50.config.Unload; | ||||||
|  | import com.gmail.nossr50.mcMMO; | ||||||
|  |  | ||||||
|  | import java.io.File; | ||||||
|  | import java.lang.reflect.InvocationTargetException; | ||||||
|  | import java.util.ArrayList; | ||||||
|  | import java.util.Collection; | ||||||
|  | import java.util.regex.Pattern; | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |  * Represents a type of config collection, these config collections are spread across multiple config files potentially | ||||||
|  |  * @param <T> | ||||||
|  |  */ | ||||||
|  | public class MultiConfigContainer<T> implements Unload { | ||||||
|  |  | ||||||
|  |     /* CONSTANTS */ | ||||||
|  |     public static final String DEFAULT_MULTICONFIG_FILENAME_SUFFIX = ".vanilla.yml"; | ||||||
|  |  | ||||||
|  |     /* VARS */ | ||||||
|  |     private final String configPrefix; | ||||||
|  |     private Collection<T> collection; | ||||||
|  |     public final CollectionClassType collectionClassType; | ||||||
|  |     private ConfigCollection vanillaConfig; | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|  |     public void unload() { | ||||||
|  |         collection.clear(); | ||||||
|  |         vanillaConfig.unload(); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public MultiConfigContainer(String configPrefix, CollectionClassType collectionClassType) | ||||||
|  |     { | ||||||
|  |         //Define Config Class | ||||||
|  |         this.collectionClassType = collectionClassType; | ||||||
|  |  | ||||||
|  |         //Define Config Filename Prefix | ||||||
|  |         this.configPrefix = configPrefix; | ||||||
|  |  | ||||||
|  |         //Init Collection | ||||||
|  |         collection = new ArrayList<T>(); | ||||||
|  |  | ||||||
|  |         //Load Configs | ||||||
|  |  | ||||||
|  |         //Vanilla Config | ||||||
|  |         initConfigAndAddCollection(getVanillaConfigName(configPrefix)); | ||||||
|  |  | ||||||
|  |         //Custom Configs | ||||||
|  |         loadCustomCollections(configPrefix); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * Add another collection to this collection | ||||||
|  |      * @param otherCollection | ||||||
|  |      */ | ||||||
|  |     private void addCollection(Collection<T> otherCollection) | ||||||
|  |     { | ||||||
|  |         collection.addAll(otherCollection); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * Grabs the Class to instance for this config collection | ||||||
|  |      * @param collectionClassType the type of class | ||||||
|  |      * @return the class to instance for this config collection | ||||||
|  |      */ | ||||||
|  |     private Class getConfigClass(CollectionClassType collectionClassType) | ||||||
|  |     { | ||||||
|  |         switch(collectionClassType) { | ||||||
|  |             case REPAIR: | ||||||
|  |                 return RepairConfig.class; | ||||||
|  |             case SALVAGE: | ||||||
|  |                 return SalvageConfig.class; | ||||||
|  |             default: | ||||||
|  |                 mcMMO.p.getLogger().severe("[DEBUG] Config Class type is undefined!"); | ||||||
|  |                 return null; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * Gets the name of the vanilla config which is always present | ||||||
|  |      * @param configPrefix the prefix to the filename, for example "repair" or "salvage" | ||||||
|  |      * @return the name of the vanilla config file for this collection | ||||||
|  |      */ | ||||||
|  |     private String getVanillaConfigName(String configPrefix) | ||||||
|  |     { | ||||||
|  |         return configPrefix+DEFAULT_MULTICONFIG_FILENAME_SUFFIX; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * Initializes a config and attempts to load add its collection | ||||||
|  |      * @param configFileName the filename of the config to load | ||||||
|  |      */ | ||||||
|  |     private void initConfigAndAddCollection(String configFileName) | ||||||
|  |     { | ||||||
|  |         mcMMO.p.getLogger().info("Reading from collection config - "+configFileName); | ||||||
|  |         ConfigCollection configCollection = null; | ||||||
|  |  | ||||||
|  |         try { | ||||||
|  |             configCollection = (ConfigCollection) getConfigClass(collectionClassType).getConstructor(String.class).newInstance(configFileName); | ||||||
|  |         } catch (InstantiationException e) { | ||||||
|  |             e.printStackTrace(); | ||||||
|  |         } catch (IllegalAccessException e) { | ||||||
|  |             e.printStackTrace(); | ||||||
|  |         } catch (InvocationTargetException e) { | ||||||
|  |             e.printStackTrace(); | ||||||
|  |         } catch (NoSuchMethodException e) { | ||||||
|  |             e.printStackTrace(); | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         //Add the collection loaded from this config | ||||||
|  |         addCollection(configCollection.getLoadedCollection()); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * mcMMO allows collection config files to be named things like repair.whatevernameyouwanthere.yml and so on, | ||||||
|  |      *  these files are treated in the same way as the vanilla file. They serve the purpose of organization | ||||||
|  |      * @param configPrefix the prefix of the file name, for example "repair", "salvage", etc | ||||||
|  |      */ | ||||||
|  |     public void loadCustomCollections(String configPrefix) | ||||||
|  |     { | ||||||
|  |         String vanillaConfigFileName = getVanillaConfigName(configPrefix); | ||||||
|  |  | ||||||
|  |         //Find other files | ||||||
|  |         Pattern pattern = Pattern.compile(configPrefix+"\\.(?:.+)\\.yml"); | ||||||
|  |         //File dataFolder = McmmoCore.getDataFolderPath(); | ||||||
|  |         File dataFolder = mcMMO.p.getDataFolder(); | ||||||
|  |  | ||||||
|  |         for (String fileName : dataFolder.list()) { | ||||||
|  |             //Vanilla Config is already loaded | ||||||
|  |             if(fileName.equalsIgnoreCase(vanillaConfigFileName)) | ||||||
|  |                 continue; | ||||||
|  |  | ||||||
|  |             //Find files that match the pattern | ||||||
|  |             if (!pattern.matcher(fileName).matches()) { | ||||||
|  |                 continue; | ||||||
|  |             } | ||||||
|  |  | ||||||
|  |             //Init file | ||||||
|  |             File currentFile = new File(dataFolder, fileName); | ||||||
|  |  | ||||||
|  |             //Make sure its not a directory (needed?) | ||||||
|  |             if(currentFile.isDirectory()) | ||||||
|  |                 continue; | ||||||
|  |  | ||||||
|  |             //Load and add the collections | ||||||
|  |             initConfigAndAddCollection(fileName); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public Collection<T> getCollection() { | ||||||
|  |         return collection; | ||||||
|  |     } | ||||||
|  | } | ||||||
| @@ -1,119 +0,0 @@ | |||||||
| package com.gmail.nossr50.config.collectionconfigs; |  | ||||||
|  |  | ||||||
| import com.gmail.nossr50.config.ConfigCollection; |  | ||||||
| import com.gmail.nossr50.config.ConfigCollections; |  | ||||||
| import com.gmail.nossr50.mcMMO; |  | ||||||
| import com.gmail.nossr50.skills.repair.repairables.Repairable; |  | ||||||
| import com.gmail.nossr50.skills.salvage.salvageables.Salvageable; |  | ||||||
|  |  | ||||||
| import java.io.File; |  | ||||||
| import java.lang.reflect.InvocationTargetException; |  | ||||||
| import java.util.ArrayList; |  | ||||||
| import java.util.Collection; |  | ||||||
| import java.util.List; |  | ||||||
| import java.util.regex.Pattern; |  | ||||||
|  |  | ||||||
| /** |  | ||||||
|  * Represents a collection of config files that serve a similar purpose |  | ||||||
|  * For example, files named repair.*.yml are all loaded into memory, this lets admins keep their config files clean |  | ||||||
|  * |  | ||||||
|  * To be honest I'm not sure how many people make use of this system, but I'm keeping it since its been in mcMMO for like 6+ years |  | ||||||
|  */ |  | ||||||
| public final class MultiConfigManager { |  | ||||||
|  |  | ||||||
|     public static final String DEFAULT_MULTICONFIG_FILENAME_SUFFIX = ".vanilla.yml"; |  | ||||||
|  |  | ||||||
|     //Configs |  | ||||||
|     public com.gmail.nossr50.config.collectionconfigs.RepairConfig vanillaRepairConfig; //This is the main config file that mcMMO will copy out |  | ||||||
|     public com.gmail.nossr50.config.collectionconfigs.SalvageConfig vanillaSalvageConfig; |  | ||||||
|  |  | ||||||
|     private static List<Repairable> repairables; |  | ||||||
|     private static List<Salvageable> salvageables; |  | ||||||
|  |  | ||||||
|     public MultiConfigManager(String fileNamePrefix) |  | ||||||
|     { |  | ||||||
|         //init Collections |  | ||||||
|         repairables = new ArrayList<>(); |  | ||||||
|         salvageables = new ArrayList<>(); |  | ||||||
|  |  | ||||||
|         //init vanilla configs |  | ||||||
|         vanillaRepairConfig = new com.gmail.nossr50.config.collectionconfigs.RepairConfig(getVanillaConfigName("repair")); |  | ||||||
|         vanillaSalvageConfig = new com.gmail.nossr50.config.collectionconfigs.SalvageConfig(getVanillaConfigName("salvage")); |  | ||||||
|  |  | ||||||
|         //add valid vanilla collections to main collection |  | ||||||
|         repairables.addAll(vanillaRepairConfig.getLoadedCollection()); |  | ||||||
|         salvageables.addAll(vanillaSalvageConfig.getLoadedCollection()); |  | ||||||
|  |  | ||||||
|         //add valid custom collections to main collection |  | ||||||
|         loadCustomCollections("repair", repairables, com.gmail.nossr50.config.collectionconfigs.RepairConfig.class); |  | ||||||
|         loadCustomCollections("salvage", salvageables, com.gmail.nossr50.config.collectionconfigs.SalvageConfig.class); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     /** |  | ||||||
|      * mcMMO allows collection config files to be named things like repair.whatevernameyouwanthere.yml and so on, |  | ||||||
|      *  these files are treated in the same way as the vanilla file. They serve the purpose of organization |  | ||||||
|      * @param configPrefix the prefix of the file name, for example "repair", "salvage", etc |  | ||||||
|      * @param collection the collection that will be added to |  | ||||||
|      */ |  | ||||||
|     public void loadCustomCollections(String configPrefix, Collection<?> collection, Class<? extends ConfigCollection> configClass) |  | ||||||
|     { |  | ||||||
|         String vanillaConfigFileName = getVanillaConfigName(configPrefix); |  | ||||||
|  |  | ||||||
|         //Find other files |  | ||||||
|         Pattern pattern = Pattern.compile(configPrefix+"\\.(?:.+)\\.yml"); |  | ||||||
|         //File dataFolder = McmmoCore.getDataFolderPath(); |  | ||||||
|         File dataFolder = mcMMO.p.getDataFolder(); |  | ||||||
|  |  | ||||||
|         for (String fileName : dataFolder.list()) { |  | ||||||
|             //Vanilla Config is already loaded |  | ||||||
|             if(fileName.equalsIgnoreCase(vanillaConfigFileName)) |  | ||||||
|                 continue; |  | ||||||
|  |  | ||||||
|             //Find files that match the pattern |  | ||||||
|             if (!pattern.matcher(fileName).matches()) { |  | ||||||
|                 continue; |  | ||||||
|             } |  | ||||||
|  |  | ||||||
|             //Init file |  | ||||||
|             File currentFile = new File(dataFolder, fileName); |  | ||||||
|  |  | ||||||
|             //Make sure its not a directory (needed?) |  | ||||||
|             if(currentFile.isDirectory()) |  | ||||||
|                 continue; |  | ||||||
|  |  | ||||||
|             try { |  | ||||||
|                 //TODO: Valid? |  | ||||||
|                 ConfigCollections customConfig = (ConfigCollections) getConfigClass(configPrefix).getConstructor(String.class).newInstance(configPrefix); |  | ||||||
|                 collection.addAll(customConfig.getLoadedCollection()); |  | ||||||
|  |  | ||||||
|             } catch (InstantiationException e) { |  | ||||||
|                 e.printStackTrace(); |  | ||||||
|             } catch (IllegalAccessException e) { |  | ||||||
|                 e.printStackTrace(); |  | ||||||
|             } catch (InvocationTargetException e) { |  | ||||||
|                 e.printStackTrace(); |  | ||||||
|             } catch (NoSuchMethodException e) { |  | ||||||
|                 e.printStackTrace(); |  | ||||||
|             } |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     private String getVanillaConfigName(String configPrefix) |  | ||||||
|     { |  | ||||||
|         return configPrefix+DEFAULT_MULTICONFIG_FILENAME_SUFFIX; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     private Class getConfigClass(String configPrefix) |  | ||||||
|     { |  | ||||||
|         switch(configPrefix) { |  | ||||||
|             case "repair": |  | ||||||
|                 return RepairConfig.class; |  | ||||||
|             case "salvage": |  | ||||||
|                 return SalvageConfig.class; |  | ||||||
|             default: |  | ||||||
|                 mcMMO.p.getLogger().severe("[DEBUG] Config Class is null!"); |  | ||||||
|                 return null; |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
|  |  | ||||||
| } |  | ||||||
| @@ -1,7 +1,8 @@ | |||||||
| package com.gmail.nossr50.config.collectionconfigs; | package com.gmail.nossr50.config.collectionconfigs; | ||||||
|  |  | ||||||
| import com.gmail.nossr50.config.ConfigCollections; | import com.gmail.nossr50.config.ConfigCollection; | ||||||
| import com.gmail.nossr50.datatypes.skills.MaterialType; | import com.gmail.nossr50.datatypes.skills.MaterialType; | ||||||
|  | import com.gmail.nossr50.mcMMO; | ||||||
| import com.gmail.nossr50.skills.repair.repairables.Repairable; | import com.gmail.nossr50.skills.repair.repairables.Repairable; | ||||||
| import com.gmail.nossr50.skills.repair.repairables.RepairableFactory; | import com.gmail.nossr50.skills.repair.repairables.RepairableFactory; | ||||||
| import com.gmail.nossr50.util.ItemUtils; | import com.gmail.nossr50.util.ItemUtils; | ||||||
| @@ -12,28 +13,16 @@ import org.bukkit.Material; | |||||||
| import org.bukkit.inventory.ItemStack; | import org.bukkit.inventory.ItemStack; | ||||||
|  |  | ||||||
| import java.util.ArrayList; | import java.util.ArrayList; | ||||||
| import java.util.Collection; |  | ||||||
| import java.util.Iterator; | import java.util.Iterator; | ||||||
| import java.util.List; | import java.util.List; | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * This config |  * This config | ||||||
|  */ |  */ | ||||||
| public class RepairConfig extends ConfigCollections { | public class RepairConfig extends ConfigCollection { | ||||||
|     private List<Repairable> repairables; |  | ||||||
|  |  | ||||||
|     public RepairConfig(String fileName) { |     public RepairConfig(String fileName) { | ||||||
|         super(McmmoCore.getDataFolderPath().getAbsoluteFile(), fileName, false); |         //super(McmmoCore.getDataFolderPath().getAbsoluteFile(), fileName, false); | ||||||
|     } |         super(mcMMO.p.getDataFolder().getAbsoluteFile(), fileName, false); | ||||||
|  |  | ||||||
|     @Override |  | ||||||
|     public void unload() { |  | ||||||
|         repairables = null; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     @Override |  | ||||||
|     public Collection getLoadedCollection() { |  | ||||||
|         return repairables == null ? new ArrayList<Repairable>() : repairables; |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
| @@ -47,9 +36,7 @@ public class RepairConfig extends ConfigCollections { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public void loadKeys() { |     public void register() { | ||||||
|         repairables = new ArrayList<Repairable>(); |  | ||||||
|  |  | ||||||
|         ConfigurationNode repairablesNode = getUserRootNode().getNode("Repairables"); |         ConfigurationNode repairablesNode = getUserRootNode().getNode("Repairables"); | ||||||
|         List<? extends ConfigurationNode> repairablesNodeChildrenList = repairablesNode.getChildrenList(); |         List<? extends ConfigurationNode> repairablesNodeChildrenList = repairablesNode.getChildrenList(); | ||||||
|         Iterator<? extends ConfigurationNode> configIter = repairablesNodeChildrenList.iterator(); |         Iterator<? extends ConfigurationNode> configIter = repairablesNodeChildrenList.iterator(); | ||||||
| @@ -164,7 +151,7 @@ public class RepairConfig extends ConfigCollections { | |||||||
|  |  | ||||||
|             if (noErrorsInRepairable(reason)) { |             if (noErrorsInRepairable(reason)) { | ||||||
|                 Repairable repairable = RepairableFactory.getRepairable(itemType, repairMaterial, repairMetadata, minimumLevel, minimumQuantity, maximumDurability, repairConfigItemCategory, repairMaterialType, xpMultiplier); |                 Repairable repairable = RepairableFactory.getRepairable(itemType, repairMaterial, repairMetadata, minimumLevel, minimumQuantity, maximumDurability, repairConfigItemCategory, repairMaterialType, xpMultiplier); | ||||||
|                 repairables.add(repairable); |                 genericCollection.add(repairable); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -1,8 +1,9 @@ | |||||||
| package com.gmail.nossr50.config.collectionconfigs; | package com.gmail.nossr50.config.collectionconfigs; | ||||||
|  |  | ||||||
| import com.gmail.nossr50.config.ConfigCollections; | import com.gmail.nossr50.config.ConfigCollection; | ||||||
| import com.gmail.nossr50.datatypes.skills.ItemType; | import com.gmail.nossr50.datatypes.skills.ItemType; | ||||||
| import com.gmail.nossr50.datatypes.skills.MaterialType; | import com.gmail.nossr50.datatypes.skills.MaterialType; | ||||||
|  | import com.gmail.nossr50.mcMMO; | ||||||
| import com.gmail.nossr50.skills.salvage.salvageables.Salvageable; | import com.gmail.nossr50.skills.salvage.salvageables.Salvageable; | ||||||
| import com.gmail.nossr50.skills.salvage.salvageables.SalvageableFactory; | import com.gmail.nossr50.skills.salvage.salvageables.SalvageableFactory; | ||||||
| import com.gmail.nossr50.util.ItemUtils; | import com.gmail.nossr50.util.ItemUtils; | ||||||
| @@ -12,25 +13,14 @@ import org.bukkit.configuration.ConfigurationSection; | |||||||
| import org.bukkit.inventory.ItemStack; | import org.bukkit.inventory.ItemStack; | ||||||
|  |  | ||||||
| import java.util.ArrayList; | import java.util.ArrayList; | ||||||
| import java.util.Collection; |  | ||||||
| import java.util.List; | import java.util.List; | ||||||
| import java.util.Set; | import java.util.Set; | ||||||
|  |  | ||||||
| public class SalvageConfig extends ConfigCollections { | public class SalvageConfig extends ConfigCollection { | ||||||
|     private List<Salvageable> salvageables; |  | ||||||
|  |  | ||||||
|     public SalvageConfig(String fileName) { |     public SalvageConfig(String fileName) { | ||||||
|         super(McmmoCore.getDataFolderPath().getAbsoluteFile(), fileName, false); |         //super(McmmoCore.getDataFolderPath().getAbsoluteFile(), fileName, false); | ||||||
|     } |         super(mcMMO.p.getDataFolder().getAbsoluteFile(), fileName, false); | ||||||
|  |  | ||||||
|     @Override |  | ||||||
|     public Collection getLoadedCollection() { |  | ||||||
|         return salvageables == null ? new ArrayList<Salvageable>() : salvageables; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     @Override |  | ||||||
|     public void unload() { |  | ||||||
|         salvageables = null; |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
| @@ -44,9 +34,7 @@ public class SalvageConfig extends ConfigCollections { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     protected void loadKeys() { |     public void register() { | ||||||
|         salvageables = new ArrayList<Salvageable>(); |  | ||||||
|  |  | ||||||
|         ConfigurationSection section = config.getConfigurationSection("Salvageables"); |         ConfigurationSection section = config.getConfigurationSection("Salvageables"); | ||||||
|         Set<String> keys = section.getKeys(false); |         Set<String> keys = section.getKeys(false); | ||||||
|  |  | ||||||
| @@ -149,7 +137,7 @@ public class SalvageConfig extends ConfigCollections { | |||||||
|  |  | ||||||
|             if (noErrorsInSalvageable(reason)) { |             if (noErrorsInSalvageable(reason)) { | ||||||
|                 Salvageable salvageable = SalvageableFactory.getSalvageable(itemMaterial, salvageMaterial, salvageMetadata, minimumLevel, maximumQuantity, maximumDurability, salvageItemType, salvageMaterialType, xpMultiplier); |                 Salvageable salvageable = SalvageableFactory.getSalvageable(itemMaterial, salvageMaterial, salvageMetadata, minimumLevel, maximumQuantity, maximumDurability, salvageItemType, salvageMaterialType, xpMultiplier); | ||||||
|                 salvageables.add(salvageable); |                 genericCollection.add(salvageable); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -5,8 +5,9 @@ import com.gmail.nossr50.datatypes.experience.FormulaType; | |||||||
| import com.gmail.nossr50.datatypes.skills.MaterialType; | import com.gmail.nossr50.datatypes.skills.MaterialType; | ||||||
| import com.gmail.nossr50.datatypes.skills.PrimarySkillType; | import com.gmail.nossr50.datatypes.skills.PrimarySkillType; | ||||||
| import com.gmail.nossr50.datatypes.skills.alchemy.PotionStage; | import com.gmail.nossr50.datatypes.skills.alchemy.PotionStage; | ||||||
|  | import com.gmail.nossr50.mcMMO; | ||||||
| import com.gmail.nossr50.util.StringUtils; | import com.gmail.nossr50.util.StringUtils; | ||||||
| import com.sk89q.worldedit.world.block.BlockType; | import org.bukkit.Material; | ||||||
| import org.bukkit.boss.BarColor; | import org.bukkit.boss.BarColor; | ||||||
| import org.bukkit.boss.BarStyle; | import org.bukkit.boss.BarStyle; | ||||||
| import org.bukkit.entity.EntityType; | import org.bukkit.entity.EntityType; | ||||||
| @@ -77,7 +78,8 @@ public class ExperienceConfig extends ConfigValidated { | |||||||
|  |  | ||||||
|     //TODO: Should merge be false? Seems okay to leave it as true.. |     //TODO: Should merge be false? Seems okay to leave it as true.. | ||||||
|     private ExperienceConfig() { |     private ExperienceConfig() { | ||||||
|         super(McmmoCore.getDataFolderPath().getAbsoluteFile(), "experience.yml", true); |         //super(McmmoCore.getDataFolderPath().getAbsoluteFile(), "experience.yml", true); | ||||||
|  |         super(mcMMO.p.getDataFolder().getAbsoluteFile(), "experience.yml", true); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public static ExperienceConfig getInstance() { |     public static ExperienceConfig getInstance() { | ||||||
| @@ -305,11 +307,11 @@ public class ExperienceConfig extends ConfigValidated { | |||||||
|  |  | ||||||
|     /* Combat XP Multipliers */ |     /* Combat XP Multipliers */ | ||||||
|     public double getCombatXP(EntityType entity) { |     public double getCombatXP(EntityType entity) { | ||||||
|         return getDoubleValue(EXPERIENCE, COMBAT, MULTIPLIER1, entity.getConfigName()); |         return getDoubleValue(EXPERIENCE, COMBAT, MULTIPLIER1, StringUtils.getEntityConfigName(entity)); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public double getAnimalsXP(EntityType entity) { |     public double getAnimalsXP(EntityType entity) { | ||||||
|         return getDoubleValue(EXPERIENCE, COMBAT, MULTIPLIER1, entity.getConfigName()); |         return getDoubleValue(EXPERIENCE, COMBAT, MULTIPLIER1, StringUtils.getEntityConfigName(entity)); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public double getAnimalsXP() { |     public double getAnimalsXP() { | ||||||
| @@ -317,7 +319,7 @@ public class ExperienceConfig extends ConfigValidated { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     public boolean hasCombatXP(EntityType entity) { |     public boolean hasCombatXP(EntityType entity) { | ||||||
|         return hasNode(EXPERIENCE, COMBAT, MULTIPLIER1, entity.getConfigName()); |         return hasNode(EXPERIENCE, COMBAT, MULTIPLIER1, StringUtils.getEntityConfigName(entity)); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /* Materials  */ |     /* Materials  */ | ||||||
| @@ -328,9 +330,10 @@ public class ExperienceConfig extends ConfigValidated { | |||||||
|      * @param blockType the type of block |      * @param blockType the type of block | ||||||
|      * @return the raw amount of XP for this block before modifiers |      * @return the raw amount of XP for this block before modifiers | ||||||
|      */ |      */ | ||||||
|     public int getXp(PrimarySkillType skill, BlockType blockType) { |     //public int getXp(PrimarySkillType skill, BlockType blockType) { | ||||||
|  |     public int getXp(PrimarySkillType skill, Material blockType) { | ||||||
|         //TODO: This is going to need to be changed, this code here is only placeholder |         //TODO: This is going to need to be changed, this code here is only placeholder | ||||||
|         String[] path = new String[]{ EXPERIENCE, StringUtils.getCapitalized(skill.toString()), blockType.getConfigName() }; |         String[] path = new String[]{ EXPERIENCE, StringUtils.getCapitalized(skill.toString()), blockType.toString()}; | ||||||
|         return getIntValue(path); |         return getIntValue(path); | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @@ -342,10 +345,10 @@ public class ExperienceConfig extends ConfigValidated { | |||||||
|      * @param blockType the type of block |      * @param blockType the type of block | ||||||
|      * @return true if the block does give XP |      * @return true if the block does give XP | ||||||
|      */ |      */ | ||||||
|     public boolean doesBlockGiveSkillXP(PrimarySkillType skill, BlockType blockType) { |     public boolean doesBlockGiveSkillXP(PrimarySkillType skill, Material blockType) { | ||||||
|         //TODO: This used to support wildcard characters, seems a bit unnecessary to do so. |         //TODO: This used to support wildcard characters, seems a bit unnecessary to do so. | ||||||
|         //TODO: This is going to need to be changed, this code here is only placeholder |         //TODO: This is going to need to be changed, this code here is only placeholder | ||||||
|         String[] path = new String[] {EXPERIENCE, StringUtils.getCapitalized(skill.toString()), blockType.getConfigName()}; |         String[] path = new String[] {EXPERIENCE, StringUtils.getCapitalized(skill.toString()), blockType.toString()}; | ||||||
|         return hasNode(path); |         return hasNode(path); | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @@ -443,6 +446,6 @@ public class ExperienceConfig extends ConfigValidated { | |||||||
|  |  | ||||||
|     /* Taming */ |     /* Taming */ | ||||||
|     public int getTamingXP(EntityType type) { |     public int getTamingXP(EntityType type) { | ||||||
|         return getIntValue(EXPERIENCE, TAMING, ANIMAL_TAMING, type.getConfigName()); |         return getIntValue(EXPERIENCE, TAMING, ANIMAL_TAMING, StringUtils.getEntityConfigName(type)); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -1,6 +1,6 @@ | |||||||
| package com.gmail.nossr50.config.mods; | package com.gmail.nossr50.config.mods; | ||||||
|  |  | ||||||
| import com.gmail.nossr50.config.ConfigCollections; | import com.gmail.nossr50.config.ConfigCollection; | ||||||
| import com.gmail.nossr50.datatypes.skills.MaterialType; | import com.gmail.nossr50.datatypes.skills.MaterialType; | ||||||
| import com.gmail.nossr50.mcMMO; | import com.gmail.nossr50.mcMMO; | ||||||
| import com.gmail.nossr50.skills.repair.repairables.Repairable; | import com.gmail.nossr50.skills.repair.repairables.Repairable; | ||||||
| @@ -14,7 +14,7 @@ import java.util.ArrayList; | |||||||
| import java.util.List; | import java.util.List; | ||||||
| import java.util.Set; | import java.util.Set; | ||||||
|  |  | ||||||
| public class CustomArmorConfig extends ConfigCollections { | public class CustomArmorConfig extends ConfigCollection { | ||||||
|     public List<Material> customBoots = new ArrayList<Material>(); |     public List<Material> customBoots = new ArrayList<Material>(); | ||||||
|     public List<Material> customChestplates = new ArrayList<Material>(); |     public List<Material> customChestplates = new ArrayList<Material>(); | ||||||
|     public List<Material> customHelmets = new ArrayList<Material>(); |     public List<Material> customHelmets = new ArrayList<Material>(); | ||||||
| @@ -24,7 +24,7 @@ public class CustomArmorConfig extends ConfigCollections { | |||||||
|  |  | ||||||
|     protected CustomArmorConfig(String fileName) { |     protected CustomArmorConfig(String fileName) { | ||||||
|         //super(McmmoCore.getDataFolderPath().getPath() + "mods", fileName, false); |         //super(McmmoCore.getDataFolderPath().getPath() + "mods", fileName, false); | ||||||
|         super(mcMMO.p.getDataFolder().getPath() + "mods", fileName, false);        loadKeys(); |         super(mcMMO.p.getDataFolder().getPath() + "mods", fileName, false);        register(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
| @@ -38,7 +38,7 @@ public class CustomArmorConfig extends ConfigCollections { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public void loadKeys() { |     public void register() { | ||||||
|         loadArmor("Boots", customBoots); |         loadArmor("Boots", customBoots); | ||||||
|         loadArmor("Chestplates", customChestplates); |         loadArmor("Chestplates", customChestplates); | ||||||
|         loadArmor("Helmets", customHelmets); |         loadArmor("Helmets", customHelmets); | ||||||
|   | |||||||
| @@ -1,6 +1,6 @@ | |||||||
| package com.gmail.nossr50.config.mods; | package com.gmail.nossr50.config.mods; | ||||||
|  |  | ||||||
| import com.gmail.nossr50.config.ConfigCollections; | import com.gmail.nossr50.config.ConfigCollection; | ||||||
| import com.gmail.nossr50.datatypes.mods.CustomBlock; | import com.gmail.nossr50.datatypes.mods.CustomBlock; | ||||||
| import com.gmail.nossr50.mcMMO; | import com.gmail.nossr50.mcMMO; | ||||||
| import org.bukkit.Material; | import org.bukkit.Material; | ||||||
| @@ -11,7 +11,7 @@ import java.util.HashMap; | |||||||
| import java.util.List; | import java.util.List; | ||||||
| import java.util.Set; | import java.util.Set; | ||||||
|  |  | ||||||
| public class CustomBlockConfig extends ConfigCollections { | public class CustomBlockConfig extends ConfigCollection { | ||||||
|     public List<Material> customExcavationBlocks = new ArrayList<>(); |     public List<Material> customExcavationBlocks = new ArrayList<>(); | ||||||
|     public List<Material> customHerbalismBlocks = new ArrayList<>(); |     public List<Material> customHerbalismBlocks = new ArrayList<>(); | ||||||
|     public List<Material> customMiningBlocks = new ArrayList<>(); |     public List<Material> customMiningBlocks = new ArrayList<>(); | ||||||
| @@ -25,11 +25,11 @@ public class CustomBlockConfig extends ConfigCollections { | |||||||
|     protected CustomBlockConfig(String fileName) { |     protected CustomBlockConfig(String fileName) { | ||||||
|         //super(McmmoCore.getDataFolderPath().getPath() + "mods", fileName, false); |         //super(McmmoCore.getDataFolderPath().getPath() + "mods", fileName, false); | ||||||
|         super(mcMMO.p.getDataFolder().getPath() + "mods", fileName, false); |         super(mcMMO.p.getDataFolder().getPath() + "mods", fileName, false); | ||||||
|         loadKeys(); |         register(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     protected void loadKeys() { |     protected void register() { | ||||||
|         loadBlocks("Excavation", customExcavationBlocks); |         loadBlocks("Excavation", customExcavationBlocks); | ||||||
|         loadBlocks("Herbalism", customHerbalismBlocks); |         loadBlocks("Herbalism", customHerbalismBlocks); | ||||||
|         loadBlocks("Mining", customMiningBlocks); |         loadBlocks("Mining", customMiningBlocks); | ||||||
|   | |||||||
| @@ -1,6 +1,6 @@ | |||||||
| package com.gmail.nossr50.config.skills.alchemy; | package com.gmail.nossr50.config.skills.alchemy; | ||||||
|  |  | ||||||
| import com.gmail.nossr50.config.ConfigCollections; | import com.gmail.nossr50.config.ConfigCollection; | ||||||
| import com.gmail.nossr50.datatypes.skills.alchemy.AlchemyPotion; | import com.gmail.nossr50.datatypes.skills.alchemy.AlchemyPotion; | ||||||
| import com.gmail.nossr50.mcMMO; | import com.gmail.nossr50.mcMMO; | ||||||
| import org.bukkit.Color; | import org.bukkit.Color; | ||||||
| @@ -14,8 +14,7 @@ import java.util.HashMap; | |||||||
| import java.util.List; | import java.util.List; | ||||||
| import java.util.Map; | import java.util.Map; | ||||||
|  |  | ||||||
| public class PotionConfig extends ConfigCollections { | public class PotionConfig extends ConfigCollection { | ||||||
|     private static PotionConfig instance; |  | ||||||
|  |  | ||||||
|     private List<ItemStack> concoctionsIngredientsTierOne = new ArrayList<ItemStack>(); |     private List<ItemStack> concoctionsIngredientsTierOne = new ArrayList<ItemStack>(); | ||||||
|     private List<ItemStack> concoctionsIngredientsTierTwo = new ArrayList<ItemStack>(); |     private List<ItemStack> concoctionsIngredientsTierTwo = new ArrayList<ItemStack>(); | ||||||
| @@ -28,21 +27,23 @@ public class PotionConfig extends ConfigCollections { | |||||||
|  |  | ||||||
|     private Map<String, AlchemyPotion> potionMap = new HashMap<String, AlchemyPotion>(); |     private Map<String, AlchemyPotion> potionMap = new HashMap<String, AlchemyPotion>(); | ||||||
|  |  | ||||||
|     private PotionConfig() { |     public PotionConfig() { | ||||||
|         super(McmmoCore.getDataFolderPath().getAbsoluteFile(),"potions.yml"); |         super(mcMMO.p.getDataFolder().getAbsoluteFile(), "potions.yml", true); | ||||||
|         loadKeys(); |         register(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public static PotionConfig getInstance() { |     /** | ||||||
|         if (instance == null) { |      * The version of this config | ||||||
|             instance = new PotionConfig(); |      * | ||||||
|         } |      * @return | ||||||
|  |      */ | ||||||
|         return instance; |     @Override | ||||||
|  |     public double getConfigVersion() { | ||||||
|  |         return 1; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     protected void loadKeys() { |     public void register() { | ||||||
|         loadConcoctions(); |         loadConcoctions(); | ||||||
|         loadPotionMap(); |         loadPotionMap(); | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -1,6 +1,6 @@ | |||||||
| package com.gmail.nossr50.config.treasure; | package com.gmail.nossr50.config.treasure; | ||||||
|  |  | ||||||
| import com.gmail.nossr50.config.ConfigCollections; | import com.gmail.nossr50.config.ConfigCollection; | ||||||
| import com.gmail.nossr50.datatypes.treasure.*; | import com.gmail.nossr50.datatypes.treasure.*; | ||||||
| import com.gmail.nossr50.mcMMO; | import com.gmail.nossr50.mcMMO; | ||||||
| import com.gmail.nossr50.util.EnchantmentUtils; | import com.gmail.nossr50.util.EnchantmentUtils; | ||||||
| @@ -20,9 +20,9 @@ import java.util.ArrayList; | |||||||
| import java.util.HashMap; | import java.util.HashMap; | ||||||
| import java.util.List; | import java.util.List; | ||||||
|  |  | ||||||
| public class TreasureConfig extends ConfigCollections { | public class TreasureConfig extends ConfigCollection { | ||||||
|  |  | ||||||
|     private static TreasureConfig instance; |     //private static TreasureConfig instance; | ||||||
|  |  | ||||||
|     public HashMap<String, List<ExcavationTreasure>> excavationMap = new HashMap<String, List<ExcavationTreasure>>(); |     public HashMap<String, List<ExcavationTreasure>> excavationMap = new HashMap<String, List<ExcavationTreasure>>(); | ||||||
|  |  | ||||||
| @@ -32,18 +32,18 @@ public class TreasureConfig extends ConfigCollections { | |||||||
|     public HashMap<Rarity, List<FishingTreasure>> fishingRewards = new HashMap<Rarity, List<FishingTreasure>>(); |     public HashMap<Rarity, List<FishingTreasure>> fishingRewards = new HashMap<Rarity, List<FishingTreasure>>(); | ||||||
|     public HashMap<Rarity, List<EnchantmentTreasure>> fishingEnchantments = new HashMap<Rarity, List<EnchantmentTreasure>>(); |     public HashMap<Rarity, List<EnchantmentTreasure>> fishingEnchantments = new HashMap<Rarity, List<EnchantmentTreasure>>(); | ||||||
|  |  | ||||||
|     private TreasureConfig() { |     public TreasureConfig() { | ||||||
|         //super(McmmoCore.getDataFolderPath().getAbsoluteFile(),"treasures.yml"); |         //super(McmmoCore.getDataFolderPath().getAbsoluteFile(),"treasures.yml"); | ||||||
|         super(mcMMO.p.getDataFolder().getAbsoluteFile(), "treasures.yml"); |         super(mcMMO.p.getDataFolder().getAbsoluteFile(), "treasures.yml", true); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public static TreasureConfig getInstance() { |     /*public static TreasureConfig getInstance() { | ||||||
|         if (instance == null) { |         if (instance == null) { | ||||||
|             instance = new TreasureConfig(); |             instance = new TreasureConfig(); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         return instance; |         return instance; | ||||||
|     } |     }*/ | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     protected boolean validateKeys() { |     protected boolean validateKeys() { | ||||||
| @@ -82,7 +82,7 @@ public class TreasureConfig extends ConfigCollections { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     protected void loadKeys() { |     protected void register() { | ||||||
|         if (config.getConfigurationSection("Treasures") != null) { |         if (config.getConfigurationSection("Treasures") != null) { | ||||||
|             backup(); |             backup(); | ||||||
|             return; |             return; | ||||||
|   | |||||||
| @@ -41,7 +41,7 @@ public abstract class AbstractSubSkill implements SubSkill, Interaction, Rank, S | |||||||
|     @Override @Deprecated |     @Override @Deprecated | ||||||
|     public boolean isEnabled() { |     public boolean isEnabled() { | ||||||
|         //TODO: This might be troublesome... |         //TODO: This might be troublesome... | ||||||
|         return CoreSkillsMainConfig.getInstance().isSkillEnabled(this); |         return CoreSkillConfig.getInstance().isSkillEnabled(this); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|   | |||||||
| @@ -1,13 +1,8 @@ | |||||||
| package com.gmail.nossr50; | package com.gmail.nossr50; | ||||||
|  |  | ||||||
| import com.gmail.nossr50.config.MainConfig; | import com.gmail.nossr50.config.*; | ||||||
| import com.gmail.nossr50.config.WorldBlacklist; | import com.gmail.nossr50.config.collectionconfigs.ConfigManager; | ||||||
| import com.gmail.nossr50.config.mods.ArmorConfigManager; | import com.gmail.nossr50.config.experience.ExperienceConfig; | ||||||
| import com.gmail.nossr50.config.mods.BlockConfigManager; |  | ||||||
| import com.gmail.nossr50.config.mods.EntityConfigManager; |  | ||||||
| import com.gmail.nossr50.config.mods.ToolConfigManager; |  | ||||||
| import com.gmail.nossr50.config.skills.repair.RepairConfigManager; |  | ||||||
| import com.gmail.nossr50.config.skills.salvage.SalvageConfigManager; |  | ||||||
| import com.gmail.nossr50.database.DatabaseManager; | import com.gmail.nossr50.database.DatabaseManager; | ||||||
| import com.gmail.nossr50.database.DatabaseManagerFactory; | import com.gmail.nossr50.database.DatabaseManagerFactory; | ||||||
| import com.gmail.nossr50.datatypes.skills.PrimarySkillType; | import com.gmail.nossr50.datatypes.skills.PrimarySkillType; | ||||||
| @@ -24,13 +19,8 @@ import com.gmail.nossr50.runnables.player.PlayerProfileLoadingTask; | |||||||
| import com.gmail.nossr50.runnables.player.PowerLevelUpdatingTask; | import com.gmail.nossr50.runnables.player.PowerLevelUpdatingTask; | ||||||
| import com.gmail.nossr50.runnables.skills.BleedTimerTask; | import com.gmail.nossr50.runnables.skills.BleedTimerTask; | ||||||
| import com.gmail.nossr50.skills.alchemy.Alchemy; | import com.gmail.nossr50.skills.alchemy.Alchemy; | ||||||
| import com.gmail.nossr50.skills.child.ChildConfig; |  | ||||||
| import com.gmail.nossr50.skills.repair.repairables.Repairable; |  | ||||||
| import com.gmail.nossr50.skills.repair.repairables.RepairableManager; | import com.gmail.nossr50.skills.repair.repairables.RepairableManager; | ||||||
| import com.gmail.nossr50.skills.repair.repairables.SimpleRepairableManager; |  | ||||||
| import com.gmail.nossr50.skills.salvage.salvageables.Salvageable; |  | ||||||
| import com.gmail.nossr50.skills.salvage.salvageables.SalvageableManager; | import com.gmail.nossr50.skills.salvage.salvageables.SalvageableManager; | ||||||
| import com.gmail.nossr50.skills.salvage.salvageables.SimpleSalvageableManager; |  | ||||||
| import com.gmail.nossr50.util.*; | import com.gmail.nossr50.util.*; | ||||||
| import com.gmail.nossr50.util.blockmeta.chunkmeta.ChunkManager; | import com.gmail.nossr50.util.blockmeta.chunkmeta.ChunkManager; | ||||||
| import com.gmail.nossr50.util.blockmeta.chunkmeta.ChunkManagerFactory; | import com.gmail.nossr50.util.blockmeta.chunkmeta.ChunkManagerFactory; | ||||||
| @@ -54,14 +44,11 @@ import java.io.File; | |||||||
| import java.io.IOException; | import java.io.IOException; | ||||||
| import java.io.InputStream; | import java.io.InputStream; | ||||||
| import java.io.InputStreamReader; | import java.io.InputStreamReader; | ||||||
| import java.util.ArrayList; |  | ||||||
| import java.util.List; |  | ||||||
|  |  | ||||||
| public class mcMMO extends JavaPlugin { | public class mcMMO extends JavaPlugin { | ||||||
|     /* Managers */ |     /* Managers */ | ||||||
|     private static ChunkManager       placeStore; |     private static ChunkManager       placeStore; | ||||||
|     private static RepairableManager  repairableManager; |     private static ConfigManager      configManager; | ||||||
|     private static SalvageableManager salvageableManager; |  | ||||||
|     private static ModManager         modManager; |     private static ModManager         modManager; | ||||||
|     private static DatabaseManager    databaseManager; |     private static DatabaseManager    databaseManager; | ||||||
|     private static FormulaManager     formulaManager; |     private static FormulaManager     formulaManager; | ||||||
| @@ -217,7 +204,7 @@ public class mcMMO extends JavaPlugin { | |||||||
|         } |         } | ||||||
|  |  | ||||||
|         //Init the blacklist |         //Init the blacklist | ||||||
|         worldBlacklist = new WorldBlacklist(this); |         worldBlacklist = new WorldBlacklist(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
| @@ -274,6 +261,11 @@ public class mcMMO extends JavaPlugin { | |||||||
|         } |         } | ||||||
|  |  | ||||||
|         databaseManager.onDisable(); |         databaseManager.onDisable(); | ||||||
|  |  | ||||||
|  |         //Unload configs last | ||||||
|  |         configManager.unloadAllConfigsAndRegisters(); | ||||||
|  |  | ||||||
|  |  | ||||||
|         debug("Was disabled."); // How informative! |         debug("Was disabled."); // How informative! | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @@ -412,54 +404,9 @@ public class mcMMO extends JavaPlugin { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     private void loadConfigFiles() { |     private void loadConfigFiles() { | ||||||
|         // New Config System |         configManager = new ConfigManager(); | ||||||
|  |  | ||||||
|         ConfigurableTest.getInstance(); //Init |  | ||||||
|  |  | ||||||
|         // End New Config System |  | ||||||
|  |  | ||||||
|  |  | ||||||
|         // Force the loading of config files |  | ||||||
|         TreasureConfig.getInstance(); |  | ||||||
|         HiddenConfig.getInstance(); |  | ||||||
|         AdvancedConfig.getInstance(); |  | ||||||
|         PotionConfig.getInstance(); |  | ||||||
|         CoreSkillsMainConfig.getInstance(); |  | ||||||
|         SoundConfig.getInstance(); |  | ||||||
|         RankConfig.getInstance(); |  | ||||||
|  |  | ||||||
|         new ChildConfig(); |  | ||||||
|  |  | ||||||
|         List<Repairable> repairables = new ArrayList<Repairable>(); |  | ||||||
|         List<Salvageable> salvageables = new ArrayList<Salvageable>(); |  | ||||||
|  |  | ||||||
|         if (MainConfig.getInstance().getToolModsEnabled()) { |  | ||||||
|             new ToolConfigManager(this); |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         if (MainConfig.getInstance().getArmorModsEnabled()) { |  | ||||||
|             new ArmorConfigManager(this); |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         if (MainConfig.getInstance().getBlockModsEnabled()) { |  | ||||||
|             new BlockConfigManager(this); |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         if (MainConfig.getInstance().getEntityModsEnabled()) { |  | ||||||
|             new EntityConfigManager(this); |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         // Load repair configs, make manager, and register them at this time |  | ||||||
|         repairables.addAll(new RepairConfigManager(this).getLoadedRepairables()); |  | ||||||
|         repairables.addAll(modManager.getLoadedRepairables()); |  | ||||||
|         repairableManager = new SimpleRepairableManager(repairables.size()); |  | ||||||
|         repairableManager.registerRepairables(repairables); |  | ||||||
|  |  | ||||||
|         // Load salvage configs, make manager and register them at this time |  | ||||||
|         SalvageConfigManager sManager = new SalvageConfigManager(this); |  | ||||||
|         salvageables.addAll(sManager.getLoadedSalvageables()); |  | ||||||
|         salvageableManager = new SimpleSalvageableManager(salvageables.size()); |  | ||||||
|         salvageableManager.registerSalvageables(salvageables); |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private void registerEvents() { |     private void registerEvents() { | ||||||
| @@ -483,13 +430,13 @@ public class mcMMO extends JavaPlugin { | |||||||
|          * Acrobatics skills |          * Acrobatics skills | ||||||
|          */ |          */ | ||||||
|  |  | ||||||
|         if(CoreSkillsMainConfig.getInstance().isPrimarySkillEnabled(PrimarySkillType.ACROBATICS)) |         if(CoreSkillsConfig.getInstance().isPrimarySkillEnabled(PrimarySkillType.ACROBATICS)) | ||||||
|         { |         { | ||||||
|             System.out.println("[mcMMO]" + " enabling Acrobatics Skills"); |             System.out.println("[mcMMO]" + " enabling Acrobatics Skills"); | ||||||
|  |  | ||||||
|             //TODO: Should do this differently |             //TODO: Should do this differently | ||||||
|             Roll roll = new Roll(); |             Roll roll = new Roll(); | ||||||
|             CoreSkillsMainConfig.getInstance().isSkillEnabled(roll); |             CoreSkillsConfig.getInstance().isSkillEnabled(roll); | ||||||
|             InteractionManager.registerSubSkill(new Roll()); |             InteractionManager.registerSubSkill(new Roll()); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -1,6 +1,5 @@ | |||||||
| package com.gmail.nossr50.skills.child; | package com.gmail.nossr50.skills.child; | ||||||
|  |  | ||||||
| import com.gmail.nossr50.config.AutoUpdateConfigLoader; |  | ||||||
| import com.gmail.nossr50.datatypes.skills.PrimarySkillType; | import com.gmail.nossr50.datatypes.skills.PrimarySkillType; | ||||||
| import com.gmail.nossr50.util.StringUtils; | import com.gmail.nossr50.util.StringUtils; | ||||||
| import org.bukkit.configuration.file.YamlConfiguration; | import org.bukkit.configuration.file.YamlConfiguration; | ||||||
|   | |||||||
| @@ -1,6 +1,8 @@ | |||||||
| package com.gmail.nossr50.skills.repair; | package com.gmail.nossr50.skills.repair; | ||||||
|  |  | ||||||
|  | import com.gmail.nossr50.config.AdvancedConfig; | ||||||
| import com.gmail.nossr50.config.MainConfig; | import com.gmail.nossr50.config.MainConfig; | ||||||
|  | import com.gmail.nossr50.config.experience.ExperienceConfig; | ||||||
| import com.gmail.nossr50.datatypes.experience.XPGainReason; | import com.gmail.nossr50.datatypes.experience.XPGainReason; | ||||||
| import com.gmail.nossr50.datatypes.interactions.NotificationType; | import com.gmail.nossr50.datatypes.interactions.NotificationType; | ||||||
| import com.gmail.nossr50.datatypes.player.McMMOPlayer; | import com.gmail.nossr50.datatypes.player.McMMOPlayer; | ||||||
|   | |||||||
| @@ -1,11 +1,12 @@ | |||||||
| package com.gmail.nossr50.skills.repair.repairables; | package com.gmail.nossr50.skills.repair.repairables; | ||||||
|  |  | ||||||
|  | import com.gmail.nossr50.config.Unload; | ||||||
| import org.bukkit.Material; | import org.bukkit.Material; | ||||||
| import org.bukkit.inventory.ItemStack; | import org.bukkit.inventory.ItemStack; | ||||||
|  |  | ||||||
| import java.util.List; | import java.util.List; | ||||||
|  |  | ||||||
| public interface RepairableManager { | public interface RepairableManager extends Unload { | ||||||
|     /** |     /** | ||||||
|      * Register a repairable with the RepairManager |      * Register a repairable with the RepairManager | ||||||
|      * |      * | ||||||
|   | |||||||
| @@ -1,20 +1,24 @@ | |||||||
| package com.gmail.nossr50.skills.repair.repairables; | package com.gmail.nossr50.skills.repair.repairables; | ||||||
|  |  | ||||||
|  | import com.gmail.nossr50.config.Unload; | ||||||
| import org.bukkit.Material; | import org.bukkit.Material; | ||||||
| import org.bukkit.inventory.ItemStack; | import org.bukkit.inventory.ItemStack; | ||||||
|  |  | ||||||
|  | import java.util.Collection; | ||||||
| import java.util.HashMap; | import java.util.HashMap; | ||||||
| import java.util.List; | import java.util.List; | ||||||
|  |  | ||||||
| public class SimpleRepairableManager implements RepairableManager { | public class SimpleRepairableManager implements RepairableManager { | ||||||
|     private HashMap<Material, Repairable> repairables; |     private HashMap<Material, Repairable> repairables; | ||||||
|  |  | ||||||
|     public SimpleRepairableManager() { |     @Override | ||||||
|         this(55); |     public void unload() { | ||||||
|  |         repairables.clear(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public SimpleRepairableManager(int repairablesSize) { |     public SimpleRepairableManager(List<Repairable> repairablesCollection) { | ||||||
|         this.repairables = new HashMap<Material, Repairable>(repairablesSize); |         this.repairables = new HashMap<Material, Repairable>(repairablesCollection.size()); | ||||||
|  |         registerRepairables(repairablesCollection); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|   | |||||||
| @@ -1,11 +1,12 @@ | |||||||
| package com.gmail.nossr50.skills.salvage.salvageables; | package com.gmail.nossr50.skills.salvage.salvageables; | ||||||
|  |  | ||||||
|  | import com.gmail.nossr50.config.Unload; | ||||||
| import org.bukkit.Material; | import org.bukkit.Material; | ||||||
| import org.bukkit.inventory.ItemStack; | import org.bukkit.inventory.ItemStack; | ||||||
|  |  | ||||||
| import java.util.List; | import java.util.List; | ||||||
|  |  | ||||||
| public interface SalvageableManager { | public interface SalvageableManager extends Unload { | ||||||
|     /** |     /** | ||||||
|      * Register a salvageable with the SalvageManager |      * Register a salvageable with the SalvageManager | ||||||
|      * |      * | ||||||
|   | |||||||
| @@ -10,12 +10,18 @@ import java.util.List; | |||||||
| public class SimpleSalvageableManager implements SalvageableManager { | public class SimpleSalvageableManager implements SalvageableManager { | ||||||
|     private HashMap<Material, Salvageable> salvageables; |     private HashMap<Material, Salvageable> salvageables; | ||||||
|  |  | ||||||
|     public SimpleSalvageableManager() { |     /*public SimpleSalvageableManager() { | ||||||
|         this(55); |         this(55); | ||||||
|  |     }*/ | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|  |     public void unload() { | ||||||
|  |         salvageables.clear(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public SimpleSalvageableManager(int salvageablesSize) { |     public SimpleSalvageableManager(List<Salvageable> salvageablesCollection) { | ||||||
|         this.salvageables = new HashMap<Material, Salvageable>(salvageablesSize); |         this.salvageables = new HashMap<Material, Salvageable>(salvageablesCollection.size()); | ||||||
|  |         registerSalvageables(salvageablesCollection); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|   | |||||||
| @@ -20,6 +20,16 @@ public class StringUtils { | |||||||
|         return target.substring(0, 1).toUpperCase() + target.substring(1).toLowerCase(); |         return target.substring(0, 1).toUpperCase() + target.substring(1).toLowerCase(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * Gets the name of the entity that the config file is expecting | ||||||
|  |      * @param entityType target entity type | ||||||
|  |      * @return the config friendly entity type string | ||||||
|  |      */ | ||||||
|  |     public static String getEntityConfigName(EntityType entityType) | ||||||
|  |     { | ||||||
|  |         return entityType.toString(); | ||||||
|  |     } | ||||||
|  |  | ||||||
|     public static String getPrettyItemString(Material material) { |     public static String getPrettyItemString(Material material) { | ||||||
|         return createPrettyString(material.toString()); |         return createPrettyString(material.toString()); | ||||||
|     } |     } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 nossr50
					nossr50