Fixed Config NPE, made LoadTreasures singleton for consistency

This commit is contained in:
bm01 2012-04-28 09:26:33 +02:00
parent 357eded2c3
commit 7d17bd7dd1
5 changed files with 40 additions and 40 deletions

View File

@ -324,15 +324,15 @@ public class Config extends ConfigLoader {
public HUDType defaulthud;
public Config(mcMMO plugin) {
private Config(mcMMO plugin) {
super(plugin, "config.yml");
config = plugin.getConfig();
xpGainMultiplier = getExperienceGainsGlobalMultiplier();
load();
}
@Override
public void load() {
protected void load() {
// If it doesn't exist, copy it from the .jar
if (!configFile.exists()) {
dataFolder.mkdir();

View File

@ -17,27 +17,37 @@ import com.gmail.nossr50.datatypes.treasure.FishingTreasure;
import com.gmail.nossr50.datatypes.treasure.Treasure;
public class LoadTreasures extends ConfigLoader{
private static LoadTreasures instance;
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 LoadTreasures getInstance() {
if (instance == null) {
instance = new LoadTreasures(mcMMO.p);
}
public LoadTreasures(mcMMO plugin) {
return instance;
}
public List<ExcavationTreasure> excavationFromDirt = new ArrayList<ExcavationTreasure>();
public List<ExcavationTreasure> excavationFromGrass = new ArrayList<ExcavationTreasure>();
public List<ExcavationTreasure> excavationFromSand = new ArrayList<ExcavationTreasure>();
public List<ExcavationTreasure> excavationFromGravel = new ArrayList<ExcavationTreasure>();
public List<ExcavationTreasure> excavationFromClay = new ArrayList<ExcavationTreasure>();
public List<ExcavationTreasure> excavationFromMycel = new ArrayList<ExcavationTreasure>();
public List<ExcavationTreasure> excavationFromSoulSand = new ArrayList<ExcavationTreasure>();
public List<FishingTreasure> fishingRewardsTier1 = new ArrayList<FishingTreasure>();
public List<FishingTreasure> fishingRewardsTier2 = new ArrayList<FishingTreasure>();
public List<FishingTreasure> fishingRewardsTier3 = new ArrayList<FishingTreasure>();
public List<FishingTreasure> fishingRewardsTier4 = new ArrayList<FishingTreasure>();
public List<FishingTreasure> fishingRewardsTier5 = new ArrayList<FishingTreasure>();
private LoadTreasures(mcMMO plugin) {
super(plugin, "treasures.yml");
config = plugin.getTreasuresConfig();
load();
}
@Override
public void load() {
protected void load() {
// If it doesn't exist, copy it from the .jar
if (!configFile.exists()) {

View File

@ -46,10 +46,6 @@ public class mcMMO extends JavaPlugin {
public static Database database;
public static mcMMO p;
//Config file stuff
Config config;
LoadTreasures config2;
//Jar stuff
public static File mcmmo;
@ -71,12 +67,6 @@ public class mcMMO extends JavaPlugin {
leaderboardDirectory = flatFileDirectory + "Leaderboards" + File.separator;
usersFile = flatFileDirectory + "mcmmo.users";
this.config = new Config(this);
this.config.load();
this.config2 = new LoadTreasures(this);
this.config2.load();
if (!Config.getInstance().getUseMySQL()) {
Users.loadUsers();
}

View File

@ -71,31 +71,31 @@ public class Excavation {
if (Permissions.getInstance().excavationTreasures(player)) {
switch (type) {
case DIRT:
treasures = LoadTreasures.excavationFromDirt;
treasures = LoadTreasures.getInstance().excavationFromDirt;
break;
case GRASS:
treasures = LoadTreasures.excavationFromGrass;
treasures = LoadTreasures.getInstance().excavationFromGrass;
break;
case SAND:
treasures = LoadTreasures.excavationFromSand;
treasures = LoadTreasures.getInstance().excavationFromSand;
break;
case GRAVEL:
treasures = LoadTreasures.excavationFromGravel;
treasures = LoadTreasures.getInstance().excavationFromGravel;
break;
case CLAY:
treasures = LoadTreasures.excavationFromClay;
treasures = LoadTreasures.getInstance().excavationFromClay;
break;
case MYCEL:
treasures = LoadTreasures.excavationFromMycel;
treasures = LoadTreasures.getInstance().excavationFromMycel;
break;
case SOUL_SAND:
treasures = LoadTreasures.excavationFromSoulSand;
treasures = LoadTreasures.getInstance().excavationFromSoulSand;
break;
default:

View File

@ -74,23 +74,23 @@ public class Fishing {
switch (getFishingLootTier(PP)) {
case 1:
rewards = LoadTreasures.fishingRewardsTier1;
rewards = LoadTreasures.getInstance().fishingRewardsTier1;
break;
case 2:
rewards = LoadTreasures.fishingRewardsTier2;
rewards = LoadTreasures.getInstance().fishingRewardsTier2;
break;
case 3:
rewards = LoadTreasures.fishingRewardsTier3;
rewards = LoadTreasures.getInstance().fishingRewardsTier3;
break;
case 4:
rewards = LoadTreasures.fishingRewardsTier4;
rewards = LoadTreasures.getInstance().fishingRewardsTier4;
break;
case 5:
rewards = LoadTreasures.fishingRewardsTier5;
rewards = LoadTreasures.getInstance().fishingRewardsTier5;
break;
default: