fix forgetting luck of the sea for the longest time

This commit is contained in:
alexcrea 2025-11-10 23:43:16 +01:00
parent bc8107ca44
commit ade94bdfca
Signed by: alexcrea
GPG key ID: E346CD16413450E3
8 changed files with 86 additions and 25 deletions

View file

@ -18,7 +18,7 @@ plugins {
} }
group = "xyz.alexcrea" group = "xyz.alexcrea"
version = "1.15.4" version = "1.15.5"
val effectiveVersion = "$version" + val effectiveVersion = "$version" +
(if (System.getenv("SMALL_COMMIT_HASH") != null) "-dev-${System.getenv("SMALL_COMMIT_HASH")!!}" else "") (if (System.getenv("SMALL_COMMIT_HASH") != null) "-dev-${System.getenv("SMALL_COMMIT_HASH")!!}" else "")

View file

@ -92,6 +92,10 @@ restriction_loyalty:
enchantments: [ minecraft:loyalty ] enchantments: [ minecraft:loyalty ]
notAffectedGroups: [ enchanted_book, trident ] notAffectedGroups: [ enchanted_book, trident ]
restriction_luck_of_the_sea:
enchantments: [ minecraft:luck_of_the_sea ]
notAffectedGroups: [ enchanted_book, fishing_rod ]
restriction_lure: restriction_lure:
enchantments: [ minecraft:lure ] enchantments: [ minecraft:lure ]
notAffectedGroups: [ enchanted_book, fishing_rod ] notAffectedGroups: [ enchanted_book, fishing_rod ]

View file

@ -152,6 +152,13 @@ restriction_loyalty:
- enchanted_book - enchanted_book
- trident - trident
restriction_luck_of_the_sea:
enchantments:
- minecraft:luck_of_the_sea
notAffectedGroups:
- enchanted_book
- fishing_rod
restriction_lure: restriction_lure:
enchantments: enchantments:
- minecraft:lure - minecraft:lure

View file

@ -92,6 +92,10 @@ restriction_loyalty:
enchantments: [ minecraft:loyalty ] enchantments: [ minecraft:loyalty ]
notAffectedGroups: [ enchanted_book, trident ] notAffectedGroups: [ enchanted_book, trident ]
restriction_luck_of_the_sea:
enchantments: [ minecraft:luck_of_the_sea ]
notAffectedGroups: [ enchanted_book, fishing_rod ]
restriction_lure: restriction_lure:
enchantments: [ minecraft:lure ] enchantments: [ minecraft:lure ]
notAffectedGroups: [ enchanted_book, fishing_rod ] notAffectedGroups: [ enchanted_book, fishing_rod ]

View file

@ -0,0 +1,27 @@
package xyz.alexcrea.cuanvil.update.plugin;
import org.bukkit.configuration.file.FileConfiguration;
import xyz.alexcrea.cuanvil.config.ConfigHolder;
import javax.annotation.Nonnull;
import java.util.Set;
import static xyz.alexcrea.cuanvil.update.UpdateUtils.addAbsentToList;
public class PUpdate_1_15_5 {
public static void handleUpdate(@Nonnull Set<ConfigHolder> toSave) {
FileConfiguration config = ConfigHolder.CONFLICT_HOLDER.getConfig();
if (config.isConfigurationSection("restriction_luck_of_the_sea")) return;
// We fix the luck of the see enchantment
addAbsentToList(config, "restriction_luck_of_the_sea.enchantments",
"minecraft:luck_of_the_sea");
addAbsentToList(config, "restriction_luck_of_the_sea.notAffectedGroups",
"enchanted_book", "fishing_rod");
toSave.add(ConfigHolder.CONFLICT_HOLDER);
}
}

View file

