Moving treasures to their own config file.

BUILD IS BROKEN, DO NOT USE.
This commit is contained in:
GJ 2012-02-28 23:28:14 -05:00
parent 345fa122c5
commit ee986970fe
6 changed files with 427 additions and 165 deletions

View File

@ -91,18 +91,18 @@ public class LoadProperties {
axesxpmodifier, acrobaticsxpmodifier, animalXP, creeperXP, skeletonXP, spiderXP, ghastXP, slimeXP, axesxpmodifier, acrobaticsxpmodifier, animalXP, creeperXP, skeletonXP, spiderXP, ghastXP, slimeXP,
zombieXP, pigzombieXP, endermanXP, cavespiderXP, silverfishXP, blazeXP, magmacubeXP, enderdragonXP; zombieXP, pigzombieXP, endermanXP, cavespiderXP, silverfishXP, blazeXP, magmacubeXP, enderdragonXP;
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>();
public static HUDType defaulthud; public static HUDType defaulthud;
protected static File configFile; protected static File configFile;
@ -181,8 +181,6 @@ public class LoadProperties {
bonesConsumedByCOTW = readInteger("Skills.Taming.Call_Of_The_Wild.Bones_Required", 10); bonesConsumedByCOTW = readInteger("Skills.Taming.Call_Of_The_Wild.Bones_Required", 10);
xpbar = readBoolean("Spout.XP.Bar.Enabled", true); xpbar = readBoolean("Spout.XP.Bar.Enabled", true);
// web_url = readString("Spout.Images.URL_DIR",
// "http://mcmmo.rycochet.net/mcmmo/");
xpicon = readBoolean("Spout.XP.Icon.Enabled", true); xpicon = readBoolean("Spout.XP.Icon.Enabled", true);
xpbar_x = readInteger("Spout.XP.Bar.X_POS", 95); xpbar_x = readInteger("Spout.XP.Bar.X_POS", 95);
xpbar_y = readInteger("Spout.XP.Bar.Y_POS", 6); xpbar_y = readInteger("Spout.XP.Bar.Y_POS", 6);
@ -435,140 +433,140 @@ public class LoadProperties {
magmacubeXP = readDouble("Experience.Combat.Multiplier.Magma_Cube", 2.0); magmacubeXP = readDouble("Experience.Combat.Multiplier.Magma_Cube", 2.0);
enderdragonXP = readDouble("Experience.Combat.Multiplier.Ender_Dragon", 8.0); enderdragonXP = readDouble("Experience.Combat.Multiplier.Ender_Dragon", 8.0);
// Load treasures // // Load treasures
Map<String, Treasure> treasures = new HashMap<String, Treasure>(); // Map<String, Treasure> treasures = new HashMap<String, Treasure>();
//
ConfigurationSection treasureSection = config.getConfigurationSection("Treasures"); // 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()) // while(iterator.hasNext())
{ // {
String treasureName = iterator.next(); // String treasureName = iterator.next();
//
// Validate all the things! // // Validate all the things!
List<String> reason = new ArrayList<String>(); // List<String> reason = new ArrayList<String>();
//
if(!config.contains("Treasures." + treasureName + ".ID")) reason.add("Missing ID"); // if(!config.contains("Treasures." + treasureName + ".ID")) reason.add("Missing ID");
if(!config.contains("Treasures." + treasureName + ".Amount")) reason.add("Missing Amount"); // if(!config.contains("Treasures." + treasureName + ".Amount")) reason.add("Missing Amount");
if(!config.contains("Treasures." + treasureName + ".Data")) reason.add("Missing Data"); // if(!config.contains("Treasures." + treasureName + ".Data")) reason.add("Missing Data");
//
int id = config.getInt("Treasures." + treasureName + ".ID"); // int id = config.getInt("Treasures." + treasureName + ".ID");
int amount = config.getInt("Treasures." + treasureName + ".Amount"); // int amount = config.getInt("Treasures." + treasureName + ".Amount");
int data = config.getInt("Treasures." + treasureName + ".Data"); // int data = config.getInt("Treasures." + treasureName + ".Data");
//
if(Material.getMaterial(id) == null) reason.add("Invlid id: " + id); // if(Material.getMaterial(id) == null) reason.add("Invlid id: " + id);
if(amount < 1) reason.add("Invalid amount: " + amount); // if(amount < 1) reason.add("Invalid amount: " + amount);
if(data > 127 || data < -128) reason.add("Invalid data: " + data); // 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 + ".XP")) reason.add("Missing XP");
if(!config.contains("Treasures." + treasureName + ".Drop_Chance")) reason.add("Missing Drop_Chance"); // if(!config.contains("Treasures." + treasureName + ".Drop_Chance")) reason.add("Missing Drop_Chance");
if(!config.contains("Treasures." + treasureName + ".Drop_Level")) reason.add("Missing Drop_Level"); // if(!config.contains("Treasures." + treasureName + ".Drop_Level")) reason.add("Missing Drop_Level");
//
int xp = config.getInt("Treasures." + treasureName + ".XP"); // int xp = config.getInt("Treasures." + treasureName + ".XP");
Double dropChance = config.getDouble("Treasures." + treasureName + ".Drop_Chance"); // Double dropChance = config.getDouble("Treasures." + treasureName + ".Drop_Chance");
int dropLevel = config.getInt("Treasures." + treasureName + ".Drop_Level"); // int dropLevel = config.getInt("Treasures." + treasureName + ".Drop_Level");
//
if(xp < 0) reason.add("Invalid xp: " + xp); // if(xp < 0) reason.add("Invalid xp: " + xp);
if(dropChance < 0) reason.add("Invalid Drop_Chance: " + dropChance); // if(dropChance < 0) reason.add("Invalid Drop_Chance: " + dropChance);
if(dropLevel < 0) reason.add("Invalid Drop_Level: " + dropLevel); // if(dropLevel < 0) reason.add("Invalid Drop_Level: " + dropLevel);
//
ItemStack item = new ItemStack(id, amount, (byte) 0, (byte) data); // ItemStack item = new ItemStack(id, amount, (byte) 0, (byte) data);
//
if(readBoolean("Treasures." + treasureName + ".Drops_From.Fishing", false)) { // if(readBoolean("Treasures." + treasureName + ".Drops_From.Fishing", false)) {
if(config.getConfigurationSection("Treasures." + treasureName + ".Drops_From").getKeys(false).size() != 1) // if(config.getConfigurationSection("Treasures." + treasureName + ".Drops_From").getKeys(false).size() != 1)
reason.add("Fishing drops cannot also be excavation drops"); // reason.add("Fishing drops cannot also be excavation drops");
//
if(!config.contains("Treasures." + treasureName + ".Max_Level")) reason.add("Missing Max_Level"); // if(!config.contains("Treasures." + treasureName + ".Max_Level")) reason.add("Missing Max_Level");
int maxLevel = config.getInt("Treasures." + treasureName + ".Max_Level"); // int maxLevel = config.getInt("Treasures." + treasureName + ".Max_Level");
//
if(maxLevel < 0) reason.add("Invalid Max_Level: " + maxLevel); // if(maxLevel < 0) reason.add("Invalid Max_Level: " + maxLevel);
//
if(noErrorsInTreasure(reason)) { // if(noErrorsInTreasure(reason)) {
FishingTreasure fTreasure = new FishingTreasure(item, xp, dropChance, dropLevel, maxLevel); // FishingTreasure fTreasure = new FishingTreasure(item, xp, dropChance, dropLevel, maxLevel);
treasures.put(treasureName, fTreasure); // treasures.put(treasureName, fTreasure);
} // }
} else { // } else {
ExcavationTreasure eTreasure = new ExcavationTreasure(item, xp, dropChance, dropLevel); // ExcavationTreasure eTreasure = new ExcavationTreasure(item, xp, dropChance, dropLevel);
if(readBoolean("Treasures." + treasureName + ".Drops_From.Dirt", false)) // if(readBoolean("Treasures." + treasureName + ".Drops_From.Dirt", false))
eTreasure.setDropsFromDirt(); // eTreasure.setDropsFromDirt();
if(readBoolean("Treasures." + treasureName + ".Drops_From.Grass", false)) // if(readBoolean("Treasures." + treasureName + ".Drops_From.Grass", false))
eTreasure.setDropsFromGrass(); // eTreasure.setDropsFromGrass();
if(readBoolean("Treasures." + treasureName + ".Drops_From.Sand", false)) // if(readBoolean("Treasures." + treasureName + ".Drops_From.Sand", false))
eTreasure.setDropsFromSand(); // eTreasure.setDropsFromSand();
if(readBoolean("Treasures." + treasureName + ".Drops_From.Gravel", false)) // if(readBoolean("Treasures." + treasureName + ".Drops_From.Gravel", false))
eTreasure.setDropsFromGravel(); // eTreasure.setDropsFromGravel();
if(readBoolean("Treasures." + treasureName + ".Drops_From.Clay", false)) // if(readBoolean("Treasures." + treasureName + ".Drops_From.Clay", false))
eTreasure.setDropsFromClay(); // eTreasure.setDropsFromClay();
if(readBoolean("Treasures." + treasureName + ".Drops_From.Mycelium", false)) // if(readBoolean("Treasures." + treasureName + ".Drops_From.Mycelium", false))
eTreasure.setDropsFromMycel(); // eTreasure.setDropsFromMycel();
if(readBoolean("Treasures." + treasureName + ".Drops_From.Soul_Sand", false)) // if(readBoolean("Treasures." + treasureName + ".Drops_From.Soul_Sand", false))
eTreasure.setDropsFromSoulSand(); // eTreasure.setDropsFromSoulSand();
//
if(readBoolean("Treasures." + treasureName + ".Drops_From.Fishing", false)) { // if(readBoolean("Treasures." + treasureName + ".Drops_From.Fishing", false)) {
reason.add("Excavation drops cannot also be fishing drops"); // reason.add("Excavation drops cannot also be fishing drops");
} // }
//
if(noErrorsInTreasure(reason)) { // if(noErrorsInTreasure(reason)) {
treasures.put(treasureName, eTreasure); // treasures.put(treasureName, eTreasure);
} // }
} // }
} }
//
List<String> excavationTreasures = config.getStringList("Excavation.Treasure"); // List<String> excavationTreasures = config.getStringList("Excavation.Treasure");
List<String> fishingTreasures = config.getStringList("Fishing.Treasure"); // List<String> fishingTreasures = config.getStringList("Fishing.Treasure");
//
Iterator<String> treasureIterator = treasures.keySet().iterator(); // Iterator<String> treasureIterator = treasures.keySet().iterator();
while(treasureIterator.hasNext()) { // while(treasureIterator.hasNext()) {
String treasureKey = treasureIterator.next(); // String treasureKey = treasureIterator.next();
Treasure treasure = treasures.get(treasureKey); // Treasure treasure = treasures.get(treasureKey);
//
if(treasure instanceof FishingTreasure) { // if(treasure instanceof FishingTreasure) {
if(!fishingTreasures.contains(treasureKey)) continue; // if(!fishingTreasures.contains(treasureKey)) continue;
//
FishingTreasure fTreasure = (FishingTreasure) treasure; // FishingTreasure fTreasure = (FishingTreasure) treasure;
int dropLevel = fTreasure.getDropLevel(); // int dropLevel = fTreasure.getDropLevel();
int maxLevel = fTreasure.getMaxLevel(); // int maxLevel = fTreasure.getMaxLevel();
//
if(dropLevel <= fishingTier1 && maxLevel >= fishingTier1) // if(dropLevel <= fishingTier1 && maxLevel >= fishingTier1)
fishingRewardsTier1.add(fTreasure); // fishingRewardsTier1.add(fTreasure);
if(dropLevel <= fishingTier2 && maxLevel >= fishingTier2) // if(dropLevel <= fishingTier2 && maxLevel >= fishingTier2)
fishingRewardsTier2.add(fTreasure); // fishingRewardsTier2.add(fTreasure);
if(dropLevel <= fishingTier3 && maxLevel >= fishingTier3) // if(dropLevel <= fishingTier3 && maxLevel >= fishingTier3)
fishingRewardsTier3.add(fTreasure); // fishingRewardsTier3.add(fTreasure);
if(dropLevel <= fishingTier4 && maxLevel >= fishingTier4) // if(dropLevel <= fishingTier4 && maxLevel >= fishingTier4)
fishingRewardsTier4.add(fTreasure); // fishingRewardsTier4.add(fTreasure);
if(dropLevel <= fishingTier5 && maxLevel >= fishingTier5) // if(dropLevel <= fishingTier5 && maxLevel >= fishingTier5)
fishingRewardsTier5.add(fTreasure); // fishingRewardsTier5.add(fTreasure);
//
} else if(treasure instanceof ExcavationTreasure) { // } else if(treasure instanceof ExcavationTreasure) {
if(!excavationTreasures.contains(treasureKey)) continue; // if(!excavationTreasures.contains(treasureKey)) continue;
//
ExcavationTreasure eTreasure = (ExcavationTreasure) treasure; // ExcavationTreasure eTreasure = (ExcavationTreasure) treasure;
if(eTreasure.getDropsFromDirt()) // if(eTreasure.getDropsFromDirt())
excavationFromDirt.add(eTreasure); // excavationFromDirt.add(eTreasure);
if(eTreasure.getDropsFromGrass()) // if(eTreasure.getDropsFromGrass())
excavationFromGrass.add(eTreasure); // excavationFromGrass.add(eTreasure);
if(eTreasure.getDropsFromSand()) // if(eTreasure.getDropsFromSand())
excavationFromSand.add(eTreasure); // excavationFromSand.add(eTreasure);
if(eTreasure.getDropsFromGravel()) // if(eTreasure.getDropsFromGravel())
excavationFromGravel.add(eTreasure); // excavationFromGravel.add(eTreasure);
if(eTreasure.getDropsFromClay()) // if(eTreasure.getDropsFromClay())
excavationFromClay.add(eTreasure); // excavationFromClay.add(eTreasure);
if(eTreasure.getDropsFromMycel()) // if(eTreasure.getDropsFromMycel())
excavationFromMycel.add(eTreasure); // excavationFromMycel.add(eTreasure);
if(eTreasure.getDropsFromSoulSand()) // if(eTreasure.getDropsFromSoulSand())
excavationFromSoulSand.add(eTreasure); // excavationFromSoulSand.add(eTreasure);
} // }
} // }
} // }
//
private boolean noErrorsInTreasure(List<String> issues) { // private boolean noErrorsInTreasure(List<String> issues) {
if(issues.isEmpty()) return true; // if(issues.isEmpty()) return true;
//
for(String issue : issues) { // for(String issue : issues) {
plugin.getLogger().warning(issue); // plugin.getLogger().warning(issue);
} // }
//
return false; // return false;
} // }
} }

