mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-26 15:16:45 +01:00
Updates to configs.
This commit is contained in:
parent
c1cdba4395
commit
b10f599a87
55
src/main/java/com/gmail/nossr50/config/ConfigLoader.java
Normal file
55
src/main/java/com/gmail/nossr50/config/ConfigLoader.java
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
package com.gmail.nossr50.config;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.mcMMO;
|
||||||
|
|
||||||
|
public abstract class ConfigLoader {
|
||||||
|
|
||||||
|
protected static File configFile;
|
||||||
|
protected static File dataFolder;
|
||||||
|
protected final mcMMO plugin;
|
||||||
|
protected static FileConfiguration config;
|
||||||
|
|
||||||
|
public ConfigLoader(mcMMO plugin, String fileName){
|
||||||
|
this.plugin = plugin;
|
||||||
|
dataFolder = plugin.getDataFolder();
|
||||||
|
configFile = new File(dataFolder, File.separator + fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load this config file.
|
||||||
|
*/
|
||||||
|
protected abstract void load();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Save this config file.
|
||||||
|
*/
|
||||||
|
private static void saveConfig() {
|
||||||
|
try {
|
||||||
|
config.save(configFile);
|
||||||
|
}
|
||||||
|
catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add the defaults to this config file.
|
||||||
|
*/
|
||||||
|
protected void addDefaults() {
|
||||||
|
|
||||||
|
// Load from included config.yml
|
||||||
|
config.options().copyDefaults(true);
|
||||||
|
saveConfig();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load the keys from this config file.
|
||||||
|
*/
|
||||||
|
protected abstract void loadKeys();
|
||||||
|
|
||||||
|
}
|
@ -1,18 +1,15 @@
|
|||||||
package com.gmail.nossr50.config;
|
package com.gmail.nossr50.config;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
|
||||||
import com.gmail.nossr50.datatypes.HUDType;
|
import com.gmail.nossr50.datatypes.HUDType;
|
||||||
|
|
||||||
public class LoadProperties {
|
public class LoadProperties extends ConfigLoader{
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* GENERAL SETTINGS
|
* GENERAL SETTINGS
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* General Settings */
|
||||||
public static String locale;
|
public static String locale;
|
||||||
public static Boolean enableMotd, statsTracking, eventCallback;
|
public static Boolean enableMotd, statsTracking, eventCallback;
|
||||||
public static int saveInterval;
|
public static int saveInterval;
|
||||||
@ -115,6 +112,7 @@ public class LoadProperties {
|
|||||||
* XP SETTINGS
|
* XP SETTINGS
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* General Settings */
|
||||||
public static Boolean xpGainsMobSpawners, pvpxp;
|
public static Boolean xpGainsMobSpawners, pvpxp;
|
||||||
public static int xpGainMultiplier;
|
public static int xpGainMultiplier;
|
||||||
|
|
||||||
@ -163,21 +161,13 @@ public class LoadProperties {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
public static HUDType defaulthud;
|
public static HUDType defaulthud;
|
||||||
protected static File configFile;
|
|
||||||
protected static File dataFolder;
|
|
||||||
protected final mcMMO plugin;
|
|
||||||
protected static FileConfiguration config;
|
|
||||||
|
|
||||||
public LoadProperties(mcMMO plugin) {
|
public LoadProperties(mcMMO plugin) {
|
||||||
this.plugin = plugin;
|
super(plugin, "config.yml");
|
||||||
dataFolder = plugin.getDataFolder();
|
|
||||||
configFile = new File(dataFolder, File.separator + "config.yml");
|
|
||||||
config = plugin.getConfig();
|
config = plugin.getConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* Load this config file.
|
|
||||||
*/
|
|
||||||
public void load() {
|
public void load() {
|
||||||
|
|
||||||
// If it doesn't exist, copy it from the .jar
|
// If it doesn't exist, copy it from the .jar
|
||||||
@ -190,32 +180,8 @@ public class LoadProperties {
|
|||||||
loadKeys();
|
loadKeys();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* Save this config file.
|
protected void loadKeys() {
|
||||||
*/
|
|
||||||
private static void saveConfig() {
|
|
||||||
try {
|
|
||||||
config.save(configFile);
|
|
||||||
}
|
|
||||||
catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add the defaults to this config file.
|
|
||||||
*/
|
|
||||||
private void addDefaults() {
|
|
||||||
|
|
||||||
// Load from included config.yml
|
|
||||||
config.options().copyDefaults(true);
|
|
||||||
saveConfig();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Load the keys from this config file.
|
|
||||||
*/
|
|
||||||
private void loadKeys() {
|
|
||||||
plugin.getLogger().info("Loading mcMMO config.yml File...");
|
plugin.getLogger().info("Loading mcMMO config.yml File...");
|
||||||
|
|
||||||
// Setup default HUD
|
// Setup default HUD
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
package com.gmail.nossr50.config;
|
package com.gmail.nossr50.config;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
@ -12,7 +10,6 @@ import java.util.Set;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
@ -20,201 +17,270 @@ import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure;
|
|||||||
import com.gmail.nossr50.datatypes.treasure.FishingTreasure;
|
import com.gmail.nossr50.datatypes.treasure.FishingTreasure;
|
||||||
import com.gmail.nossr50.datatypes.treasure.Treasure;
|
import com.gmail.nossr50.datatypes.treasure.Treasure;
|
||||||
|
|
||||||
public class LoadTreasures {
|
public class LoadTreasures extends ConfigLoader{
|
||||||
|
|
||||||
public static List<ExcavationTreasure> excavationFromDirt = new ArrayList<ExcavationTreasure>();
|
public static List<ExcavationTreasure> excavationFromDirt = new ArrayList<ExcavationTreasure>();
|
||||||
public static List<ExcavationTreasure> excavationFromGrass = new ArrayList<ExcavationTreasure>();
|
public static List<ExcavationTreasure> excavationFromGrass = new ArrayList<ExcavationTreasure>();
|
||||||
public static List<ExcavationTreasure> excavationFromSand = new ArrayList<ExcavationTreasure>();
|
public static List<ExcavationTreasure> excavationFromSand = new ArrayList<ExcavationTreasure>();
|
||||||
public static List<ExcavationTreasure> excavationFromGravel = new ArrayList<ExcavationTreasure>();
|
public static List<ExcavationTreasure> excavationFromGravel = new ArrayList<ExcavationTreasure>();
|
||||||
public static List<ExcavationTreasure> excavationFromClay = new ArrayList<ExcavationTreasure>();
|
public static List<ExcavationTreasure> excavationFromClay = new ArrayList<ExcavationTreasure>();
|
||||||
public static List<ExcavationTreasure> excavationFromMycel = new ArrayList<ExcavationTreasure>();
|
public static List<ExcavationTreasure> excavationFromMycel = new ArrayList<ExcavationTreasure>();
|
||||||
public static List<ExcavationTreasure> excavationFromSoulSand = new ArrayList<ExcavationTreasure>();
|
public static List<ExcavationTreasure> excavationFromSoulSand = new ArrayList<ExcavationTreasure>();
|
||||||
public static List<FishingTreasure> fishingRewardsTier1 = new ArrayList<FishingTreasure>();
|
public static List<FishingTreasure> fishingRewardsTier1 = new ArrayList<FishingTreasure>();
|
||||||
public static List<FishingTreasure> fishingRewardsTier2 = new ArrayList<FishingTreasure>();
|
public static List<FishingTreasure> fishingRewardsTier2 = new ArrayList<FishingTreasure>();
|
||||||
public static List<FishingTreasure> fishingRewardsTier3 = new ArrayList<FishingTreasure>();
|
public static List<FishingTreasure> fishingRewardsTier3 = new ArrayList<FishingTreasure>();
|
||||||
public static List<FishingTreasure> fishingRewardsTier4 = new ArrayList<FishingTreasure>();
|
public static List<FishingTreasure> fishingRewardsTier4 = new ArrayList<FishingTreasure>();
|
||||||
public static List<FishingTreasure> fishingRewardsTier5 = new ArrayList<FishingTreasure>();
|
public static List<FishingTreasure> fishingRewardsTier5 = new ArrayList<FishingTreasure>();
|
||||||
|
|
||||||
protected static File configFile;
|
|
||||||
protected static File dataFolder;
|
|
||||||
protected final mcMMO plugin;
|
|
||||||
protected static FileConfiguration config;
|
|
||||||
|
|
||||||
public LoadTreasures(mcMMO plugin) {
|
public LoadTreasures(mcMMO plugin) {
|
||||||
this.plugin = plugin;
|
super(plugin, "treasures.yml");
|
||||||
dataFolder = plugin.getDataFolder();
|
config = plugin.getTreasuresConfig();
|
||||||
configFile = new File(dataFolder, File.separator + "treasures.yml");
|
}
|
||||||
config = plugin.getTreasuresConfig();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void load() {
|
@Override
|
||||||
// If not exist, copy from the jar
|
public void load() {
|
||||||
if (!configFile.exists()) {
|
|
||||||
dataFolder.mkdir();
|
|
||||||
plugin.saveTreasuresConfig();
|
|
||||||
}
|
|
||||||
addDefaults();
|
|
||||||
loadKeys();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void saveConfig() {
|
|
||||||
try {
|
|
||||||
config.save(configFile);
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addDefaults() {
|
|
||||||
// Load from included config.yml
|
|
||||||
config.options().copyDefaults(true);
|
|
||||||
saveConfig();
|
|
||||||
}
|
|
||||||
|
|
||||||
private Boolean readBoolean(String root, Boolean def) {
|
|
||||||
Boolean result = config.getBoolean(root, def);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void loadKeys()
|
|
||||||
{
|
|
||||||
plugin.getLogger().info("Loading mcMMO treasures.yml File...");
|
|
||||||
|
|
||||||
// Load treasures
|
|
||||||
Map<String, Treasure> treasures = new HashMap<String, Treasure>();
|
|
||||||
|
|
||||||
ConfigurationSection treasureSection = config.getConfigurationSection("Treasures");
|
// If it doesn't exist, copy it from the .jar
|
||||||
|
if (!configFile.exists()) {
|
||||||
|
dataFolder.mkdir();
|
||||||
|
plugin.saveTreasuresConfig();
|
||||||
|
}
|
||||||
|
|
||||||
|
addDefaults();
|
||||||
|
loadKeys();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void loadKeys() {
|
||||||
|
plugin.getLogger().info("Loading mcMMO treasures.yml File...");
|
||||||
|
|
||||||
|
Map<String, Treasure> treasures = new HashMap<String, Treasure>();
|
||||||
|
ConfigurationSection treasureSection = config.getConfigurationSection("Treasures");
|
||||||
Set<String> treasureConfigSet = treasureSection.getKeys(false);
|
Set<String> treasureConfigSet = treasureSection.getKeys(false);
|
||||||
Iterator<String> iterator = treasureConfigSet.iterator();
|
Iterator<String> iterator = treasureConfigSet.iterator();
|
||||||
while(iterator.hasNext())
|
|
||||||
{
|
|
||||||
String treasureName = iterator.next();
|
|
||||||
|
|
||||||
// Validate all the things!
|
while (iterator.hasNext()) {
|
||||||
List<String> reason = new ArrayList<String>();
|
String treasureName = iterator.next();
|
||||||
|
|
||||||
if(!config.contains("Treasures." + treasureName + ".ID")) reason.add("Missing ID");
|
// Validate all the things!
|
||||||
if(!config.contains("Treasures." + treasureName + ".Amount")) reason.add("Missing Amount");
|
List<String> reason = new ArrayList<String>();
|
||||||
if(!config.contains("Treasures." + treasureName + ".Data")) reason.add("Missing Data");
|
|
||||||
|
|
||||||
int id = config.getInt("Treasures." + treasureName + ".ID");
|
/*
|
||||||
int amount = config.getInt("Treasures." + treasureName + ".Amount");
|
* ID, Amount, and Data
|
||||||
int data = config.getInt("Treasures." + treasureName + ".Data");
|
*/
|
||||||
|
|
||||||
if(Material.getMaterial(id) == null) reason.add("Invlid id: " + id);
|
if (!config.contains("Treasures." + treasureName + ".ID")) {
|
||||||
if(amount < 1) reason.add("Invalid amount: " + amount);
|
reason.add("Missing ID");
|
||||||
if(data > 127 || data < -128) reason.add("Invalid data: " + data);
|
}
|
||||||
|
|
||||||
if(!config.contains("Treasures." + treasureName + ".XP")) reason.add("Missing XP");
|
if (!config.contains("Treasures." + treasureName + ".Amount")) {
|
||||||
if(!config.contains("Treasures." + treasureName + ".Drop_Chance")) reason.add("Missing Drop_Chance");
|
reason.add("Missing Amount");
|
||||||
if(!config.contains("Treasures." + treasureName + ".Drop_Level")) reason.add("Missing Drop_Level");
|
}
|
||||||
|
|
||||||
int xp = config.getInt("Treasures." + treasureName + ".XP");
|
if (!config.contains("Treasures." + treasureName + ".Data")) {
|
||||||
Double dropChance = config.getDouble("Treasures." + treasureName + ".Drop_Chance");
|
reason.add("Missing Data");
|
||||||
int dropLevel = config.getInt("Treasures." + treasureName + ".Drop_Level");
|
}
|
||||||
|
|
||||||
if(xp < 0) reason.add("Invalid xp: " + xp);
|
int id = config.getInt("Treasures." + treasureName + ".ID");
|
||||||
if(dropChance < 0) reason.add("Invalid Drop_Chance: " + dropChance);
|
int amount = config.getInt("Treasures." + treasureName + ".Amount");
|
||||||
if(dropLevel < 0) reason.add("Invalid Drop_Level: " + dropLevel);
|
int data = config.getInt("Treasures." + treasureName + ".Data");
|
||||||
|
|
||||||
ItemStack item = new ItemStack(id, amount, (short) 0, (byte) data);
|
if (Material.getMaterial(id) == null) {
|
||||||
|
reason.add("Invlid id: " + id);
|
||||||
|
}
|
||||||
|
|
||||||
if(readBoolean("Treasures." + treasureName + ".Drops_From.Fishing", false)) {
|
if (amount < 1) {
|
||||||
if(config.getConfigurationSection("Treasures." + treasureName + ".Drops_From").getKeys(false).size() != 1)
|
reason.add("Invalid amount: " + amount);
|
||||||
reason.add("Fishing drops cannot also be excavation drops");
|
}
|
||||||
|
|
||||||
if(!config.contains("Treasures." + treasureName + ".Max_Level")) reason.add("Missing Max_Level");
|
if (data > 127 || data < -128) {
|
||||||
int maxLevel = config.getInt("Treasures." + treasureName + ".Max_Level");
|
reason.add("Invalid data: " + data);
|
||||||
|
}
|
||||||
|
|
||||||
if(maxLevel < 0) reason.add("Invalid Max_Level: " + maxLevel);
|
/*
|
||||||
|
* XP, Drop Chance, and Drop Level
|
||||||
|
*/
|
||||||
|
|
||||||
if(noErrorsInTreasure(reason)) {
|
if (!config.contains("Treasures." + treasureName + ".XP")) {
|
||||||
FishingTreasure fTreasure = new FishingTreasure(item, xp, dropChance, dropLevel, maxLevel);
|
reason.add("Missing XP");
|
||||||
treasures.put(treasureName, fTreasure);
|
}
|
||||||
}
|
|
||||||
} else {
|
|
||||||
ExcavationTreasure eTreasure = new ExcavationTreasure(item, xp, dropChance, dropLevel);
|
|
||||||
if(readBoolean("Treasures." + treasureName + ".Drops_From.Dirt", false))
|
|
||||||
eTreasure.setDropsFromDirt();
|
|
||||||
if(readBoolean("Treasures." + treasureName + ".Drops_From.Grass", false))
|
|
||||||
eTreasure.setDropsFromGrass();
|
|
||||||
if(readBoolean("Treasures." + treasureName + ".Drops_From.Sand", false))
|
|
||||||
eTreasure.setDropsFromSand();
|
|
||||||
if(readBoolean("Treasures." + treasureName + ".Drops_From.Gravel", false))
|
|
||||||
eTreasure.setDropsFromGravel();
|
|
||||||
if(readBoolean("Treasures." + treasureName + ".Drops_From.Clay", false))
|
|
||||||
eTreasure.setDropsFromClay();
|
|
||||||
if(readBoolean("Treasures." + treasureName + ".Drops_From.Mycelium", false))
|
|
||||||
eTreasure.setDropsFromMycel();
|
|
||||||
if(readBoolean("Treasures." + treasureName + ".Drops_From.Soul_Sand", false))
|
|
||||||
eTreasure.setDropsFromSoulSand();
|
|
||||||
|
|
||||||
if(readBoolean("Treasures." + treasureName + ".Drops_From.Fishing", false)) {
|
if (!config.contains("Treasures." + treasureName + ".Drop_Chance")) {
|
||||||
reason.add("Excavation drops cannot also be fishing drops");
|
reason.add("Missing Drop_Chance");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(noErrorsInTreasure(reason)) {
|
if (!config.contains("Treasures." + treasureName + ".Drop_Level")) {
|
||||||
treasures.put(treasureName, eTreasure);
|
reason.add("Missing Drop_Level");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
List<String> excavationTreasures = config.getStringList("Excavation.Treasure");
|
int xp = config.getInt("Treasures." + treasureName + ".XP");
|
||||||
List<String> fishingTreasures = config.getStringList("Fishing.Treasure");
|
Double dropChance = config.getDouble("Treasures." + treasureName + ".Drop_Chance");
|
||||||
|
int dropLevel = config.getInt("Treasures." + treasureName + ".Drop_Level");
|
||||||
|
|
||||||
Iterator<String> treasureIterator = treasures.keySet().iterator();
|
if (xp < 0) {
|
||||||
while(treasureIterator.hasNext()) {
|
reason.add("Invalid xp: " + xp);
|
||||||
String treasureKey = treasureIterator.next();
|
}
|
||||||
Treasure treasure = treasures.get(treasureKey);
|
|
||||||
|
|
||||||
if(treasure instanceof FishingTreasure) {
|
if (dropChance < 0) {
|
||||||
if(!fishingTreasures.contains(treasureKey)) continue;
|
reason.add("Invalid Drop_Chance: " + dropChance);
|
||||||
|
}
|
||||||
FishingTreasure fTreasure = (FishingTreasure) treasure;
|
|
||||||
int dropLevel = fTreasure.getDropLevel();
|
|
||||||
int maxLevel = fTreasure.getMaxLevel();
|
|
||||||
|
|
||||||
if(dropLevel <= LoadProperties.fishingTier1 && maxLevel >= LoadProperties.fishingTier1)
|
|
||||||
fishingRewardsTier1.add(fTreasure);
|
|
||||||
if(dropLevel <= LoadProperties.fishingTier2 && maxLevel >= LoadProperties.fishingTier2)
|
|
||||||
fishingRewardsTier2.add(fTreasure);
|
|
||||||
if(dropLevel <= LoadProperties.fishingTier3 && maxLevel >= LoadProperties.fishingTier3)
|
|
||||||
fishingRewardsTier3.add(fTreasure);
|
|
||||||
if(dropLevel <= LoadProperties.fishingTier4 && maxLevel >= LoadProperties.fishingTier4)
|
|
||||||
fishingRewardsTier4.add(fTreasure);
|
|
||||||
if(dropLevel <= LoadProperties.fishingTier5 && maxLevel >= LoadProperties.fishingTier5)
|
|
||||||
fishingRewardsTier5.add(fTreasure);
|
|
||||||
|
|
||||||
} else if(treasure instanceof ExcavationTreasure) {
|
|
||||||
if(!excavationTreasures.contains(treasureKey)) continue;
|
|
||||||
|
|
||||||
ExcavationTreasure eTreasure = (ExcavationTreasure) treasure;
|
if (dropLevel < 0) {
|
||||||
if(eTreasure.getDropsFromDirt())
|
reason.add("Invalid Drop_Level: " + dropLevel);
|
||||||
excavationFromDirt.add(eTreasure);
|
}
|
||||||
if(eTreasure.getDropsFromGrass())
|
|
||||||
excavationFromGrass.add(eTreasure);
|
|
||||||
if(eTreasure.getDropsFromSand())
|
|
||||||
excavationFromSand.add(eTreasure);
|
|
||||||
if(eTreasure.getDropsFromGravel())
|
|
||||||
excavationFromGravel.add(eTreasure);
|
|
||||||
if(eTreasure.getDropsFromClay())
|
|
||||||
excavationFromClay.add(eTreasure);
|
|
||||||
if(eTreasure.getDropsFromMycel())
|
|
||||||
excavationFromMycel.add(eTreasure);
|
|
||||||
if(eTreasure.getDropsFromSoulSand())
|
|
||||||
excavationFromSoulSand.add(eTreasure);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean noErrorsInTreasure(List<String> issues) {
|
/*
|
||||||
if(issues.isEmpty()) return true;
|
* Drops From & Max Level
|
||||||
|
*/
|
||||||
|
|
||||||
for(String issue : issues) {
|
ItemStack item = new ItemStack(id, amount, (short) 0, (byte) data);
|
||||||
Bukkit.getLogger().warning(issue);
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Fishing", false)) {
|
||||||
}
|
if (config.getConfigurationSection("Treasures." + treasureName + ".Drops_From").getKeys(false).size() != 1) {
|
||||||
|
reason.add("Fishing drops cannot also be excavation drops");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!config.contains("Treasures." + treasureName + ".Max_Level")) {
|
||||||
|
reason.add("Missing Max_Level");
|
||||||
|
}
|
||||||
|
|
||||||
|
int maxLevel = config.getInt("Treasures." + treasureName + ".Max_Level");
|
||||||
|
|
||||||
|
if (maxLevel < 0) {
|
||||||
|
reason.add("Invalid Max_Level: " + maxLevel);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (noErrorsInTreasure(reason)) {
|
||||||
|
FishingTreasure fTreasure = new FishingTreasure(item, xp, dropChance, dropLevel, maxLevel);
|
||||||
|
treasures.put(treasureName, fTreasure);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ExcavationTreasure eTreasure = new ExcavationTreasure(item, xp, dropChance, dropLevel);
|
||||||
|
|
||||||
|
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Dirt", false)) {
|
||||||
|
eTreasure.setDropsFromDirt();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Grass", false)) {
|
||||||
|
eTreasure.setDropsFromGrass();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Sand", false)) {
|
||||||
|
eTreasure.setDropsFromSand();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Gravel", false)) {
|
||||||
|
eTreasure.setDropsFromGravel();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Clay", false)) {
|
||||||
|
eTreasure.setDropsFromClay();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Mycelium", false)) {
|
||||||
|
eTreasure.setDropsFromMycel();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Soul_Sand", false)) {
|
||||||
|
eTreasure.setDropsFromSoulSand();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Fishing", false)) {
|
||||||
|
reason.add("Excavation drops cannot also be fishing drops");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (noErrorsInTreasure(reason)) {
|
||||||
|
treasures.put(treasureName, eTreasure);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
List<String> excavationTreasures = config.getStringList("Excavation.Treasure");
|
||||||
|
List<String> fishingTreasures = config.getStringList("Fishing.Treasure");
|
||||||
|
Iterator<String> treasureIterator = treasures.keySet().iterator();
|
||||||
|
|
||||||
|
while (treasureIterator.hasNext()) {
|
||||||
|
String treasureKey = treasureIterator.next();
|
||||||
|
Treasure treasure = treasures.get(treasureKey);
|
||||||
|
|
||||||
|
if (treasure instanceof FishingTreasure) {
|
||||||
|
if (!fishingTreasures.contains(treasureKey)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
FishingTreasure fTreasure = (FishingTreasure) treasure;
|
||||||
|
int dropLevel = fTreasure.getDropLevel();
|
||||||
|
int maxLevel = fTreasure.getMaxLevel();
|
||||||
|
|
||||||
|
if(dropLevel <= LoadProperties.fishingTier1 && maxLevel >= LoadProperties.fishingTier1) {
|
||||||
|
fishingRewardsTier1.add(fTreasure);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(dropLevel <= LoadProperties.fishingTier2 && maxLevel >= LoadProperties.fishingTier2) {
|
||||||
|
fishingRewardsTier2.add(fTreasure);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dropLevel <= LoadProperties.fishingTier3 && maxLevel >= LoadProperties.fishingTier3) {
|
||||||
|
fishingRewardsTier3.add(fTreasure);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dropLevel <= LoadProperties.fishingTier4 && maxLevel >= LoadProperties.fishingTier4) {
|
||||||
|
fishingRewardsTier4.add(fTreasure);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dropLevel <= LoadProperties.fishingTier5 && maxLevel >= LoadProperties.fishingTier5) {
|
||||||
|
fishingRewardsTier5.add(fTreasure);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else if (treasure instanceof ExcavationTreasure) {
|
||||||
|
if (!excavationTreasures.contains(treasureKey)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
ExcavationTreasure eTreasure = (ExcavationTreasure) treasure;
|
||||||
|
|
||||||
|
if (eTreasure.getDropsFromDirt()) {
|
||||||
|
excavationFromDirt.add(eTreasure);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (eTreasure.getDropsFromGrass()) {
|
||||||
|
excavationFromGrass.add(eTreasure);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (eTreasure.getDropsFromSand()) {
|
||||||
|
excavationFromSand.add(eTreasure);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (eTreasure.getDropsFromGravel()) {
|
||||||
|
excavationFromGravel.add(eTreasure);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (eTreasure.getDropsFromClay()) {
|
||||||
|
excavationFromClay.add(eTreasure);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (eTreasure.getDropsFromMycel()) {
|
||||||
|
excavationFromMycel.add(eTreasure);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (eTreasure.getDropsFromSoulSand()) {
|
||||||
|
excavationFromSoulSand.add(eTreasure);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean noErrorsInTreasure(List<String> issues) {
|
||||||
|
if (issues.isEmpty()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
for (String issue : issues) {
|
||||||
|
Bukkit.getLogger().warning(issue);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,6 @@ import java.io.FileReader;
|
|||||||
import java.io.FileWriter;
|
import java.io.FileWriter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.ArrayDeque;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
@ -36,7 +35,6 @@ import org.bukkit.plugin.Plugin;
|
|||||||
import org.bukkit.plugin.PluginDescriptionFile;
|
import org.bukkit.plugin.PluginDescriptionFile;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import org.bukkit.plugin.PluginManager;
|
import org.bukkit.plugin.PluginManager;
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -53,10 +51,6 @@ public class mcMMO extends JavaPlugin {
|
|||||||
private final mcBlockListener blockListener = new mcBlockListener(this);
|
private final mcBlockListener blockListener = new mcBlockListener(this);
|
||||||
private final mcEntityListener entityListener = new mcEntityListener(this);
|
private final mcEntityListener entityListener = new mcEntityListener(this);
|
||||||
|
|
||||||
//Queue for block data change for R2+ fix
|
|
||||||
public ArrayDeque<Block> changeQueue = new ArrayDeque<Block>();
|
|
||||||
public ArrayDeque<Block> fastChangeQueue = new ArrayDeque<Block>();
|
|
||||||
|
|
||||||
private Runnable mcMMO_Timer = new mcTimer(this); //BLEED AND REGENERATION
|
private Runnable mcMMO_Timer = new mcTimer(this); //BLEED AND REGENERATION
|
||||||
private Runnable mcMMO_SaveTimer = new mcSaveTimer(this); //Periodic saving of Player Data
|
private Runnable mcMMO_SaveTimer = new mcSaveTimer(this); //Periodic saving of Player Data
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user