diff --git a/src/main/java/xyz/alexcrea/cuanvil/api/AnvilRecipeBuilder.java b/src/main/java/xyz/alexcrea/cuanvil/api/AnvilRecipeBuilder.java index 4292fa0..48c3a23 100644 --- a/src/main/java/xyz/alexcrea/cuanvil/api/AnvilRecipeBuilder.java +++ b/src/main/java/xyz/alexcrea/cuanvil/api/AnvilRecipeBuilder.java @@ -68,7 +68,7 @@ public class AnvilRecipeBuilder { * Get if the recipe is exact count. (default 0) *

* Exact count mean the recipe can only be crafted 1 by 1. - * If set to false, then it will craft as much as possible in 1 go and will keep unused material onto the anvil inventory. + * If set to false, then it will craft as much as possible in 1 go and will keep unused items onto the anvil inventory. * * @return If the recipe is exact count. */ @@ -80,7 +80,7 @@ public class AnvilRecipeBuilder { * Sets if the recipe is exact count. *

* Exact count mean the recipe can only be crafted 1 by 1. - * If set to false, then it will craft as much as possible in 1 go and will keep unused material onto the anvil inventory. + * If set to false, then it will craft as much as possible in 1 go and will keep unused items onto the anvil inventory. * * @param exactCount If the recipe is exact count * @return This recipe builder instance. diff --git a/src/main/java/xyz/alexcrea/cuanvil/api/ConflictBuilder.java b/src/main/java/xyz/alexcrea/cuanvil/api/ConflictBuilder.java index 77479d2..284f659 100644 --- a/src/main/java/xyz/alexcrea/cuanvil/api/ConflictBuilder.java +++ b/src/main/java/xyz/alexcrea/cuanvil/api/ConflictBuilder.java @@ -14,7 +14,7 @@ import java.util.List; import java.util.Set; /** - * A Builder for material conflict. + * A Builder for enchantment conflicts. */ @SuppressWarnings("unused") public class ConflictBuilder { @@ -135,7 +135,7 @@ public class ConflictBuilder { * This value represent how many enchantment contained on this conflict can be applied to before conflict is considered active. * That mean new enchantment will not be able to be added to the item and present enchantment will not have its level upgraded. *

- * In vanilla. material restriction have this value set to 0 and enchantment conflict set to 1. + * In vanilla. item type restriction have this value set to 0 and exclusive set conflict set to 1. * * @return the max number of conflicting enchantment before conflict. 0 by default. */ @@ -160,7 +160,7 @@ public class ConflictBuilder { * This value represent how many enchantment contained on this conflict can be applied to before conflict is considered active. * That mean new enchantment will not be able to be added to the item and present enchantment will not have its level upgraded. *

- * In vanilla. material restriction have this value set to 0 and enchantment conflict set to 1. + * In vanilla. item type restriction have this value set to 0 and exclusive set conflict set to 1. * * @param maxBeforeConflict The max before conflict * @return This conflict builder instance. @@ -246,9 +246,9 @@ public class ConflictBuilder { *

* If left item of an anvil craft is included on one of the excluded group it will ignore this conflict. *

- * This allows to create conflict only for some item. Material restriction can be written like that. + * This allows to create conflict only for some item. Item type restriction can be written like that. *

- * For example: If we exclude a material group containing every pickaxe and add efficiency enchantment + * For example: If we exclude an item group containing every pickaxe and add efficiency enchantment * with {@link #setMaxBeforeConflict(int) maxBeforeConflict} set to 0. * Then only pickaxe will be able to have efficiency. * @@ -266,9 +266,9 @@ public class ConflictBuilder { *

* If left item of an anvil craft is included on one of the excluded group it will ignore this conflict. *

- * This allows to create conflict only for some item. Material restriction can be written like that. - *

- * For example: If we exclude a material group containing every pickaxe and add efficiency enchantment + * This allows to create conflict only for some item. Item type restriction can be written like that. +n *

+ * For example: If we exclude an item group containing every pickaxe and add efficiency enchantment * with {@link #setMaxBeforeConflict(int) maxBeforeConflict} set to 0. * Then only pickaxe will be able to have efficiency. * @@ -285,9 +285,9 @@ public class ConflictBuilder { *

* If left item of an anvil craft is included on one of the excluded group it will ignore this conflict. *

- * This allows to create conflict only for some item. Material restriction can be written like that. + * This allows to create conflict only for some item. Item type restriction can be written like that. *

- * For example: If we exclude a material group containing every pickaxe and add efficiency enchantment + * For example: If we exclude an item group containing every pickaxe and add efficiency enchantment * with {@link #setMaxBeforeConflict(int) maxBeforeConflict} set to 0. * Then only pickaxe will be able to have efficiency. * @@ -305,9 +305,9 @@ public class ConflictBuilder { *

* If left item of an anvil craft is included on one of the excluded group it will ignore this conflict. *

- * This allows to create conflict only for some item. Material restriction can be written like that. + * This allows to create conflict only for some item. Item type restriction can be written like that. *

- * For example: If we exclude a material group containing every pickaxe and add efficiency enchantment + * For example: If we exclude an item group containing every pickaxe and add efficiency enchantment * with {@link #setMaxBeforeConflict(int) maxBeforeConflict} set to 0. * Then only pickaxe will be able to have efficiency. * @@ -432,9 +432,9 @@ public class ConflictBuilder { } /** - * Extract group abstract material group. + * Extract group abstract item group. * - * @return The abstract material group from the builder. + * @return The abstract item group from the builder. */ protected AbstractItemTypeGroup extractGroups() { ItemGroupManager itemGroupManager = ConfigHolder.ITEM_GROUP_HOLDER.getItemGroupsManager(); diff --git a/src/main/java/xyz/alexcrea/cuanvil/api/MaterialGroupApi.java b/src/main/java/xyz/alexcrea/cuanvil/api/ItemGroupApi.java similarity index 81% rename from src/main/java/xyz/alexcrea/cuanvil/api/MaterialGroupApi.java rename to src/main/java/xyz/alexcrea/cuanvil/api/ItemGroupApi.java index 88fa7cd..095d3b5 100644 --- a/src/main/java/xyz/alexcrea/cuanvil/api/MaterialGroupApi.java +++ b/src/main/java/xyz/alexcrea/cuanvil/api/ItemGroupApi.java @@ -20,12 +20,12 @@ import java.util.Map; import java.util.Set; /** - * Custom Anvil api for material group registry. + * Custom Anvil api for item group registry. */ @SuppressWarnings({"unused"}) -public class MaterialGroupApi { +public class ItemGroupApi { - private MaterialGroupApi() { + private ItemGroupApi() { } private static Object saveChangeTask = null; @@ -39,8 +39,8 @@ public class MaterialGroupApi { * @param group The group to add * @return true if successful. */ - public static boolean addMaterialGroup(@NotNull AbstractItemTypeGroup group) { - return addMaterialGroup(group, false); + public static boolean addItemGroup(@NotNull AbstractItemTypeGroup group) { + return addItemGroup(group, false); } /** @@ -52,7 +52,7 @@ public class MaterialGroupApi { * @param overrideDeleted If we should write even if the group was previously deleted. * @return true if successful. */ - public static boolean addMaterialGroup(@NotNull AbstractItemTypeGroup group, boolean overrideDeleted) { + public static boolean addItemGroup(@NotNull AbstractItemTypeGroup group, boolean overrideDeleted) { ItemGroupManager itemGroupManager = ConfigHolder.ITEM_GROUP_HOLDER.getItemGroupsManager(); // Test if it exists/existed @@ -62,7 +62,7 @@ public class MaterialGroupApi { // Add group itemGroupManager.getGroupMap().put(group.getName(), group); - if (!writeMaterialGroup(group, false)) return false; + if (!writeItemGroup(group, false)) return false; if (group instanceof IncludeItemTypeGroup includeGroup) { GroupConfigGui configGui = GroupConfigGui.getCurrentInstance(); @@ -77,27 +77,27 @@ public class MaterialGroupApi { } /** - * Write a material group to the config file and plan an update of groups. + * Write an item group to the config file and plan an update of groups. *

- * You may want to use {@link #addMaterialGroup(AbstractItemTypeGroup)} instead as it is more performance in most case as this function will reload every conflict. + * You may want to use {@link #addItemGroup(AbstractItemTypeGroup)} instead as it is more performance in most case as this function will reload every conflict. * * @param group the group to write * @return true if was written successfully. */ - public static boolean writeMaterialGroup(@NotNull AbstractItemTypeGroup group) { - return writeMaterialGroup(group, true); + public static boolean writeItemGroup(@NotNull AbstractItemTypeGroup group) { + return writeItemGroup(group, true); } /** - * Write a material group to the config file. + * Write an item group to the config file. *

- * You should use {@link #addMaterialGroup(AbstractItemTypeGroup)} or {@link #writeMaterialGroup(AbstractItemTypeGroup)} instead + * You should use {@link #addItemGroup(AbstractItemTypeGroup)} or {@link #writeItemGroup(AbstractItemTypeGroup)} instead * * @param group the group to write - * @param updatePlanned if we should plan a global update for material groups + * @param updatePlanned if we should plan a global update for item groups * @return true if was written successfully. */ - public static boolean writeMaterialGroup(@NotNull AbstractItemTypeGroup group, boolean updatePlanned) { + public static boolean writeItemGroup(@NotNull AbstractItemTypeGroup group, boolean updatePlanned) { String name = group.getName(); if (name.contains(".")) { CustomAnvil.instance.getLogger().warning("Group " + name + " contain . in its name but should not. this material group is ignored."); @@ -127,18 +127,18 @@ public class MaterialGroupApi { FileConfiguration config = ConfigHolder.ITEM_GROUP_HOLDER.getConfig(); String basePath = group.getName() + "."; - Set itemSets = group.getNonGroupInheritedMaterials(); + Set itemSets = group.getNonGroupInheritedItemTypes(); Set groupSet = group.getGroups(); boolean empty = true; if (!itemSets.isEmpty()) { - config.set(basePath + ItemGroupManager.MATERIAL_LIST_PATH, itemTypesSetToStringList(itemSets)); + config.set(basePath + ItemGroupManager.ITEMS_LIST_PATH, itemTypesSetToStringList(itemSets)); empty = false; } else { - config.set(basePath + ItemGroupManager.MATERIAL_LIST_PATH, null); + config.set(basePath + ItemGroupManager.ITEMS_LIST_PATH, null); } if (!groupSet.isEmpty()) { - config.set(basePath + ItemGroupManager.GROUP_LIST_PATH, materialGroupSetToStringList(groupSet)); + config.set(basePath + ItemGroupManager.GROUP_LIST_PATH, itemGroupSetToStringList(groupSet)); empty = false; } else { config.set(basePath + ItemGroupManager.GROUP_LIST_PATH, null); @@ -162,7 +162,7 @@ public class MaterialGroupApi { if (itemTypes.isEmpty()) return false; config.set(basePath + ItemGroupManager.GROUP_TYPE_PATH, "include"); - config.set(basePath + ItemGroupManager.MATERIAL_LIST_PATH, itemTypesSetToStringList(itemTypes)); + config.set(basePath + ItemGroupManager.ITEMS_LIST_PATH, itemTypesSetToStringList(itemTypes)); return true; } @@ -171,13 +171,13 @@ public class MaterialGroupApi { return types.stream().map(item -> item.getKey().toString()).toList(); } - public static List materialGroupSetToStringList(@NotNull Set groups) { + public static List itemGroupSetToStringList(@NotNull Set groups) { return groups.stream().map(AbstractItemTypeGroup::getName).toList(); } /** - * Remove a material group. - * Caution ! It will not be removed from depending conflict or other material group at runtime. + * Remove an item group. + * Caution ! It will not be removed from depending conflict or other item groups at runtime. * For that reason, it is not recommended to use this function. * * @param group The recipe to remove @@ -242,7 +242,7 @@ public class MaterialGroupApi { } /** - * Get every registered material groups. + * Get every registered item groups. * * @return An immutable map of group name as its key and group as mapped value. */ diff --git a/src/main/java/xyz/alexcrea/cuanvil/api/UnitRepairApi.java b/src/main/java/xyz/alexcrea/cuanvil/api/UnitRepairApi.java index 4752095..4028095 100644 --- a/src/main/java/xyz/alexcrea/cuanvil/api/UnitRepairApi.java +++ b/src/main/java/xyz/alexcrea/cuanvil/api/UnitRepairApi.java @@ -44,7 +44,7 @@ public class UnitRepairApi { * Write and add a custom anvil unit repair recipe. * Will not write the recipe if it already exists or was deleted. * - * @param unit The unit material used to repair the bellow item. + * @param unit The unit type used to repair the bellow item. * @param repairable The item to be repaired. * @param value The amount to be repaired by every unit. (1% = 0.01) * @return true if successful. @@ -201,7 +201,7 @@ public class UnitRepairApi { // Test if value section exist if (!section.isDouble(repairableKey)) continue; - // Test if repairable is valid a material + // Test if repairable is valid a item type ItemType repairable = ItemTypeUtil.INSTANCE.getItemType(repairableKey); if (repairable == null) continue; diff --git a/src/main/java/xyz/alexcrea/cuanvil/api/event/CAConfigReadyEvent.java b/src/main/java/xyz/alexcrea/cuanvil/api/event/CAConfigReadyEvent.java index ac73d0c..0abefa9 100644 --- a/src/main/java/xyz/alexcrea/cuanvil/api/event/CAConfigReadyEvent.java +++ b/src/main/java/xyz/alexcrea/cuanvil/api/event/CAConfigReadyEvent.java @@ -3,6 +3,7 @@ package xyz.alexcrea.cuanvil.api.event; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; import org.jetbrains.annotations.NotNull; +import xyz.alexcrea.cuanvil.api.ItemGroupApi; /** * Called when the configuration of CustomAnvil is ready. @@ -17,7 +18,7 @@ import org.jetbrains.annotations.NotNull; *

* use {@link xyz.alexcrea.cuanvil.api.ConflictAPI ConflictApi}, * {@link xyz.alexcrea.cuanvil.gui.config.global.CustomRecipeConfigGui CustomRecipeConfigGui}, - * {@link xyz.alexcrea.cuanvil.api.MaterialGroupApi MaterialGroupApi} + * {@link ItemGroupApi MaterialGroupApi} * and {@link xyz.alexcrea.cuanvil.api.UnitRepairApi UnitRepairApi} * to add/remove/edit configurations */ diff --git a/src/main/java/xyz/alexcrea/cuanvil/gui/config/SelectItemTypeContainer.java b/src/main/java/xyz/alexcrea/cuanvil/gui/config/SelectItemTypeContainer.java index 58e065e..a808303 100644 --- a/src/main/java/xyz/alexcrea/cuanvil/gui/config/SelectItemTypeContainer.java +++ b/src/main/java/xyz/alexcrea/cuanvil/gui/config/SelectItemTypeContainer.java @@ -11,17 +11,17 @@ import java.util.Set; @SuppressWarnings("UnstableApiUsage") public interface SelectItemTypeContainer { - Set getSelectedMaterials(); + Set getSelectedItems(); boolean setSelectedItems(Set types); - Set illegalMaterials(); + Set illegalItems(); - static List getMaterialLore(SelectItemTypeContainer container, String containerType, String action) { + static List getItemLore(SelectItemTypeContainer container, String containerType, String action) { // Prepare material lore ArrayList groupLore = new ArrayList<>(); groupLore.add("§7Allow you to select a list of §ematerials §7that this " + containerType + " should " + action); - Set typeSet = container.getSelectedMaterials(); + Set typeSet = container.getSelectedItems(); if (typeSet.isEmpty()) { groupLore.add("§7There is no " + action + "d material for this " + containerType + "."); } else { diff --git a/src/main/java/xyz/alexcrea/cuanvil/gui/config/ask/SelectItemTypeGui.java b/src/main/java/xyz/alexcrea/cuanvil/gui/config/ask/SelectItemTypeGui.java index a8f2023..50c610b 100644 --- a/src/main/java/xyz/alexcrea/cuanvil/gui/config/ask/SelectItemTypeGui.java +++ b/src/main/java/xyz/alexcrea/cuanvil/gui/config/ask/SelectItemTypeGui.java @@ -25,7 +25,7 @@ public class SelectItemTypeGui extends AbstractAskGui { @NotNull String actionDescription, @NotNull Gui backOnCancel, @NotNull BiConsumer onSave, - boolean materialOnly) { + boolean typeOnly) { super(3, title, backOnCancel); this.selectedItem = null; @@ -56,7 +56,7 @@ public class SelectItemTypeGui extends AbstractAskGui { if(cursor.getType().isAir()) return; ItemStack finalItem; - if(materialOnly){ + if(typeOnly){ finalItem = setDisplayMeta( cursor.getType().asItemType().createItemStack(), actionDescription); diff --git a/src/main/java/xyz/alexcrea/cuanvil/gui/config/global/EnchantConflictGui.java b/src/main/java/xyz/alexcrea/cuanvil/gui/config/global/EnchantConflictGui.java index 065538b..f3d234c 100644 --- a/src/main/java/xyz/alexcrea/cuanvil/gui/config/global/EnchantConflictGui.java +++ b/src/main/java/xyz/alexcrea/cuanvil/gui/config/global/EnchantConflictGui.java @@ -70,7 +70,7 @@ public class EnchantConflictGui extends MappedGuiListConfigGui { ItemMeta meta = itemStack.getItemMeta(); @@ -103,7 +103,7 @@ public class UnitRepairElementListGui extends @Override protected String createItemName() { - return "§aAdd a new item reparable by " + this.materialName; + return "§aAdd a new item reparable by " + this.typeName; } @Override @@ -117,7 +117,7 @@ public class UnitRepairElementListGui extends this.parentType.getKey() + "." + type.getKey(), Arrays.asList( "§7Click here to change how many §e% §7of §a" + materialDisplayName, - "§7Should get repaired by §e" + this.materialName + "§7Should get repaired by §e" + this.typeName ), 2, true, true, @@ -134,15 +134,15 @@ public class UnitRepairElementListGui extends @Override protected GuiItem itemFromFactory(ItemType type, DoubleSettingGui.DoubleSettingFactory factory) { return factory.getItem(type, - "§7%§a" + CasedStringUtil.snakeToUpperSpacedCase(type.getKey().getKey()) + " §erepaired by §a" + this.materialName); + "§7%§a" + CasedStringUtil.snakeToUpperSpacedCase(type.getKey().getKey()) + " §erepaired by §a" + this.typeName); } private void fillSet(HashSet set, String path){ - ConfigurationSection materialSection = ConfigHolder.UNIT_REPAIR_HOLDER + ConfigurationSection itemSection = ConfigHolder.UNIT_REPAIR_HOLDER .getConfig() .getConfigurationSection(path); - if (materialSection != null) { - for (String key : materialSection.getKeys(false)) { + if (itemSection != null) { + for (String key : itemSection.getKeys(false)) { ItemType type = ItemTypeUtil.INSTANCE.getItemTypeExact(key); if(type == null) continue; // maybe warn the user ? diff --git a/src/main/java/xyz/alexcrea/cuanvil/gui/config/list/elements/GroupConfigSubSettingGui.java b/src/main/java/xyz/alexcrea/cuanvil/gui/config/list/elements/GroupConfigSubSettingGui.java index 2e46963..0e91807 100644 --- a/src/main/java/xyz/alexcrea/cuanvil/gui/config/list/elements/GroupConfigSubSettingGui.java +++ b/src/main/java/xyz/alexcrea/cuanvil/gui/config/list/elements/GroupConfigSubSettingGui.java @@ -18,7 +18,7 @@ import xyz.alexcrea.cuanvil.gui.config.SelectItemTypeContainer; import xyz.alexcrea.cuanvil.gui.config.ask.ConfirmActionGui; import xyz.alexcrea.cuanvil.gui.config.global.GroupConfigGui; import xyz.alexcrea.cuanvil.gui.config.settings.GroupSelectSettingGui; -import xyz.alexcrea.cuanvil.gui.config.settings.MaterialSelectSettingGui; +import xyz.alexcrea.cuanvil.gui.config.settings.ItemTypeSelectSettingGui; import xyz.alexcrea.cuanvil.gui.util.GuiGlobalActions; import xyz.alexcrea.cuanvil.gui.util.GuiGlobalItems; import xyz.alexcrea.cuanvil.gui.util.GuiSharedConstant; @@ -55,7 +55,7 @@ public class GroupConfigSubSettingGui extends MappedToListSubSettingGui implemen prepareStaticValues(); } - private GuiItem materialSelection; + private GuiItem itemSelection; private GuiItem groupSelection; private void prepareStaticValues() { @@ -73,16 +73,16 @@ public class GroupConfigSubSettingGui extends MappedToListSubSettingGui implemen this.pane.bindItem('D', new GuiItem(deleteItem, openGuiAndCheckAction(), CustomAnvil.instance)); // Displayed item will be updated later - String materialSelectionName = "§e" + CasedStringUtil.snakeToUpperSpacedCase(group.getName()) + " §rMaterials"; + String selectionName = "§e" + CasedStringUtil.snakeToUpperSpacedCase(group.getName()) + " §rItems"; ItemStack selectItem = ItemType.DIAMOND_SWORD.createItemStack(); ItemMeta selectItemMeta = selectItem.getItemMeta(); - selectItemMeta.setDisplayName(materialSelectionName); + selectItemMeta.setDisplayName(selectionName); selectItem.setItemMeta(selectItemMeta); - this.materialSelection = new GuiItem(selectItem, (event) -> { + this.itemSelection = new GuiItem(selectItem, (event) -> { event.setCancelled(true); - MaterialSelectSettingGui selectGui = new MaterialSelectSettingGui(this, - materialSelectionName + ItemTypeSelectSettingGui selectGui = new ItemTypeSelectSettingGui(this, + selectionName , this); selectGui.show(event.getWhoClicked()); @@ -102,7 +102,7 @@ public class GroupConfigSubSettingGui extends MappedToListSubSettingGui implemen enchantGui.show(event.getWhoClicked()); }, CustomAnvil.instance); - this.pane.bindItem('1', this.materialSelection); + this.pane.bindItem('1', this.itemSelection); this.pane.bindItem('2', this.groupSelection); } @@ -217,13 +217,13 @@ public class GroupConfigSubSettingGui extends MappedToListSubSettingGui implemen public void updateLocal() { if (!this.usable) return; // Prepare material lore - List matLore = SelectItemTypeContainer.getMaterialLore(this, "group", "include"); + List matLore = SelectItemTypeContainer.getItemLore(this, "group", "include"); // Prepare group lore List groupLore = SelectGroupContainer.getGroupLore(this, "group", "include"); // Configure included material setting item - ItemStack matSelectItem = this.materialSelection.getItem(); + ItemStack matSelectItem = this.itemSelection.getItem(); ItemMeta matSelectMeta = matSelectItem.getItemMeta(); matSelectMeta.setDisplayName("§aSelect included §eMaterials §aSettings"); @@ -232,7 +232,7 @@ public class GroupConfigSubSettingGui extends MappedToListSubSettingGui implemen matSelectItem.setItemMeta(matSelectMeta); - this.materialSelection.setItem(matSelectItem); // Just in case + this.itemSelection.setItem(matSelectItem); // Just in case // Configure enchant setting item ItemStack groupSelectItem = this.groupSelection.getItem(); @@ -327,13 +327,13 @@ public class GroupConfigSubSettingGui extends MappedToListSubSettingGui implemen // ---------------------------- @Override - public Set getSelectedMaterials() { - return this.group.getNonGroupInheritedMaterials(); + public Set getSelectedItems() { + return this.group.getNonGroupInheritedItemTypes(); } @Override public boolean setSelectedItems(Set types) { - this.group.setNonGroupInheritedMaterials(types); + this.group.setNonGroupInheritedItemTypes(types); // Write to file configuration String[] groupNames = new String[types.size()]; @@ -342,7 +342,7 @@ public class GroupConfigSubSettingGui extends MappedToListSubSettingGui implemen groupNames[index++] = otherGroup.key().value().toLowerCase(); } - ConfigHolder.ITEM_GROUP_HOLDER.getConfig().set(this.group.getName() + "." + ItemGroupManager.MATERIAL_LIST_PATH, groupNames); + ConfigHolder.ITEM_GROUP_HOLDER.getConfig().set(this.group.getName() + "." + ItemGroupManager.ITEMS_LIST_PATH, groupNames); // update referencing groups updateDirectReferencingGroups(this.group); @@ -363,7 +363,7 @@ public class GroupConfigSubSettingGui extends MappedToListSubSettingGui implemen } @Override - public Set illegalMaterials() { + public Set illegalItems() { return ONLY_AIR_ITEM_SET; } @@ -390,7 +390,7 @@ public class GroupConfigSubSettingGui extends MappedToListSubSettingGui implemen // Update other stored group for (AbstractItemTypeGroup otherGroup : everyStoredGroups) { if (otherGroup.getGroups().contains(testGroup)) { - otherGroup.updateMaterials(); + otherGroup.update(); updateFuture.add(otherGroup); } } @@ -413,7 +413,7 @@ public class GroupConfigSubSettingGui extends MappedToListSubSettingGui implemen // Update conflict group for (AbstractItemTypeGroup conflictGroup : conflictGroupPlanned) { - conflictGroup.updateMaterials(); + conflictGroup.update(); } } diff --git a/src/main/java/xyz/alexcrea/cuanvil/gui/config/settings/GroupSelectSettingGui.java b/src/main/java/xyz/alexcrea/cuanvil/gui/config/settings/GroupSelectSettingGui.java index c2d6182..0592caa 100644 --- a/src/main/java/xyz/alexcrea/cuanvil/gui/config/settings/GroupSelectSettingGui.java +++ b/src/main/java/xyz/alexcrea/cuanvil/gui/config/settings/GroupSelectSettingGui.java @@ -86,7 +86,7 @@ public class GroupSelectSettingGui extends AbstractSettingGui { private GuiItem getGuiItemFromGroup(AbstractItemTypeGroup group) { boolean isIn = this.selectedGroups.contains(group); - ItemStack item = group.getRepresentativeMaterial().createItemStack(); + ItemStack item = group.getRepresentativeItem().createItemStack(); setGroupItemMeta(item, group.getName(), isIn); diff --git a/src/main/java/xyz/alexcrea/cuanvil/gui/config/settings/MaterialSelectSettingGui.java b/src/main/java/xyz/alexcrea/cuanvil/gui/config/settings/ItemTypeSelectSettingGui.java similarity index 98% rename from src/main/java/xyz/alexcrea/cuanvil/gui/config/settings/MaterialSelectSettingGui.java rename to src/main/java/xyz/alexcrea/cuanvil/gui/config/settings/ItemTypeSelectSettingGui.java index 85f4f08..7d537c5 100644 --- a/src/main/java/xyz/alexcrea/cuanvil/gui/config/settings/MaterialSelectSettingGui.java +++ b/src/main/java/xyz/alexcrea/cuanvil/gui/config/settings/ItemTypeSelectSettingGui.java @@ -23,7 +23,7 @@ import java.util.*; import java.util.function.Consumer; @SuppressWarnings("UnstableApiUsage") -public class MaterialSelectSettingGui extends MappedElementListConfigGui { +public class ItemTypeSelectSettingGui extends MappedElementListConfigGui { private final SelectItemTypeContainer selector; private final Gui backGui; @@ -34,7 +34,7 @@ public class MaterialSelectSettingGui extends MappedElementListConfigGui(this.selector.getSelectedMaterials()); - this.illegalMaterials = this.selector.illegalMaterials(); + this.defaultMaterials = new ArrayList<>(this.selector.getSelectedItems()); + this.illegalMaterials = this.selector.illegalItems(); this.defaultMaterialHash = hashFromItemTypeList(this.defaultMaterials); this.nowMaterialHash = this.defaultMaterialHash; diff --git a/src/main/java/xyz/alexcrea/cuanvil/update/plugin/PUpdate_1_11_0.java b/src/main/java/xyz/alexcrea/cuanvil/update/plugin/PUpdate_1_11_0.java index 429a5a4..470b130 100644 --- a/src/main/java/xyz/alexcrea/cuanvil/update/plugin/PUpdate_1_11_0.java +++ b/src/main/java/xyz/alexcrea/cuanvil/update/plugin/PUpdate_1_11_0.java @@ -5,7 +5,7 @@ import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.inventory.ItemType; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import xyz.alexcrea.cuanvil.api.MaterialGroupApi; +import xyz.alexcrea.cuanvil.api.ItemGroupApi; import xyz.alexcrea.cuanvil.config.ConfigHolder; import xyz.alexcrea.cuanvil.group.AbstractItemTypeGroup; import xyz.alexcrea.cuanvil.group.IncludeItemTypeGroup; @@ -56,7 +56,7 @@ public class PUpdate_1_11_0 { private static void handleToolsMigration() { // We migrate the mace conflict if exist and unmodified - AbstractItemTypeGroup tools = MaterialGroupApi.getGroup("tools"); + AbstractItemTypeGroup tools = ItemGroupApi.getGroup("tools"); migrateTools(tools, "pickaxes", PICKAXES); migrateTools(tools, "shovels", SHOVELS); @@ -72,19 +72,19 @@ public class PUpdate_1_11_0 { IncludeItemTypeGroup group = new IncludeItemTypeGroup(toolset); group.addAll(toolMats); - MaterialGroupApi.addMaterialGroup(group, true); + ItemGroupApi.addItemGroup(group, true); // Try to see if all the materials was in the tools group. and if so, replace it with the new group if (tools == null) return; if (!(tools instanceof IncludeItemTypeGroup include)) return; List types = List.of(toolMats); - Set typeSet = include.getNonGroupInheritedMaterials(); + Set typeSet = include.getNonGroupInheritedItemTypes(); if (!typeSet.containsAll(types)) return; types.forEach(typeSet::remove); tools.addToPolicy(group); - MaterialGroupApi.writeMaterialGroup(tools); + ItemGroupApi.writeItemGroup(tools); } private static void handleMaceMigration(@Nonnull Set toSave) { diff --git a/src/main/kotlin/io/delilaheve/util/ConfigOptions.kt b/src/main/kotlin/io/delilaheve/util/ConfigOptions.kt index 3f9812e..a910ccc 100644 --- a/src/main/kotlin/io/delilaheve/util/ConfigOptions.kt +++ b/src/main/kotlin/io/delilaheve/util/ConfigOptions.kt @@ -344,7 +344,7 @@ object ConfigOptions { } /** - * Get material enchantment count limit + * Get item enchantment count limit * * @return the current enchantment limit. -1 if none */ @@ -358,7 +358,7 @@ object ConfigOptions { } /** - * Get the material enchantment count limit. + * Get the item enchantment count limit. * * @return The current enchantment limit. -1 if none */ diff --git a/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/datapack/DataPackDependency.kt b/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/datapack/DataPackDependency.kt index 4434c8f..19ca7b1 100644 --- a/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/datapack/DataPackDependency.kt +++ b/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/datapack/DataPackDependency.kt @@ -8,7 +8,7 @@ import org.bukkit.configuration.file.FileConfiguration import org.bukkit.configuration.file.YamlConfiguration import xyz.alexcrea.cuanvil.api.ConflictBuilder import xyz.alexcrea.cuanvil.api.EnchantmentApi -import xyz.alexcrea.cuanvil.api.MaterialGroupApi +import xyz.alexcrea.cuanvil.api.ItemGroupApi import xyz.alexcrea.cuanvil.config.ConfigHolder import xyz.alexcrea.cuanvil.dependency.DependencyManager import xyz.alexcrea.cuanvil.enchant.wrapped.CABukkitEnchantment @@ -138,7 +138,7 @@ object DataPackDependency { for (groupName in yml.getKeys(false)) { val section = yml.getConfigurationSection(groupName) ?: continue - var group = MaterialGroupApi.getGroup(groupName) + var group = ItemGroupApi.getGroup(groupName) val exist = group != null if (group == null) group = IncludeItemTypeGroup(groupName) @@ -154,7 +154,7 @@ object DataPackDependency { group.addToPolicy(type) } for (name in section.getStringList("groups")) { - val otherGroup = MaterialGroupApi.getGroup(name) + val otherGroup = ItemGroupApi.getGroup(name) if (otherGroup == null) { CustomAnvil.instance.logger.warning("Could not find sub group $name for group $groupName") continue @@ -163,12 +163,12 @@ object DataPackDependency { group.addToPolicy(otherGroup) } - group.updateMaterials() + group.update() if (exist) { - MaterialGroupApi.writeMaterialGroup(group) + ItemGroupApi.writeItemGroup(group) } else { - MaterialGroupApi.addMaterialGroup(group, true) + ItemGroupApi.addItemGroup(group, true) } } } diff --git a/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/plugins/EnchantmentSquaredDependency.kt b/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/plugins/EnchantmentSquaredDependency.kt index 1327c95..265e33c 100644 --- a/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/plugins/EnchantmentSquaredDependency.kt +++ b/src/main/kotlin/xyz/alexcrea/cuanvil/dependency/plugins/EnchantmentSquaredDependency.kt @@ -12,7 +12,7 @@ import org.bukkit.inventory.ItemType import org.bukkit.plugin.Plugin import xyz.alexcrea.cuanvil.api.ConflictBuilder import xyz.alexcrea.cuanvil.api.EnchantmentApi -import xyz.alexcrea.cuanvil.api.MaterialGroupApi +import xyz.alexcrea.cuanvil.api.ItemGroupApi import xyz.alexcrea.cuanvil.enchant.CAEnchantment import xyz.alexcrea.cuanvil.enchant.CAEnchantmentRegistry import xyz.alexcrea.cuanvil.enchant.bulk.EnchantSquaredBulkOperation @@ -106,15 +106,15 @@ class EnchantmentSquaredDependency(private val enchantmentSquaredPlugin: Plugin) // Write group that do not exist on custom anvil. val shield = IncludeItemTypeGroup("shield") shield.addToPolicy(ItemType.SHIELD) - MaterialGroupApi.addMaterialGroup(shield) + ItemGroupApi.addItemGroup(shield) val elytra = IncludeItemTypeGroup("elytra") elytra.addToPolicy(ItemType.ELYTRA) - MaterialGroupApi.addMaterialGroup(elytra) + ItemGroupApi.addItemGroup(elytra) val trinkets = IncludeItemTypeGroup("trinkets") trinkets.addToPolicy(ItemType.ROTTEN_FLESH) - MaterialGroupApi.addMaterialGroup(trinkets) + ItemGroupApi.addItemGroup(trinkets) } private fun writeMaterialRestriction(esEnchantments: List) { diff --git a/src/main/kotlin/xyz/alexcrea/cuanvil/group/AbstractItemTypeGroup.kt b/src/main/kotlin/xyz/alexcrea/cuanvil/group/AbstractItemTypeGroup.kt index 21167c0..dcf11c2 100644 --- a/src/main/kotlin/xyz/alexcrea/cuanvil/group/AbstractItemTypeGroup.kt +++ b/src/main/kotlin/xyz/alexcrea/cuanvil/group/AbstractItemTypeGroup.kt @@ -69,14 +69,14 @@ abstract class AbstractItemTypeGroup(private val name: String) { /** * Get the group non-inherited items as a set */ - open fun getNonGroupInheritedMaterials(): MutableSet { + open fun getNonGroupInheritedItemTypes(): MutableSet { return includedItems } /** * Set the group non-inherited items */ - open fun setNonGroupInheritedMaterials(types: Set) { + open fun setNonGroupInheritedItemTypes(types: Set) { this.includedItems.clear() this.includedItems.addAll(types) } @@ -102,7 +102,7 @@ abstract class AbstractItemTypeGroup(private val name: String) { */ abstract fun getGroups(): MutableSet - open fun getRepresentativeMaterial(): ItemType { + open fun getRepresentativeItem(): ItemType { // Test inner material val itemIterator = includedItems.iterator() while (itemIterator.hasNext()) { @@ -113,13 +113,13 @@ abstract class AbstractItemTypeGroup(private val name: String) { // Test included group representative material val groupIterator = getGroups().iterator() while (groupIterator.hasNext()) { - val groupType = groupIterator.next().getRepresentativeMaterial() + val groupType = groupIterator.next().getRepresentativeItem() if (groupType == ItemType.AIR) continue return groupType } return ItemType.PAPER } - abstract fun updateMaterials() + abstract fun update() } \ No newline at end of file diff --git a/src/main/kotlin/xyz/alexcrea/cuanvil/group/EnchantConflictGroup.kt b/src/main/kotlin/xyz/alexcrea/cuanvil/group/EnchantConflictGroup.kt index f0e7137..7b567ea 100644 --- a/src/main/kotlin/xyz/alexcrea/cuanvil/group/EnchantConflictGroup.kt +++ b/src/main/kotlin/xyz/alexcrea/cuanvil/group/EnchantConflictGroup.kt @@ -58,11 +58,11 @@ class EnchantConflictGroup( enchantments.addAll(enchants) } - fun getRepresentativeMaterial(): ItemType { + fun getRepresentativeItemType(): ItemType { val groups = getCantConflictGroup().getGroups() val groupIterator = groups.iterator() while (groupIterator.hasNext()) { - val itemType = groupIterator.next().getRepresentativeMaterial() + val itemType = groupIterator.next().getRepresentativeItem() if (itemType != ItemType.ENCHANTED_BOOK) return itemType } diff --git a/src/main/kotlin/xyz/alexcrea/cuanvil/group/ExcludeItemTypeGroup.kt b/src/main/kotlin/xyz/alexcrea/cuanvil/group/ExcludeItemTypeGroup.kt index e02c20e..77f97c8 100644 --- a/src/main/kotlin/xyz/alexcrea/cuanvil/group/ExcludeItemTypeGroup.kt +++ b/src/main/kotlin/xyz/alexcrea/cuanvil/group/ExcludeItemTypeGroup.kt @@ -18,8 +18,8 @@ class ExcludeItemTypeGroup(name: String) : AbstractItemTypeGroup(name) { private val groupItems by lazy { createDefaultSet() } override fun isReferencing(other: AbstractItemTypeGroup): Boolean { - for (materialGroup in includedGroup.iterator()) { - if ((materialGroup == other) || (materialGroup.isReferencing(other))) { + for (itemGroup in includedGroup.iterator()) { + if ((itemGroup == other) || (itemGroup.isReferencing(other))) { return true } } @@ -57,7 +57,7 @@ class ExcludeItemTypeGroup(name: String) : AbstractItemTypeGroup(name) { return includedGroup } - override fun updateMaterials() { + override fun update() { groupItems.clear() groupItems.addAll(includedItems) diff --git a/src/main/kotlin/xyz/alexcrea/cuanvil/group/IncludeItemTypeGroup.kt b/src/main/kotlin/xyz/alexcrea/cuanvil/group/IncludeItemTypeGroup.kt index 26fb8fb..5bb2ef6 100644 --- a/src/main/kotlin/xyz/alexcrea/cuanvil/group/IncludeItemTypeGroup.kt +++ b/src/main/kotlin/xyz/alexcrea/cuanvil/group/IncludeItemTypeGroup.kt @@ -12,8 +12,8 @@ class IncludeItemTypeGroup(name: String) : AbstractItemTypeGroup(name) { private val groupItems by lazy { createDefaultSet() } override fun isReferencing(other: AbstractItemTypeGroup): Boolean { - for (materialGroup in includedGroup.iterator()) { - if ((materialGroup == other) || (materialGroup.isReferencing(other))) { + for (subGroup in includedGroup.iterator()) { + if ((subGroup == other) || (subGroup.isReferencing(other))) { return true } } @@ -47,17 +47,17 @@ class IncludeItemTypeGroup(name: String) : AbstractItemTypeGroup(name) { } } - override fun setNonGroupInheritedMaterials(types: Set) { - super.setNonGroupInheritedMaterials(types) + override fun setNonGroupInheritedItemTypes(types: Set) { + super.setNonGroupInheritedItemTypes(types) - updateMaterials() + update() } override fun getGroups(): MutableSet { return includedGroup } - override fun updateMaterials() { + override fun update() { groupItems.clear() groupItems.addAll(includedItems) diff --git a/src/main/kotlin/xyz/alexcrea/cuanvil/group/ItemGroupManager.kt b/src/main/kotlin/xyz/alexcrea/cuanvil/group/ItemGroupManager.kt index c999f43..7a6d242 100644 --- a/src/main/kotlin/xyz/alexcrea/cuanvil/group/ItemGroupManager.kt +++ b/src/main/kotlin/xyz/alexcrea/cuanvil/group/ItemGroupManager.kt @@ -13,13 +13,10 @@ class ItemGroupManager { const val GROUP_TYPE_PATH = "type" // Path for included items list - const val MATERIAL_LIST_PATH = "items" + const val ITEMS_LIST_PATH = "items" // Path for included groups list const val GROUP_LIST_PATH = "groups" - - // Temporary list of elements in default config that are use in future - private val FUTURE_MATERIAL = setOf("PIGLIN_HEAD", "BRUSH") } lateinit var groupMap: LinkedHashMap @@ -78,17 +75,13 @@ class ItemGroupManager { keys: Set ) { // Read material to include in this group policy - val materialList = groupSection.getStringList(MATERIAL_LIST_PATH) - for (typeName in materialList) { + val itemTypeNames = groupSection.getStringList(ITEMS_LIST_PATH) + for (typeName in itemTypeNames) { val type = ItemTypeUtil.getItemType(typeName) if (type == null) { - // Check if we should warn the user - if (typeName !in FUTURE_MATERIAL) { - CustomAnvil.instance.logger.warning( - "Unknown item type $typeName on group ${group.getName()}" - ) - - } + CustomAnvil.instance.logger.warning( + "Unknown item type $typeName on group ${group.getName()}" + ) continue } diff --git a/src/test/java/xyz/alexcrea/cuanvil/api/MaterialGroupApiTests.java b/src/test/java/xyz/alexcrea/cuanvil/api/MaterialGroupApiTests.java index 2459705..e3be653 100644 --- a/src/test/java/xyz/alexcrea/cuanvil/api/MaterialGroupApiTests.java +++ b/src/test/java/xyz/alexcrea/cuanvil/api/MaterialGroupApiTests.java @@ -23,22 +23,22 @@ public class MaterialGroupApiTests extends ConfigResetCustomAnvilTest { assertFalse(doGroupCanBeFound(groupName)); // Add group - assertTrue(MaterialGroupApi.addMaterialGroup(group)); - assertFalse(MaterialGroupApi.addMaterialGroup(group, true)); + assertTrue(ItemGroupApi.addItemGroup(group)); + assertFalse(ItemGroupApi.addItemGroup(group, true)); assertTrue(doGroupExist(groupName)); assertTrue(doGroupCanBeFound(groupName)); // Remove group - assertTrue(MaterialGroupApi.removeGroup(group)); - assertFalse(MaterialGroupApi.removeGroup(group)); + assertTrue(ItemGroupApi.removeGroup(group)); + assertFalse(ItemGroupApi.removeGroup(group)); assertFalse(doGroupExist(groupName)); assertFalse(doGroupCanBeFound(groupName)); // Re add - assertFalse(MaterialGroupApi.addMaterialGroup(group, false)); - assertTrue(MaterialGroupApi.addMaterialGroup(group, true)); + assertFalse(ItemGroupApi.addItemGroup(group, false)); + assertTrue(ItemGroupApi.addItemGroup(group, true)); assertTrue(doGroupExist(groupName)); assertTrue(doGroupCanBeFound(groupName)); @@ -56,7 +56,7 @@ public class MaterialGroupApiTests extends ConfigResetCustomAnvilTest { assertFalse(doGroupCanBeFound(groupName)); // Add group and reload - assertTrue(MaterialGroupApi.writeMaterialGroup(group)); + assertTrue(ItemGroupApi.writeItemGroup(group)); assertFalse(doGroupExist(groupName)); assertFalse(doGroupCanBeFound(groupName)); @@ -73,7 +73,7 @@ public class MaterialGroupApiTests extends ConfigResetCustomAnvilTest { IncludeItemTypeGroup group = new IncludeItemTypeGroup(groupName); // Add group and reload - assertFalse(MaterialGroupApi.writeMaterialGroup(group)); + assertFalse(ItemGroupApi.writeItemGroup(group)); assertFalse(doGroupExist(groupName)); assertFalse(doGroupCanBeFound(groupName)); @@ -90,11 +90,11 @@ public class MaterialGroupApiTests extends ConfigResetCustomAnvilTest { IncludeItemTypeGroup group = new IncludeItemTypeGroup(groupName); // Try write group - assertFalse(MaterialGroupApi.writeMaterialGroup(group)); + assertFalse(ItemGroupApi.writeItemGroup(group)); } boolean doGroupExist(String groupName) { - return MaterialGroupApi.getGroup(groupName) != null; + return ItemGroupApi.getGroup(groupName) != null; } boolean doGroupCanBeFound(String groupName) {