ChestShop-3/com/Acrobot/ChestShop/Config/Config.java
Acrobot f1ee558e3a - Reformatted code
- Switched from YamlConfiguration to BreezeConfiguration (from ChestShop 4)
- Fixed getDouble()
- Instead of checking for Admin Shops, we just pass in a new AdminShop Container
- Created events for shop creation, protection checks and protection creation
- Expanded string data value parsing, for example - you can use "Ocelot Monster" on the sign
- Collected all external plugin wrappers in a single folder
- Instead of using statics, now we use objects
- Fixed enchantments for armour
- Made config more readable
- Added a setting for removing empty shops
- Switched from System.out to logger
- Also, switched from ugly file logging to Java's native one (FileHandler)
- Added an option to tax transactions even when SERVER_ECONOMY_ACCOUNT is empty
- Changed the Container interface
2012-05-10 16:32:25 +02:00

71 lines
2.1 KiB
Java

package com.Acrobot.ChestShop.Config;
import com.Acrobot.ChestShop.ChestShop;
import com.Acrobot.ChestShop.Utils.uName;
import com.nijikokun.register.payment.forChestShop.Methods;
import java.io.File;
/**
* @author Acrobot
*/
public class Config {
public static BreezeConfiguration normalConfig;
public static BreezeConfiguration languageConfig;
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"));
Methods.setPreferred(Config.getString(Property.PREFERRED_ECONOMY_PLUGIN));
}
public static boolean getBoolean(Property value) {
return (Boolean) getValue(value.name());
}
public static float getFloat(Property value) {
return getFloat(value.name());
}
public static float getFloat(String value) {
return new Float(getValue(value).toString());
}
public static String getString(Property value) {
return (String) getValue(value.name());
}
public static int getInteger(Property value) {
return Integer.parseInt(getValue(value.name()).toString());
}
public static double getDouble(Property value) {
return getDouble(value.name());
}
public static double getDouble(String value) {
return new Double(getValue(value).toString());
}
private static String getColored(String msg) {
return msg.replaceAll("&([0-9a-fk-or])", "\u00A7$1");
}
public static String getLocal(Language lang) {
return getColored(languageConfig.getString(Language.prefix.name()) + languageConfig.getString(lang.name()));
}
public static boolean exists(String value) {
return getValue(value) != null;
}
private static Object getValue(String node) {
return normalConfig.get(node);
}
}