View File

@ -0,0 +1,219 @@
package com.gmail.nossr50.config;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure;
import com.gmail.nossr50.datatypes.treasure.FishingTreasure;
import com.gmail.nossr50.datatypes.treasure.Treasure;
public class LoadTreasures {
public static List<ExcavationTreasure> excavationFromDirt = new ArrayList<ExcavationTreasure>();
public static List<ExcavationTreasure> excavationFromGrass = new ArrayList<ExcavationTreasure>();
public static List<ExcavationTreasure> excavationFromSand = new ArrayList<ExcavationTreasure>();
public static List<ExcavationTreasure> excavationFromGravel = new ArrayList<ExcavationTreasure>();
public static List<ExcavationTreasure> excavationFromClay = new ArrayList<ExcavationTreasure>();
public static List<ExcavationTreasure> excavationFromMycel = new ArrayList<ExcavationTreasure>();
public static List<ExcavationTreasure> excavationFromSoulSand = new ArrayList<ExcavationTreasure>();
public static List<FishingTreasure> fishingRewardsTier1 = new ArrayList<FishingTreasure>();
public static List<FishingTreasure> fishingRewardsTier2 = new ArrayList<FishingTreasure>();
public static List<FishingTreasure> fishingRewardsTier3 = new ArrayList<FishingTreasure>();
public static List<FishingTreasure> fishingRewardsTier4 = 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) {
this.plugin = plugin;
dataFolder = plugin.getDataFolder();
configFile = new File(dataFolder, File.separator + "treasures.yml");
config = plugin.getCustomConfig();
}
public void load() {
// If not exist, copy from the jar
if (!configFile.exists()) {
dataFolder.mkdir();
plugin.saveCustomConfig();
}
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 Config File...");
// Load treasures
Map<String, Treasure> treasures = new HashMap<String, Treasure>();
ConfigurationSection treasureSection = config.getConfigurationSection("Treasures");
Set<String> treasureConfigSet = treasureSection.getKeys(true);
Iterator<String> iterator = treasureConfigSet.iterator();
while(iterator.hasNext())
{
String treasureName = iterator.next();
// Validate all the things!
List<String> reason = new ArrayList<String>();
if(!config.contains("Treasures." + treasureName + ".ID")) reason.add("Missing ID");
if(!config.contains("Treasures." + treasureName + ".Amount")) reason.add("Missing Amount");
if(!config.contains("Treasures." + treasureName + ".Data")) reason.add("Missing Data");
int id = config.getInt("Treasures." + treasureName + ".ID");
int amount = config.getInt("Treasures." + treasureName + ".Amount");
int data = config.getInt("Treasures." + treasureName + ".Data");
if(Material.getMaterial(id) == null) reason.add("Invlid id: " + id);
if(amount < 1) reason.add("Invalid amount: " + amount);
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 + ".Drop_Chance")) reason.add("Missing Drop_Chance");
if(!config.contains("Treasures." + treasureName + ".Drop_Level")) reason.add("Missing Drop_Level");
int xp = config.getInt("Treasures." + treasureName + ".XP");
Double dropChance = config.getDouble("Treasures." + treasureName + ".Drop_Chance");
int dropLevel = config.getInt("Treasures." + treasureName + ".Drop_Level");
if(xp < 0) reason.add("Invalid xp: " + xp);
if(dropChance < 0) reason.add("Invalid Drop_Chance: " + dropChance);
if(dropLevel < 0) reason.add("Invalid Drop_Level: " + dropLevel);
ItemStack item = new ItemStack(id, amount, (byte) 0, (byte) data);
if(readBoolean("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(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)) {
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;
for(String issue : issues) {
plugin.getLogger().warning(issue);
}
return false;
}
}

