mirror of
				https://github.com/mcMMO-Dev/mcMMO.git
				synced 2025-11-04 02:53:43 +01:00 
			
		
		
		
	new config pt 8 (moving to configurable branch to test..)
This commit is contained in:
		@@ -1,15 +1,14 @@
 | 
				
			|||||||
package com.gmail.nossr50.core.api;
 | 
					package com.gmail.nossr50.core.api;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.gmail.nossr50.core.McmmoCore;
 | 
				
			||||||
import com.gmail.nossr50.core.config.MainConfig;
 | 
					import com.gmail.nossr50.core.config.MainConfig;
 | 
				
			||||||
import com.gmail.nossr50.core.data.UserManager;
 | 
					import com.gmail.nossr50.core.data.UserManager;
 | 
				
			||||||
import com.gmail.nossr50.core.datatypes.interactions.NotificationType;
 | 
					import com.gmail.nossr50.core.datatypes.interactions.NotificationType;
 | 
				
			||||||
import com.gmail.nossr50.core.datatypes.party.Party;
 | 
					import com.gmail.nossr50.core.datatypes.party.Party;
 | 
				
			||||||
import com.gmail.nossr50.core.datatypes.party.PartyLeader;
 | 
					import com.gmail.nossr50.core.datatypes.party.PartyLeader;
 | 
				
			||||||
import com.gmail.nossr50.mcMMO;
 | 
					import com.gmail.nossr50.core.mcmmo.entity.Player;
 | 
				
			||||||
import com.gmail.nossr50.party.PartyManager;
 | 
					import com.gmail.nossr50.core.party.PartyManager;
 | 
				
			||||||
import com.gmail.nossr50.util.player.NotificationManager;
 | 
					import com.gmail.nossr50.core.util.player.NotificationManager;
 | 
				
			||||||
import org.bukkit.OfflinePlayer;
 | 
					 | 
				
			||||||
