Fix custom enchantments max level from supported enchantments reseting every restart

This commit is contained in:
alexcrea 2024-10-16 21:45:28 +02:00
parent be53cbf5bd
commit 55d3ea8765
No known key found for this signature in database
GPG key ID: 43FD265DB0DBF91F
2 changed files with 6 additions and 2 deletions

View file

@ -15,7 +15,7 @@ plugins {
}
group = "xyz.alexcrea"
version = "1.6.3-test"
version = "1.6.4"
repositories {
// EcoEnchants

View file

@ -170,7 +170,7 @@ public class EnchantmentApi {
*/
public static boolean writeDefaultConfig(CAEnchantment enchantment, boolean override){
FileConfiguration config = ConfigHolder.DEFAULT_CONFIG.getConfig();
if(!override && config.contains(enchantment.getName())) return false;
if(!override && containEnchantment(config, enchantment)) return false;
writeDefaultConfig(config, enchantment);
@ -178,6 +178,10 @@ public class EnchantmentApi {
return true;
}
private static boolean containEnchantment(FileConfiguration config, CAEnchantment enchantment) {
return config.contains(enchantment.getName()) || config.contains(enchantment.getKey().toString());
}
private static void writeDefaultConfig(FileConfiguration defaultConfig, CAEnchantment enchantment) {
defaultConfig.set("enchant_limits." + enchantment.getKey(), enchantment.defaultMaxLevel());