de.teamlapen.lib.lib.config.forge.ConfigCategory.getQualifiedName() - java examples

Here are the examples of the java api de.teamlapen.lib.lib.config.forge.ConfigCategory.getQualifiedName() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

1 Examples 7

13 View Complete Implementation : BalanceValues.java
Copyright GNU Lesser General Public License v3.0
Author : TeamLapen
public void loadBalance() {
    ConfigCategory cat = configuration.getCategory(Configuration.CATEGORY_GENERAL);
    boolean alt = shouldUseAlternate();
    for (Field f : this.getClreplaced().getDeclaredFields()) {
        String name = f.getName();
        Clreplaced type = f.getType();
        try {
            if (type == int.clreplaced) {
                DefaultInt a = f.getAnnotation(DefaultInt.clreplaced);
                int value = (alt && a.hasAlternate()) ? a.alternateValue() : a.value();
                f.set(this, MathHelper.clamp(configuration.get(cat.getQualifiedName(), chooseName(name, a.name()), value, a.comment(), a.minValue(), a.maxValue()).getInt(), a.minValue(), a.maxValue()));
            } else if (type == double.clreplaced) {
                // Possible exception should not be caught so you can't forget a default value
                DefaultDouble a = f.getAnnotation(DefaultDouble.clreplaced);
                double value = (alt && a.hasAlternate()) ? a.alternateValue() : a.value();
                f.set(this, MathHelper.clamp(configuration.get(cat.getQualifiedName(), chooseName(name, a.name()), value, a.comment(), a.minValue(), a.maxValue()).getDouble(), a.minValue(), a.maxValue()));
            } else if (type == boolean.clreplaced) {
                DefaultBoolean a = f.getAnnotation(DefaultBoolean.clreplaced);
                boolean value = (alt && a.hasAlternate()) ? a.alternateValue() : a.value();
                f.set(this, configuration.get(cat.getQualifiedName(), chooseName(name, a.name()), value, a.comment()).getBoolean());
            }
        } catch (NullPointerException e1) {
            LOGGER.error(LogUtil.CONFIG, "Author probably forgot to specify a default annotation for " + name + " in " + this.name, e1);
            throw new Error("Please check you default values in " + this.name);
        } catch (Exception e) {
            LOGGER.error(LogUtil.CONFIG, "Cant set " + this.name + " values", e);
            throw new Error("Please check your " + configuration.getConfigFile().getAbsolutePath() + " config file");
        }
    }
    if (configuration.hasChanged()) {
        configuration.save();
    }
}