View File

@ -25,7 +25,6 @@ import java.util.ArrayList;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -36,8 +35,6 @@ import com.gmail.nossr50.Users;
import com.gmail.nossr50.m; import com.gmail.nossr50.m;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
public class PlayerProfile public class PlayerProfile
{ {
protected final Logger log = Logger.getLogger("Minecraft"); protected final Logger log = Logger.getLogger("Minecraft");

View File

@ -45,6 +45,7 @@ import java.io.FileNotFoundException;
import java.io.FileReader; 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.util.ArrayDeque; import java.util.ArrayDeque;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
@ -56,6 +57,8 @@ 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.block.Block;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.getspout.spoutapi.SpoutManager; import org.getspout.spoutapi.SpoutManager;
import org.getspout.spoutapi.player.FileManager; import org.getspout.spoutapi.player.FileManager;
@ -81,7 +84,6 @@ public class mcMMO extends JavaPlugin
private Runnable mcMMO_SaveTimer = new mcSaveTimer(this); //Periodic saving of Player Data private Runnable mcMMO_SaveTimer = new mcSaveTimer(this); //Periodic saving of Player Data
private Runnable ChangeDataValueTimer = new ChangeDataValueTimer(changeQueue); //R2 block place workaround private Runnable ChangeDataValueTimer = new ChangeDataValueTimer(changeQueue); //R2 block place workaround
private Runnable FastChangeDataValueTimer = new ChangeDataValueTimer(fastChangeQueue); private Runnable FastChangeDataValueTimer = new ChangeDataValueTimer(fastChangeQueue);
//private Timer mcMMO_SpellTimer = new Timer(true);
//Alias - Command //Alias - Command
public HashMap<String, String> aliasMap = new HashMap<String, String>(); public HashMap<String, String> aliasMap = new HashMap<String, String>();
@ -91,6 +93,8 @@ public class mcMMO extends JavaPlugin
//Config file stuff //Config file stuff
LoadProperties config; LoadProperties config;
LoadTreasures config2;
//Jar stuff //Jar stuff
public static File mcmmo; public static File mcmmo;
@ -119,6 +123,9 @@ public class mcMMO extends JavaPlugin
this.config = new LoadProperties(this); this.config = new LoadProperties(this);
this.config.load(); this.config.load();
this.config2 = new LoadTreasures(this);
this.config2.load();
Party.getInstance().loadParties(); Party.getInstance().loadParties();
new Party(this); new Party(this);
@ -380,4 +387,43 @@ public class mcMMO extends JavaPlugin
return new String(buffer); return new String(buffer);
} }
/*
* Boilerplate Custom Config Stuff
*/
private FileConfiguration customConfig = null;
private File customConfigFile = null;
public void reloadCustomConfig() {
if (customConfigFile == null) {
customConfigFile = new File(getDataFolder(), "customConfig.yml");
}
customConfig = YamlConfiguration.loadConfiguration(customConfigFile);
// Look for defaults in the jar
InputStream defConfigStream = getResource("customConfig.yml");
if (defConfigStream != null) {
YamlConfiguration defConfig = YamlConfiguration.loadConfiguration(defConfigStream);
customConfig.setDefaults(defConfig);
}
}
public FileConfiguration getCustomConfig() {
if (customConfig == null) {
reloadCustomConfig();
}
return customConfig;
}
public void saveCustomConfig() {
if (customConfig == null || customConfigFile == null) {
return;
}
try {
customConfig.save(customConfigFile);
} catch (IOException ex) {
Logger.getLogger(JavaPlugin.class.getName()).log(Level.SEVERE, "Could not save config to " + customConfigFile, ex);
}
}
} }

