mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-06-23 16:16:17 +02:00
Merge branch 'v1.x.x-temp' into v2.x.x
This commit is contained in:
commit
b2ccd8ae75
20 changed files with 320 additions and 166 deletions
98
src/main/java/xyz/alexcrea/cuanvil/update/UpdateHandler.java
Normal file
98
src/main/java/xyz/alexcrea/cuanvil/update/UpdateHandler.java
Normal file
|
|
@ -0,0 +1,98 @@
|
|||
package xyz.alexcrea.cuanvil.update;
|
||||
|
||||
import io.delilaheve.CustomAnvil;
|
||||
import xyz.alexcrea.cuanvil.config.ConfigHolder;
|
||||
import xyz.alexcrea.cuanvil.update.minecraft.MCUpdate;
|
||||
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 javax.annotation.Nonnull;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class UpdateHandler {
|
||||
|
||||
private static final String CONFIG_VERSION_PATH = "configVersion";
|
||||
|
||||
// Handle mc version update then plugin version update
|
||||
public static void handleUpdates() {
|
||||
handleMCVersionUpdate();
|
||||
handlePluginUpdate();
|
||||
}
|
||||
|
||||
private static final Map<Version, Consumer<Set<ConfigHolder>>> pUpdateMap = Map.of(
|
||||
new Version(1, 6, 2), PUpdate_1_6_2::handleUpdate,
|
||||
new Version(1, 6, 7), PUpdate_1_6_7::handleUpdate,
|
||||
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
|
||||
);
|
||||
|
||||
private static final List<MCUpdate> mcUpdateMap = List.of(
|
||||
new Update_1_21(),
|
||||
new Update_1_21_9(),
|
||||
new Update_1_21_11()
|
||||
);
|
||||
|
||||
// Handle only plugin update
|
||||
private static void handlePluginUpdate() {
|
||||
String versionString = ConfigHolder.DEFAULT_CONFIG.getConfig().getString(CONFIG_VERSION_PATH);
|
||||
Version current = versionString == null ? new Version(0) : Version.fromString(versionString);
|
||||
|
||||
Set<ConfigHolder> toSave = new HashSet<>();
|
||||
|
||||
AtomicReference<Version> latest = new AtomicReference<>(null);
|
||||
|
||||
// Hopefully, should iterate in the "insertion" order
|
||||
pUpdateMap.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)
|
||||
public static void handleMCVersionUpdate() {
|
||||
Version current = UpdateUtils.currentMinecraftVersion();
|
||||
|
||||
boolean hadUpdate = false;
|
||||
for (MCUpdate mcUpdate : mcUpdateMap) {
|
||||
hadUpdate |= mcUpdate.handleUpdate(current);
|
||||
}
|
||||
|
||||
if (hadUpdate) {
|
||||
CustomAnvil.instance.getLogger().info("Updating Done !");
|
||||
}
|
||||
}
|
||||
|
||||
private static void finishConfiguration(@Nonnull String newVersion, @Nonnull Set<ConfigHolder> toSave) {
|
||||
CustomAnvil.instance.getLogger().info("Configuration file updated to " + newVersion);
|
||||
ConfigHolder.DEFAULT_CONFIG.getConfig().set(CONFIG_VERSION_PATH, newVersion);
|
||||
|
||||
toSave.add(ConfigHolder.DEFAULT_CONFIG);
|
||||
// save
|
||||
for (ConfigHolder configHolder : toSave) {
|
||||
configHolder.saveToDisk(true);
|
||||
}
|
||||
|
||||
// then reload
|
||||
for (ConfigHolder configHolder : toSave) {
|
||||
configHolder.reload();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
package xyz.alexcrea.cuanvil.update.minecraft;
|
||||
|
||||
import io.delilaheve.CustomAnvil;
|
||||
import xyz.alexcrea.cuanvil.config.ConfigHolder;
|
||||
import xyz.alexcrea.cuanvil.update.UpdateUtils;
|
||||
import xyz.alexcrea.cuanvil.update.Version;
|
||||
|
||||
public abstract class MCUpdate {
|
||||
|
||||
public final Version version;
|
||||
|
||||
public MCUpdate(Version version){
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public boolean handleUpdate(Version current){
|
||||
// Test if we are running in this update version or better
|
||||
if(version.greaterThan(current))
|
||||
return false;
|
||||
|
||||
// if version path is not null then check if its it's before this update version
|
||||
String oldVersion = ConfigHolder.DEFAULT_CONFIG.getConfig().getString(UpdateUtils.MINECRAFT_VERSION_PATH);
|
||||
if(oldVersion != null){
|
||||
var version = Version.fromString(oldVersion);
|
||||
if(this.version.lesserEqual(version)) return false;
|
||||
}
|
||||
|
||||
CustomAnvil.instance.getLogger().info("Updating config to support " + version +" ...");
|
||||
doUpdate();
|
||||
return true;
|
||||
}
|
||||
|
||||
protected abstract void doUpdate();
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,33 +1,20 @@
|
|||
package xyz.alexcrea.cuanvil.update;
|
||||
package xyz.alexcrea.cuanvil.update.minecraft;
|
||||
|
||||
import io.delilaheve.CustomAnvil;
|
||||
import xyz.alexcrea.cuanvil.config.ConfigHolder;
|
||||
import xyz.alexcrea.cuanvil.update.UpdateUtils;
|
||||
import xyz.alexcrea.cuanvil.update.Version;
|
||||
|
||||
import static xyz.alexcrea.cuanvil.update.UpdateUtils.addAbsentToList;
|
||||
|
||||
public class Update_1_21 {
|
||||
public class Update_1_21 extends MCUpdate {
|
||||
|
||||
private static final Version V1_21 = new Version(1, 21);
|
||||
|
||||
public static boolean handleUpdate(Version current){
|
||||
// Test if we are running in 1.21 or better
|
||||
if(V1_21.greaterThan(current))
|
||||
return false;
|
||||
|
||||
// if version path is not null then check if its it's before 1.21
|
||||
String oldVersion = ConfigHolder.DEFAULT_CONFIG.getConfig().getString(UpdateUtils.MINECRAFT_VERSION_PATH);
|
||||
if(oldVersion != null){
|
||||
var version = Version.fromString(oldVersion);
|
||||
if(V1_21.lesserEqual(version)) return false;
|
||||
}
|
||||
|
||||
doUpdate();
|
||||
return true;
|
||||
public Update_1_21() {
|
||||
super(new Version(1, 21));
|
||||
}
|
||||
|
||||
private static void doUpdate() {
|
||||
CustomAnvil.instance.getLogger().info("Updating config to support 1.21 ...");
|
||||
|
||||
@Override
|
||||
protected void doUpdate() {
|
||||
var baseConfig = ConfigHolder.DEFAULT_CONFIG.getConfig();
|
||||
var groupConfig = ConfigHolder.ITEM_GROUP_HOLDER.getConfig();
|
||||
var conflictConfig = ConfigHolder.CONFLICT_HOLDER.getConfig();
|
||||
|
|
@ -75,8 +62,8 @@ public class Update_1_21 {
|
|||
// Add unit repair for mace
|
||||
unitConfig.set("breeze_rod.mace", 0.25);
|
||||
|
||||
// Set version string as 1.21
|
||||
baseConfig.set(UpdateUtils.MINECRAFT_VERSION_PATH, V1_21.toString());
|
||||
// Set version string as current
|
||||
baseConfig.set(UpdateUtils.MINECRAFT_VERSION_PATH, version.toString());
|
||||
|
||||
// Save
|
||||
ConfigHolder.DEFAULT_CONFIG.saveToDisk(true);
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
package xyz.alexcrea.cuanvil.update.minecraft;
|
||||
|
||||
import xyz.alexcrea.cuanvil.config.ConfigHolder;
|
||||
import xyz.alexcrea.cuanvil.update.UpdateUtils;
|
||||
import xyz.alexcrea.cuanvil.update.Version;
|
||||
|
||||
import static xyz.alexcrea.cuanvil.update.UpdateUtils.addAbsentToList;
|
||||
|
||||
public class Update_1_21_11 extends MCUpdate{
|
||||
|
||||
public Update_1_21_11() {
|
||||
super(new Version(1, 21, 11));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doUpdate() {
|
||||
var baseConfig = ConfigHolder.DEFAULT_CONFIG.getConfig();
|
||||
var groupConfig = ConfigHolder.ITEM_GROUP_HOLDER.getConfig();
|
||||
var conflictConfig = ConfigHolder.CONFLICT_HOLDER.getConfig();
|
||||
|
||||
// Create spear group
|
||||
groupConfig.set("spears.type", "include");
|
||||
addAbsentToList(groupConfig, "spears.items",
|
||||
"wooden_spear",
|
||||
"golden_spear",
|
||||
"stone_spear",
|
||||
"copper_spear",
|
||||
"iron_spear",
|
||||
"diamond_spear",
|
||||
"netherite_spear");
|
||||
|
||||
// Add spear group to super group and enchantments
|
||||
addAbsentToList(groupConfig, "melee_weapons.groups", "spears");
|
||||
|
||||
addAbsentToList(conflictConfig, "restriction_looting.notAffectedGroups", "spears");
|
||||
addAbsentToList(conflictConfig, "restriction_knockback.notAffectedGroups", "spears");
|
||||
addAbsentToList(conflictConfig, "restriction_fire_aspect.notAffectedGroups", "spears");
|
||||
|
||||
// Create lunge enchant value and group
|
||||
baseConfig.set("enchant_limits.minecraft:lunge", 3);
|
||||
baseConfig.set("enchant_values.minecraft:lunge.item", 2);
|
||||
baseConfig.set("enchant_values.minecraft:lunge.book", 1);
|
||||
|
||||
addAbsentToList(conflictConfig, "restriction_lunge.enchantments", "minecraft:lunge");
|
||||
addAbsentToList(conflictConfig, "restriction_lunge.notAffectedGroups", "spears", "enchanted_book");
|
||||
|
||||
// Set version string as current
|
||||
baseConfig.set(UpdateUtils.MINECRAFT_VERSION_PATH, version.toString());
|
||||
|
||||
// Save
|
||||
ConfigHolder.DEFAULT_CONFIG.saveToDisk(true);
|
||||
ConfigHolder.ITEM_GROUP_HOLDER.saveToDisk(true);
|
||||
ConfigHolder.CONFLICT_HOLDER.saveToDisk(true);
|
||||
|
||||
// imply reload of CONFLICT_HOLDER
|
||||
// We also do not need to reload base config as there is no object related to it.
|
||||
ConfigHolder.ITEM_GROUP_HOLDER.reload();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,37 +1,24 @@
|
|||
package xyz.alexcrea.cuanvil.update;
|
||||
package xyz.alexcrea.cuanvil.update.minecraft;
|
||||
|
||||
import io.delilaheve.CustomAnvil;
|
||||
import xyz.alexcrea.cuanvil.config.ConfigHolder;
|
||||
import xyz.alexcrea.cuanvil.update.UpdateUtils;
|
||||
import xyz.alexcrea.cuanvil.update.Version;
|
||||
|
||||
import static xyz.alexcrea.cuanvil.update.UpdateUtils.addAbsentToList;
|
||||
|
||||
public class Update_1_21_9 {
|
||||
public class Update_1_21_9 extends MCUpdate{
|
||||
|
||||
private static final Version V1_21_9 = new Version(1, 21, 9);
|
||||
|
||||
public static boolean handleUpdate(Version current){
|
||||
// Test if we are running in 1.21.9 or better
|
||||
if(V1_21_9.greaterThan(current))
|
||||
return false;
|
||||
|
||||
// if version path is not null then check if its it's before 1.21.9
|
||||
String oldVersion = ConfigHolder.DEFAULT_CONFIG.getConfig().getString(UpdateUtils.MINECRAFT_VERSION_PATH);
|
||||
if(oldVersion != null){
|
||||
var version = Version.fromString(oldVersion);
|
||||
if(V1_21_9.lesserEqual(version)) return false;
|
||||
}
|
||||
|
||||
doUpdate();
|
||||
return true;
|
||||
public Update_1_21_9() {
|
||||
super(new Version(1, 21, 9));
|
||||
}
|
||||
|
||||
private static void doUpdate() {
|
||||
CustomAnvil.instance.getLogger().info("Updating config to support 1.21.9 ...");
|
||||
|
||||
@Override
|
||||
protected void doUpdate() {
|
||||
var baseConfig = ConfigHolder.DEFAULT_CONFIG.getConfig();
|
||||
var groupConfig = ConfigHolder.ITEM_GROUP_HOLDER.getConfig();
|
||||
|
||||
// Add mace to groups
|
||||
// Add cooper items to groups
|
||||
addAbsentToList(groupConfig, "helmets.items", "copper_helmet");
|
||||
addAbsentToList(groupConfig, "chestplate.items", "copper_chestplate");
|
||||
addAbsentToList(groupConfig, "leggings.items", "copper_leggings");
|
||||
|
|
@ -43,8 +30,8 @@ public class Update_1_21_9 {
|
|||
addAbsentToList(groupConfig, "axes.items", "copper_axe");
|
||||
addAbsentToList(groupConfig, "swords.items", "copper_sword");
|
||||
|
||||
// Set version string as 1.21
|
||||
baseConfig.set(UpdateUtils.MINECRAFT_VERSION_PATH, V1_21_9.toString());
|
||||
// Set version string as current
|
||||
baseConfig.set(UpdateUtils.MINECRAFT_VERSION_PATH, version.toString());
|
||||
|
||||
// Save
|
||||
ConfigHolder.DEFAULT_CONFIG.saveToDisk(true);
|
||||
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,79 +0,0 @@
|
|||
package xyz.alexcrea.cuanvil.update.plugin;
|
||||
|
||||
import io.delilaheve.CustomAnvil;
|
||||
import xyz.alexcrea.cuanvil.config.ConfigHolder;
|
||||
import xyz.alexcrea.cuanvil.update.UpdateUtils;
|
||||
import xyz.alexcrea.cuanvil.update.Update_1_21;
|
||||
import xyz.alexcrea.cuanvil.update.Update_1_21_9;
|
||||
import xyz.alexcrea.cuanvil.update.Version;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class PluginUpdates {
|
||||
|
||||
private static final String CONFIG_VERSION_PATH = "configVersion";
|
||||
|
||||
// Handle mc version update then plugin version update
|
||||
public static void handleUpdates() {
|
||||
handleMCVersionUpdate();
|
||||
handlePluginUpdate();
|
||||
}
|
||||
|
||||
private static final Version V1_6_2 = new Version(1, 6, 2);
|
||||
private static final Version V1_6_7 = new Version(1, 6, 7);
|
||||
private static final Version V1_8_0 = new Version(1, 8, 0);
|
||||
private static final Version V1_11_0 = new Version(1, 11, 0);
|
||||
|
||||
// Handle only plugin update
|
||||
private static void handlePluginUpdate() {
|
||||
String versionString = ConfigHolder.DEFAULT_CONFIG.getConfig().getString(CONFIG_VERSION_PATH);
|
||||
Version current = versionString == null ? new Version(0) : Version.fromString(versionString);
|
||||
|
||||
Set<ConfigHolder> toSave = new HashSet<>();
|
||||
|
||||
if (V1_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 (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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Handle minecraft version update (not plugin version update)
|
||||
public static void handleMCVersionUpdate(){
|
||||
Version current = UpdateUtils.currentMinecraftVersion();
|
||||
|
||||
boolean hadUpdate = false;
|
||||
hadUpdate |= Update_1_21.handleUpdate(current);
|
||||
hadUpdate |= Update_1_21_9.handleUpdate(current);
|
||||
|
||||
if(hadUpdate){
|
||||
CustomAnvil.instance.getLogger().info("Updating Done !");
|
||||
}
|
||||
}
|
||||
|
||||
private static void finishConfiguration(@Nonnull String newVersion, @Nonnull Set<ConfigHolder> toSave) {
|
||||
CustomAnvil.instance.getLogger().info("Configuration file updated to " + newVersion);
|
||||
ConfigHolder.DEFAULT_CONFIG.getConfig().set(CONFIG_VERSION_PATH, newVersion);
|
||||
|
||||
toSave.add(ConfigHolder.DEFAULT_CONFIG);
|
||||
for (ConfigHolder configHolder : toSave) {
|
||||
configHolder.saveToDisk(true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -10,6 +10,7 @@ import xyz.alexcrea.cuanvil.command.EditConfigExecutor
|
|||
import xyz.alexcrea.cuanvil.command.ReloadExecutor
|
||||
import xyz.alexcrea.cuanvil.config.ConfigHolder
|
||||
import xyz.alexcrea.cuanvil.dependency.DependencyManager
|
||||
import xyz.alexcrea.cuanvil.dependency.util.PlatformUtil
|
||||
import xyz.alexcrea.cuanvil.enchant.CAEnchantmentRegistry
|
||||
import xyz.alexcrea.cuanvil.gui.config.MainConfigGui
|
||||
import xyz.alexcrea.cuanvil.gui.util.GuiSharedConstant
|
||||
|
|
@ -18,8 +19,7 @@ import xyz.alexcrea.cuanvil.listener.AnvilResultListener
|
|||
import xyz.alexcrea.cuanvil.listener.ChatEventListener
|
||||
import xyz.alexcrea.cuanvil.listener.PrepareAnvilListener
|
||||
import xyz.alexcrea.cuanvil.update.PluginSetDefault
|
||||
import xyz.alexcrea.cuanvil.update.Update_1_21
|
||||
import xyz.alexcrea.cuanvil.update.plugin.PluginUpdates
|
||||
import xyz.alexcrea.cuanvil.update.UpdateHandler
|
||||
import xyz.alexcrea.cuanvil.util.Metrics
|
||||
import java.io.File
|
||||
import java.io.FileReader
|
||||
|
|
@ -64,7 +64,7 @@ open class CustomAnvil : JavaPlugin() {
|
|||
/**
|
||||
* Logging handler
|
||||
*/
|
||||
fun log(message: String) {
|
||||
@JvmStatic fun log(message: String) {
|
||||
if (ConfigOptions.debugLog) {
|
||||
instance.logger.info(message)
|
||||
}
|
||||
|
|
@ -79,7 +79,6 @@ open class CustomAnvil : JavaPlugin() {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -140,7 +139,7 @@ open class CustomAnvil : JavaPlugin() {
|
|||
}
|
||||
|
||||
// Handle minecraft and plugin updates
|
||||
PluginUpdates.handleUpdates()
|
||||
UpdateHandler.handleUpdates()
|
||||
|
||||
// Register enchantment of compatible plugin and load configuration change.
|
||||
DependencyManager.handleCompatibilityConfig()
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import xyz.alexcrea.cuanvil.api.event.CAConfigReadyEvent
|
|||
import xyz.alexcrea.cuanvil.config.ConfigHolder
|
||||
import xyz.alexcrea.cuanvil.dependency.DependencyManager
|
||||
import xyz.alexcrea.cuanvil.gui.config.global.*
|
||||
import xyz.alexcrea.cuanvil.update.plugin.PluginUpdates
|
||||
import xyz.alexcrea.cuanvil.update.UpdateHandler
|
||||
|
||||
class ReloadExecutor : CommandExecutor {
|
||||
override fun onCommand(sender: CommandSender, cmd: Command, cmdstr: String, args: Array<out String>): Boolean {
|
||||
|
|
@ -49,7 +49,7 @@ class ReloadExecutor : CommandExecutor {
|
|||
CustomRecipeConfigGui.getCurrentInstance()?.reloadValues()
|
||||
|
||||
// handle minecraft version update
|
||||
PluginUpdates.handleMCVersionUpdate()
|
||||
UpdateHandler.handleMCVersionUpdate()
|
||||
|
||||
// Handle dependency reload
|
||||
DependencyManager.handleConfigReload()
|
||||
|
|
|
|||
|
|
@ -2,11 +2,15 @@ package xyz.alexcrea.cuanvil.dependency.gui
|
|||
|
||||
import org.bukkit.craftbukkit.inventory.CraftInventoryView
|
||||
import org.bukkit.inventory.InventoryView
|
||||
import xyz.alexcrea.cuanvil.dependency.DependencyManager
|
||||
import xyz.alexcrea.cuanvil.dependency.util.PlatformUtil
|
||||
|
||||
object ExternGuiTester {
|
||||
|
||||
object Const{
|
||||
val cannonicalPaperAnvilMenu = "net.minecraft.world.inventory.AnvilMenu"
|
||||
}
|
||||
|
||||
|
||||
fun getContainerClass(view: InventoryView): Class<Any>? {
|
||||
if (view !is CraftInventoryView<*, *>) return null
|
||||
val container = view.handle
|
||||
|
|
@ -19,37 +23,9 @@ object ExternGuiTester {
|
|||
val clazz = getContainerClass(view) ?: return false
|
||||
|
||||
val clazzName = clazz.name
|
||||
//TODO maybe instead of testing non default, better to be testing we are default ?
|
||||
if (expectWesjd(clazzName)) return true
|
||||
if (expectXenondevUI(clazzName)) return true
|
||||
if (expectVanePortal(clazzName)) return true
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
fun expectWesjd(name: String): Boolean {
|
||||
val spigotVer = GuiTesterSelector.spigotVersionString
|
||||
if (spigotVer == null) return false
|
||||
|
||||
val expectedWesjdGuiPath = "anvilgui.version.Wrapper${spigotVer}"
|
||||
|
||||
return name.contains(expectedWesjdGuiPath)
|
||||
}
|
||||
|
||||
private val XenondevUIPrefix: String
|
||||
get() = "xyz.xenondevs.inventoryaccess."
|
||||
private val XenondevUISufix: String
|
||||
get() = ".AnvilInventoryImpl"
|
||||
|
||||
fun expectXenondevUI(name: String): Boolean {
|
||||
return name.startsWith(XenondevUIPrefix)
|
||||
&& name.endsWith(XenondevUISufix)
|
||||
}
|
||||
|
||||
fun expectVanePortal(name: String): Boolean {
|
||||
val expected = "org.oddlama.vane.core.menu.AnvilMenu\$AnvilContainer"
|
||||
|
||||
return name == expected
|
||||
// Only allow cannonical anvil menu class
|
||||
return !Const.cannonicalPaperAnvilMenu.equals(clazzName, true)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import java.lang.reflect.Method
|
|||
import su.nightexpress.excellentenchants.api.EnchantRegistry as V5EnchantRegistry
|
||||
import su.nightexpress.excellentenchants.manager.listener.AnvilListener as V5AnvilListener
|
||||
|
||||
//TODO newer version
|
||||
class ExcellentEnchantsDependency {
|
||||
|
||||
init {
|
||||
|
|
|
|||
|
|
@ -92,6 +92,10 @@ restriction_loyalty:
|
|||
enchantments: [ minecraft:loyalty ]
|
||||
notAffectedGroups: [ enchanted_book, trident ]
|
||||
|
||||
restriction_luck_of_the_sea:
|
||||
enchantments: [ minecraft:luck_of_the_sea ]
|
||||
notAffectedGroups: [ enchanted_book, fishing_rod ]
|
||||
|
||||
restriction_lure:
|
||||
enchantments: [ minecraft:lure ]
|
||||
notAffectedGroups: [ enchanted_book, fishing_rod ]
|
||||
|
|
|
|||
|
|
@ -29,9 +29,11 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
// TODO redo test as now color split should be handled in AnvilColorUtilTest and not here
|
||||
// Especially since some behavior changed
|
||||
public class LoreEditTests extends SharedCustomAnvilTest {
|
||||
|
||||
private static AnvilInventory anvil;
|
||||
/*private static AnvilInventory anvil;
|
||||
private static PlayerMock player;
|
||||
|
||||
private static final String COLORED_LORE_LINE = "§x§1§2§3§4§5§6TEST §atest";
|
||||
|
|
@ -615,6 +617,6 @@ public class LoreEditTests extends SharedCustomAnvilTest {
|
|||
).executeTest(anvil, player);
|
||||
}
|
||||
|
||||
//TODO work penalty test
|
||||
//TODO work penalty test*/
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue