mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-06-24 00:26:16 +02:00
progress
This commit is contained in:
parent
8cb11c3c18
commit
94847832c0
16 changed files with 34 additions and 38 deletions
|
|
@ -444,7 +444,7 @@ n * <p>
|
||||||
AbstractItemTypeGroup typeGroup = itemGroupManager.get(groupName);
|
AbstractItemTypeGroup typeGroup = itemGroupManager.get(groupName);
|
||||||
|
|
||||||
if (typeGroup == null) {
|
if (typeGroup == null) {
|
||||||
CustomAnvil.instance.getLogger().warning("Material group " + groupName + " do not exist but is ask by conflict " + getName());
|
CustomAnvil.instance.getLogger().warning("Item group " + groupName + " do not exist but is ask by conflict " + getName());
|
||||||
ConflictAPI.logConflictOrigin(this);
|
ConflictAPI.logConflictOrigin(this);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -100,7 +100,7 @@ public class ItemGroupApi {
|
||||||
public static boolean writeItemGroup(@NotNull AbstractItemTypeGroup group, boolean updatePlanned) {
|
public static boolean writeItemGroup(@NotNull AbstractItemTypeGroup group, boolean updatePlanned) {
|
||||||
String name = group.getName();
|
String name = group.getName();
|
||||||
if (name.contains(".")) {
|
if (name.contains(".")) {
|
||||||
CustomAnvil.instance.getLogger().warning("Group " + name + " contain . in its name but should not. this material group is ignored.");
|
CustomAnvil.instance.getLogger().warning("Group " + name + " contain . in its name but should not. this item group is ignored.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ import xyz.alexcrea.cuanvil.api.ItemGroupApi;
|
||||||
* <p>
|
* <p>
|
||||||
* use {@link xyz.alexcrea.cuanvil.api.ConflictAPI ConflictApi},
|
* use {@link xyz.alexcrea.cuanvil.api.ConflictAPI ConflictApi},
|
||||||
* {@link xyz.alexcrea.cuanvil.gui.config.global.CustomRecipeConfigGui CustomRecipeConfigGui},
|
* {@link xyz.alexcrea.cuanvil.gui.config.global.CustomRecipeConfigGui CustomRecipeConfigGui},
|
||||||
* {@link ItemGroupApi MaterialGroupApi}
|
* {@link ItemGroupApi ItemGroupApi}
|
||||||
* and {@link xyz.alexcrea.cuanvil.api.UnitRepairApi UnitRepairApi}
|
* and {@link xyz.alexcrea.cuanvil.api.UnitRepairApi UnitRepairApi}
|
||||||
* to add/remove/edit configurations
|
* to add/remove/edit configurations
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -20,12 +20,12 @@ public interface SelectItemTypeContainer {
|
||||||
static List<String> getItemLore(SelectItemTypeContainer container, String containerType, String action) {
|
static List<String> getItemLore(SelectItemTypeContainer container, String containerType, String action) {
|
||||||
// Prepare material lore
|
// Prepare material lore
|
||||||
ArrayList<String> groupLore = new ArrayList<>();
|
ArrayList<String> groupLore = new ArrayList<>();
|
||||||
groupLore.add("§7Allow you to select a list of §ematerials §7that this " + containerType + " should " + action);
|
groupLore.add("§7Allow you to select a list of §eitems §7that this " + containerType + " should " + action);
|
||||||
Set<ItemType> typeSet = container.getSelectedItems();
|
Set<ItemType> typeSet = container.getSelectedItems();
|
||||||
if (typeSet.isEmpty()) {
|
if (typeSet.isEmpty()) {
|
||||||
groupLore.add("§7There is no " + action + "d material for this " + containerType + ".");
|
groupLore.add("§7There is no " + action + "d item for this " + containerType + ".");
|
||||||
} else {
|
} else {
|
||||||
groupLore.add("§7List of " + action + "d materials for this " + containerType + ":");
|
groupLore.add("§7List of " + action + "d items for this " + containerType + ":");
|
||||||
Iterator<ItemType> typeIterator = typeSet.iterator();
|
Iterator<ItemType> typeIterator = typeSet.iterator();
|
||||||
|
|
||||||
boolean greaterThanMax = typeSet.size() > 5;
|
boolean greaterThanMax = typeSet.size() > 5;
|
||||||
|
|
|
||||||
|
|
@ -53,9 +53,9 @@ public class GroupConfigGui extends MappedGuiListConfigGui<IncludeItemTypeGroup,
|
||||||
meta.setDisplayName("§e" + CasedStringUtil.snakeToUpperSpacedCase(group.getName()) + " §fGroup");
|
meta.setDisplayName("§e" + CasedStringUtil.snakeToUpperSpacedCase(group.getName()) + " §fGroup");
|
||||||
meta.setLore(Arrays.asList(
|
meta.setLore(Arrays.asList(
|
||||||
"§7Number of selected groups: " + group.getGroups().size(),
|
"§7Number of selected groups: " + group.getGroups().size(),
|
||||||
"§7Number of included material : " + group.getNonGroupInheritedItemTypes().size(),
|
"§7Number of included item: " + group.getNonGroupInheritedItemTypes().size(),
|
||||||
"",
|
"",
|
||||||
"§7Total number of included material " + group.getItemTypes().size()));
|
"§7Total number of included item: " + group.getItemTypes().size()));
|
||||||
|
|
||||||
item.setItemMeta(meta);
|
item.setItemMeta(meta);
|
||||||
return item;
|
return item;
|
||||||
|
|
@ -80,7 +80,7 @@ public class GroupConfigGui extends MappedGuiListConfigGui<IncludeItemTypeGroup,
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String genericDisplayedName() {
|
protected String genericDisplayedName() {
|
||||||
return "material group";
|
return "item group";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ public class UnitRepairElementListGui extends
|
||||||
protected List<String> getCreateItemLore() {
|
protected List<String> getCreateItemLore() {
|
||||||
return Arrays.asList(
|
return Arrays.asList(
|
||||||
"§7Select a new item to be repairable.",
|
"§7Select a new item to be repairable.",
|
||||||
"§7You will be asked the material to use."
|
"§7You will be asked the item to use."
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -223,22 +223,22 @@ public class GroupConfigSubSettingGui extends MappedToListSubSettingGui implemen
|
||||||
List<String> groupLore = SelectGroupContainer.getGroupLore(this, "group", "include");
|
List<String> groupLore = SelectGroupContainer.getGroupLore(this, "group", "include");
|
||||||
|
|
||||||
// Configure included material setting item
|
// Configure included material setting item
|
||||||
ItemStack matSelectItem = this.itemSelection.getItem();
|
ItemStack itemSelectItem = this.itemSelection.getItem();
|
||||||
ItemMeta matSelectMeta = matSelectItem.getItemMeta();
|
ItemMeta itemSelectMeta = itemSelectItem.getItemMeta();
|
||||||
|
|
||||||
matSelectMeta.setDisplayName("§aSelect included §eMaterials §aSettings");
|
itemSelectMeta.setDisplayName("§aSelect included §eItems");
|
||||||
matSelectMeta.setLore(matLore);
|
itemSelectMeta.setLore(matLore);
|
||||||
matSelectMeta.addItemFlags(ItemFlag.values());
|
itemSelectMeta.addItemFlags(ItemFlag.values());
|
||||||
|
|
||||||
matSelectItem.setItemMeta(matSelectMeta);
|
itemSelectItem.setItemMeta(itemSelectMeta);
|
||||||
|
|
||||||
this.itemSelection.setItem(matSelectItem); // Just in case
|
this.itemSelection.setItem(itemSelectItem); // Just in case
|
||||||
|
|
||||||
// Configure enchant setting item
|
// Configure enchant setting item
|
||||||
ItemStack groupSelectItem = this.groupSelection.getItem();
|
ItemStack groupSelectItem = this.groupSelection.getItem();
|
||||||
ItemMeta groupSelectMeta = groupSelectItem.getItemMeta();
|
ItemMeta groupSelectMeta = groupSelectItem.getItemMeta();
|
||||||
|
|
||||||
groupSelectMeta.setDisplayName("§aSelect included §3Groups §aSettings");
|
groupSelectMeta.setDisplayName("§aSelect included §3Groups");
|
||||||
groupSelectMeta.setLore(groupLore);
|
groupSelectMeta.setLore(groupLore);
|
||||||
|
|
||||||
groupSelectItem.setItemMeta(groupSelectMeta);
|
groupSelectItem.setItemMeta(groupSelectMeta);
|
||||||
|
|
|
||||||
|
|
@ -90,7 +90,7 @@ public class ItemTypeSelectSettingGui extends MappedElementListConfigGui<ItemTyp
|
||||||
selectMeta.setDisplayName("§aAdd Item");
|
selectMeta.setDisplayName("§aAdd Item");
|
||||||
selectMeta.setLore(Arrays.asList(
|
selectMeta.setLore(Arrays.asList(
|
||||||
"§7Click here with an item to add",
|
"§7Click here with an item to add",
|
||||||
"§7it's Material to the list."));
|
"§7it to the list."));
|
||||||
|
|
||||||
selectItem.setItemMeta(selectMeta);
|
selectItem.setItemMeta(selectMeta);
|
||||||
|
|
||||||
|
|
@ -208,7 +208,7 @@ public class ItemTypeSelectSettingGui extends MappedElementListConfigGui<ItemTyp
|
||||||
|
|
||||||
if (meta == null) return item;
|
if (meta == null) return item;
|
||||||
meta.setDisplayName("§a" + CasedStringUtil.snakeToUpperSpacedCase(type.key().value().toLowerCase()));
|
meta.setDisplayName("§a" + CasedStringUtil.snakeToUpperSpacedCase(type.key().value().toLowerCase()));
|
||||||
meta.setLore(Collections.singletonList("§7Click here to remove this material from the list"));
|
meta.setLore(Collections.singletonList("§7Click here to remove this item from the list"));
|
||||||
meta.addItemFlags(ItemFlag.values());
|
meta.addItemFlags(ItemFlag.values());
|
||||||
|
|
||||||
item.setItemMeta(meta);
|
item.setItemMeta(meta);
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,7 @@ public class PUpdate_1_11_0 {
|
||||||
|
|
||||||
ItemGroupApi.addItemGroup(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
|
// Try to see if all the items was in the tools group. and if so, replace it with the new group
|
||||||
if (tools == null) return;
|
if (tools == null) return;
|
||||||
if (!(tools instanceof IncludeItemTypeGroup include)) return;
|
if (!(tools instanceof IncludeItemTypeGroup include)) return;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ abstract class AbstractItemTypeGroup(private val name: String) {
|
||||||
protected abstract fun createDefaultSet(): MutableSet<ItemType>
|
protected abstract fun createDefaultSet(): MutableSet<ItemType>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get if a material is allowed following the group policy
|
* Get if an item is allowed following the group policy
|
||||||
*/
|
*/
|
||||||
open fun contain(mat: ItemType): Boolean {
|
open fun contain(mat: ItemType): Boolean {
|
||||||
return mat in getItemTypes()
|
return mat in getItemTypes()
|
||||||
|
|
@ -98,19 +98,19 @@ abstract class AbstractItemTypeGroup(private val name: String) {
|
||||||
abstract fun setGroups(groups: MutableSet<AbstractItemTypeGroup>)
|
abstract fun setGroups(groups: MutableSet<AbstractItemTypeGroup>)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the contained group of this material group
|
* Get the contained group of this item group
|
||||||
*/
|
*/
|
||||||
abstract fun getGroups(): MutableSet<AbstractItemTypeGroup>
|
abstract fun getGroups(): MutableSet<AbstractItemTypeGroup>
|
||||||
|
|
||||||
open fun getRepresentativeItem(): ItemType {
|
open fun getRepresentativeItem(): ItemType {
|
||||||
// Test inner material
|
// Test inner item
|
||||||
val itemIterator = includedItems.iterator()
|
val itemIterator = includedItems.iterator()
|
||||||
while (itemIterator.hasNext()) {
|
while (itemIterator.hasNext()) {
|
||||||
val type = itemIterator.next()
|
val type = itemIterator.next()
|
||||||
if (type == ItemType.AIR) continue
|
if (type == ItemType.AIR) continue
|
||||||
return type
|
return type
|
||||||
}
|
}
|
||||||
// Test included group representative material
|
// Test included group representative item
|
||||||
val groupIterator = getGroups().iterator()
|
val groupIterator = getGroups().iterator()
|
||||||
while (groupIterator.hasNext()) {
|
while (groupIterator.hasNext()) {
|
||||||
val groupType = groupIterator.next().getRepresentativeItem()
|
val groupType = groupIterator.next().getRepresentativeItem()
|
||||||
|
|
|
||||||
|
|
@ -165,7 +165,7 @@ class EnchantConflictManager {
|
||||||
): AbstractItemTypeGroup {
|
): AbstractItemTypeGroup {
|
||||||
val group = itemManager.get(groupName)
|
val group = itemManager.get(groupName)
|
||||||
if (group == null) {
|
if (group == null) {
|
||||||
CustomAnvil.instance.logger.warning("Material group $groupName do not exist but is ask by conflict $conflictName")
|
CustomAnvil.instance.logger.warning("Item group $groupName do not exist but is ask by conflict $conflictName")
|
||||||
return IncludeItemTypeGroup("error_placeholder")
|
return IncludeItemTypeGroup("error_placeholder")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ class ItemGroupManager {
|
||||||
|
|
||||||
lateinit var groupMap: LinkedHashMap<String, AbstractItemTypeGroup>
|
lateinit var groupMap: LinkedHashMap<String, AbstractItemTypeGroup>
|
||||||
|
|
||||||
// Read and create material groups
|
// Read and create item groups
|
||||||
fun prepareGroups(config: ConfigurationSection) {
|
fun prepareGroups(config: ConfigurationSection) {
|
||||||
groupMap = LinkedHashMap()
|
groupMap = LinkedHashMap()
|
||||||
|
|
||||||
|
|
@ -51,7 +51,7 @@ class ItemGroupManager {
|
||||||
val groupSection = config.getConfigurationSection(key)!!
|
val groupSection = config.getConfigurationSection(key)!!
|
||||||
val groupType = groupSection.getString(GROUP_TYPE_PATH, null)
|
val groupType = groupSection.getString(GROUP_TYPE_PATH, null)
|
||||||
|
|
||||||
// Create Material group according to the group type
|
// Create item group according to the group type
|
||||||
val group: AbstractItemTypeGroup
|
val group: AbstractItemTypeGroup
|
||||||
if (groupType != null && GroupType.EXCLUDE.equal(groupType)) {
|
if (groupType != null && GroupType.EXCLUDE.equal(groupType)) {
|
||||||
group = ExcludeItemTypeGroup(key)
|
group = ExcludeItemTypeGroup(key)
|
||||||
|
|
@ -74,7 +74,7 @@ class ItemGroupManager {
|
||||||
config: ConfigurationSection,
|
config: ConfigurationSection,
|
||||||
keys: Set<String>
|
keys: Set<String>
|
||||||
) {
|
) {
|
||||||
// Read material to include in this group policy
|
// Read item to include in this group policy
|
||||||
val itemTypeNames = groupSection.getStringList(ITEMS_LIST_PATH)
|
val itemTypeNames = groupSection.getStringList(ITEMS_LIST_PATH)
|
||||||
for (typeName in itemTypeNames) {
|
for (typeName in itemTypeNames) {
|
||||||
val type = ItemTypeUtil.getItemType(typeName)
|
val type = ItemTypeUtil.getItemType(typeName)
|
||||||
|
|
|
||||||
|
|
@ -153,7 +153,7 @@ class AnvilCustomRecipe(
|
||||||
DEFAULT_RESULT_ITEM_CONFIG
|
DEFAULT_RESULT_ITEM_CONFIG
|
||||||
)
|
)
|
||||||
|
|
||||||
// Update material map
|
// Update item map
|
||||||
ConfigHolder.CUSTOM_RECIPE_HOLDER.recipeManager.cleanSetLeftItem(this, leftItem)
|
ConfigHolder.CUSTOM_RECIPE_HOLDER.recipeManager.cleanSetLeftItem(this, leftItem)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,7 @@ enum class LoreEditType(
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If the edit should consume the provided material
|
* If the edit should consume the provided item
|
||||||
*/
|
*/
|
||||||
val doConsume: Boolean
|
val doConsume: Boolean
|
||||||
get() {
|
get() {
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
# You can still manually edit here if you like to. but if you do, don't forget to /anvilconfigreload 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
|
# item conflicts
|
||||||
#
|
#
|
||||||
# If you want to edit this file:
|
# If you want to edit this file:
|
||||||
# - A conflict will apply to every item except if in one of the notAffectedGroups group
|
# - A conflict will apply to every item except if in one of the notAffectedGroups group
|
||||||
|
|
|
||||||
|
|
@ -2,11 +2,7 @@
|
||||||
# It is recommended that you use /configanvil to edit theses config.
|
# 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 /anvilconfigreload 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 !
|
||||||
#
|
#
|
||||||
|
# This config use the item namespace. or assume minecraft: namespace if absent.
|
||||||
# Please note this config use spigot material names.
|
|
||||||
# It should match minecraft name in most case, maybe every case, but I can't be sure
|
|
||||||
# In case there an issue with material name, you can found them here:
|
|
||||||
# https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Material.html
|
|
||||||
|
|
||||||
# An empty Exclude group exclude nothing, so it contain everything
|
# An empty Exclude group exclude nothing, so it contain everything
|
||||||
everything:
|
everything:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue