mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-08-28 08:25:56 +02:00
Compare commits
9 commits
2a5eb8fdd7
...
eeb6dd0e57
| Author | SHA1 | Date | |
|---|---|---|---|
| eeb6dd0e57 | |||
| b7627970c1 | |||
| 96ecc93f76 | |||
| 71568f8a0b | |||
| 4291e41eaa | |||
| 58b1cb7648 | |||
| 880d8e93c7 | |||
| f1b89e9c93 | |||
| 82099277da |
33 changed files with 101 additions and 233 deletions
|
|
@ -17,7 +17,7 @@ These plugins have compatibility handled by custom anvil. seek help on custom an
|
|||
Also use ExcellentEnchant max enchant limit
|
||||
|
||||
- [EcoEnchant](https://www.spigotmc.org/resources/ecoenchants-%E2%AD%95-250-enchantments-%E2%9C%85-create-custom-enchants-%E2%9C%A8-essentials-cmi-support.79573/) by Auxilor:
|
||||
Need to use /ca reload or a server restart to add newly added enchantment.
|
||||
Need to use /anvilconfigreload or a server restart to add newly added enchantment.
|
||||
Use EcoEnchant restriction system but new restriction can be added in custom anvil
|
||||
|
||||
- [Enchantment²](https://www.spigotmc.org/resources/enchants-squared-the-enchantsplus-rewrite-custom-enchantments-that-act-like-vanilla-ones.86747/) by Athlaeos:
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ plugins {
|
|||
}
|
||||
|
||||
group = "xyz.alexcrea"
|
||||
version = "1.17.7"
|
||||
version = "1.17.6"
|
||||
|
||||
val isDevBuild = System.getenv("SMALL_COMMIT_HASH") != null
|
||||
val isPreRelease = System.getenv("IS_GITHUB_PRERELEASE") == "true"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#
|
||||
# It is recommended that you use /configanvil to edit theses config.
|
||||
# You can still manually edit here if you like to. but if you do, don't forget to /ca reload after you changes !
|
||||
# You can still manually edit here if you like to. but if you do, don't forget to /anvilconfigreload after you changes !
|
||||
#
|
||||
|
||||
# What service of metric should custom anvil use
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#
|
||||
# It is recommended that you use /configanvil to edit theses config.
|
||||
# You can still manually edit here if you like to. but if you do, don't forget to /ca reload after you changes !
|
||||
# You can still manually edit here if you like to. but if you do, don't forget to /anvilconfigreload after you changes !
|
||||
#
|
||||
|
||||
# material conflicts
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#
|
||||
# It is recommended that you use /configanvil to edit theses config.
|
||||
# You can still manually edit here if you like to. but if you do, don't forget to /ca reload after you changes !
|
||||
# You can still manually edit here if you like to. but if you do, don't forget to /anvilconfigreload after you changes !
|
||||
#
|
||||
|
||||
# Please note this config use spigot material names.
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#
|
||||
# It is recommended that you use /configanvil to edit theses config.
|
||||
# You can still manually edit here if you like to. but if you do, don't forget to /ca reload after you changes !
|
||||
# You can still manually edit here if you like to. but if you do, don't forget to /anvilconfigreload after you changes !
|
||||
#
|
||||
|
||||
# Unit repair configuration
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#
|
||||
# It is recommended that you use /configanvil to edit theses config.
|
||||
# You can still manually edit here if you like to. but if you do, don't forget to /ca reload after you changes !
|
||||
# You can still manually edit here if you like to. but if you do, don't forget to /anvilconfigreload after you changes !
|
||||
#
|
||||
|
||||
# What service of metric should custom anvil use
|
||||
|
|
@ -154,6 +154,7 @@ enchant_limits:
|
|||
minecraft:knockback: 2
|
||||
minecraft:fire_aspect: 2
|
||||
minecraft:looting: 3
|
||||
minecraft:sweeping: 3
|
||||
minecraft:sweeping_edge: 3
|
||||
minecraft:efficiency: 5
|
||||
minecraft:unbreaking: 3
|
||||
|
|
@ -292,6 +293,9 @@ enchant_values:
|
|||
minecraft:swift_sneak:
|
||||
item: 8
|
||||
book: 4
|
||||
minecraft:sweeping:
|
||||
item: 4
|
||||
book: 2
|
||||
minecraft:sweeping_edge:
|
||||
item: 4
|
||||
book: 2
|
||||
|
|
@ -485,5 +489,5 @@ debug_log_verbose: false
|
|||
# Whether to show inside the console or require to run /ca debug get
|
||||
display_debug_in_console: false
|
||||
|
||||
configVersion: 1.17.7
|
||||
configVersion: 1.15.5
|
||||
lowMinecraftVersion: 1.21.11
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#
|
||||
# It is recommended that you use /configanvil to edit theses config.
|
||||
# You can still manually edit here if you like to. but if you do, don't forget to /ca reload after you changes !
|
||||
# You can still manually edit here if you like to. but if you do, don't forget to /anvilconfigreload after you changes !
|
||||
#
|
||||
|
||||
# material conflicts
|
||||
|
|
@ -270,6 +270,7 @@ restriction_soul_speed:
|
|||
|
||||
restriction_sweeping_edge:
|
||||
enchantments:
|
||||
- minecraft:sweeping
|
||||
- minecraft:sweeping_edge
|
||||
notAffectedGroups:
|
||||
- enchanted_book
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#
|
||||
# It is recommended that you use /configanvil to edit theses config.
|
||||
# You can still manually edit here if you like to. but if you do, don't forget to /ca reload after you changes !
|
||||
# You can still manually edit here if you like to. but if you do, don't forget to /anvilconfigreload after you changes !
|
||||
#
|
||||
|
||||
# Please note this config use spigot material names.
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#
|
||||
# It is recommended that you use /configanvil to edit theses config.
|
||||
# You can still manually edit here if you like to. but if you do, don't forget to /ca reload after you changes !
|
||||
# You can still manually edit here if you like to. but if you do, don't forget to /anvilconfigreload after you changes !
|
||||
#
|
||||
|
||||
# Unit repair configuration
|
||||
|
|
@ -104,7 +104,7 @@ leather:
|
|||
phantom_membrane:
|
||||
elytra: 0.25
|
||||
|
||||
turtle_scute:
|
||||
scute:
|
||||
turtle_helmet: 0.25
|
||||
|
||||
oak_planks:
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#
|
||||
# It is recommended that you use /configanvil to edit theses config.
|
||||
# You can still manually edit here if you like to. but if you do, don't forget to /ca reload after you changes !
|
||||
# You can still manually edit here if you like to. but if you do, don't forget to /anvilconfigreload after you changes !
|
||||
#
|
||||
|
||||
# What service of metric should custom anvil use
|
||||
|
|
@ -152,6 +152,7 @@ enchant_limits:
|
|||
minecraft:knockback: 2
|
||||
minecraft:fire_aspect: 2
|
||||
minecraft:looting: 3
|
||||
minecraft:sweeping: 3
|
||||
minecraft:sweeping_edge: 3
|
||||
minecraft:efficiency: 5
|
||||
minecraft:unbreaking: 3
|
||||
|
|
@ -289,6 +290,9 @@ enchant_values:
|
|||
minecraft:swift_sneak:
|
||||
item: 8
|
||||
book: 4
|
||||
minecraft:sweeping:
|
||||
item: 4
|
||||
book: 2
|
||||
minecraft:sweeping_edge:
|
||||
item: 4
|
||||
book: 2
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#
|
||||
# It is recommended that you use /configanvil to edit theses config.
|
||||
# You can still manually edit here if you like to. but if you do, don't forget to /ca reload after you changes !
|
||||
# You can still manually edit here if you like to. but if you do, don't forget to /anvilconfigreload after you changes !
|
||||
#
|
||||
|
||||
# material conflicts
|
||||
|
|
@ -267,6 +267,7 @@ restriction_soul_speed:
|
|||
|
||||
restriction_sweeping_edge:
|
||||
enchantments:
|
||||
- minecraft:sweeping
|
||||
- minecraft:sweeping_edge
|
||||
notAffectedGroups:
|
||||
- enchanted_book
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#
|
||||
# It is recommended that you use /configanvil to edit theses config.
|
||||
# You can still manually edit here if you like to. but if you do, don't forget to /ca reload after you changes !
|
||||
# You can still manually edit here if you like to. but if you do, don't forget to /anvilconfigreload after you changes !
|
||||
#
|
||||
|
||||
# Please note this config use spigot material names.
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#
|
||||
# It is recommended that you use /configanvil to edit theses config.
|
||||
# You can still manually edit here if you like to. but if you do, don't forget to /ca reload after you changes !
|
||||
# You can still manually edit here if you like to. but if you do, don't forget to /anvilconfigreload after you changes !
|
||||
#
|
||||
|
||||
# Unit repair configuration
|
||||
|
|
@ -98,7 +98,7 @@ leather:
|
|||
phantom_membrane:
|
||||
elytra: 0.25
|
||||
|
||||
turtle_scute:
|
||||
scute:
|
||||
turtle_helmet: 0.25
|
||||
|
||||
oak_planks:
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#
|
||||
# It is recommended that you use /configanvil to edit theses config.
|
||||
# You can still manually edit here if you like to. but if you do, don't forget to /ca reload after you changes !
|
||||
# You can still manually edit here if you like to. but if you do, don't forget to /anvilconfigreload after you changes !
|
||||
#
|
||||
|
||||
# What service of metric should custom anvil use
|
||||
|
|
@ -152,6 +152,7 @@ enchant_limits:
|
|||
minecraft:knockback: 2
|
||||
minecraft:fire_aspect: 2
|
||||
minecraft:looting: 3
|
||||
minecraft:sweeping: 3
|
||||
minecraft:sweeping_edge: 3
|
||||
minecraft:efficiency: 5
|
||||
minecraft:unbreaking: 3
|
||||
|
|
@ -286,6 +287,9 @@ enchant_values:
|
|||
minecraft:swift_sneak:
|
||||
item: 8
|
||||
book: 4
|
||||
minecraft:sweeping:
|
||||
item: 4
|
||||
book: 2
|
||||
minecraft:sweeping_edge:
|
||||
item: 4
|
||||
book: 2
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#
|
||||
# It is recommended that you use /configanvil to edit theses config.
|
||||
# You can still manually edit here if you like to. but if you do, don't forget to /ca reload after you changes !
|
||||
# You can still manually edit here if you like to. but if you do, don't forget to /anvilconfigreload after you changes !
|
||||
#
|
||||
|
||||
# material conflicts
|
||||
|
|
@ -157,10 +157,13 @@ restriction_soul_speed:
|
|||
notAffectedGroups: [ enchanted_book, boots ]
|
||||
|
||||
restriction_sweeping_edge:
|
||||
enchantments: [ minecraft:sweeping_edge ]
|
||||
enchantments: [ minecraft:sweeping, minecraft:sweeping_edge ]
|
||||
notAffectedGroups: [ enchanted_book, swords ]
|
||||
|
||||
# Do not exist in 1.18, that mean useInFuture will be set to true
|
||||
# useInFuture set to true also mean it will not warn if there is an issue
|
||||
restriction_swift_sneak:
|
||||
useInFuture: true
|
||||
enchantments: [ minecraft:swift_sneak ]
|
||||
notAffectedGroups: [ enchanted_book, leggings ]
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#
|
||||
# It is recommended that you use /configanvil to edit theses config.
|
||||
# You can still manually edit here if you like to. but if you do, don't forget to /ca reload after you changes !
|
||||
# You can still manually edit here if you like to. but if you do, don't forget to /anvilconfigreload after you changes !
|
||||
#
|
||||
|
||||
# Please note this config use spigot material names.
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#
|
||||
# It is recommended that you use /configanvil to edit theses config.
|
||||
# You can still manually edit here if you like to. but if you do, don't forget to /ca reload after you changes !
|
||||
# You can still manually edit here if you like to. but if you do, don't forget to /anvilconfigreload after you changes !
|
||||
#
|
||||
|
||||
# Unit repair configuration
|
||||
|
|
@ -98,7 +98,7 @@ leather:
|
|||
phantom_membrane:
|
||||
elytra: 0.25
|
||||
|
||||
turtle_scute:
|
||||
scute:
|
||||
turtle_helmet: 0.25
|
||||
|
||||
oak_planks:
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package xyz.alexcrea.cuanvil.gui.config.global;
|
||||
|
||||
import com.github.stefvanschie.inventoryframework.gui.GuiItem;
|
||||
import com.github.stefvanschie.inventoryframework.gui.type.util.Gui;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemFlag;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
|
@ -41,10 +40,6 @@ public class CustomRecipeConfigGui extends MappedGuiListConfigGui<AnvilCustomRec
|
|||
init();
|
||||
}
|
||||
|
||||
public CustomRecipeConfigGui(Gui parent) {
|
||||
super("Custom Recipe Config", parent);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ItemStack createItemForGeneric(AnvilCustomRecipe recipe) {
|
||||
// Get base item to display
|
||||
|
|
|
|||
|
|
@ -9,14 +9,8 @@ import org.bukkit.Material;
|
|||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import xyz.alexcrea.cuanvil.config.ConfigHolder;
|
||||
import xyz.alexcrea.cuanvil.gui.util.GuiGlobalActions;
|
||||
import xyz.alexcrea.cuanvil.gui.util.GuiGlobalItems;
|
||||
import xyz.alexcrea.cuanvil.util.CasedStringUtil;
|
||||
import xyz.alexcrea.cuanvil.util.MaterialUtil;
|
||||
import xyz.alexcrea.cuanvil.util.UnitRepairUtil;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
|
|
@ -27,8 +21,8 @@ public class ItemConfigGui extends ChestGui {
|
|||
public UnitRepairConfigGui unitRepairConfigGui;
|
||||
public CustomRecipeConfigGui customRecipeConfigGui;
|
||||
|
||||
public ItemConfigGui(@NotNull Material display, @NotNull NamespacedKey material) {
|
||||
super(3, CasedStringUtil.snakeToUpperSpacedCase(material.getKey().toLowerCase()) + " Config", CustomAnvil.instance);
|
||||
public ItemConfigGui(Material display, NamespacedKey material) {
|
||||
super(3, material.getKey() + " Config", CustomAnvil.instance);
|
||||
|
||||
Pattern pattern = new Pattern(
|
||||
"0000D0000",
|
||||
|
|
@ -82,7 +76,8 @@ public class ItemConfigGui extends ChestGui {
|
|||
unitRepairMeta.setLore(Collections.singletonList("§7Click here to open anvil unit repair menu"));
|
||||
unirRepairItemstack.setItemMeta(unitRepairMeta);
|
||||
|
||||
GuiItem unitRepairItem = GuiGlobalItems.goToGuiItem(unirRepairItemstack, getUnitRepairConfigGui(material));
|
||||
//TODO
|
||||
GuiItem unitRepairItem = GuiGlobalItems.goToGuiItem(unirRepairItemstack, UnitRepairConfigGui.getInstance());
|
||||
pane.bindItem('7', unitRepairItem);
|
||||
|
||||
// Custom recipe item
|
||||
|
|
@ -94,11 +89,12 @@ public class ItemConfigGui extends ChestGui {
|
|||
customRecipeMeta.setLore(Collections.singletonList("§7Click here to open anvil custom recipe menu"));
|
||||
customRecipeItemstack.setItemMeta(customRecipeMeta);
|
||||
|
||||
GuiItem customRecipeItem = GuiGlobalItems.goToGuiItem(customRecipeItemstack, getCustomRecipeConfigGui(material));
|
||||
//TODO
|
||||
GuiItem customRecipeItem = GuiGlobalItems.goToGuiItem(customRecipeItemstack, CustomRecipeConfigGui.getInstance());
|
||||
pane.bindItem('8', customRecipeItem);
|
||||
}
|
||||
|
||||
private EnchantConflictGui getEnchantConflictGui(@NotNull NamespacedKey material) {
|
||||
private EnchantConflictGui getEnchantConflictGui(NamespacedKey material) {
|
||||
if (enchantConflictGui == null) {
|
||||
enchantConflictGui = new EnchantConflictGui(this);
|
||||
enchantConflictGui.setFilter(group ->
|
||||
|
|
@ -110,7 +106,7 @@ public class ItemConfigGui extends ChestGui {
|
|||
return enchantConflictGui;
|
||||
}
|
||||
|
||||
private GroupConfigGui getGroupConfigGui(@NotNull NamespacedKey material) {
|
||||
private GroupConfigGui getGroupConfigGui(NamespacedKey material) {
|
||||
if (groupConfigGui == null) {
|
||||
groupConfigGui = new GroupConfigGui(this);
|
||||
groupConfigGui.setFilter(group ->
|
||||
|
|
@ -122,38 +118,16 @@ public class ItemConfigGui extends ChestGui {
|
|||
return groupConfigGui;
|
||||
}
|
||||
|
||||
private UnitRepairConfigGui getUnitRepairConfigGui(@NotNull NamespacedKey material) {
|
||||
/*private UnitRepairConfigGui getUnitRepairConfigGui(NamespacedKey material) {
|
||||
if (unitRepairConfigGui == null) {
|
||||
unitRepairConfigGui = new UnitRepairConfigGui(this);
|
||||
unitRepairConfigGui.setFilter(otherMat ->
|
||||
otherMat.equals(material) || UnitRepairUtil.INSTANCE.findRawRepairValue(
|
||||
material, otherMat, ConfigHolder.UNIT_REPAIR_HOLDER.getConfig()) != null
|
||||
group.contain(material) //TODO check material & what inside
|
||||
);
|
||||
unitRepairConfigGui.init();
|
||||
}
|
||||
|
||||
return unitRepairConfigGui;
|
||||
}
|
||||
|
||||
private CustomRecipeConfigGui getCustomRecipeConfigGui(@NotNull NamespacedKey material) {
|
||||
if (customRecipeConfigGui == null) {
|
||||
customRecipeConfigGui = new CustomRecipeConfigGui(this);
|
||||
customRecipeConfigGui.setFilter(recipe -> {
|
||||
if(isMaterial(recipe.getLeftItem(), material)) return true;
|
||||
if(isMaterial(recipe.getRightItem(), material)) return true;
|
||||
return isMaterial(recipe.getResultItem(), material);
|
||||
}
|
||||
);
|
||||
customRecipeConfigGui.init();
|
||||
}
|
||||
|
||||
return customRecipeConfigGui;
|
||||
}
|
||||
|
||||
private boolean isMaterial(@Nullable ItemStack item, @NotNull NamespacedKey material) {
|
||||
if(item == null) return false;
|
||||
|
||||
return material.equals(MaterialUtil.INSTANCE.getCustomType(item));
|
||||
}
|
||||
}*/
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ public class UnitRepairConfigGui extends
|
|||
protected ItemStack createItemForGeneric(@NotNull NamespacedKey material) {
|
||||
var unitConfig = ConfigHolder.UNIT_REPAIR_HOLDER.getConfig();
|
||||
var section = unitConfig.getConfigurationSection(material.toString().toLowerCase());
|
||||
var legacySection = unitConfig.getConfigurationSection(material.getKey().toLowerCase());
|
||||
var legacySection = unitConfig.getConfigurationSection(material.toString().toLowerCase());
|
||||
|
||||
String materialName = CasedStringUtil.snakeToUpperSpacedCase(material.getKey().toLowerCase());
|
||||
|
||||
|
|
|
|||
|
|
@ -37,7 +37,6 @@ public abstract class ElementListConfigGui<T> extends ChestGui implements ValueU
|
|||
protected PatternPane backgroundPane;
|
||||
|
||||
private Predicate<T> filter = (t) -> true;
|
||||
private boolean hasDefaultFilter = true;
|
||||
|
||||
protected ElementListConfigGui(@NotNull String title, Gui parent) {
|
||||
super(6, title, CustomAnvil.instance);
|
||||
|
|
@ -52,7 +51,6 @@ public abstract class ElementListConfigGui<T> extends ChestGui implements ValueU
|
|||
|
||||
public void setFilter(Predicate<T> filter) {
|
||||
this.filter = filter;
|
||||
this.hasDefaultFilter = false;
|
||||
}
|
||||
|
||||
protected Pattern getBackgroundPattern() {
|
||||
|
|
@ -121,12 +119,7 @@ public abstract class ElementListConfigGui<T> extends ChestGui implements ValueU
|
|||
viewer.setItemOnCursor(cursor);
|
||||
}, CustomAnvil.instance);
|
||||
|
||||
GuiItem createNew;
|
||||
if(hasDefaultFilter)
|
||||
createNew = prepareCreateNewItem();
|
||||
else
|
||||
createNew = GuiSharedConstant.SECONDARY_BACKGROUND_ITEM;
|
||||
|
||||
GuiItem createNew = prepareCreateNewItem();
|
||||
if (createNew != null) {
|
||||
this.backgroundPane.bindItem('C', createNew);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,10 @@ package xyz.alexcrea.cuanvil.update;
|
|||
|
||||
import io.delilaheve.CustomAnvil;
|
||||
import xyz.alexcrea.cuanvil.config.ConfigHolder;
|
||||
import xyz.alexcrea.cuanvil.update.minecraft.*;
|
||||
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;
|
||||
|
|
@ -29,12 +32,10 @@ public class UpdateHandler {
|
|||
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,
|
||||
new Version(1, 15, 6), PUpdate_1_15_6::handleUpdate,
|
||||
new Version(1, 17, 7), PUpdate_1_17_7::handleUpdate
|
||||
new Version(1, 15, 6), PUpdate_1_15_6::handleUpdate
|
||||
);
|
||||
|
||||
private static final List<MCUpdate> mcUpdateMap = List.of(
|
||||
new Update_1_20_5(),
|
||||
new Update_1_21(),
|
||||
new Update_1_21_9(),
|
||||
new Update_1_21_11()
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package xyz.alexcrea.cuanvil.update;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
|
@ -34,20 +33,4 @@ 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));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,98 +0,0 @@
|
|||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -613,9 +613,20 @@ object ConfigOptions {
|
|||
* Get default value if enchantment do not exist on config
|
||||
*/
|
||||
private fun getDefaultValue(
|
||||
enchantment: CAEnchantment,
|
||||
enchantment: CAEnchantment, // compatibility with 1.20.5. TODO better update system
|
||||
isFromBook: Boolean
|
||||
): Int {
|
||||
|
||||
val enchantmentName = enchantment.key.toString()
|
||||
if (enchantmentName == "minecraft:sweeping_edge") {
|
||||
var limit = enchantmentValue("minecraft:sweeping", isFromBook)
|
||||
if (limit != null) return limit
|
||||
|
||||
// legacy name
|
||||
limit = enchantmentValue("sweeping", isFromBook)
|
||||
if (limit != null) return limit
|
||||
}
|
||||
|
||||
val rarity = enchantment.defaultRarity()
|
||||
return if (isFromBook)
|
||||
rarity.bookValue
|
||||
|
|
@ -637,6 +648,15 @@ object ConfigOptions {
|
|||
value = maxBeforeMergeDisabled(legacy)
|
||||
if (value >= 0) return value
|
||||
|
||||
if (key == "minecraft:sweeping_edge") {
|
||||
value = maxBeforeMergeDisabled("minecraft:sweeping")
|
||||
if (value >= 0) return value
|
||||
|
||||
// legacy name of legacy enchantment name
|
||||
value = maxBeforeMergeDisabled("sweeping")
|
||||
if (value >= 0) return value
|
||||
}
|
||||
|
||||
return DEFAULT_MAX_BEFORE_MERGE_DISABLED
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -39,6 +39,13 @@ class EnchantConflictManager {
|
|||
|
||||
// Default name for a joining group
|
||||
const val DEFAULT_GROUP_NAME = "joinedGroup"
|
||||
|
||||
// 1.20.5 compatibility TODO better update system
|
||||
private val SWEEPING_EDGE_ENCHANT = Collections.singletonList<CAEnchantment>(
|
||||
CAEnchantment.getByKey(NamespacedKey.minecraft("sweeping_edge"))
|
||||
?: CAEnchantment.getByKey(Enchantment.SWEEPING_EDGE.key)
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
lateinit var conflictList: ArrayList<EnchantConflictGroup>
|
||||
|
|
@ -165,6 +172,14 @@ class EnchantConflictManager {
|
|||
|
||||
}
|
||||
|
||||
// Temporary solution for 1.20.5
|
||||
when (enchantName) {
|
||||
"minecraft:sweeping", "sweeping",
|
||||
"minecraft:sweeping_edge", "sweeping_edge" -> {
|
||||
return SWEEPING_EDGE_ENCHANT
|
||||
}
|
||||
}
|
||||
|
||||
return CAEnchantment.getListByName(enchantName)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ object UnitRepairUtil {
|
|||
if (other == null) return null
|
||||
val config = ConfigHolder.UNIT_REPAIR_HOLDER.config
|
||||
|
||||
val result = findRawRepairValue(this, other, config) ?: return null
|
||||
val result = findRepairValue(this, other, config) ?: return null
|
||||
|
||||
if(result > 0) return result
|
||||
|
||||
|
|
@ -36,7 +36,7 @@ object UnitRepairUtil {
|
|||
return userDefault
|
||||
}
|
||||
|
||||
private fun findRawRepairValue(
|
||||
private fun findRepairValue(
|
||||
self: ItemStack,
|
||||
other: ItemStack,
|
||||
config: FileConfiguration
|
||||
|
|
@ -50,17 +50,6 @@ object UnitRepairUtil {
|
|||
return checkSection(config, material.key, selfType)
|
||||
}
|
||||
|
||||
fun findRawRepairValue(
|
||||
self: NamespacedKey,
|
||||
other: NamespacedKey,
|
||||
config: FileConfiguration
|
||||
): Double? {
|
||||
val result = checkSection(config, other.toString(), self)
|
||||
if (result != null) return result
|
||||
|
||||
return checkSection(config, other.key, self)
|
||||
}
|
||||
|
||||
fun checkSection(
|
||||
config: FileConfiguration,
|
||||
path: String,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#
|
||||
# It is recommended that you use /configanvil to edit most of these config.
|
||||
# You can still manually edit here if you like to. but if you do, don't forget to /ca reload after you changes !
|
||||
# You can still manually edit here if you like to. but if you do, don't forget to /anvilconfigreload after you changes !
|
||||
#
|
||||
|
||||
# What service of metric should custom anvil use
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#
|
||||
# It is recommended that you use /configanvil to edit theses config.
|
||||
# You can still manually edit here if you like to. but if you do, don't forget to /ca reload after you changes !
|
||||
# You can still manually edit here if you like to. but if you do, don't forget to /anvilconfigreload after you changes !
|
||||
#
|
||||
|
||||
# material conflicts
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#
|
||||
# It is recommended that you use /configanvil to edit theses config.
|
||||
# You can still manually edit here if you like to. but if you do, don't forget to /ca reload after you changes !
|
||||
# You can still manually edit here if you like to. but if you do, don't forget to /anvilconfigreload after you changes !
|
||||
#
|
||||
|
||||
# Please note this config use spigot material names.
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#
|
||||
# It is recommended that you use /configanvil to edit theses config.
|
||||
# You can still manually edit here if you like to. but if you do, don't forget to /ca reload after you changes !
|
||||
# You can still manually edit here if you like to. but if you do, don't forget to /anvilconfigreload after you changes !
|
||||
#
|
||||
|
||||
# Unit repair configuration
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue