mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-08-28 08:25:56 +02:00
fix turtle scule unit repair and force migratation of sweeping edge
This commit is contained in:
parent
45dd92e0f4
commit
f1c3cf46e1
11 changed files with 143 additions and 22 deletions
|
|
@ -22,7 +22,7 @@ plugins {
|
||||||
}
|
}
|
||||||
|
|
||||||
group = "xyz.alexcrea"
|
group = "xyz.alexcrea"
|
||||||
version = "1.17.6"
|
version = "1.17.7"
|
||||||
|
|
||||||
val isDevBuild = System.getenv("SMALL_COMMIT_HASH") != null
|
val isDevBuild = System.getenv("SMALL_COMMIT_HASH") != null
|
||||||
val isPreRelease = System.getenv("IS_GITHUB_PRERELEASE") == "true"
|
val isPreRelease = System.getenv("IS_GITHUB_PRERELEASE") == "true"
|
||||||
|
|
|
||||||
|
|
@ -154,7 +154,6 @@ enchant_limits:
|
||||||
minecraft:knockback: 2
|
minecraft:knockback: 2
|
||||||
minecraft:fire_aspect: 2
|
minecraft:fire_aspect: 2
|
||||||
minecraft:looting: 3
|
minecraft:looting: 3
|
||||||
minecraft:sweeping: 3
|
|
||||||
minecraft:sweeping_edge: 3
|
minecraft:sweeping_edge: 3
|
||||||
minecraft:efficiency: 5
|
minecraft:efficiency: 5
|
||||||
minecraft:unbreaking: 3
|
minecraft:unbreaking: 3
|
||||||
|
|
@ -293,9 +292,6 @@ enchant_values:
|
||||||
minecraft:swift_sneak:
|
minecraft:swift_sneak:
|
||||||
item: 8
|
item: 8
|
||||||
book: 4
|
book: 4
|
||||||
minecraft:sweeping:
|
|
||||||
item: 4
|
|
||||||
book: 2
|
|
||||||
minecraft:sweeping_edge:
|
minecraft:sweeping_edge:
|
||||||
item: 4
|
item: 4
|
||||||
book: 2
|
book: 2
|
||||||
|
|
@ -489,5 +485,5 @@ debug_log_verbose: false
|
||||||
# Whether to show inside the console or require to run /ca debug get
|
# Whether to show inside the console or require to run /ca debug get
|
||||||
display_debug_in_console: false
|
display_debug_in_console: false
|
||||||
|
|
||||||
configVersion: 1.15.5
|
configVersion: 1.17.7
|
||||||
lowMinecraftVersion: 1.21.11
|
lowMinecraftVersion: 1.21.11
|
||||||
|
|
|
||||||
|
|
@ -270,7 +270,6 @@ restriction_soul_speed:
|
||||||
|
|
||||||
restriction_sweeping_edge:
|
restriction_sweeping_edge:
|
||||||
enchantments:
|
enchantments:
|
||||||
- minecraft:sweeping
|
|
||||||
- minecraft:sweeping_edge
|
- minecraft:sweeping_edge
|
||||||
notAffectedGroups:
|
notAffectedGroups:
|
||||||
- enchanted_book
|
- enchanted_book
|
||||||
|
|
|
||||||
|
|
@ -152,7 +152,6 @@ enchant_limits:
|
||||||
minecraft:knockback: 2
|
minecraft:knockback: 2
|
||||||
minecraft:fire_aspect: 2
|
minecraft:fire_aspect: 2
|
||||||
minecraft:looting: 3
|
minecraft:looting: 3
|
||||||
minecraft:sweeping: 3
|
|
||||||
minecraft:sweeping_edge: 3
|
minecraft:sweeping_edge: 3
|
||||||
minecraft:efficiency: 5
|
minecraft:efficiency: 5
|
||||||
minecraft:unbreaking: 3
|
minecraft:unbreaking: 3
|
||||||
|
|
@ -290,9 +289,6 @@ enchant_values:
|
||||||
minecraft:swift_sneak:
|
minecraft:swift_sneak:
|
||||||
item: 8
|
item: 8
|
||||||
book: 4
|
book: 4
|
||||||
minecraft:sweeping:
|
|
||||||
item: 4
|
|
||||||
book: 2
|
|
||||||
minecraft:sweeping_edge:
|
minecraft:sweeping_edge:
|
||||||
item: 4
|
item: 4
|
||||||
book: 2
|
book: 2
|
||||||
|
|
|
||||||
|
|
@ -267,7 +267,6 @@ restriction_soul_speed:
|
||||||
|
|
||||||
restriction_sweeping_edge:
|
restriction_sweeping_edge:
|
||||||
enchantments:
|
enchantments:
|
||||||
- minecraft:sweeping
|
|
||||||
- minecraft:sweeping_edge
|
- minecraft:sweeping_edge
|
||||||
notAffectedGroups:
|
notAffectedGroups:
|
||||||
- enchanted_book
|
- enchanted_book
|
||||||
|
|
|
||||||
|
|
@ -152,7 +152,6 @@ enchant_limits:
|
||||||
minecraft:knockback: 2
|
minecraft:knockback: 2
|
||||||
minecraft:fire_aspect: 2
|
minecraft:fire_aspect: 2
|
||||||
minecraft:looting: 3
|
minecraft:looting: 3
|
||||||
minecraft:sweeping: 3
|
|
||||||
minecraft:sweeping_edge: 3
|
minecraft:sweeping_edge: 3
|
||||||
minecraft:efficiency: 5
|
minecraft:efficiency: 5
|
||||||
minecraft:unbreaking: 3
|
minecraft:unbreaking: 3
|
||||||
|
|
@ -287,9 +286,6 @@ enchant_values:
|
||||||
minecraft:swift_sneak:
|
minecraft:swift_sneak:
|
||||||
item: 8
|
item: 8
|
||||||
book: 4
|
book: 4
|
||||||
minecraft:sweeping:
|
|
||||||
item: 4
|
|
||||||
book: 2
|
|
||||||
minecraft:sweeping_edge:
|
minecraft:sweeping_edge:
|
||||||
item: 4
|
item: 4
|
||||||
book: 2
|
book: 2
|
||||||
|
|
|
||||||
|
|
@ -157,7 +157,7 @@ restriction_soul_speed:
|
||||||
notAffectedGroups: [ enchanted_book, boots ]
|
notAffectedGroups: [ enchanted_book, boots ]
|
||||||
|
|
||||||
restriction_sweeping_edge:
|
restriction_sweeping_edge:
|
||||||
enchantments: [ minecraft:sweeping, minecraft:sweeping_edge ]
|
enchantments: [ minecraft:sweeping_edge ]
|
||||||
notAffectedGroups: [ enchanted_book, swords ]
|
notAffectedGroups: [ enchanted_book, swords ]
|
||||||
|
|
||||||
restriction_swift_sneak:
|
restriction_swift_sneak:
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,7 @@ package xyz.alexcrea.cuanvil.update;
|
||||||
|
|
||||||
import io.delilaheve.CustomAnvil;
|
import io.delilaheve.CustomAnvil;
|
||||||
import xyz.alexcrea.cuanvil.config.ConfigHolder;
|
import xyz.alexcrea.cuanvil.config.ConfigHolder;
|
||||||
import xyz.alexcrea.cuanvil.update.minecraft.MCUpdate;
|
import xyz.alexcrea.cuanvil.update.minecraft.*;
|
||||||
import xyz.alexcrea.cuanvil.update.minecraft.Update_1_21;
|
|
||||||
import xyz.alexcrea.cuanvil.update.minecraft.Update_1_21_11;
|
|
||||||
import xyz.alexcrea.cuanvil.update.minecraft.Update_1_21_9;
|
|
||||||
import xyz.alexcrea.cuanvil.update.plugin.*;
|
import xyz.alexcrea.cuanvil.update.plugin.*;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
@ -32,10 +29,12 @@ public class UpdateHandler {
|
||||||
new Version(1, 8, 0), PUpdate_1_8_0::handleUpdate,
|
new Version(1, 8, 0), PUpdate_1_8_0::handleUpdate,
|
||||||
new Version(1, 11, 0), PUpdate_1_11_0::handleUpdate,
|
new Version(1, 11, 0), PUpdate_1_11_0::handleUpdate,
|
||||||
new Version(1, 15, 5), PUpdate_1_15_5::handleUpdate,
|
new Version(1, 15, 5), PUpdate_1_15_5::handleUpdate,
|
||||||
new Version(1, 15, 6), PUpdate_1_15_6::handleUpdate
|
new Version(1, 15, 6), PUpdate_1_15_6::handleUpdate,
|
||||||
|
new Version(1, 17, 7), PUpdate_1_17_7::handleUpdate
|
||||||
);
|
);
|
||||||
|
|
||||||
private static final List<MCUpdate> mcUpdateMap = List.of(
|
private static final List<MCUpdate> mcUpdateMap = List.of(
|
||||||
|
new Update_1_20_5(),
|
||||||
new Update_1_21(),
|
new Update_1_21(),
|
||||||
new Update_1_21_9(),
|
new Update_1_21_9(),
|
||||||
new Update_1_21_11()
|
new Update_1_21_11()
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package xyz.alexcrea.cuanvil.update;
|
package xyz.alexcrea.cuanvil.update;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
@ -33,4 +34,20 @@ public class UpdateUtils {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean removeFromList(FileConfiguration config, String path, String toRemove) {
|
||||||
|
List<String> groups = new ArrayList<>(config.getStringList(path));
|
||||||
|
if (!groups.remove(toRemove)) return false;
|
||||||
|
|
||||||
|
config.set(path, groups);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void mergeSections(ConfigurationSection source, ConfigurationSection target) {
|
||||||
|
for (String key : source.getKeys(false)) {
|
||||||
|
if(target.contains(key)) continue;
|
||||||
|
target.set(key, source.get(key));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,98 @@
|
||||||
|
package xyz.alexcrea.cuanvil.update.minecraft;
|
||||||
|
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import xyz.alexcrea.cuanvil.config.ConfigHolder;
|
||||||
|
import xyz.alexcrea.cuanvil.update.Version;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import static xyz.alexcrea.cuanvil.update.UpdateUtils.*;
|
||||||
|
|
||||||
|
public class Update_1_20_5 extends MCUpdate {
|
||||||
|
|
||||||
|
public Update_1_20_5() {
|
||||||
|
super(new Version(1, 20, 5));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void doUpdate() {
|
||||||
|
var tosave = new HashSet<ConfigHolder>();
|
||||||
|
updateName(tosave);
|
||||||
|
|
||||||
|
for (ConfigHolder holder : tosave) {
|
||||||
|
holder.saveToDisk(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String SWEEPING_ENCHANTS = "restriction_sweeping_edge.enchantments";
|
||||||
|
|
||||||
|
public static void updateName(@NotNull Set<ConfigHolder> tosave) {
|
||||||
|
var config = ConfigHolder.DEFAULT_CONFIG.getConfig();
|
||||||
|
var unitConfig = ConfigHolder.UNIT_REPAIR_HOLDER.getConfig();
|
||||||
|
var conflict = ConfigHolder.CONFLICT_HOLDER.getConfig();
|
||||||
|
|
||||||
|
// Rename sweeping to sweeping_edge
|
||||||
|
migrateEnchantLimit(config, "minecraft:sweeping");
|
||||||
|
migrateEnchantLimit(config, "sweeping");
|
||||||
|
|
||||||
|
migrateEnchantValues(config, "minecraft:sweeping");
|
||||||
|
migrateEnchantValues(config, "sweeping");
|
||||||
|
|
||||||
|
if (removeFromList(conflict, SWEEPING_ENCHANTS, "minecraft:sweeping"))
|
||||||
|
addAbsentToList(conflict, SWEEPING_ENCHANTS, "minecraft:sweeping_edge");
|
||||||
|
if (removeFromList(conflict, SWEEPING_ENCHANTS, "sweeping"))
|
||||||
|
addAbsentToList(conflict, SWEEPING_ENCHANTS, "minecraft:sweeping_edge");
|
||||||
|
|
||||||
|
// Rename scute to turtle_scute
|
||||||
|
migrateUnitRepair(unitConfig, "minecraft:scute");
|
||||||
|
migrateUnitRepair(unitConfig, "scute");
|
||||||
|
|
||||||
|
ConfigHolder.ITEM_GROUP_HOLDER.reload();
|
||||||
|
|
||||||
|
tosave.add(ConfigHolder.DEFAULT_CONFIG);
|
||||||
|
tosave.add(ConfigHolder.UNIT_REPAIR_HOLDER);
|
||||||
|
tosave.add(ConfigHolder.CONFLICT_HOLDER);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void migrateEnchantLimit(FileConfiguration config, String path) {
|
||||||
|
var finalPath = "enchant_limits." + path;
|
||||||
|
if (!config.isInt(finalPath)) return;
|
||||||
|
var value = config.getInt(finalPath);
|
||||||
|
|
||||||
|
config.set(finalPath, null);
|
||||||
|
if (!config.contains("enchant_limits.minecraft:sweeping_edge")) return;
|
||||||
|
if (!config.contains("enchant_limits.sweeping_edge")) return;
|
||||||
|
|
||||||
|
config.set("enchant_limits.minecraft:sweeping_edge", value);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void migrateEnchantValues(FileConfiguration config, String path) {
|
||||||
|
migrateEnchantValues(config, path, "item");
|
||||||
|
migrateEnchantValues(config, path, "book");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void migrateEnchantValues(FileConfiguration config, String path, String child) {
|
||||||
|
var finalPath = "enchant_values." + path + "." + child;
|
||||||
|
if (config.isInt(finalPath)) return;
|
||||||
|
var value = config.getInt(finalPath);
|
||||||
|
|
||||||
|
config.set(finalPath, null);
|
||||||
|
if (!config.contains("enchant_values.minecraft:sweeping_edge." + child)) return;
|
||||||
|
if (!config.contains("enchant_values.sweeping_edge." + child)) return;
|
||||||
|
|
||||||
|
config.set("enchant_values.minecraft:sweeping_edge." + child, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void migrateUnitRepair(FileConfiguration config, String path) {
|
||||||
|
var section = config.getConfigurationSection(path);
|
||||||
|
if (section == null) return;
|
||||||
|
|
||||||
|
config.set(path, null);
|
||||||
|
var turtle_scute = config.getConfigurationSection("minecraft:turtle_scute");
|
||||||
|
if (turtle_scute == null) config.set("minecraft:turtle_scute", section);
|
||||||
|
else mergeSections(section, turtle_scute);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
package xyz.alexcrea.cuanvil.update.plugin;
|
||||||
|
|
||||||
|
import xyz.alexcrea.cuanvil.config.ConfigHolder;
|
||||||
|
import xyz.alexcrea.cuanvil.update.UpdateUtils;
|
||||||
|
import xyz.alexcrea.cuanvil.update.Version;
|
||||||
|
import xyz.alexcrea.cuanvil.update.minecraft.Update_1_20_5;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
public class PUpdate_1_17_7 {
|
||||||
|
|
||||||
|
public static void handleUpdate(@Nonnull Set<ConfigHolder> toSave) {
|
||||||
|
// fix only needed for 1.20.5 and above
|
||||||
|
Version current = UpdateUtils.currentMinecraftVersion();
|
||||||
|
if (new Version(1, 20, 5).greaterThan(current)) return;
|
||||||
|
|
||||||
|
Update_1_20_5.updateName(toSave);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue