#347 Add NewSetting to command service
- Adjust NewSetting constructor to match needs in AuthMe - Add NewSetting to the command service - See CaptchaCommand for a sample replacement from Settings to NewSetting
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
package fr.xephi.authme.settings.domain;
|
||||
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -19,7 +19,7 @@ class EnumPropertyType<E extends Enum<E>> extends PropertyType<E> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public E getFromFile(Property<E> property, YamlConfiguration configuration) {
|
||||
public E getFromFile(Property<E> property, FileConfiguration configuration) {
|
||||
String textValue = configuration.getString(property.getPath());
|
||||
if (textValue == null) {
|
||||
return property.getDefaultValue();
|
||||
@@ -34,7 +34,7 @@ class EnumPropertyType<E extends Enum<E>> extends PropertyType<E> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(Property<E> property, YamlConfiguration configuration) {
|
||||
public boolean contains(Property<E> property, FileConfiguration configuration) {
|
||||
return super.contains(property, configuration)
|
||||
&& mapToEnum(configuration.getString(property.getPath())) != null;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package fr.xephi.authme.settings.domain;
|
||||
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@@ -60,7 +60,7 @@ public class Property<T> {
|
||||
* @param configuration The configuration to read the value from
|
||||
* @return The value, or default if not present
|
||||
*/
|
||||
public T getFromFile(YamlConfiguration configuration) {
|
||||
public T getFromFile(FileConfiguration configuration) {
|
||||
return type.getFromFile(this, configuration);
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ public class Property<T> {
|
||||
* @param configuration The configuration to read the value from
|
||||
* @return The property value as YAML
|
||||
*/
|
||||
public List<String> formatValueAsYaml(YamlConfiguration configuration) {
|
||||
public List<String> formatValueAsYaml(FileConfiguration configuration) {
|
||||
return type.asYaml(this, configuration);
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ public class Property<T> {
|
||||
* @param configuration The configuration file to verify
|
||||
* @return True if the property is present, false otherwise
|
||||
*/
|
||||
public boolean isPresent(YamlConfiguration configuration) {
|
||||
public boolean isPresent(FileConfiguration configuration) {
|
||||
return type.contains(this, configuration);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package fr.xephi.authme.settings.domain;
|
||||
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -28,7 +28,7 @@ public abstract class PropertyType<T> {
|
||||
* @param configuration The YAML configuration to read from
|
||||
* @return The read value, or the default value if absent
|
||||
*/
|
||||
public abstract T getFromFile(Property<T> property, YamlConfiguration configuration);
|
||||
public abstract T getFromFile(Property<T> property, FileConfiguration configuration);
|
||||
|
||||
/**
|
||||
* Return the property's value (or its default) as YAML.
|
||||
@@ -37,7 +37,7 @@ public abstract class PropertyType<T> {
|
||||
* @param configuration The YAML configuration to read from
|
||||
* @return The read value or its default in YAML format
|
||||
*/
|
||||
public List<String> asYaml(Property<T> property, YamlConfiguration configuration) {
|
||||
public List<String> asYaml(Property<T> property, FileConfiguration configuration) {
|
||||
return asYaml(getFromFile(property, configuration));
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ public abstract class PropertyType<T> {
|
||||
* @param configuration The configuration to verify
|
||||
* @return True if the property is present, false otherwise
|
||||
*/
|
||||
public boolean contains(Property<T> property, YamlConfiguration configuration) {
|
||||
public boolean contains(Property<T> property, FileConfiguration configuration) {
|
||||
return configuration.contains(property.getPath());
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ public abstract class PropertyType<T> {
|
||||
*/
|
||||
private static final class BooleanProperty extends PropertyType<Boolean> {
|
||||
@Override
|
||||
public Boolean getFromFile(Property<Boolean> property, YamlConfiguration configuration) {
|
||||
public Boolean getFromFile(Property<Boolean> property, FileConfiguration configuration) {
|
||||
return configuration.getBoolean(property.getPath(), property.getDefaultValue());
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ public abstract class PropertyType<T> {
|
||||
*/
|
||||
private static final class DoubleProperty extends PropertyType<Double> {
|
||||
@Override
|
||||
public Double getFromFile(Property<Double> property, YamlConfiguration configuration) {
|
||||
public Double getFromFile(Property<Double> property, FileConfiguration configuration) {
|
||||
return configuration.getDouble(property.getPath(), property.getDefaultValue());
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ public abstract class PropertyType<T> {
|
||||
*/
|
||||
private static final class IntegerProperty extends PropertyType<Integer> {
|
||||
@Override
|
||||
public Integer getFromFile(Property<Integer> property, YamlConfiguration configuration) {
|
||||
public Integer getFromFile(Property<Integer> property, FileConfiguration configuration) {
|
||||
return configuration.getInt(property.getPath(), property.getDefaultValue());
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ public abstract class PropertyType<T> {
|
||||
*/
|
||||
private static final class StringProperty extends PropertyType<String> {
|
||||
@Override
|
||||
public String getFromFile(Property<String> property, YamlConfiguration configuration) {
|
||||
public String getFromFile(Property<String> property, FileConfiguration configuration) {
|
||||
return configuration.getString(property.getPath(), property.getDefaultValue());
|
||||
}
|
||||
|
||||
@@ -131,7 +131,7 @@ public abstract class PropertyType<T> {
|
||||
*/
|
||||
private static final class StringListProperty extends PropertyType<List<String>> {
|
||||
@Override
|
||||
public List<String> getFromFile(Property<List<String>> property, YamlConfiguration configuration) {
|
||||
public List<String> getFromFile(Property<List<String>> property, FileConfiguration configuration) {
|
||||
if (!configuration.isList(property.getPath())) {
|
||||
return property.getDefaultValue();
|
||||
}
|
||||
@@ -154,7 +154,7 @@ public abstract class PropertyType<T> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(Property<List<String>> property, YamlConfiguration configuration) {
|
||||
public boolean contains(Property<List<String>> property, FileConfiguration configuration) {
|
||||
return configuration.contains(property.getPath()) && configuration.isList(property.getPath());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user