mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-22 13:16:45 +01:00
Config refactoring.
This commit is contained in:
parent
26481c547a
commit
0afc0d59a4
@ -16,12 +16,12 @@ import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure;
|
||||
import com.gmail.nossr50.datatypes.treasure.FishingTreasure;
|
||||
import com.gmail.nossr50.datatypes.treasure.Treasure;
|
||||
|
||||
public class LoadTreasures extends ConfigLoader{
|
||||
private static LoadTreasures instance;
|
||||
public class TreasuresConfig extends ConfigLoader{
|
||||
private static TreasuresConfig instance;
|
||||
|
||||
public static LoadTreasures getInstance() {
|
||||
public static TreasuresConfig getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new LoadTreasures(mcMMO.p);
|
||||
instance = new TreasuresConfig(mcMMO.p);
|
||||
instance.load();
|
||||
}
|
||||
|
||||
@ -41,7 +41,7 @@ public class LoadTreasures extends ConfigLoader{
|
||||
public List<FishingTreasure> fishingRewardsTier4 = new ArrayList<FishingTreasure>();
|
||||
public List<FishingTreasure> fishingRewardsTier5 = new ArrayList<FishingTreasure>();
|
||||
|
||||
private LoadTreasures(mcMMO plugin) {
|
||||
private TreasuresConfig(mcMMO plugin) {
|
||||
super(plugin, "treasures.yml");
|
||||
config = plugin.getTreasuresConfig();
|
||||
}
|
@ -11,12 +11,12 @@ import org.bukkit.inventory.ItemStack;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.datatypes.mods.CustomItem;
|
||||
|
||||
public class LoadCustomArmor extends ModConfigLoader{
|
||||
private static LoadCustomArmor instance;
|
||||
public class CustomArmorConfig extends ModConfigLoader{
|
||||
private static CustomArmorConfig instance;
|
||||
|
||||
public static LoadCustomArmor getInstance() {
|
||||
public static CustomArmorConfig getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new LoadCustomArmor(mcMMO.p);
|
||||
instance = new CustomArmorConfig(mcMMO.p);
|
||||
}
|
||||
|
||||
return instance;
|
||||
@ -30,7 +30,7 @@ public class LoadCustomArmor extends ModConfigLoader{
|
||||
public List<Integer> customIDs = new ArrayList<Integer>();
|
||||
public List<CustomItem> customItems = new ArrayList<CustomItem>();
|
||||
|
||||
public LoadCustomArmor(mcMMO plugin) {
|
||||
public CustomArmorConfig(mcMMO plugin) {
|
||||
super(plugin, "armor.yml");
|
||||
config = plugin.getArmorConfig();
|
||||
}
|
@ -12,12 +12,12 @@ import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.datatypes.mods.CustomItem;
|
||||
import com.gmail.nossr50.datatypes.mods.CustomTool;
|
||||
|
||||
public class LoadCustomTools extends ModConfigLoader {
|
||||
private static LoadCustomTools instance;
|
||||
public class CustomToolsConfig extends ModConfigLoader {
|
||||
private static CustomToolsConfig instance;
|
||||
|
||||
public static LoadCustomTools getInstance() {
|
||||
public static CustomToolsConfig getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new LoadCustomTools(mcMMO.p);
|
||||
instance = new CustomToolsConfig(mcMMO.p);
|
||||
}
|
||||
|
||||
return instance;
|
||||
@ -33,7 +33,7 @@ public class LoadCustomTools extends ModConfigLoader {
|
||||
public List<Integer> customIDs = new ArrayList<Integer>();
|
||||
public List<CustomItem> customItems = new ArrayList<CustomItem>();
|
||||
|
||||
private LoadCustomTools(mcMMO plugin) {
|
||||
private CustomToolsConfig(mcMMO plugin) {
|
||||
super(plugin, "tools.yml");
|
||||
config = plugin.getToolsConfig();
|
||||
}
|
@ -7,10 +7,10 @@ import com.gmail.nossr50.commands.mc.*;
|
||||
import com.gmail.nossr50.commands.party.*;
|
||||
import com.gmail.nossr50.commands.general.*;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.config.LoadTreasures;
|
||||
import com.gmail.nossr50.config.TreasuresConfig;
|
||||
import com.gmail.nossr50.config.mods.CustomBlocksConfig;
|
||||
import com.gmail.nossr50.config.mods.LoadCustomArmor;
|
||||
import com.gmail.nossr50.config.mods.LoadCustomTools;
|
||||
import com.gmail.nossr50.config.mods.CustomArmorConfig;
|
||||
import com.gmail.nossr50.config.mods.CustomToolsConfig;
|
||||
import com.gmail.nossr50.runnables.*;
|
||||
import com.gmail.nossr50.util.Database;
|
||||
import com.gmail.nossr50.util.Leaderboard;
|
||||
@ -73,14 +73,14 @@ public class mcMMO extends JavaPlugin {
|
||||
|
||||
//Force the loading of config files
|
||||
Config configInstance = Config.getInstance();
|
||||
LoadTreasures.getInstance();
|
||||
TreasuresConfig.getInstance();
|
||||
|
||||
if (configInstance.getToolModsEnabled()) {
|
||||
LoadCustomTools.getInstance().load();
|
||||
CustomToolsConfig.getInstance().load();
|
||||
}
|
||||
|
||||
if (configInstance.getArmorModsEnabled()) {
|
||||
LoadCustomArmor.getInstance().load();
|
||||
CustomArmorConfig.getInstance().load();
|
||||
}
|
||||
|
||||
if (configInstance.getBlockModsEnabled()) {
|
||||
|
@ -18,7 +18,7 @@ import com.gmail.nossr50.util.Skills;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.config.LoadTreasures;
|
||||
import com.gmail.nossr50.config.TreasuresConfig;
|
||||
import com.gmail.nossr50.config.mods.CustomBlocksConfig;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
@ -59,31 +59,31 @@ public class Excavation {
|
||||
if (Permissions.getInstance().excavationTreasures(player)) {
|
||||
switch (type) {
|
||||
case DIRT:
|
||||
treasures = LoadTreasures.getInstance().excavationFromDirt;
|
||||
treasures = TreasuresConfig.getInstance().excavationFromDirt;
|
||||
break;
|
||||
|
||||
case GRASS:
|
||||
treasures = LoadTreasures.getInstance().excavationFromGrass;
|
||||
treasures = TreasuresConfig.getInstance().excavationFromGrass;
|
||||
break;
|
||||
|
||||
case SAND:
|
||||
treasures = LoadTreasures.getInstance().excavationFromSand;
|
||||
treasures = TreasuresConfig.getInstance().excavationFromSand;
|
||||
break;
|
||||
|
||||
case GRAVEL:
|
||||
treasures = LoadTreasures.getInstance().excavationFromGravel;
|
||||
treasures = TreasuresConfig.getInstance().excavationFromGravel;
|
||||
break;
|
||||
|
||||
case CLAY:
|
||||
treasures = LoadTreasures.getInstance().excavationFromClay;
|
||||
treasures = TreasuresConfig.getInstance().excavationFromClay;
|
||||
break;
|
||||
|
||||
case MYCEL:
|
||||
treasures = LoadTreasures.getInstance().excavationFromMycel;
|
||||
treasures = TreasuresConfig.getInstance().excavationFromMycel;
|
||||
break;
|
||||
|
||||
case SOUL_SAND:
|
||||
treasures = LoadTreasures.getInstance().excavationFromSoulSand;
|
||||
treasures = TreasuresConfig.getInstance().excavationFromSoulSand;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -18,7 +18,7 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.material.Wool;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.config.LoadTreasures;
|
||||
import com.gmail.nossr50.config.TreasuresConfig;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.datatypes.treasure.FishingTreasure;
|
||||
@ -76,23 +76,23 @@ public class Fishing {
|
||||
|
||||
switch (getFishingLootTier(PP)) {
|
||||
case 1:
|
||||
rewards = LoadTreasures.getInstance().fishingRewardsTier1;
|
||||
rewards = TreasuresConfig.getInstance().fishingRewardsTier1;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
rewards = LoadTreasures.getInstance().fishingRewardsTier2;
|
||||
rewards = TreasuresConfig.getInstance().fishingRewardsTier2;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
rewards = LoadTreasures.getInstance().fishingRewardsTier3;
|
||||
rewards = TreasuresConfig.getInstance().fishingRewardsTier3;
|
||||
break;
|
||||
|
||||
case 4:
|
||||
rewards = LoadTreasures.getInstance().fishingRewardsTier4;
|
||||
rewards = TreasuresConfig.getInstance().fishingRewardsTier4;
|
||||
break;
|
||||
|
||||
case 5:
|
||||
rewards = LoadTreasures.getInstance().fishingRewardsTier5;
|
||||
rewards = TreasuresConfig.getInstance().fishingRewardsTier5;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -16,8 +16,8 @@ import org.getspout.spoutapi.player.SpoutPlayer;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.config.mods.LoadCustomArmor;
|
||||
import com.gmail.nossr50.config.mods.LoadCustomTools;
|
||||
import com.gmail.nossr50.config.mods.CustomArmorConfig;
|
||||
import com.gmail.nossr50.config.mods.CustomToolsConfig;
|
||||
import com.gmail.nossr50.spout.SpoutSounds;
|
||||
import com.gmail.nossr50.util.ItemChecks;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
@ -113,7 +113,7 @@ public class Repair {
|
||||
* REPAIR CUSTOM TOOLS
|
||||
*/
|
||||
else if (ItemChecks.isCustomTool(is) && permInstance.toolRepair(player)) {
|
||||
LoadCustomTools toolsInstance = LoadCustomTools.getInstance();
|
||||
CustomToolsConfig toolsInstance = CustomToolsConfig.getInstance();
|
||||
|
||||
for (CustomItem tool : toolsInstance.customItems) {
|
||||
if (tool.getItemID() == is.getTypeId()) {
|
||||
@ -136,7 +136,7 @@ public class Repair {
|
||||
* REPAIR CUSTOM ARMOR
|
||||
*/
|
||||
else if (ItemChecks.isCustomArmor(is) && permInstance.armorRepair(player)) {
|
||||
LoadCustomArmor armorInstance = LoadCustomArmor.getInstance();
|
||||
CustomArmorConfig armorInstance = CustomArmorConfig.getInstance();
|
||||
|
||||
for (CustomItem armor : armorInstance.customItems) {
|
||||
if (armor.getItemID() == is.getTypeId()) {
|
||||
@ -406,8 +406,8 @@ public class Repair {
|
||||
int materialsRequired = 0;
|
||||
int repairAmount = 0;
|
||||
|
||||
LoadCustomTools toolInstance = LoadCustomTools.getInstance();
|
||||
LoadCustomArmor armorInstance = LoadCustomArmor.getInstance();
|
||||
CustomToolsConfig toolInstance = CustomToolsConfig.getInstance();
|
||||
CustomArmorConfig armorInstance = CustomArmorConfig.getInstance();
|
||||
|
||||
if (ModChecks.getToolFromItemStack(is) != null) {
|
||||
for (CustomItem tool : toolInstance.customItems) {
|
||||
|
@ -3,8 +3,8 @@ package com.gmail.nossr50.util;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.config.mods.LoadCustomArmor;
|
||||
import com.gmail.nossr50.config.mods.LoadCustomTools;
|
||||
import com.gmail.nossr50.config.mods.CustomArmorConfig;
|
||||
import com.gmail.nossr50.config.mods.CustomToolsConfig;
|
||||
|
||||
public class ItemChecks {
|
||||
private static Config configInstance = Config.getInstance();
|
||||
@ -27,7 +27,7 @@ public class ItemChecks {
|
||||
return true;
|
||||
|
||||
default:
|
||||
if (customToolsEnabled && LoadCustomTools.getInstance().customSwordIDs.contains(is.getTypeId())) {
|
||||
if (customToolsEnabled && CustomToolsConfig.getInstance().customSwordIDs.contains(is.getTypeId())) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
@ -52,7 +52,7 @@ public class ItemChecks {
|
||||
return true;
|
||||
|
||||
default:
|
||||
if (customToolsEnabled && LoadCustomTools.getInstance().customHoeIDs.contains(is.getTypeId())) {
|
||||
if (customToolsEnabled && CustomToolsConfig.getInstance().customHoeIDs.contains(is.getTypeId())) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
@ -77,7 +77,7 @@ public class ItemChecks {
|
||||
return true;
|
||||
|
||||
default:
|
||||
if (customToolsEnabled && LoadCustomTools.getInstance().customShovelIDs.contains(is.getTypeId())) {
|
||||
if (customToolsEnabled && CustomToolsConfig.getInstance().customShovelIDs.contains(is.getTypeId())) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
@ -102,7 +102,7 @@ public class ItemChecks {
|
||||
return true;
|
||||
|
||||
default:
|
||||
if (customToolsEnabled && LoadCustomTools.getInstance().customAxeIDs.contains(is.getTypeId())) {
|
||||
if (customToolsEnabled && CustomToolsConfig.getInstance().customAxeIDs.contains(is.getTypeId())) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
@ -127,7 +127,7 @@ public class ItemChecks {
|
||||
return true;
|
||||
|
||||
default:
|
||||
if (customToolsEnabled && LoadCustomTools.getInstance().customPickaxeIDs.contains(is.getTypeId())) {
|
||||
if (customToolsEnabled && CustomToolsConfig.getInstance().customPickaxeIDs.contains(is.getTypeId())) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
@ -151,7 +151,7 @@ public class ItemChecks {
|
||||
return true;
|
||||
|
||||
default:
|
||||
if (customArmorEnabled && LoadCustomArmor.getInstance().customHelmetIDs.contains(is.getTypeId())) {
|
||||
if (customArmorEnabled && CustomArmorConfig.getInstance().customHelmetIDs.contains(is.getTypeId())) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
@ -175,7 +175,7 @@ public class ItemChecks {
|
||||
return true;
|
||||
|
||||
default:
|
||||
if (customArmorEnabled && LoadCustomArmor.getInstance().customChestplateIDs.contains(is.getTypeId())) {
|
||||
if (customArmorEnabled && CustomArmorConfig.getInstance().customChestplateIDs.contains(is.getTypeId())) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
@ -199,7 +199,7 @@ public class ItemChecks {
|
||||
return true;
|
||||
|
||||
default:
|
||||
if (customArmorEnabled && LoadCustomArmor.getInstance().customLeggingIDs.contains(is.getTypeId())) {
|
||||
if (customArmorEnabled && CustomArmorConfig.getInstance().customLeggingIDs.contains(is.getTypeId())) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
@ -223,7 +223,7 @@ public class ItemChecks {
|
||||
return true;
|
||||
|
||||
default:
|
||||
if (customArmorEnabled && LoadCustomArmor.getInstance().customBootIDs.contains(is.getTypeId())) {
|
||||
if (customArmorEnabled && CustomArmorConfig.getInstance().customBootIDs.contains(is.getTypeId())) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
@ -249,7 +249,7 @@ public class ItemChecks {
|
||||
* @return true if the item is a custom tool, false otherwise
|
||||
*/
|
||||
public static boolean isCustomArmor(ItemStack is) {
|
||||
if (customArmorEnabled && LoadCustomArmor.getInstance().customIDs.contains(is.getTypeId())) {
|
||||
if (customArmorEnabled && CustomArmorConfig.getInstance().customIDs.contains(is.getTypeId())) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
@ -350,7 +350,7 @@ public class ItemChecks {
|
||||
* @return true if the item is a custom tool, false otherwise
|
||||
*/
|
||||
public static boolean isCustomTool(ItemStack is) {
|
||||
if (customToolsEnabled && LoadCustomTools.getInstance().customIDs.contains(is.getTypeId())) {
|
||||
if (customToolsEnabled && CustomToolsConfig.getInstance().customIDs.contains(is.getTypeId())) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
|
@ -4,15 +4,15 @@ import org.bukkit.block.Block;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.config.mods.CustomBlocksConfig;
|
||||
import com.gmail.nossr50.config.mods.LoadCustomArmor;
|
||||
import com.gmail.nossr50.config.mods.LoadCustomTools;
|
||||
import com.gmail.nossr50.config.mods.CustomArmorConfig;
|
||||
import com.gmail.nossr50.config.mods.CustomToolsConfig;
|
||||
import com.gmail.nossr50.datatypes.mods.CustomBlock;
|
||||
import com.gmail.nossr50.datatypes.mods.CustomItem;
|
||||
import com.gmail.nossr50.datatypes.mods.CustomTool;
|
||||
|
||||
public class ModChecks {
|
||||
private static LoadCustomTools toolInstance = LoadCustomTools.getInstance();
|
||||
private static LoadCustomArmor armorInstance = LoadCustomArmor.getInstance();
|
||||
private static CustomToolsConfig toolInstance = CustomToolsConfig.getInstance();
|
||||
private static CustomArmorConfig armorInstance = CustomArmorConfig.getInstance();
|
||||
private static CustomBlocksConfig blocksInstance = CustomBlocksConfig.getInstance();
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user