mirror of
https://github.com/Auxilor/EcoEnchants.git
synced 2024-11-22 15:05:18 +01:00
Finished EnchantmentType refactor
This commit is contained in:
parent
7c0e17f1f3
commit
05f1775ef6
@ -43,7 +43,7 @@ public abstract class EnchantmentYamlConfig {
|
||||
|
||||
if(!basedir.exists()) basedir.mkdirs();
|
||||
|
||||
File dir = new File(basedir, type.name().toLowerCase() + "/");
|
||||
File dir = new File(basedir, type.getName() + "/");
|
||||
if (!dir.exists()) {
|
||||
dir.mkdirs();
|
||||
}
|
||||
@ -64,7 +64,7 @@ public abstract class EnchantmentYamlConfig {
|
||||
}
|
||||
|
||||
private void saveResource(boolean replace) {
|
||||
String resourcePath = "/enchants/" + type.name().toLowerCase() + "/" + name + ".yml";
|
||||
String resourcePath = "/enchants/" + type.getName() + "/" + name + ".yml";
|
||||
|
||||
InputStream in = source.getResourceAsStream(resourcePath);
|
||||
|
||||
@ -98,7 +98,7 @@ public abstract class EnchantmentYamlConfig {
|
||||
try {
|
||||
config.load(configFile);
|
||||
|
||||
String resourcePath = "/enchants/" + type.name().toLowerCase() + "/" + name + ".yml";
|
||||
String resourcePath = "/enchants/" + type.getName() + "/" + name + ".yml";
|
||||
InputStream newIn = source.getResourceAsStream(resourcePath);
|
||||
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(newIn, StandardCharsets.UTF_8));
|
||||
|
@ -436,28 +436,30 @@ public abstract class EcoEnchant extends Enchantment implements Listener, Regist
|
||||
}
|
||||
|
||||
public static class EnchantmentType {
|
||||
public static final EnchantmentType NORMAL = new EnchantmentType(false, () -> ConfigManager.getLang().getString("not-curse-color"));
|
||||
public static final EnchantmentType CURSE = new EnchantmentType(false, () -> ConfigManager.getLang().getString("curse-color"));
|
||||
public static final EnchantmentType SPECIAL = new EnchantmentType(() -> !ConfigManager.getConfig().getBool("types.special.allow-multiple"), () -> ConfigManager.getLang().getString("special-color"));
|
||||
public static final EnchantmentType ARTIFACT = new EnchantmentType(() -> !ConfigManager.getConfig().getBool("types.artifact.allow-multiple"), () -> ConfigManager.getLang().getString("artifact-color"));
|
||||
public static final EnchantmentType SPELL = new EnchantmentType(true, () -> ConfigManager.getLang().getString("spell-color"));
|
||||
public static final EnchantmentType NORMAL = new EnchantmentType("normal", false, () -> ConfigManager.getLang().getString("not-curse-color"));
|
||||
public static final EnchantmentType CURSE = new EnchantmentType("curse", false, () -> ConfigManager.getLang().getString("curse-color"));
|
||||
public static final EnchantmentType SPECIAL = new EnchantmentType("special", () -> !ConfigManager.getConfig().getBool("types.special.allow-multiple"), () -> ConfigManager.getLang().getString("special-color"));
|
||||
public static final EnchantmentType ARTIFACT = new EnchantmentType("artifact", () -> !ConfigManager.getConfig().getBool("types.artifact.allow-multiple"), () -> ConfigManager.getLang().getString("artifact-color"));
|
||||
public static final EnchantmentType SPELL = new EnchantmentType("spell", true, () -> ConfigManager.getLang().getString("spell-color"));
|
||||
|
||||
private static final Set<EnchantmentType> values = new HashSet<>();
|
||||
|
||||
private boolean singular;
|
||||
private String color;
|
||||
private final String name;
|
||||
private final ObjectCallable<String> colorCallable;
|
||||
private final ObjectCallable<Boolean> singularCallable;
|
||||
|
||||
public EnchantmentType(boolean singular, String color) {
|
||||
this(() -> singular, () -> color);
|
||||
public EnchantmentType(String name, boolean singular, String color) {
|
||||
this(name, () -> singular, () -> color);
|
||||
}
|
||||
|
||||
public EnchantmentType(boolean singular, ObjectCallable<String> colorCallable) {
|
||||
this(() -> singular, colorCallable);
|
||||
public EnchantmentType(String name, boolean singular, ObjectCallable<String> colorCallable) {
|
||||
this(name, () -> singular, colorCallable);
|
||||
}
|
||||
|
||||
public EnchantmentType(ObjectCallable<Boolean> singularCallable, ObjectCallable<String> colorCallable) {
|
||||
public EnchantmentType(String name, ObjectCallable<Boolean> singularCallable, ObjectCallable<String> colorCallable) {
|
||||
this.name = name;
|
||||
this.singularCallable = singularCallable;
|
||||
this.colorCallable = colorCallable;
|
||||
color = colorCallable.call();
|
||||
@ -478,6 +480,10 @@ public abstract class EcoEnchant extends Enchantment implements Listener, Regist
|
||||
return singular;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public static void update() {
|
||||
values.forEach(EnchantmentType::refresh);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user