import org.bukkit.entity.Player;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
import java.util.*;
 | 
					import java.util.*;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -83,7 +82,7 @@ public final class PartyAPI {
 | 
				
			|||||||
        Party party = PartyManager.getParty(partyName);
 | 
					        Party party = PartyManager.getParty(partyName);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (party == null) {
 | 
					        if (party == null) {
 | 
				
			||||||
            party = new Party(new PartyLeader(player.getUniqueId(), player.getName()), partyName);
 | 
					            party = new Party(new PartyLeader(player.getUUID(), player.getName()), partyName);
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            if (PartyManager.isPartyFull(player, party)) {
 | 
					            if (PartyManager.isPartyFull(player, party)) {
 | 
				
			||||||
                NotificationManager.sendPlayerInformation(player, NotificationType.PARTY_MESSAGE, "Commands.Party.PartyFull", party.toString());
 | 
					                NotificationManager.sendPlayerInformation(player, NotificationType.PARTY_MESSAGE, "Commands.Party.PartyFull", party.toString());
 | 
				
			||||||
@@ -117,7 +116,7 @@ public final class PartyAPI {
 | 
				
			|||||||
        Party party = PartyManager.getParty(partyName);
 | 
					        Party party = PartyManager.getParty(partyName);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (party == null) {
 | 
					        if (party == null) {
 | 
				
			||||||
            party = new Party(new PartyLeader(player.getUniqueId(), player.getName()), partyName);
 | 
					            party = new Party(new PartyLeader(player.getUUID(), player.getName()), partyName);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        PartyManager.addToParty(UserManager.getPlayer(player), party);
 | 
					        PartyManager.addToParty(UserManager.getPlayer(player), party);
 | 
				
			||||||
@@ -156,7 +155,7 @@ public final class PartyAPI {
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    @Deprecated
 | 
					    @Deprecated
 | 
				
			||||||
    public static void setPartyLeader(String partyName, String playerName) {
 | 
					    public static void setPartyLeader(String partyName, String playerName) {
 | 
				
			||||||
        PartyManager.setPartyLeader(mcMMO.p.getServer().getOfflinePlayer(playerName).getUniqueId(), PartyManager.getParty(partyName));
 | 
					        PartyManager.setPartyLeader(McmmoCore.getServer().getOfflinePlayer(playerName).getUniqueId(), PartyManager.getParty(partyName));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2,9 +2,8 @@ package com.gmail.nossr50.core.chat;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import com.gmail.nossr50.core.config.MainConfig;
 | 
					import com.gmail.nossr50.core.config.MainConfig;
 | 
				
			||||||
import com.gmail.nossr50.core.datatypes.party.Party;
 | 
					import com.gmail.nossr50.core.datatypes.party.Party;
 | 
				
			||||||
 | 
					import com.gmail.nossr50.core.events.chat.McMMOPartyChatEvent;
 | 
				
			||||||
import com.gmail.nossr50.core.runnables.party.PartyChatTask;
 | 
					import com.gmail.nossr50.core.runnables.party.PartyChatTask;
 | 
				
			||||||
import com.gmail.nossr50.events.chat.McMMOPartyChatEvent;
 | 
					 | 
				
			||||||
import org.bukkit.plugin.Plugin;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class PartyChatManager extends ChatManager {
 | 
					public class PartyChatManager extends ChatManager {
 | 
				
			||||||
    private Party party;
 | 
					    private Party party;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -0,0 +1,7 @@
 | 
				
			|||||||
 | 
					package com.gmail.nossr50.core.config;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.util.Collection;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public interface ConfigCollection<T> {
 | 
				
			||||||
 | 
					    Collection<T> getLoadedCollection();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -5,14 +5,14 @@ import java.io.File;
 | 
				
			|||||||
/**
 | 
					/**
 | 
				
			||||||
 * Represents a config file that registers keys after its initialized
 | 
					 * Represents a config file that registers keys after its initialized
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
public abstract class ConfigKeyRegister extends Config implements RegistersKeys {
 | 
					public abstract class ConfigCollections extends Config implements RegistersKeys, ConfigCollection {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public ConfigKeyRegister(String pathToParentFolder, String relativePath, boolean mergeNewKeys) {
 | 
					    public ConfigCollections(String pathToParentFolder, String relativePath, boolean mergeNewKeys) {
 | 
				
			||||||
        super(pathToParentFolder, relativePath, mergeNewKeys);
 | 
					        super(pathToParentFolder, relativePath, mergeNewKeys);
 | 
				
			||||||
        loadKeys();
 | 
					        loadKeys();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public ConfigKeyRegister(File pathToParentFolder, String relativePath, boolean mergeNewKeys) {
 | 
					    public ConfigCollections(File pathToParentFolder, String relativePath, boolean mergeNewKeys) {
 | 
				
			||||||
        super(pathToParentFolder, relativePath, mergeNewKeys);
 | 
					        super(pathToParentFolder, relativePath, mergeNewKeys);
 | 
				
			||||||
        loadKeys();
 | 
					        loadKeys();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@@ -0,0 +1,107 @@
 | 
				
			|||||||
 | 
					package com.gmail.nossr50.core.config.collectionconfigs;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.gmail.nossr50.core.McmmoCore;
 | 
				
			||||||
 | 
					import com.gmail.nossr50.core.config.ConfigCollection;
 | 
				
			||||||
 | 
					import com.gmail.nossr50.core.config.ConfigCollections;
 | 
				
			||||||
 | 
					import com.gmail.nossr50.core.skills.child.salvage.salvageables.Salvageable;
 | 
				
			||||||
 | 
					import com.gmail.nossr50.core.skills.primary.repair.repairables.Repairable;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					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 RepairConfig vanillaRepairConfig; //This is the main config file that mcMMO will copy out
 | 
				
			||||||
 | 
					    public 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 RepairConfig(getVanillaConfigName("repair"));
 | 
				
			||||||
 | 
					        vanillaSalvageConfig = new 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, RepairConfig.class);
 | 
				
			||||||
 | 
					        loadCustomCollections("salvage", salvageables, 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();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        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 {
 | 
				
			||||||
 | 
					                ConfigCollections customConfig = configClass.getClass().getConstructor(fileName).newInstance();
 | 
				
			||||||
 | 
					                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;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -1,7 +1,7 @@
 | 
				
			|||||||
package com.gmail.nossr50.core.config.skills.repair;
 | 
					package com.gmail.nossr50.core.config.collectionconfigs;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import com.gmail.nossr50.core.McmmoCore;
 | 
					import com.gmail.nossr50.core.McmmoCore;
 | 
				
			||||||
import com.gmail.nossr50.core.config.ConfigKeyRegister;
 | 
					import com.gmail.nossr50.core.config.ConfigCollections;
 | 
				
			||||||
import com.gmail.nossr50.core.mcmmo.item.ItemStack;
 | 
					import com.gmail.nossr50.core.mcmmo.item.ItemStack;
 | 
				
			||||||
import com.gmail.nossr50.core.skills.ConfigItemCategory;
 | 
					import com.gmail.nossr50.core.skills.ConfigItemCategory;
 | 
				
			||||||
import com.gmail.nossr50.core.skills.MaterialType;
 | 
					import com.gmail.nossr50.core.skills.MaterialType;
 | 
				
			||||||
@@ -13,23 +13,28 @@ import com.gmail.nossr50.core.util.skills.SkillUtils;
 | 
				
			|||||||
import ninja.leaping.configurate.ConfigurationNode;
 | 
					import ninja.leaping.configurate.ConfigurationNode;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
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 ConfigKeyRegister {
 | 
					public class RepairConfig extends ConfigCollections {
 | 
				
			||||||
    private List<Repairable> repairables;
 | 
					    private List<Repairable> repairables;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public RepairConfig(String fileName) {
 | 
					    public RepairConfig(String fileName) {
 | 
				
			||||||
        super(McmmoCore.getDataFolderPath().getAbsoluteFile(), fileName, false);
 | 
					        super(McmmoCore.getDataFolderPath().getAbsoluteFile(), fileName, false);
 | 
				
			||||||
        loadKeys();
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public void unload() {
 | 
					    public void unload() {
 | 
				
			||||||
 | 
					        repairables = null;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public Collection getLoadedCollection() {
 | 
				
			||||||
 | 
					        return repairables == null ? new ArrayList<Repairable>() : repairables;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
@@ -59,8 +64,6 @@ public class RepairConfig extends ConfigKeyRegister {
 | 
				
			|||||||
            // Validate all the things!
 | 
					            // Validate all the things!
 | 
				
			||||||
            List<String> reason = new ArrayList<String>();
 | 
					            List<String> reason = new ArrayList<String>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            try {
 | 
					            try {
 | 
				
			||||||
                // ItemStack Material
 | 
					                // ItemStack Material
 | 
				
			||||||
                ConfigItemCategory configItemCategory = ItemUtils.matchItemType(key);
 | 
					                ConfigItemCategory configItemCategory = ItemUtils.matchItemType(key);
 | 
				
			||||||
@@ -167,13 +170,15 @@ public class RepairConfig extends ConfigKeyRegister {
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    protected List<Repairable> getLoadedRepairables() {
 | 
					 | 
				
			||||||
        return repairables == null ? new ArrayList<Repairable>() : repairables;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Check if there are any errors for this repairable and if there are reports them to console
 | 
				
			||||||
 | 
					     * @param issues errors related to loading a repairable
 | 
				
			||||||
 | 
					     * @return returns true if there are no errors for this repairable
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
    private boolean noErrorsInRepairable(List<String> issues) {
 | 
					    private boolean noErrorsInRepairable(List<String> issues) {
 | 
				
			||||||
        for (String issue : issues) {
 | 
					        for (String issue : issues) {
 | 
				
			||||||
            plugin.getLogger().warning(issue);
 | 
					            McmmoCore.getLogger().warning(issue);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return issues.isEmpty();
 | 
					        return issues.isEmpty();
 | 
				
			||||||
@@ -1,7 +1,9 @@
 | 
				
			|||||||
package com.gmail.nossr50.core.config.skills.salvage;
 | 
					package com.gmail.nossr50.core.config.collectionconfigs;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import com.gmail.nossr50.core.McmmoCore;
 | 
					import com.gmail.nossr50.core.McmmoCore;
 | 
				
			||||||
import com.gmail.nossr50.core.config.Config;
 | 
					import com.gmail.nossr50.core.config.Config;
 | 
				
			||||||
 | 
					import com.gmail.nossr50.core.config.ConfigCollection;
 | 
				
			||||||
 | 
					import com.gmail.nossr50.core.config.ConfigCollections;
 | 
				
			||||||
import com.gmail.nossr50.core.mcmmo.item.ItemStack;
 | 
					import com.gmail.nossr50.core.mcmmo.item.ItemStack;
 | 
				
			||||||
import com.gmail.nossr50.core.skills.MaterialType;
 | 
					import com.gmail.nossr50.core.skills.MaterialType;
 | 
				
			||||||
import com.gmail.nossr50.core.skills.child.salvage.salvageables.Salvageable;
 | 
					import com.gmail.nossr50.core.skills.child.salvage.salvageables.Salvageable;
 | 
				
			||||||
@@ -10,15 +12,35 @@ import com.gmail.nossr50.core.util.ItemUtils;
 | 
				
			|||||||
import com.gmail.nossr50.core.util.skills.SkillUtils;
 | 
					import com.gmail.nossr50.core.util.skills.SkillUtils;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
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 Config {
 | 
					public class SalvageConfig extends ConfigCollections {
 | 
				
			||||||
    private List<Salvageable> salvageables;
 | 
					    private List<Salvageable> salvageables;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public SalvageConfig(String fileName) {
 | 
					    public SalvageConfig(String fileName) {
 | 
				
			||||||
        super(McmmoCore.getDataFolderPath().getAbsoluteFile(), fileName);
 | 
					        super(McmmoCore.getDataFolderPath().getAbsoluteFile(), fileName, false);
 | 
				
			||||||
        loadKeys();
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public Collection getLoadedCollection() {
 | 
				
			||||||
 | 
					        return salvageables == null ? new ArrayList<Salvageable>() : salvageables;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void unload() {
 | 
				
			||||||
 | 
					        salvageables = null;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * The version of this config
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @return
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public double getConfigVersion() {
 | 
				
			||||||
 | 
					        return 1;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
@@ -132,10 +154,6 @@ public class SalvageConfig extends Config {
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    protected List<Salvageable> getLoadedSalvageables() {
 | 
					 | 
				
			||||||
        return salvageables == null ? new ArrayList<Salvageable>() : salvageables;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    private boolean noErrorsInSalvageable(List<String> issues) {
 | 
					    private boolean noErrorsInSalvageable(List<String> issues) {
 | 
				
			||||||
        if (!issues.isEmpty()) {
 | 
					        if (!issues.isEmpty()) {
 | 
				
			||||||
            plugin.getLogger().warning("Errors have been found in: " + fileName);
 | 
					            plugin.getLogger().warning("Errors have been found in: " + fileName);
 | 
				
			||||||
@@ -1,7 +1,7 @@
 | 
				
			|||||||
package com.gmail.nossr50.core.config.mods;
 | 
					package com.gmail.nossr50.core.config.mods;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import com.gmail.nossr50.core.McmmoCore;
 | 
					import com.gmail.nossr50.core.McmmoCore;
 | 
				
			||||||
import com.gmail.nossr50.core.config.ConfigKeyRegister;
 | 
					import com.gmail.nossr50.core.config.ConfigCollections;
 | 
				
			||||||
import com.gmail.nossr50.core.mcmmo.item.ItemStack;
 | 
					import com.gmail.nossr50.core.mcmmo.item.ItemStack;
 | 
				
			||||||
import com.gmail.nossr50.core.skills.ConfigItemCategory;
 | 
					import com.gmail.nossr50.core.skills.ConfigItemCategory;
 | 
				
			||||||
import com.gmail.nossr50.core.skills.MaterialType;
 | 
					import com.gmail.nossr50.core.skills.MaterialType;
 | 
				
			||||||
@@ -13,7 +13,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 ConfigKeyRegister {
 | 
					public class CustomArmorConfig extends ConfigCollections {
 | 
				
			||||||
    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>();
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,14 +1,14 @@
 | 
				
			|||||||
package com.gmail.nossr50.core.config.mods;
 | 
					package com.gmail.nossr50.core.config.mods;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import com.gmail.nossr50.core.McmmoCore;
 | 
					import com.gmail.nossr50.core.McmmoCore;
 | 
				
			||||||
import com.gmail.nossr50.core.config.ConfigKeyRegister;
 | 
					import com.gmail.nossr50.core.config.ConfigCollections;
 | 
				
			||||||
import com.gmail.nossr50.core.datatypes.mods.CustomBlock;
 | 
					import com.gmail.nossr50.core.datatypes.mods.CustomBlock;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import java.util.ArrayList;
 | 
					import java.util.ArrayList;
 | 
				
			||||||
import java.util.HashMap;
 | 
					import java.util.HashMap;
 | 
				
			||||||
import java.util.Set;
 | 
					import java.util.Set;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class CustomBlockConfig extends ConfigKeyRegister {
 | 
					public class CustomBlockConfig extends ConfigCollections {
 | 
				
			||||||
    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<>();
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,42 +0,0 @@
 | 
				
			|||||||
package com.gmail.nossr50.core.config.skills.repair;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import com.gmail.nossr50.core.config.skills.repair.RepairConfig;
 | 
					 | 
				
			||||||
import com.gmail.nossr50.core.skills.primary.repair.repairables.Repairable;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import java.io.File;
 | 
					 | 
				
			||||||
import java.util.ArrayList;
 | 
					 | 
				
			||||||
import java.util.List;
 | 
					 | 
				
			||||||
import java.util.regex.Pattern;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
public class RepairConfigManager {
 | 
					 | 
				
			||||||
    private final List<Repairable> repairables = new ArrayList<Repairable>();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    public RepairConfigManager(mcMMO plugin) {
 | 
					 | 
				
			||||||
        Pattern pattern = Pattern.compile("repair\\.(?:.+)\\.yml");
 | 
					 | 
				
			||||||
        File dataFolder = plugin.getDataFolder();
 | 
					 | 
				
			||||||
        File vanilla = new File(dataFolder, "repair.vanilla.yml");
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        if (!vanilla.exists()) {
 | 
					 | 
				
			||||||
            plugin.saveResource("repair.vanilla.yml", false);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        for (String fileName : dataFolder.list()) {
 | 
					 | 
				
			||||||
            if (!pattern.matcher(fileName).matches()) {
 | 
					 | 
				
			||||||
                continue;
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            File file = new File(dataFolder, fileName);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            if (file.isDirectory()) {
 | 
					 | 
				
			||||||
                continue;
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            RepairConfig rConfig = new RepairConfig(fileName);
 | 
					 | 
				
			||||||
            repairables.addAll(rConfig.getLoadedRepairables());
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    public List<Repairable> getLoadedRepairables() {
 | 
					 | 
				
			||||||
        return repairables;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
@@ -1,42 +0,0 @@
 | 
				
			|||||||
package com.gmail.nossr50.core.config.skills.salvage;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import com.gmail.nossr50.core.skills.child.salvage.salvageables.Salvageable;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import java.io.File;
 | 
					 | 
				
			||||||
import java.util.ArrayList;
 | 
					 | 
				
			||||||
import java.util.List;
 | 
					 | 
				
			||||||
import java.util.regex.Pattern;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
public class SalvageConfigManager {
 | 
					 | 
				
			||||||
    private final List<Salvageable> salvageables = new ArrayList<Salvageable>();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    public SalvageConfigManager(mcMMO plugin) {
 | 
					 | 
				
			||||||
        Pattern pattern = Pattern.compile("salvage\\.(?:.+)\\.yml");
 | 
					 | 
				
			||||||
        File dataFolder = plugin.getDataFolder();
 | 
					 | 
				
			||||||
        File vanilla = new File(dataFolder, "salvage.vanilla.yml");
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        if (!vanilla.exists()) {
 | 
					 | 
				
			||||||
            plugin.saveResource("salvage.vanilla.yml", false);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        for (String fileName : dataFolder.list()) {
 | 
					 | 
				
			||||||
            if (!pattern.matcher(fileName).matches()) {
 | 
					 | 
				
			||||||
                continue;
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            File file = new File(dataFolder, fileName);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            if (file.isDirectory()) {
 | 
					 | 
				
			||||||
                continue;
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            com.gmail.nossr50.config.skills.salvage.SalvageConfig salvageConfig = new com.gmail.nossr50.config.skills.salvage.SalvageConfig(fileName);
 | 
					 | 
				
			||||||
            salvageables.addAll(salvageConfig.getLoadedSalvageables());
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    public List<Salvageable> getLoadedSalvageables() {
 | 
					 | 
				
			||||||
        return salvageables;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
		Reference in New Issue
	
	Block a user