mostly removed all the reference to "material"

This commit is contained in:
alexcrea 2025-08-16 16:28:08 +02:00
parent 6dfd504177
commit 2947315013
Signed by: alexcrea
GPG key ID: E346CD16413450E3
10 changed files with 37 additions and 37 deletions

View file

@ -22,7 +22,7 @@ the plugin can be downloaded on
- Custom enchantment level limit.
- Custom anvil recipes.
- Custom enchant restrictions (allow unsafe enchantment only for a group of item or create new restriction).
- Custom items of unit repairs (repair damaged with unit of "material", for example the repair of diamond sword by diamonds).
- Custom items of unit repairs (repair damaged with unit of items types, for example the repair of diamond sword by diamonds).
- Custom XP cost for every aspect of the anvil.
- Permissions to bypass level limit or enchantment restriction.
- Display XP cost instead of "too expensive" when above level 40. (see below for more information)

View file

@ -18,7 +18,7 @@ public interface SelectItemTypeContainer {
Set<ItemType> illegalItems();
static List<String> getItemLore(SelectItemTypeContainer container, String containerType, String action) {
// Prepare material lore
// Prepare item lore
ArrayList<String> groupLore = new ArrayList<>();
groupLore.add("§7Allow you to select a list of §eitems §7that this " + containerType + " should " + action);
Set<ItemType> typeSet = container.getSelectedItems();

View file

@ -81,7 +81,7 @@ public class UnitRepairElementListGui extends
return;
}
// Add new material
// Add new item
ConfigHolder.UNIT_REPAIR_HOLDER.getConfig().set(parentType.getKey() + "." + type.getKey(), 0.25);
if (GuiSharedConstant.TEMPORARY_DO_SAVE_TO_DISK_EVERY_CHANGE) {
@ -92,7 +92,7 @@ public class UnitRepairElementListGui extends
updateValueForGeneric(type, true);
this.parentGui.updateValueForGeneric(this.parentType, true);
// Display material edit setting
// Display item edit setting
this.factoryMap.get(type).create().show(player);
},
true
@ -108,15 +108,15 @@ public class UnitRepairElementListGui extends
@Override
protected DoubleSettingGui.DoubleSettingFactory createFactory(ItemType type) {
String materialDisplayName = CasedStringUtil.snakeToUpperSpacedCase(type.getKey().getKey());
String displayName = CasedStringUtil.snakeToUpperSpacedCase(type.getKey().getKey());
return new DoubleSettingGui.DoubleSettingFactory(
"§0%§8" + materialDisplayName + " Repair",
"§0%§8" + displayName + " Repair",
this,
ConfigHolder.UNIT_REPAIR_HOLDER,
this.parentType.getKey() + "." + type.getKey(),
Arrays.asList(
"§7Click here to change how many §e% §7of §a" + materialDisplayName,
"§7Click here to change how many §e% §7of §a" + displayName,
"§7Should get repaired by §e" + this.typeName
),
2,

View file

@ -323,7 +323,7 @@ public class GroupConfigSubSettingGui extends MappedToListSubSettingGui implemen
// ----------------------------
// End of SelectGroupContainer related methods
// ----------------------------
// SelectMaterialContainer related methods
// SelectItemTypeContainer related methods
// ----------------------------
@Override
@ -368,7 +368,7 @@ public class GroupConfigSubSettingGui extends MappedToListSubSettingGui implemen
}
// ----------------------------
// End of SelectMaterialContainer related methods
// End of SelectItemTypeContainer related methods
// ----------------------------
private void updateDirectReferencingGroups(AbstractItemTypeGroup referenceTo) {

View file

@ -268,7 +268,7 @@ public class DoubleSettingGui extends AbstractSettingGui {
protected GuiItem stepGuiItem(int stepIndex) {
BigDecimal stepValue = holder.steps[stepIndex];
// Get material properties
// Get item properties
ItemType stepType;
StringBuilder stepName = new StringBuilder("§");
List<String> stepLore;

View file

@ -218,7 +218,7 @@ public class IntSettingsGui extends AbstractSettingGui {
protected GuiItem stepGuiItem(int stepIndex) {
int stepValue = holder.steps[stepIndex];
// Get material properties
// Get item properties
ItemType stepMat;
StringBuilder stepName = new StringBuilder("§");
List<String> stepLore;

View file

@ -29,10 +29,10 @@ public class ItemTypeSelectSettingGui extends MappedElementListConfigGui<ItemTyp
private final Gui backGui;
private boolean instantRemove;
private final List<ItemType> defaultMaterials;
private final Set<ItemType> illegalMaterials;
private final int defaultMaterialHash;
private int nowMaterialHash;
private final List<ItemType> defaultItems;
private final Set<ItemType> illegalItems;
private final int defaultItemHash;
private int nowItemHash;
public ItemTypeSelectSettingGui(
@NotNull SelectItemTypeContainer selector,
@ -43,11 +43,11 @@ public class ItemTypeSelectSettingGui extends MappedElementListConfigGui<ItemTyp
this.backGui = backGui;
this.instantRemove = false;
this.defaultMaterials = new ArrayList<>(this.selector.getSelectedItems());
this.illegalMaterials = this.selector.illegalItems();
this.defaultItems = new ArrayList<>(this.selector.getSelectedItems());
this.illegalItems = this.selector.illegalItems();
this.defaultMaterialHash = hashFromItemTypeList(this.defaultMaterials);
this.nowMaterialHash = this.defaultMaterialHash;
this.defaultItemHash = hashFromItemTypeList(this.defaultItems);
this.nowItemHash = this.defaultItemHash;
init();
@ -185,15 +185,15 @@ public class ItemTypeSelectSettingGui extends MappedElementListConfigGui<ItemTyp
HumanEntity player = event.getWhoClicked();
ItemStack cursor = player.getItemOnCursor();
// Test if cursor material allowed
// Test if cursor item allowed
ItemType cursorMat = cursor.getType().asItemType();
if (cursorMat == ItemType.AIR) return;
if (this.illegalMaterials.contains(cursorMat)) return;
if (this.illegalItems.contains(cursorMat)) return;
// Update gui only if item did not exist before.
if (!this.elementGuiMap.containsKey(cursorMat)) {
updateValueForGeneric(cursorMat, true);
this.nowMaterialHash ^= cursorMat.hashCode();
this.nowItemHash ^= cursorMat.hashCode();
setSaveItem();
update();
@ -218,7 +218,7 @@ public class ItemTypeSelectSettingGui extends MappedElementListConfigGui<ItemTyp
@Override
protected Collection<ItemType> getEveryDisplayableInstanceOfGeneric() {
return this.defaultMaterials;
return this.defaultItems;
}
@Override
@ -232,12 +232,12 @@ public class ItemTypeSelectSettingGui extends MappedElementListConfigGui<ItemTyp
if (this.instantRemove) {
removeItemType(type);
} else {
String materialName = CasedStringUtil.snakeToUpperSpacedCase(type.key().value().toLowerCase());
String name = CasedStringUtil.snakeToUpperSpacedCase(type.key().value().toLowerCase());
// Create and show confirm remove gui.
ConfirmActionGui confirmGui = new ConfirmActionGui(
"Remove " + materialName,
"§7Confirm Remove " + materialName.toLowerCase() + " from this list.",
"Remove " + name,
"§7Confirm Remove " + name.toLowerCase() + " from this list.",
this, this,
() -> {
removeItemType(type);
@ -253,7 +253,7 @@ public class ItemTypeSelectSettingGui extends MappedElementListConfigGui<ItemTyp
private void removeItemType(ItemType type) {
if (this.elementGuiMap.containsKey(type)) {
this.nowMaterialHash ^= type.hashCode(); //TODO check would this be valid with item type
this.nowItemHash ^= type.hashCode(); //TODO check would this be valid with item type
setSaveItem();
removeGeneric(type);
}
@ -270,11 +270,11 @@ public class ItemTypeSelectSettingGui extends MappedElementListConfigGui<ItemTyp
}
private static int hashFromItemTypeList(List<ItemType> itemTypeList) {
int defaultMaterialHash = 0;
int hash = 0;
for (ItemType type : itemTypeList) {
defaultMaterialHash ^= type.hashCode(); //TODO check would this be valid with item type
hash ^= type.hashCode(); //TODO check would this be valid with item type
}
return defaultMaterialHash;
return hash;
}
private void setSaveItem() {
@ -287,7 +287,7 @@ public class ItemTypeSelectSettingGui extends MappedElementListConfigGui<ItemTyp
}
private boolean testCantSave() {
return this.defaultMaterialHash == this.nowMaterialHash;
return this.defaultItemHash == this.nowItemHash;
}

View file

@ -72,11 +72,11 @@ public class GuiGlobalItems {
private static final ItemType DEFAULT_BACKGROUND_TYPE = ItemType.LIGHT_GRAY_STAINED_GLASS_PANE;
/**
* Get a background item with backgroundMat as the displayed material.
* Get a background item with backgroundMat as the displayed item type.
* A background item is a GuiItem that do nothing when interacted with and have an empty name.
*
* @param backgroundType The item type of the background.
* @return A background item with backgroundMat as material.
* @return A background item with backgroundMat as item type.
*/
public static GuiItem backgroundItem(ItemType backgroundType) {
ItemStack item = backgroundType.createItemStack();

View file

@ -17,8 +17,8 @@ public class GuiSharedConstant {
private GuiSharedConstant(){}
public static final ItemType SECONDARY_BACKGROUND_MATERIAL = ItemType.BLACK_STAINED_GLASS_PANE;
public static final GuiItem SECONDARY_BACKGROUND_ITEM = GuiGlobalItems.backgroundItem(GuiSharedConstant.SECONDARY_BACKGROUND_MATERIAL);
public static final ItemType SECONDARY_BACKGROUND_ITEM_TYPE = ItemType.BLACK_STAINED_GLASS_PANE;
public static final GuiItem SECONDARY_BACKGROUND_ITEM = GuiGlobalItems.backgroundItem(GuiSharedConstant.SECONDARY_BACKGROUND_ITEM_TYPE);
public static final String UPPER_FILLER_FULL_PLANE = "111111111";
public static final String EMPTY_GUI_FULL_LINE = "000000000";

View file

@ -96,7 +96,7 @@ class EnchantmentSquaredDependency(private val enchantmentSquaredPlugin: Plugin)
// Write groups and conflicts
writeMissingGroups()
writeMaterialRestriction(esEnchantments)
writeItemRestriction(esEnchantments)
writeEnchantmentConflicts(esEnchantments)
CustomAnvil.instance.logger.info("Enchantment Squared should now work as expected !")
@ -117,7 +117,7 @@ class EnchantmentSquaredDependency(private val enchantmentSquaredPlugin: Plugin)
ItemGroupApi.addItemGroup(trinkets)
}
private fun writeMaterialRestriction(esEnchantments: List<CAEnchantSquaredEnchantment>) {
private fun writeItemRestriction(esEnchantments: List<CAEnchantSquaredEnchantment>) {
for (enchantment in esEnchantments) {
val conflict = ConflictBuilder("restriction_${enchantment.key.key}", CustomAnvil.instance)
conflict.addEnchantment(enchantment)