mirror of
https://github.com/Auxilor/EcoArmor.git
synced 2025-12-27 19:09:13 +00:00
Fixed conditions
This commit is contained in:
@@ -126,16 +126,10 @@ public class ArmorSet {
|
||||
this.plugin = plugin;
|
||||
this.name = config.getString("name");
|
||||
|
||||
for (String definedKey : this.getConfig().getStrings("conditions")) {
|
||||
String[] split = definedKey.split(":");
|
||||
String key = split[0].trim();
|
||||
String value = split[1].trim();
|
||||
Condition<?> condition = Conditions.getByName(key);
|
||||
if (condition == null) {
|
||||
Bukkit.getLogger().warning("Invalid condition specified in " + this.name);
|
||||
} else {
|
||||
conditions.put(condition, ArmorUtils.getConditionValue(value, condition));
|
||||
}
|
||||
for (JSONConfig cfg : this.getConfig().getSubsections("conditions")) {
|
||||
Condition<?> effect = Conditions.getByName(cfg.getString("id"));
|
||||
Object value = cfg.get("args");
|
||||
conditions.put(effect, value);
|
||||
}
|
||||
|
||||
for (JSONConfig cfg : this.getConfig().getSubsections("effects")) {
|
||||
|
||||
@@ -401,30 +401,4 @@ public class ArmorUtils {
|
||||
|
||||
return ArmorSets.getByName(shardSet);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get value of condition.
|
||||
*
|
||||
* @param string Value as string.
|
||||
* @param condition Condition.
|
||||
* @param <T> The type of the condition.
|
||||
* @return Value.
|
||||
*/
|
||||
@NotNull
|
||||
public static <T> Object getConditionValue(@NotNull final String string,
|
||||
@NotNull final Condition<T> condition) {
|
||||
if (condition.getTypeClass().equals(Boolean.class)) {
|
||||
return Boolean.parseBoolean(string);
|
||||
}
|
||||
|
||||
if (condition.getTypeClass().equals(Integer.class)) {
|
||||
return Integer.parseInt(string);
|
||||
}
|
||||
|
||||
if (condition.getTypeClass().equals(Double.class)) {
|
||||
return Double.parseDouble(string);
|
||||
}
|
||||
|
||||
return string;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user