mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-06-23 08:14:00 +02:00
progress on removing material reference
This commit is contained in:
parent
96c60a9733
commit
8cb11c3c18
23 changed files with 134 additions and 140 deletions
|
|
@ -68,7 +68,7 @@ public class AnvilRecipeBuilder {
|
|||
* Get if the recipe is exact count. (default 0)
|
||||
* <p>
|
||||
* 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.
|
||||
* <p>
|
||||
* 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.
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
* <p>
|
||||
* 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.
|
||||
* <p>
|
||||
* 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 {
|
|||
* <p>
|
||||
* If left item of an anvil craft is included on one of the excluded group it will ignore this conflict.
|
||||
* <p>
|
||||
* 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.
|
||||
* <p>
|
||||
* 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 {
|
|||
* <p>
|
||||
* If left item of an anvil craft is included on one of the excluded group it will ignore this conflict.
|
||||
* <p>
|
||||
* This allows to create conflict only for some item. Material restriction can be written like that.
|
||||
* <p>
|
||||
* 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 * <p>
|
||||
* 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 {
|
|||
* <p>
|
||||
* If left item of an anvil craft is included on one of the excluded group it will ignore this conflict.
|
||||
* <p>
|
||||
* 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.
|
||||
* <p>
|
||||
* 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 {
|
|||
* <p>
|
||||
* If left item of an anvil craft is included on one of the excluded group it will ignore this conflict.
|
||||
* <p>
|
||||
* 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.
|
||||
* <p>
|
||||
* 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();
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
* <p>
|
||||
* 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.
|
||||
* <p>
|
||||
* 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<ItemType> itemSets = group.getNonGroupInheritedMaterials();
|
||||
Set<ItemType> itemSets = group.getNonGroupInheritedItemTypes();
|
||||
Set<AbstractItemTypeGroup> 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<String> materialGroupSetToStringList(@NotNull Set<AbstractItemTypeGroup> groups) {
|
||||
public static List<String> itemGroupSetToStringList(@NotNull Set<AbstractItemTypeGroup> 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.
|
||||
*/
|
||||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
|||
* <p>
|
||||
* 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
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -11,17 +11,17 @@ import java.util.Set;
|
|||
@SuppressWarnings("UnstableApiUsage")
|
||||
public interface SelectItemTypeContainer {
|
||||
|
||||
Set<ItemType> getSelectedMaterials();
|
||||
Set<ItemType> getSelectedItems();
|
||||
|
||||
boolean setSelectedItems(Set<ItemType> types);
|
||||
|
||||
Set<ItemType> illegalMaterials();
|
||||
Set<ItemType> illegalItems();
|
||||
|
||||
static List<String> getMaterialLore(SelectItemTypeContainer container, String containerType, String action) {
|
||||
static List<String> getItemLore(SelectItemTypeContainer container, String containerType, String action) {
|
||||
// Prepare material lore
|
||||
ArrayList<String> groupLore = new ArrayList<>();
|
||||
groupLore.add("§7Allow you to select a list of §ematerials §7that this " + containerType + " should " + action);
|
||||
Set<ItemType> typeSet = container.getSelectedMaterials();
|
||||
Set<ItemType> typeSet = container.getSelectedItems();
|
||||
if (typeSet.isEmpty()) {
|
||||
groupLore.add("§7There is no " + action + "d material for this " + containerType + ".");
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ public class SelectItemTypeGui extends AbstractAskGui {
|
|||
@NotNull String actionDescription,
|
||||
@NotNull Gui backOnCancel,
|
||||
@NotNull BiConsumer<ItemStack, HumanEntity> 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);
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ public class EnchantConflictGui extends MappedGuiListConfigGui<EnchantConflictGr
|
|||
|
||||
@Override
|
||||
public ItemStack createItemForGeneric(EnchantConflictGroup conflict) {
|
||||
ItemStack item = conflict.getRepresentativeMaterial().createItemStack();
|
||||
ItemStack item = conflict.getRepresentativeItemType().createItemStack();
|
||||
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
assert meta != null;
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ public class GroupConfigGui extends MappedGuiListConfigGui<IncludeItemTypeGroup,
|
|||
|
||||
@Override
|
||||
protected ItemStack createItemForGeneric(IncludeItemTypeGroup group) {
|
||||
ItemStack item = group.getRepresentativeMaterial().createItemStack();
|
||||
ItemStack item = group.getRepresentativeItem().createItemStack();
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
assert meta != null;
|
||||
|
||||
|
|
@ -53,7 +53,7 @@ public class GroupConfigGui extends MappedGuiListConfigGui<IncludeItemTypeGroup,
|
|||
meta.setDisplayName("§e" + CasedStringUtil.snakeToUpperSpacedCase(group.getName()) + " §fGroup");
|
||||
meta.setLore(Arrays.asList(
|
||||
"§7Number of selected groups : " + group.getGroups().size(),
|
||||
"§7Number of included material : " + group.getNonGroupInheritedMaterials().size(),
|
||||
"§7Number of included material : " + group.getNonGroupInheritedItemTypes().size(),
|
||||
"",
|
||||
"§7Total number of included material " + group.getItemTypes().size()));
|
||||
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ public class UnitRepairElementListGui extends
|
|||
|
||||
private final ItemType parentType;
|
||||
private final UnitRepairConfigGui parentGui;
|
||||
private final String materialName;
|
||||
private final String typeName;
|
||||
|
||||
private boolean shouldWork = true;
|
||||
|
||||
|
|
@ -40,7 +40,7 @@ public class UnitRepairElementListGui extends
|
|||
super("§e" + CasedStringUtil.snakeToUpperSpacedCase(parentType.getKey().getKey()) + " §rUnit repair");
|
||||
this.parentType = parentType;
|
||||
this.parentGui = parentGui;
|
||||
this.materialName = CasedStringUtil.snakeToUpperSpacedCase(parentType.getKey().getKey());
|
||||
this.typeName = CasedStringUtil.snakeToUpperSpacedCase(parentType.getKey().getKey());
|
||||
|
||||
GuiGlobalItems.addBackItem(this.backgroundPane, parentGui);
|
||||
}
|
||||
|
|
@ -66,7 +66,7 @@ public class UnitRepairElementListGui extends
|
|||
new SelectItemTypeGui(
|
||||
"Select item to be repaired.",
|
||||
"§7Click here with an item to set the item\n" +
|
||||
"§7You like to be repaired by " + this.materialName,
|
||||
"§7You like to be repaired by " + this.typeName,
|
||||
this,
|
||||
(itemStack, player) -> {
|
||||
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<ItemType> 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 ?
|
||||
|
||||
|
|
|
|||
|
|
@ -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<String> matLore = SelectItemTypeContainer.getMaterialLore(this, "group", "include");
|
||||
List<String> matLore = SelectItemTypeContainer.getItemLore(this, "group", "include");
|
||||
|
||||
// Prepare group lore
|
||||
List<String> 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<ItemType> getSelectedMaterials() {
|
||||
return this.group.getNonGroupInheritedMaterials();
|
||||
public Set<ItemType> getSelectedItems() {
|
||||
return this.group.getNonGroupInheritedItemTypes();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setSelectedItems(Set<ItemType> 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<ItemType> illegalMaterials() {
|
||||
public Set<ItemType> 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();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ import java.util.*;
|
|||
import java.util.function.Consumer;
|
||||
|
||||
@SuppressWarnings("UnstableApiUsage")
|
||||
public class MaterialSelectSettingGui extends MappedElementListConfigGui<ItemType, GuiItem> {
|
||||
public class ItemTypeSelectSettingGui extends MappedElementListConfigGui<ItemType, GuiItem> {
|
||||
|
||||
private final SelectItemTypeContainer selector;
|
||||
private final Gui backGui;
|
||||
|
|
@ -34,7 +34,7 @@ public class MaterialSelectSettingGui extends MappedElementListConfigGui<ItemTyp
|
|||
private final int defaultMaterialHash;
|
||||
private int nowMaterialHash;
|
||||
|
||||
public MaterialSelectSettingGui(
|
||||
public ItemTypeSelectSettingGui(
|
||||
@NotNull SelectItemTypeContainer selector,
|
||||
@NotNull String title,
|
||||
@NotNull Gui backGui) {
|
||||
|
|
@ -43,8 +43,8 @@ public class MaterialSelectSettingGui extends MappedElementListConfigGui<ItemTyp
|
|||
this.backGui = backGui;
|
||||
this.instantRemove = false;
|
||||
|
||||
this.defaultMaterials = new ArrayList<>(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;
|
||||
|
|
@ -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<ItemType> types = List.of(toolMats);
|
||||
Set<ItemType> typeSet = include.getNonGroupInheritedMaterials();
|
||||
Set<ItemType> 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<ConfigHolder> toSave) {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<CAEnchantSquaredEnchantment>) {
|
||||
|
|
|
|||
|
|
@ -69,14 +69,14 @@ abstract class AbstractItemTypeGroup(private val name: String) {
|
|||
/**
|
||||
* Get the group non-inherited items as a set
|
||||
*/
|
||||
open fun getNonGroupInheritedMaterials(): MutableSet<ItemType> {
|
||||
open fun getNonGroupInheritedItemTypes(): MutableSet<ItemType> {
|
||||
return includedItems
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the group non-inherited items
|
||||
*/
|
||||
open fun setNonGroupInheritedMaterials(types: Set<ItemType>) {
|
||||
open fun setNonGroupInheritedItemTypes(types: Set<ItemType>) {
|
||||
this.includedItems.clear()
|
||||
this.includedItems.addAll(types)
|
||||
}
|
||||
|
|
@ -102,7 +102,7 @@ abstract class AbstractItemTypeGroup(private val name: String) {
|
|||
*/
|
||||
abstract fun getGroups(): MutableSet<AbstractItemTypeGroup>
|
||||
|
||||
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()
|
||||
|
||||
}
|
||||
|
|
@ -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
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
|
|
@ -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<ItemType>) {
|
||||
super.setNonGroupInheritedMaterials(types)
|
||||
override fun setNonGroupInheritedItemTypes(types: Set<ItemType>) {
|
||||
super.setNonGroupInheritedItemTypes(types)
|
||||
|
||||
updateMaterials()
|
||||
update()
|
||||
}
|
||||
|
||||
override fun getGroups(): MutableSet<AbstractItemTypeGroup> {
|
||||
return includedGroup
|
||||
}
|
||||
|
||||
override fun updateMaterials() {
|
||||
override fun update() {
|
||||
groupItems.clear()
|
||||
groupItems.addAll(includedItems)
|
||||
|
||||
|
|
|
|||
|
|
@ -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<String, AbstractItemTypeGroup>
|
||||
|
|
@ -78,17 +75,13 @@ class ItemGroupManager {
|
|||
keys: Set<String>
|
||||
) {
|
||||
// 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
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue