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,
zombieXP, pigzombieXP, endermanXP, cavespiderXP, silverfishXP, blazeXP, magmacubeXP, enderdragonXP;
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>();
// 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>();
public static HUDType defaulthud;
protected static File configFile;
@ -181,8 +181,6 @@ public class LoadProperties {
bonesConsumedByCOTW = readInteger("Skills.Taming.Call_Of_The_Wild.Bones_Required", 10);
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);
xpbar_x = readInteger("Spout.XP.Bar.X_POS", 95);
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);
enderdragonXP = readDouble("Experience.Combat.Multiplier.Ender_Dragon", 8.0);
// Load treasures
Map<String, Treasure> treasures = new HashMap<String, Treasure>();
ConfigurationSection treasureSection = config.getConfigurationSection("Treasures");
Set<String> treasureConfigSet = treasureSection.getKeys(false);
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);
}
}
// // Load treasures
// Map<String, Treasure> treasures = new HashMap<String, Treasure>();
//
// ConfigurationSection treasureSection = config.getConfigurationSection("Treasures");
// Set<String> treasureConfigSet = treasureSection.getKeys(false);
// 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 <= fishingTier1 && maxLevel >= fishingTier1)
fishingRewardsTier1.add(fTreasure);
if(dropLevel <= fishingTier2 && maxLevel >= fishingTier2)
fishingRewardsTier2.add(fTreasure);
if(dropLevel <= fishingTier3 && maxLevel >= fishingTier3)
fishingRewardsTier3.add(fTreasure);
if(dropLevel <= fishingTier4 && maxLevel >= fishingTier4)
fishingRewardsTier4.add(fTreasure);
if(dropLevel <= fishingTier5 && maxLevel >= 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;
}
//
// 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 <= fishingTier1 && maxLevel >= fishingTier1)
// fishingRewardsTier1.add(fTreasure);
// if(dropLevel <= fishingTier2 && maxLevel >= fishingTier2)
// fishingRewardsTier2.add(fTreasure);
// if(dropLevel <= fishingTier3 && maxLevel >= fishingTier3)
// fishingRewardsTier3.add(fTreasure);
// if(dropLevel <= fishingTier4 && maxLevel >= fishingTier4)
// fishingRewardsTier4.add(fTreasure);
// if(dropLevel <= fishingTier5 && maxLevel >= 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

@ -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.Logger;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.entity.Player;
@ -36,8 +35,6 @@ import com.gmail.nossr50.Users;
import com.gmail.nossr50.m;
import com.gmail.nossr50.mcMMO;
public class PlayerProfile
{
protected final Logger log = Logger.getLogger("Minecraft");

View File

@ -45,6 +45,7 @@ import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.HashMap;
@ -56,6 +57,8 @@ import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.plugin.PluginManager;
import org.bukkit.block.Block;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.getspout.spoutapi.SpoutManager;
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 ChangeDataValueTimer = new ChangeDataValueTimer(changeQueue); //R2 block place workaround
private Runnable FastChangeDataValueTimer = new ChangeDataValueTimer(fastChangeQueue);
//private Timer mcMMO_SpellTimer = new Timer(true);
//Alias - Command
public HashMap<String, String> aliasMap = new HashMap<String, String>();
@ -91,6 +93,8 @@ public class mcMMO extends JavaPlugin
//Config file stuff
LoadProperties config;
LoadTreasures config2;
//Jar stuff
public static File mcmmo;
@ -119,6 +123,9 @@ public class mcMMO extends JavaPlugin
this.config = new LoadProperties(this);
this.config.load();
this.config2 = new LoadTreasures(this);
this.config2.load();
Party.getInstance().loadParties();
new Party(this);
@ -380,4 +387,43 @@ public class mcMMO extends JavaPlugin
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.m;
import com.gmail.nossr50.config.LoadProperties;
import com.gmail.nossr50.config.LoadTreasures;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure;
@ -67,7 +68,7 @@ public class Excavation
switch(type)
{
case DIRT:
for(ExcavationTreasure treasure : LoadProperties.excavationFromDirt)
for(ExcavationTreasure treasure : LoadTreasures.excavationFromDirt)
{
if(skillLevel >= treasure.getDropLevel())
{
@ -80,7 +81,7 @@ public class Excavation
}
break;
case GRASS:
for(ExcavationTreasure treasure : LoadProperties.excavationFromGrass)
for(ExcavationTreasure treasure : LoadTreasures.excavationFromGrass)
{
if(skillLevel >= treasure.getDropLevel())
{
@ -93,7 +94,7 @@ public class Excavation
}
break;
case SAND:
for(ExcavationTreasure treasure : LoadProperties.excavationFromSand)
for(ExcavationTreasure treasure : LoadTreasures.excavationFromSand)
{
if(skillLevel >= treasure.getDropLevel())
{
@ -106,7 +107,7 @@ public class Excavation
}
break;
case GRAVEL:
for(ExcavationTreasure treasure : LoadProperties.excavationFromGravel)
for(ExcavationTreasure treasure : LoadTreasures.excavationFromGravel)
{
if(skillLevel >= treasure.getDropLevel())
{
@ -119,7 +120,7 @@ public class Excavation
}
break;
case CLAY:
for(ExcavationTreasure treasure : LoadProperties.excavationFromClay)
for(ExcavationTreasure treasure : LoadTreasures.excavationFromClay)
{
if(skillLevel >= treasure.getDropLevel())
{
@ -132,7 +133,7 @@ public class Excavation
}
break;
case MYCEL:
for(ExcavationTreasure treasure : LoadProperties.excavationFromMycel)
for(ExcavationTreasure treasure : LoadTreasures.excavationFromMycel)
{
if(skillLevel >= treasure.getDropLevel())
{
@ -145,7 +146,7 @@ public class Excavation
}
break;
case SOUL_SAND:
for(ExcavationTreasure treasure : LoadProperties.excavationFromSoulSand)
for(ExcavationTreasure treasure : LoadTreasures.excavationFromSoulSand)
{
if(skillLevel >= treasure.getDropLevel())
{

View File

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