replace density conflict and use sword conflict instead

This commit is contained in:
alexcrea 2025-04-27 10:06:18 +02:00
parent d8fbb034e5
commit 64d5bafc7a
No known key found for this signature in database
GPG key ID: 027DD67D2D3280C5
4 changed files with 76 additions and 7 deletions

View file

@ -59,9 +59,8 @@ public class Update_1_21 {
addToStringList(conflictConfig, "restriction_smite.notAffectedGroups", "mace"); addToStringList(conflictConfig, "restriction_smite.notAffectedGroups", "mace");
addToStringList(conflictConfig, "restriction_bane_of_arthropods.notAffectedGroups", "mace"); addToStringList(conflictConfig, "restriction_bane_of_arthropods.notAffectedGroups", "mace");
addToStringList(conflictConfig, "mace_enchant_conflict.enchantments", addToStringList(conflictConfig, "sword_enchant_conflict.enchantments",
"minecraft:density", "minecraft:breach", "minecraft:smite", "minecraft:bane_of_arthropods"); "minecraft:density", "minecraft:breach");
conflictConfig.set("mace_enchant_conflict.maxEnchantmentBeforeConflict", 1);
// Add level limit // Add level limit
baseConfig.set("enchant_limits.minecraft:density", 5); baseConfig.set("enchant_limits.minecraft:density", 5);

View file

@ -0,0 +1,67 @@
package xyz.alexcrea.cuanvil.update.plugin;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration;
import xyz.alexcrea.cuanvil.config.ConfigHolder;
import javax.annotation.Nonnull;
import java.util.List;
import java.util.Set;
import static xyz.alexcrea.cuanvil.update.UpdateUtils.addToStringList;
public class PUpdate_1_11_0 {
private static final List<String> mace_expected = List.of(
"density",
"breach",
"smite",
"bane_of_arthropods"
);
private static final List<String> sword_expected = List.of(
"sharpness",
"smite",
"bane_of_arthropods"
);
public static void handleUpdate(@Nonnull Set<ConfigHolder> toSave) {
FileConfiguration config = ConfigHolder.DEFAULT_CONFIG.getConfig();
// We migrate the mace conflict if exist and unmodified
if (!config.isConfigurationSection("sword_enchant_conflict")) return;
if (!config.isConfigurationSection("mace_enchant_conflict")) return;
ConfigurationSection mace_conflict = config.getConfigurationSection("mace_enchant_conflict");
// Test mace conflict if default
if (mace_conflict == null) return;
if (mace_conflict.getInt("maxEnchantmentBeforeConflict", 0) != 1) return;
if (mace_conflict.isList("notAffectedGroups") && !mace_conflict.getList("notAffectedGroups").isEmpty()) return;
List<String> enchantments = mace_conflict.getStringList("enchantments");
if (enchantments.size() != 4) return;
for (String ench : mace_expected) {
if(!enchantments.contains(ench) && !enchantments.contains("minecraft:" + ench)) return;
}
// Test sword_enchant_conflict is default
ConfigurationSection sword_conflict = config.getConfigurationSection("sword_enchant_conflict");
if (sword_conflict.getInt("maxEnchantmentBeforeConflict", 0) != 1) return;
if (sword_conflict.isList("notAffectedGroups") && !sword_conflict.getList("notAffectedGroups").isEmpty()) return;
enchantments = sword_conflict.getStringList("enchantments");
if (enchantments.size() != 3) return;
for (String ench : sword_expected) {
if(!enchantments.contains(ench) && !enchantments.contains("minecraft:" + ench)) return;
}
// Finally we know both conflict are default. so we fix
addToStringList(config, "sword_enchant_conflict.enchantments",
"minecraft:density", "minecraft:breach");
config.set("mace_enchant_conflict", null);
}
}

View file

@ -20,18 +20,21 @@ public class PluginUpdates {
if (new Version(1, 6, 2).greaterThan(current)) { if (new Version(1, 6, 2).greaterThan(current)) {
PUpdate_1_6_2.handleUpdate(toSave); PUpdate_1_6_2.handleUpdate(toSave);
// We assume 1.6.7 will run. TODO a better system instead of that I guess // We assume 1.6.7 will run. TODO a better system instead of that I guess
} }
if (new Version(1, 6, 7).greaterThan(current)) { if (new Version(1, 6, 7).greaterThan(current)) {
PUpdate_1_6_7.handleUpdate(toSave); PUpdate_1_6_7.handleUpdate(toSave);
// We assume 1.8.0 will run. // We assume 1.8.0 will run.
} }
if (new Version(1, 8, 0).greaterThan(current)) { if (new Version(1, 8, 0).greaterThan(current)) {
PUpdate_1_8_0.handleUpdate(toSave); PUpdate_1_8_0.handleUpdate(toSave);
// We assume 1.11.0 will run.
}
finishConfiguration("1.8.0", toSave); if (new Version(1, 11, 0).greaterThan(current)) {
PUpdate_1_11_0.handleUpdate(toSave);
finishConfiguration("1.11.0", toSave);
} }
} }

View file

@ -367,4 +367,4 @@ debug_log_verbose: false
# ProtocoLib may also be used if the server is in an "unsupported" version even if this option is disabled. # ProtocoLib may also be used if the server is in an "unsupported" version even if this option is disabled.
force_protocolib: false force_protocolib: false
configVersion: 1.8.0 configVersion: 1.11.0