mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-12-26 02:28:03 +01:00
new config pt 9
This commit is contained in:
parent
09c91f3b4b
commit
5e1c12d8ec
@ -1,7 +1,5 @@
|
|||||||
package com.gmail.nossr50.commands;
|
package com.gmail.nossr50.commands;
|
||||||
|
|
||||||
import com.gmail.nossr50.config.AdvancedConfig;
|
|
||||||
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.gmail.nossr50.commands.skills;
|
package com.gmail.nossr50.commands.skills;
|
||||||
|
|
||||||
import com.gmail.nossr50.config.AdvancedConfig;
|
|
||||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
|
59
src/main/java/com/gmail/nossr50/config/ChildConfig.java
Normal file
59
src/main/java/com/gmail/nossr50/config/ChildConfig.java
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
package com.gmail.nossr50.config;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||||
|
import com.gmail.nossr50.skills.child.FamilyTree;
|
||||||
|
import com.gmail.nossr50.util.StringUtils;
|
||||||
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
|
||||||
|
import java.util.EnumSet;
|
||||||
|
|
||||||
|
public class ChildConfig extends ConfigCollections {
|
||||||
|
public ChildConfig() {
|
||||||
|
super("child.yml");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void loadKeys() {
|
||||||
|
config.setDefaults(YamlConfiguration.loadConfiguration(plugin.getResourceAsReader("child.yml")));
|
||||||
|
|
||||||
|
FamilyTree.clearRegistrations(); // when reloading, need to clear statics
|
||||||
|
|
||||||
|
for (PrimarySkillType skill : PrimarySkillType.CHILD_SKILLS) {
|
||||||
|
plugin.debug("Finding parents of " + skill.name());
|
||||||
|
|
||||||
|
EnumSet<PrimarySkillType> parentSkills = EnumSet.noneOf(PrimarySkillType.class);
|
||||||
|
boolean useDefaults = false; // If we had an error we back out and use defaults
|
||||||
|
|
||||||
|
for (String name : config.getStringList(StringUtils.getCapitalized(skill.name()))) {
|
||||||
|
try {
|
||||||
|
PrimarySkillType parentSkill = PrimarySkillType.valueOf(name.toUpperCase());
|
||||||
|
FamilyTree.enforceNotChildSkill(parentSkill);
|
||||||
|
parentSkills.add(parentSkill);
|
||||||
|
} catch (IllegalArgumentException ex) {
|
||||||
|
plugin.getLogger().warning(name + " is not a valid skill type, or is a child skill!");
|
||||||
|
useDefaults = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (useDefaults) {
|
||||||
|
parentSkills.clear();
|
||||||
|
for (String name : config.getDefaults().getStringList(StringUtils.getCapitalized(skill.name()))) {
|
||||||
|
/* We do less checks in here because it's from inside our jar.
|
||||||
|
* If they're dedicated enough to have modified it, they can have the errors it may produce.
|
||||||
|
* Alternatively, this can be used to allow child skills to be parent skills, provided there are no circular dependencies this is an advanced sort of configuration.
|
||||||
|
*/
|
||||||
|
parentSkills.add(PrimarySkillType.valueOf(name.toUpperCase()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Register them
|
||||||
|
for (PrimarySkillType parentSkill : parentSkills) {
|
||||||
|
plugin.debug("Registering " + parentSkill.name() + " as parent of " + skill.name());
|
||||||
|
FamilyTree.registerParent(skill, parentSkill);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FamilyTree.closeRegistration();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
11
src/main/java/com/gmail/nossr50/config/RegistersKeys.java
Normal file
11
src/main/java/com/gmail/nossr50/config/RegistersKeys.java
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
package com.gmail.nossr50.config;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A class that registers keys
|
||||||
|
*/
|
||||||
|
public interface RegistersKeys {
|
||||||
|
/**
|
||||||
|
* Loads up keys
|
||||||
|
*/
|
||||||
|
void loadKeys();
|
||||||
|
}
|
@ -0,0 +1,119 @@
|
|||||||
|
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,181 +0,0 @@
|
|||||||
package com.gmail.nossr50.config.collectionconfigs;
|
|
||||||
|
|
||||||
import com.gmail.nossr50.config.ConfigCollection;
|
|
||||||
import com.gmail.nossr50.config.ConfigConstants;
|
|
||||||
import com.gmail.nossr50.datatypes.skills.ItemMaterialCategory;
|
|
||||||
import com.gmail.nossr50.datatypes.skills.ItemType;
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
|
||||||
import com.gmail.nossr50.skills.salvage.salvageables.Salvageable;
|
|
||||||
import com.gmail.nossr50.skills.salvage.salvageables.SalvageableFactory;
|
|
||||||
import com.gmail.nossr50.util.ItemUtils;
|
|
||||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
|
||||||
import ninja.leaping.configurate.ConfigurationNode;
|
|
||||||
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@ConfigSerializable
|
|
||||||
public class SalvageConfig extends ConfigCollection {
|
|
||||||
|
|
||||||
public static final String SALVAGEABLES = "Salvageables";
|
|
||||||
public static final String MATERIAL_TYPE = "ItemMaterialCategory";
|
|
||||||
public static final String SALVAGE_MATERIAL = "SalvageMaterial";
|
|
||||||
public static final String MAXIMUM_DURABILITY = "MaximumDurability";
|
|
||||||
public static final String ITEM_TYPE = "ItemType";
|
|
||||||
public static final String METADATA = "Metadata";
|
|
||||||
public static final String MINIMUM_LEVEL = "MinimumLevel";
|
|
||||||
public static final String XP_MULTIPLIER = "XpMultiplier";
|
|
||||||
public static final String MAXIMUM_QUANTITY = "MaximumQuantity";
|
|
||||||
|
|
||||||
public SalvageConfig() {
|
|
||||||
//super(McmmoCore.getDataFolderPath().getAbsoluteFile(), fileName, false);
|
|
||||||
super("salvage", mcMMO.p.getDataFolder().getAbsoluteFile(), ConfigConstants.RELATIVE_PATH_SKILLS_DIR, true, false, true, false);
|
|
||||||
register();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The version of this config
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public double getConfigVersion() {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void register() {
|
|
||||||
//Grab the "keys" under the Repairables node
|
|
||||||
ArrayList<ConfigurationNode> salvageChildrenNodes = new ArrayList<>(getChildren(SALVAGEABLES));
|
|
||||||
|
|
||||||
for (ConfigurationNode salvageChildNode : salvageChildrenNodes) {
|
|
||||||
// Validate all the things!
|
|
||||||
List<String> errorMessages = new ArrayList<String>();
|
|
||||||
|
|
||||||
// ItemStack Material
|
|
||||||
String salvageChildNodeName = salvageChildNode.getString();
|
|
||||||
Material itemMaterial = Material.matchMaterial(salvageChildNodeName);
|
|
||||||
|
|
||||||
if (itemMaterial == null) {
|
|
||||||
errorMessages.add("Salvage Config: Invalid material - " + salvageChildNodeName);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Salvage Material Type
|
|
||||||
ItemMaterialCategory salvageItemMaterialCategory = ItemMaterialCategory.OTHER;
|
|
||||||
|
|
||||||
String salvageMaterialTypeString;
|
|
||||||
|
|
||||||
if(hasNode(SALVAGEABLES, salvageChildNodeName, MATERIAL_TYPE))
|
|
||||||
salvageMaterialTypeString = getStringValue(SALVAGEABLES, salvageChildNodeName, MATERIAL_TYPE);
|
|
||||||
else
|
|
||||||
salvageMaterialTypeString = "OTHER";
|
|
||||||
|
|
||||||
if (!hasNode(SALVAGEABLES, salvageChildNodeName, MATERIAL_TYPE)) {
|
|
||||||
ItemStack salvageItem = new ItemStack(itemMaterial);
|
|
||||||
|
|
||||||
if (ItemUtils.isWoodTool(salvageItem)) {
|
|
||||||
salvageItemMaterialCategory = ItemMaterialCategory.WOOD;
|
|
||||||
} else if (ItemUtils.isStoneTool(salvageItem)) {
|
|
||||||
salvageItemMaterialCategory = ItemMaterialCategory.STONE;
|
|
||||||
} else if (ItemUtils.isStringTool(salvageItem)) {
|
|
||||||
salvageItemMaterialCategory = ItemMaterialCategory.STRING;
|
|
||||||
} else if (ItemUtils.isLeatherArmor(salvageItem)) {
|
|
||||||
salvageItemMaterialCategory = ItemMaterialCategory.LEATHER;
|
|
||||||
} else if (ItemUtils.isIronArmor(salvageItem) || ItemUtils.isIronTool(salvageItem)) {
|
|
||||||
salvageItemMaterialCategory = ItemMaterialCategory.IRON;
|
|
||||||
} else if (ItemUtils.isGoldArmor(salvageItem) || ItemUtils.isGoldTool(salvageItem)) {
|
|
||||||
salvageItemMaterialCategory = ItemMaterialCategory.GOLD;
|
|
||||||
} else if (ItemUtils.isDiamondArmor(salvageItem) || ItemUtils.isDiamondTool(salvageItem)) {
|
|
||||||
salvageItemMaterialCategory = ItemMaterialCategory.DIAMOND;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
try {
|
|
||||||
salvageItemMaterialCategory = ItemMaterialCategory.valueOf(salvageMaterialTypeString.replace(" ", "_").toUpperCase());
|
|
||||||
} catch (IllegalArgumentException ex) {
|
|
||||||
errorMessages.add("Salvage Config: " + salvageChildNodeName + " has an invalid ItemMaterialCategory of " + salvageMaterialTypeString);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Salvage Material
|
|
||||||
String salvageMaterialName = getStringValue(SALVAGEABLES, salvageChildNodeName, SALVAGE_MATERIAL);
|
|
||||||
Material salvageMaterial = (salvageMaterialName == null ? salvageItemMaterialCategory.getDefaultMaterial() : Material.matchMaterial(salvageMaterialName));
|
|
||||||
|
|
||||||
if (salvageMaterial == null) {
|
|
||||||
errorMessages.add(salvageChildNodeName + " has an invalid salvage material: " + salvageMaterialName);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Maximum Durability
|
|
||||||
short maximumDurability = itemMaterial.getMaxDurability();
|
|
||||||
|
|
||||||
// ItemStack Type
|
|
||||||
ItemType salvageItemType = ItemType.OTHER;
|
|
||||||
|
|
||||||
String salvageItemTypeString;
|
|
||||||
|
|
||||||
if(hasNode(SALVAGEABLES, salvageChildNodeName, ITEM_TYPE))
|
|
||||||
salvageItemTypeString = getStringValue(SALVAGEABLES, salvageChildNodeName, ITEM_TYPE);
|
|
||||||
else
|
|
||||||
salvageItemTypeString = "OTHER";
|
|
||||||
|
|
||||||
if (!hasNode(SALVAGEABLES, salvageChildNodeName, ITEM_TYPE)) {
|
|
||||||
ItemStack salvageItem = new ItemStack(itemMaterial);
|
|
||||||
|
|
||||||
if (ItemUtils.isMinecraftTool(salvageItem)) {
|
|
||||||
salvageItemType = ItemType.TOOL;
|
|
||||||
} else if (ItemUtils.isArmor(salvageItem)) {
|
|
||||||
salvageItemType = ItemType.ARMOR;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
try {
|
|
||||||
salvageItemType = ItemType.valueOf(salvageItemTypeString.replace(" ", "_").toUpperCase());
|
|
||||||
} catch (IllegalArgumentException ex) {
|
|
||||||
errorMessages.add("Salvage Config: " + salvageChildNodeName + " has an invalid " + ITEM_TYPE + " of " + salvageItemTypeString);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
byte salvageMetadata = -1;
|
|
||||||
|
|
||||||
if(hasNode(SALVAGEABLES, salvageChildNodeName, SALVAGE_MATERIAL, METADATA))
|
|
||||||
salvageMetadata = (byte) getIntValue(SALVAGEABLES, salvageChildNodeName, SALVAGE_MATERIAL, METADATA);
|
|
||||||
|
|
||||||
int minimumLevel = getIntValue(SALVAGEABLES, salvageChildNodeName, MINIMUM_LEVEL);
|
|
||||||
double xpMultiplier = 1;
|
|
||||||
|
|
||||||
if(hasNode(SALVAGEABLES, salvageChildNodeName, XP_MULTIPLIER))
|
|
||||||
xpMultiplier = getDoubleValue(SALVAGEABLES, salvageChildNodeName, XP_MULTIPLIER);
|
|
||||||
|
|
||||||
// Maximum Quantity
|
|
||||||
int maximumQuantity = SkillUtils.getRepairAndSalvageQuantities(new ItemStack(itemMaterial), salvageMaterial, salvageMetadata);
|
|
||||||
|
|
||||||
if(hasNode(SALVAGEABLES, salvageChildNodeName, MAXIMUM_QUANTITY))
|
|
||||||
maximumQuantity = getIntValue(SALVAGEABLES, salvageChildNodeName, MAXIMUM_QUANTITY);
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* VALIDATE
|
|
||||||
*/
|
|
||||||
|
|
||||||
if(minimumLevel < 0)
|
|
||||||
minimumLevel = 0;
|
|
||||||
|
|
||||||
if(maximumQuantity < 0)
|
|
||||||
maximumQuantity = 1;
|
|
||||||
|
|
||||||
if(xpMultiplier < 0)
|
|
||||||
xpMultiplier = 0;
|
|
||||||
|
|
||||||
Salvageable salvageable = SalvageableFactory.getSalvageable(itemMaterial, salvageMaterial, salvageMetadata, minimumLevel, maximumQuantity, maximumDurability, salvageItemType, salvageItemMaterialCategory, xpMultiplier);
|
|
||||||
genericCollection.add(salvageable);
|
|
||||||
|
|
||||||
for (String issue : errorMessages) {
|
|
||||||
mcMMO.p.getLogger().warning(issue);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,6 +1,5 @@
|
|||||||
package com.gmail.nossr50.datatypes.experience;
|
package com.gmail.nossr50.datatypes.experience;
|
||||||
|
|
||||||
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
|
||||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||||
|
|
||||||
import java.util.concurrent.Delayed;
|
import java.util.concurrent.Delayed;
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.gmail.nossr50.datatypes.skills.alchemy;
|
package com.gmail.nossr50.datatypes.skills.alchemy;
|
||||||
|
|
||||||
import com.gmail.nossr50.config.skills.alchemy.PotionConfig;
|
|
||||||
import org.bukkit.Color;
|
import org.bukkit.Color;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
@ -123,7 +122,7 @@ public class AlchemyPotion {
|
|||||||
if (!children.isEmpty()) {
|
if (!children.isEmpty()) {
|
||||||
for (Entry<ItemStack, String> child : children.entrySet()) {
|
for (Entry<ItemStack, String> child : children.entrySet()) {
|
||||||
if (ingredient.isSimilar(child.getKey())) {
|
if (ingredient.isSimilar(child.getKey())) {
|
||||||
return PotionConfig.getInstance().getPotion(child.getValue());
|
return PotionMainConfig.getInstance().getPotion(child.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.gmail.nossr50.datatypes.skills.subskills;
|
package com.gmail.nossr50.datatypes.skills.subskills;
|
||||||
|
|
||||||
import com.gmail.nossr50.config.CoreSkillsConfig;
|
|
||||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||||
import com.gmail.nossr50.datatypes.skills.subskills.interfaces.Interaction;
|
import com.gmail.nossr50.datatypes.skills.subskills.interfaces.Interaction;
|
||||||
import com.gmail.nossr50.datatypes.skills.subskills.interfaces.Rank;
|
import com.gmail.nossr50.datatypes.skills.subskills.interfaces.Rank;
|
||||||
@ -42,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 CoreSkillsConfig.getInstance().isSkillEnabled(this);
|
return CoreSkillsMainConfig.getInstance().isSkillEnabled(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.gmail.nossr50.runnables.database;
|
package com.gmail.nossr50.runnables.database;
|
||||||
|
|
||||||
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
|
||||||
import com.gmail.nossr50.database.DatabaseManager;
|
import com.gmail.nossr50.database.DatabaseManager;
|
||||||
import com.gmail.nossr50.datatypes.experience.FormulaType;
|
import com.gmail.nossr50.datatypes.experience.FormulaType;
|
||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.gmail.nossr50.runnables.skills;
|
package com.gmail.nossr50.runnables.skills;
|
||||||
|
|
||||||
import com.gmail.nossr50.config.AdvancedConfig;
|
|
||||||
import com.gmail.nossr50.datatypes.interactions.NotificationType;
|
import com.gmail.nossr50.datatypes.interactions.NotificationType;
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.util.MobHealthbarUtils;
|
import com.gmail.nossr50.util.MobHealthbarUtils;
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.gmail.nossr50.skills.alchemy;
|
package com.gmail.nossr50.skills.alchemy;
|
||||||
|
|
||||||
import com.gmail.nossr50.config.AdvancedConfig;
|
|
||||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.runnables.skills.AlchemyBrewTask;
|
import com.gmail.nossr50.runnables.skills.AlchemyBrewTask;
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
package com.gmail.nossr50.skills.alchemy;
|
package com.gmail.nossr50.skills.alchemy;
|
||||||
|
|
||||||
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
|
||||||
import com.gmail.nossr50.config.skills.alchemy.PotionConfig;
|
|
||||||
import com.gmail.nossr50.datatypes.experience.XPGainReason;
|
import com.gmail.nossr50.datatypes.experience.XPGainReason;
|
||||||
import com.gmail.nossr50.datatypes.experience.XPGainSource;
|
import com.gmail.nossr50.datatypes.experience.XPGainSource;
|
||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
@ -27,7 +25,7 @@ public class AlchemyManager extends SkillManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<ItemStack> getIngredients() {
|
public List<ItemStack> getIngredients() {
|
||||||
return PotionConfig.getInstance().getIngredients(getTier());
|
return PotionMainConfig.getInstance().getIngredients(getTier());
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getIngredientList() {
|
public String getIngredientList() {
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.gmail.nossr50.skills.alchemy;
|
package com.gmail.nossr50.skills.alchemy;
|
||||||
|
|
||||||
import com.gmail.nossr50.config.skills.alchemy.PotionConfig;
|
|
||||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||||
import com.gmail.nossr50.datatypes.skills.alchemy.AlchemyPotion;
|
import com.gmail.nossr50.datatypes.skills.alchemy.AlchemyPotion;
|
||||||
import com.gmail.nossr50.datatypes.skills.alchemy.PotionStage;
|
import com.gmail.nossr50.datatypes.skills.alchemy.PotionStage;
|
||||||
@ -35,7 +34,7 @@ public final class AlchemyPotionBrewer {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getChildPotion(PotionConfig.getInstance().getPotion(contents[i]), contents[Alchemy.INGREDIENT_SLOT]) != null) {
|
if (getChildPotion(PotionMainConfig.getInstance().getPotion(contents[i]), contents[Alchemy.INGREDIENT_SLOT]) != null) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -93,7 +92,7 @@ public final class AlchemyPotionBrewer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static List<ItemStack> getValidIngredients(Player player) {
|
private static List<ItemStack> getValidIngredients(Player player) {
|
||||||
return PotionConfig.getInstance().getIngredients((player == null || !Permissions.isSubSkillEnabled(player, SubSkillType.ALCHEMY_CONCOCTIONS)) ? 1 : UserManager.getPlayer(player).getAlchemyManager().getTier());
|
return PotionMainConfig.getInstance().getIngredients((player == null || !Permissions.isSubSkillEnabled(player, SubSkillType.ALCHEMY_CONCOCTIONS)) ? 1 : UserManager.getPlayer(player).getAlchemyManager().getTier());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void finishBrewing(BlockState brewingStand, Player player, boolean forced) {
|
public static void finishBrewing(BlockState brewingStand, Player player, boolean forced) {
|
||||||
@ -113,11 +112,11 @@ public final class AlchemyPotionBrewer {
|
|||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
ItemStack item = inventory.getItem(i);
|
ItemStack item = inventory.getItem(i);
|
||||||
|
|
||||||
if (isEmpty(item) || item.getType() == Material.GLASS_BOTTLE || !PotionConfig.getInstance().isValidPotion(item)) {
|
if (isEmpty(item) || item.getType() == Material.GLASS_BOTTLE || !PotionMainConfig.getInstance().isValidPotion(item)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
AlchemyPotion input = PotionConfig.getInstance().getPotion(item);
|
AlchemyPotion input = PotionMainConfig.getInstance().getPotion(item);
|
||||||
AlchemyPotion output = input.getChild(ingredient);
|
AlchemyPotion output = input.getChild(ingredient);
|
||||||
|
|
||||||
inputList.add(input);
|
inputList.add(input);
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
package com.gmail.nossr50.skills.archery;
|
package com.gmail.nossr50.skills.archery;
|
||||||
|
|
||||||
import com.gmail.nossr50.config.AdvancedConfig;
|
|
||||||
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
|
||||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.skills.RankUtils;
|
import com.gmail.nossr50.util.skills.RankUtils;
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.gmail.nossr50.skills.axes;
|
package com.gmail.nossr50.skills.axes;
|
||||||
|
|
||||||
import com.gmail.nossr50.config.AdvancedConfig;
|
|
||||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||||
import com.gmail.nossr50.util.ItemUtils;
|
import com.gmail.nossr50.util.ItemUtils;
|
||||||
import com.gmail.nossr50.util.skills.RankUtils;
|
import com.gmail.nossr50.util.skills.RankUtils;
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.gmail.nossr50.skills.mining;
|
package com.gmail.nossr50.skills.mining;
|
||||||
|
|
||||||
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
|
||||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
package com.gmail.nossr50.skills.repair;
|
package com.gmail.nossr50.skills.repair;
|
||||||
|
|
||||||
import com.gmail.nossr50.config.AdvancedConfig;
|
|
||||||
|
|
||||||
public class ArcaneForging {
|
public class ArcaneForging {
|
||||||
|
|
||||||
public static boolean arcaneForgingDowngrades = AdvancedConfig.getInstance().getArcaneForgingDowngradeEnabled();
|
public static boolean arcaneForgingDowngrades = AdvancedConfig.getInstance().getArcaneForgingDowngradeEnabled();
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
package com.gmail.nossr50.skills.swords;
|
package com.gmail.nossr50.skills.swords;
|
||||||
|
|
||||||
import com.gmail.nossr50.config.AdvancedConfig;
|
|
||||||
|
|
||||||
public class Swords {
|
public class Swords {
|
||||||
public static int bleedMaxTicks = AdvancedConfig.getInstance().getRuptureMaxTicks();
|
public static int bleedMaxTicks = AdvancedConfig.getInstance().getRuptureMaxTicks();
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.gmail.nossr50.skills.taming;
|
package com.gmail.nossr50.skills.taming;
|
||||||
|
|
||||||
import com.gmail.nossr50.config.AdvancedConfig;
|
|
||||||
import org.bukkit.EntityEffect;
|
import org.bukkit.EntityEffect;
|
||||||
import org.bukkit.entity.*;
|
import org.bukkit.entity.*;
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.gmail.nossr50.skills.unarmed;
|
package com.gmail.nossr50.skills.unarmed;
|
||||||
|
|
||||||
import com.gmail.nossr50.config.AdvancedConfig;
|
|
||||||
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;
|
||||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.gmail.nossr50.util.experience;
|
package com.gmail.nossr50.util.experience;
|
||||||
|
|
||||||
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
|
||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||||
import com.gmail.nossr50.runnables.skills.ExperienceBarHideTask;
|
import com.gmail.nossr50.runnables.skills.ExperienceBarHideTask;
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.gmail.nossr50.util.experience;
|
package com.gmail.nossr50.util.experience;
|
||||||
|
|
||||||
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
|
||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.gmail.nossr50.util.player;
|
package com.gmail.nossr50.util.player;
|
||||||
|
|
||||||
import com.gmail.nossr50.config.AdvancedConfig;
|
|
||||||
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;
|
||||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.gmail.nossr50.util.random;
|
package com.gmail.nossr50.util.random;
|
||||||
|
|
||||||
import com.gmail.nossr50.config.AdvancedConfig;
|
|
||||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||||
import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill;
|
import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill;
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.gmail.nossr50.util.skills;
|
package com.gmail.nossr50.util.skills;
|
||||||
|
|
||||||
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,6 +1,5 @@
|
|||||||
package com.gmail.nossr50.util.skills;
|
package com.gmail.nossr50.util.skills;
|
||||||
|
|
||||||
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
|
||||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.gmail.nossr50.util.skills;
|
package com.gmail.nossr50.util.skills;
|
||||||
|
|
||||||
import com.gmail.nossr50.config.RankConfig;
|
|
||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.gmail.nossr50.util.sounds;
|
package com.gmail.nossr50.util.sounds;
|
||||||
|
|
||||||
import com.gmail.nossr50.config.SoundConfig;
|
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
@ -15,13 +14,13 @@ public class SoundManager {
|
|||||||
*/
|
*/
|
||||||
public static void sendSound(Player player, Location location, SoundType soundType)
|
public static void sendSound(Player player, Location location, SoundType soundType)
|
||||||
{
|
{
|
||||||
if(SoundConfig.getInstance().getIsEnabled(soundType))
|
if(SoundMainConfig.getInstance().getIsEnabled(soundType))
|
||||||
player.playSound(location, getSound(soundType), SoundCategory.MASTER, getVolume(soundType), getPitch(soundType));
|
player.playSound(location, getSound(soundType), SoundCategory.MASTER, getVolume(soundType), getPitch(soundType));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void sendCategorizedSound(Player player, Location location, SoundType soundType, SoundCategory soundCategory)
|
public static void sendCategorizedSound(Player player, Location location, SoundType soundType, SoundCategory soundCategory)
|
||||||
{
|
{
|
||||||
if(SoundConfig.getInstance().getIsEnabled(soundType))
|
if(SoundMainConfig.getInstance().getIsEnabled(soundType))
|
||||||
player.playSound(location, getSound(soundType), soundCategory, getVolume(soundType), getPitch(soundType));
|
player.playSound(location, getSound(soundType), soundCategory, getVolume(soundType), getPitch(soundType));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -29,13 +28,13 @@ public class SoundManager {
|
|||||||
{
|
{
|
||||||
float totalPitch = Math.min(2.0F, (getPitch(soundType) + pitchModifier));
|
float totalPitch = Math.min(2.0F, (getPitch(soundType) + pitchModifier));
|
||||||
|
|
||||||
if(SoundConfig.getInstance().getIsEnabled(soundType))
|
if(SoundMainConfig.getInstance().getIsEnabled(soundType))
|
||||||
player.playSound(location, getSound(soundType), soundCategory, getVolume(soundType), totalPitch);
|
player.playSound(location, getSound(soundType), soundCategory, getVolume(soundType), totalPitch);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void worldSendSound(World world, Location location, SoundType soundType)
|
public static void worldSendSound(World world, Location location, SoundType soundType)
|
||||||
{
|
{
|
||||||
if(SoundConfig.getInstance().getIsEnabled(soundType))
|
if(SoundMainConfig.getInstance().getIsEnabled(soundType))
|
||||||
world.playSound(location, getSound(soundType), getVolume(soundType), getPitch(soundType));
|
world.playSound(location, getSound(soundType), getVolume(soundType), getPitch(soundType));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,7 +45,7 @@ public class SoundManager {
|
|||||||
*/
|
*/
|
||||||
private static float getVolume(SoundType soundType)
|
private static float getVolume(SoundType soundType)
|
||||||
{
|
{
|
||||||
return SoundConfig.getInstance().getVolume(soundType) * SoundConfig.getInstance().getMasterVolume();
|
return SoundMainConfig.getInstance().getVolume(soundType) * SoundMainConfig.getInstance().getMasterVolume();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static float getPitch(SoundType soundType)
|
private static float getPitch(SoundType soundType)
|
||||||
@ -56,7 +55,7 @@ public class SoundManager {
|
|||||||
else if (soundType == SoundType.POP)
|
else if (soundType == SoundType.POP)
|
||||||
return getPopPitch();
|
return getPopPitch();
|
||||||
else
|
else
|
||||||
return SoundConfig.getInstance().getPitch(soundType);
|
return SoundMainConfig.getInstance().getPitch(soundType);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Sound getSound(SoundType soundType)
|
private static Sound getSound(SoundType soundType)
|
||||||
|
Loading…
Reference in New Issue
Block a user