@ -9,7 +9,10 @@ import xyz.alexcrea.cuanvil.update.Version;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import java.util.HashSet; import java.util.HashSet;
import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Consumer;
public class PluginUpdates { public class PluginUpdates {
@ -21,10 +24,13 @@ public class PluginUpdates {
handlePluginUpdate(); handlePluginUpdate();
} }
private static final Version V1_6_2 = new Version(1, 6, 2); private static final Map<Version, Consumer<Set<ConfigHolder>>> updateMap = Map.of(
private static final Version V1_6_7 = new Version(1, 6, 7); new Version(1, 6, 2), PUpdate_1_6_2::handleUpdate,
private static final Version V1_8_0 = new Version(1, 8, 0); new Version(1, 6, 7), PUpdate_1_6_7::handleUpdate,
private static final Version V1_11_0 = new Version(1, 11, 0); new Version(1, 8, 0), PUpdate_1_8_0::handleUpdate,
new Version(1, 11, 0), PUpdate_1_11_0::handleUpdate,
new Version(1, 15, 5), PUpdate_1_15_5::handleUpdate
);
// Handle only plugin update // Handle only plugin update
private static void handlePluginUpdate() { private static void handlePluginUpdate() {
@ -33,24 +39,21 @@ public class PluginUpdates {
Set<ConfigHolder> toSave = new HashSet<>(); Set<ConfigHolder> toSave = new HashSet<>();
if (V1_6_2.greaterThan(current)) { AtomicReference<Version> latest = new AtomicReference<>(null);
PUpdate_1_6_2.handleUpdate(toSave);
// We assume 1.6.7 will run. TODO a better system instead of that I guess
}
if (V1_6_7.greaterThan(current)) {
PUpdate_1_6_7.handleUpdate(toSave);
// We assume 1.8.0 will run.
}
if (V1_8_0.greaterThan(current)) {
PUpdate_1_8_0.handleUpdate(toSave);
// We assume 1.11.0 will run.
}
if (V1_11_0.greaterThan(current)) {
PUpdate_1_11_0.handleUpdate(toSave);
finishConfiguration("1.11.0", toSave); // Hopefully, should iterate in the "insertion" order
} updateMap.forEach((ver, consumer) -> {
if (ver.greaterThan(current)) {
CustomAnvil.log("handling plugin update to " + ver);
consumer.accept(toSave);
latest.set(ver);
}
});
if (latest.get() != null) {
finishConfiguration(latest.get().toString(), toSave);
}
} }
// Handle minecraft version update (not plugin version update) // Handle minecraft version update (not plugin version update)
@ -71,9 +74,16 @@ public class PluginUpdates {
ConfigHolder.DEFAULT_CONFIG.getConfig().set(CONFIG_VERSION_PATH, newVersion); ConfigHolder.DEFAULT_CONFIG.getConfig().set(CONFIG_VERSION_PATH, newVersion);
toSave.add(ConfigHolder.DEFAULT_CONFIG); toSave.add(ConfigHolder.DEFAULT_CONFIG);
// save
for (ConfigHolder configHolder : toSave) { for (ConfigHolder configHolder : toSave) {
configHolder.saveToDisk(true); configHolder.saveToDisk(true);
} }
// then reload
for (ConfigHolder configHolder : toSave) {
configHolder.reload();
}
} }
} }

View file

@ -10,6 +10,7 @@ import xyz.alexcrea.cuanvil.command.EditConfigExecutor
import xyz.alexcrea.cuanvil.command.ReloadExecutor import xyz.alexcrea.cuanvil.command.ReloadExecutor
import xyz.alexcrea.cuanvil.config.ConfigHolder import xyz.alexcrea.cuanvil.config.ConfigHolder
import xyz.alexcrea.cuanvil.dependency.DependencyManager import xyz.alexcrea.cuanvil.dependency.DependencyManager
import xyz.alexcrea.cuanvil.dependency.util.PlatformUtil
import xyz.alexcrea.cuanvil.enchant.CAEnchantmentRegistry import xyz.alexcrea.cuanvil.enchant.CAEnchantmentRegistry
import xyz.alexcrea.cuanvil.gui.config.MainConfigGui import xyz.alexcrea.cuanvil.gui.config.MainConfigGui
import xyz.alexcrea.cuanvil.gui.util.GuiSharedConstant import xyz.alexcrea.cuanvil.gui.util.GuiSharedConstant
@ -64,7 +65,7 @@ open class CustomAnvil : JavaPlugin() {
/** /**
* Logging handler * Logging handler
*/ */
fun log(message: String) { @JvmStatic fun log(message: String) {
if (ConfigOptions.debugLog) { if (ConfigOptions.debugLog) {
instance.logger.info(message) instance.logger.info(message)
} }
@ -79,7 +80,6 @@ open class CustomAnvil : JavaPlugin() {
} }
} }
} }
/** /**
@ -96,6 +96,11 @@ open class CustomAnvil : JavaPlugin() {
logger.warning("Please note CustomAnvil is a more recent version of UnsafeEnchantsPlus") logger.warning("Please note CustomAnvil is a more recent version of UnsafeEnchantsPlus")
} }
if(!PlatformUtil.isPaper) {
logger.warning("It seems you are using spigot")
logger.warning("Please take notice that spigot is less supported than paper and derivatives")
}
// Add commands // Add commands
prepareCommand() prepareCommand()

View file

@ -92,6 +92,10 @@ restriction_loyalty:
enchantments: [ minecraft:loyalty ] enchantments: [ minecraft:loyalty ]
notAffectedGroups: [ enchanted_book, trident ] notAffectedGroups: [ enchanted_book, trident ]
restriction_luck_of_the_sea:
enchantments: [ minecraft:luck_of_the_sea ]
notAffectedGroups: [ enchanted_book, fishing_rod ]
restriction_lure: restriction_lure:
enchantments: [ minecraft:lure ] enchantments: [ minecraft:lure ]
notAffectedGroups: [ enchanted_book, fishing_rod ] notAffectedGroups: [ enchanted_book, fishing_rod ]