2011-06-09 22:54:01 +02:00
|
|
|
package com.Acrobot.ChestShop.Config;
|
2011-05-15 18:16:25 +02:00
|
|
|
|
2012-05-10 16:32:25 +02:00
|
|
|
import com.Acrobot.ChestShop.ChestShop;
|
|
|
|
import com.Acrobot.ChestShop.Utils.uName;
|
2011-10-11 13:15:53 +02:00
|
|
|
import com.nijikokun.register.payment.forChestShop.Methods;
|
2012-06-08 15:28:36 +02:00
|
|
|
import org.bukkit.ChatColor;
|
2011-05-15 18:16:25 +02:00
|
|
|
|
2012-05-10 16:32:25 +02:00
|
|
|
import java.io.File;
|
|
|
|
|
2011-05-15 18:16:25 +02:00
|
|
|
/**
|
|
|
|
* @author Acrobot
|
|
|
|
*/
|
|
|
|
public class Config {
|
2012-06-08 15:28:36 +02:00
|
|
|
private static BreezeConfiguration normalConfig;
|
|
|
|
private static BreezeConfiguration languageConfig;
|
2012-05-10 16:32:25 +02:00
|
|
|
|
|
|
|
public static void setup() {
|
|
|
|
File configFolder = ChestShop.getFolder();
|
|
|
|
|
|
|
|
normalConfig = BreezeConfiguration.loadConfiguration(new File(configFolder, "config.yml"), Property.getValues());
|
|
|
|
languageConfig = BreezeConfiguration.loadConfiguration(new File(configFolder, "local.yml"), Language.getValues());
|
|
|
|
|
|
|
|
uName.config = BreezeConfiguration.loadConfiguration(new File(configFolder, "longName.storage"));
|
2011-05-15 18:16:25 +02:00
|
|
|
|
2011-09-22 15:56:06 +02:00
|
|
|
Methods.setPreferred(Config.getString(Property.PREFERRED_ECONOMY_PLUGIN));
|
2011-05-15 18:16:25 +02:00
|
|
|
}
|
|
|
|
|
2011-07-02 20:34:14 +02:00
|
|
|
public static boolean getBoolean(Property value) {
|
2011-06-11 17:36:55 +02:00
|
|
|
return (Boolean) getValue(value.name());
|
2011-05-15 19:33:03 +02:00
|
|
|
}
|
|
|
|
|
2011-09-06 19:01:57 +02:00
|
|
|
public static float getFloat(Property value) {
|
2012-04-19 15:46:05 +02:00
|
|
|
return getFloat(value.name());
|
2011-08-13 12:08:34 +02:00
|
|
|
}
|
2012-03-17 15:00:25 +01:00
|
|
|
|
2012-03-01 22:03:59 +01:00
|
|
|
public static float getFloat(String value) {
|
|
|
|
return new Float(getValue(value).toString());
|
|
|
|
}
|
2011-08-13 12:08:34 +02:00
|
|
|
|
2011-07-02 20:34:14 +02:00
|
|
|
public static String getString(Property value) {
|
2011-06-13 00:59:10 +02:00
|
|
|
return (String) getValue(value.name());
|
2011-05-15 18:16:25 +02:00
|
|
|
}
|
|
|
|
|
2011-07-02 20:34:14 +02:00
|
|
|
public static int getInteger(Property value) {
|
2011-06-11 17:36:55 +02:00
|
|
|
return Integer.parseInt(getValue(value.name()).toString());
|
2011-05-15 18:16:25 +02:00
|
|
|
}
|
2011-05-21 19:55:55 +02:00
|
|
|
|
2011-07-02 20:34:14 +02:00
|
|
|
public static double getDouble(Property value) {
|
2012-05-10 16:32:25 +02:00
|
|
|
return getDouble(value.name());
|
2012-04-19 15:46:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public static double getDouble(String value) {
|
2012-05-10 16:32:25 +02:00
|
|
|
return new Double(getValue(value).toString());
|
2011-05-21 19:55:55 +02:00
|
|
|
}
|
|
|
|
|
2011-07-23 21:00:47 +02:00
|
|
|
private static String getColored(String msg) {
|
2012-06-08 15:28:36 +02:00
|
|
|
return ChatColor.translateAlternateColorCodes('&', msg);
|
2011-05-21 19:55:55 +02:00
|
|
|
}
|
|
|
|
|
2011-06-11 17:36:55 +02:00
|
|
|
public static String getLocal(Language lang) {
|
2012-05-10 16:32:25 +02:00
|
|
|
return getColored(languageConfig.getString(Language.prefix.name()) + languageConfig.getString(lang.name()));
|
2011-05-21 19:55:55 +02:00
|
|
|
}
|
2012-03-17 15:00:25 +01:00
|
|
|
|
2012-03-01 22:03:59 +01:00
|
|
|
public static boolean exists(String value) {
|
|
|
|
return getValue(value) != null;
|
|
|
|
}
|
2011-05-21 19:55:55 +02:00
|
|
|
|
2011-05-29 13:25:25 +02:00
|
|
|
private static Object getValue(String node) {
|
2012-05-10 16:32:25 +02:00
|
|
|
return normalConfig.get(node);
|
2011-05-21 19:55:55 +02:00
|
|
|
}
|
2011-05-15 18:16:25 +02:00
|
|
|
}
|