View File

@ -31,6 +31,7 @@ import com.gmail.nossr50.spout.SpoutStuff;
import com.gmail.nossr50.Users; import com.gmail.nossr50.Users;
import com.gmail.nossr50.m; import com.gmail.nossr50.m;
import com.gmail.nossr50.config.LoadProperties; import com.gmail.nossr50.config.LoadProperties;
import com.gmail.nossr50.config.LoadTreasures;
import com.gmail.nossr50.datatypes.PlayerProfile; import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType; import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure; import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure;
@ -67,7 +68,7 @@ public class Excavation
switch(type) switch(type)
{ {
case DIRT: case DIRT:
for(ExcavationTreasure treasure : LoadProperties.excavationFromDirt) for(ExcavationTreasure treasure : LoadTreasures.excavationFromDirt)
{ {
if(skillLevel >= treasure.getDropLevel()) if(skillLevel >= treasure.getDropLevel())
{ {
@ -80,7 +81,7 @@ public class Excavation
} }
break; break;
case GRASS: case GRASS:
for(ExcavationTreasure treasure : LoadProperties.excavationFromGrass) for(ExcavationTreasure treasure : LoadTreasures.excavationFromGrass)
{ {
if(skillLevel >= treasure.getDropLevel()) if(skillLevel >= treasure.getDropLevel())
{ {
@ -93,7 +94,7 @@ public class Excavation
} }
break; break;
case SAND: case SAND:
for(ExcavationTreasure treasure : LoadProperties.excavationFromSand) for(ExcavationTreasure treasure : LoadTreasures.excavationFromSand)
{ {
if(skillLevel >= treasure.getDropLevel()) if(skillLevel >= treasure.getDropLevel())
{ {
@ -106,7 +107,7 @@ public class Excavation
} }
break; break;
case GRAVEL: case GRAVEL:
for(ExcavationTreasure treasure : LoadProperties.excavationFromGravel) for(ExcavationTreasure treasure : LoadTreasures.excavationFromGravel)
{ {
if(skillLevel >= treasure.getDropLevel()) if(skillLevel >= treasure.getDropLevel())
{ {
@ -119,7 +120,7 @@ public class Excavation
} }
break; break;
case CLAY: case CLAY:
for(ExcavationTreasure treasure : LoadProperties.excavationFromClay) for(ExcavationTreasure treasure : LoadTreasures.excavationFromClay)
{ {
if(skillLevel >= treasure.getDropLevel()) if(skillLevel >= treasure.getDropLevel())
{ {
@ -132,7 +133,7 @@ public class Excavation
} }
break; break;
case MYCEL: case MYCEL:
for(ExcavationTreasure treasure : LoadProperties.excavationFromMycel) for(ExcavationTreasure treasure : LoadTreasures.excavationFromMycel)
{ {
if(skillLevel >= treasure.getDropLevel()) if(skillLevel >= treasure.getDropLevel())
{ {
@ -145,7 +146,7 @@ public class Excavation
} }
break; break;
case SOUL_SAND: case SOUL_SAND:
for(ExcavationTreasure treasure : LoadProperties.excavationFromSoulSand) for(ExcavationTreasure treasure : LoadTreasures.excavationFromSoulSand)
{ {
if(skillLevel >= treasure.getDropLevel()) if(skillLevel >= treasure.getDropLevel())
{ {

View File

@ -30,6 +30,7 @@ import com.gmail.nossr50.Combat;
import com.gmail.nossr50.Users; import com.gmail.nossr50.Users;
import com.gmail.nossr50.m; import com.gmail.nossr50.m;
import com.gmail.nossr50.config.LoadProperties; import com.gmail.nossr50.config.LoadProperties;
import com.gmail.nossr50.config.LoadTreasures;
import com.gmail.nossr50.datatypes.PlayerProfile; import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType; import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.datatypes.treasure.FishingTreasure; import com.gmail.nossr50.datatypes.treasure.FishingTreasure;
@ -94,7 +95,7 @@ public class Fishing {
Item theCatch = (Item)event.getCaught(); Item theCatch = (Item)event.getCaught();
if(LoadProperties.fishingDrops) if(LoadProperties.fishingDrops)
{ {
List<FishingTreasure> rewards = LoadProperties.fishingRewardsTier1; List<FishingTreasure> rewards = LoadTreasures.fishingRewardsTier1;
FishingTreasure treasure = rewards.get((int)(Math.random() * rewards.size())); FishingTreasure treasure = rewards.get((int)(Math.random() * rewards.size()));
if(Math.random() * 100 > (100.00 - treasure.getDropChance())) if(Math.random() * 100 > (100.00 - treasure.getDropChance()))
@ -116,7 +117,7 @@ public class Fishing {
Item theCatch = (Item)event.getCaught(); Item theCatch = (Item)event.getCaught();
if(LoadProperties.fishingDrops) if(LoadProperties.fishingDrops)
{ {
List<FishingTreasure> rewards = LoadProperties.fishingRewardsTier2; List<FishingTreasure> rewards = LoadTreasures.fishingRewardsTier2;
FishingTreasure treasure = rewards.get((int)(Math.random() * rewards.size())); FishingTreasure treasure = rewards.get((int)(Math.random() * rewards.size()));
if(Math.random() * 100 > (100.00 - treasure.getDropChance())) if(Math.random() * 100 > (100.00 - treasure.getDropChance()))
@ -138,7 +139,7 @@ public class Fishing {
Item theCatch = (Item)event.getCaught(); Item theCatch = (Item)event.getCaught();
if(LoadProperties.fishingDrops) if(LoadProperties.fishingDrops)
{ {
List<FishingTreasure> rewards = LoadProperties.fishingRewardsTier3; List<FishingTreasure> rewards = LoadTreasures.fishingRewardsTier3;
FishingTreasure treasure = rewards.get((int)(Math.random() * rewards.size())); FishingTreasure treasure = rewards.get((int)(Math.random() * rewards.size()));
if(Math.random() * 100 > (100.00 - treasure.getDropChance())) if(Math.random() * 100 > (100.00 - treasure.getDropChance()))
@ -160,7 +161,7 @@ public class Fishing {
Item theCatch = (Item)event.getCaught(); Item theCatch = (Item)event.getCaught();
if(LoadProperties.fishingDrops) if(LoadProperties.fishingDrops)
{ {
List<FishingTreasure> rewards = LoadProperties.fishingRewardsTier4; List<FishingTreasure> rewards = LoadTreasures.fishingRewardsTier4;
FishingTreasure treasure = rewards.get((int)(Math.random() * rewards.size())); FishingTreasure treasure = rewards.get((int)(Math.random() * rewards.size()));
if(Math.random() * 100 > (100.00 - treasure.getDropChance())) if(Math.random() * 100 > (100.00 - treasure.getDropChance()))
@ -182,7 +183,7 @@ public class Fishing {
Item theCatch = (Item)event.getCaught(); Item theCatch = (Item)event.getCaught();
if(LoadProperties.fishingDrops) if(LoadProperties.fishingDrops)
{ {
List<FishingTreasure> rewards = LoadProperties.fishingRewardsTier5; List<FishingTreasure> rewards = LoadTreasures.fishingRewardsTier5;
FishingTreasure treasure = rewards.get((int)(Math.random() * rewards.size())); FishingTreasure treasure = rewards.get((int)(Math.random() * rewards.size()));
if(Math.random() * 100 > (100.00 - treasure.getDropChance())) if(Math.random() * 100 > (100.00 - treasure.getDropChance()))