mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-06-24 00:26:16 +02:00
replace density conflict and use sword conflict instead
This commit is contained in:
parent
d8fbb034e5
commit
64d5bafc7a
4 changed files with 76 additions and 7 deletions
|
|
@ -59,9 +59,8 @@ public class Update_1_21 {
|
|||
addToStringList(conflictConfig, "restriction_smite.notAffectedGroups", "mace");
|
||||
addToStringList(conflictConfig, "restriction_bane_of_arthropods.notAffectedGroups", "mace");
|
||||
|
||||
addToStringList(conflictConfig, "mace_enchant_conflict.enchantments",
|
||||
"minecraft:density", "minecraft:breach", "minecraft:smite", "minecraft:bane_of_arthropods");
|
||||
conflictConfig.set("mace_enchant_conflict.maxEnchantmentBeforeConflict", 1);
|
||||
addToStringList(conflictConfig, "sword_enchant_conflict.enchantments",
|
||||
"minecraft:density", "minecraft:breach");
|
||||
|
||||
// Add level limit
|
||||
baseConfig.set("enchant_limits.minecraft:density", 5);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -20,18 +20,21 @@ public class PluginUpdates {
|
|||
|
||||
if (new Version(1, 6, 2).greaterThan(current)) {
|
||||
PUpdate_1_6_2.handleUpdate(toSave);
|
||||
|
||||
// We assume 1.6.7 will run. TODO a better system instead of that I guess
|
||||
}
|
||||
if (new Version(1, 6, 7).greaterThan(current)) {
|
||||
PUpdate_1_6_7.handleUpdate(toSave);
|
||||
|
||||
// We assume 1.8.0 will run.
|
||||
}
|
||||
if (new Version(1, 8, 0).greaterThan(current)) {
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
force_protocolib: false
|
||||
|
||||
configVersion: 1.8.0
|
||||
configVersion: 1.11.0
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue