mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-06-23 08:14:00 +02:00
mostly removed all the reference to "material"
This commit is contained in:
parent
6dfd504177
commit
2947315013
10 changed files with 37 additions and 37 deletions
|
|
@ -22,7 +22,7 @@ the plugin can be downloaded on
|
||||||
- Custom enchantment level limit.
|
- Custom enchantment level limit.
|
||||||
- Custom anvil recipes.
|
- Custom anvil recipes.
|
||||||
- Custom enchant restrictions (allow unsafe enchantment only for a group of item or create new restriction).
|
- 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.
|
- Custom XP cost for every aspect of the anvil.
|
||||||
- Permissions to bypass level limit or enchantment restriction.
|
- Permissions to bypass level limit or enchantment restriction.
|
||||||
- Display XP cost instead of "too expensive" when above level 40. (see below for more information)
|
- Display XP cost instead of "too expensive" when above level 40. (see below for more information)
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ public interface SelectItemTypeContainer {
|
||||||
Set<ItemType> illegalItems();
|
Set<ItemType> illegalItems();
|
||||||
|
|
||||||
static List<String> getItemLore(SelectItemTypeContainer container, String containerType, String action) {
|
static List<String> getItemLore(SelectItemTypeContainer container, String containerType, String action) {
|
||||||
// Prepare material lore
|
// Prepare item lore
|
||||||
ArrayList<String> groupLore = new ArrayList<>();
|
ArrayList<String> groupLore = new ArrayList<>();
|
||||||
groupLore.add("§7Allow you to select a list of §eitems §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();
|
||||||
|
|
|
||||||
|
|
@ -81,7 +81,7 @@ public class UnitRepairElementListGui extends
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add new material
|
// Add new item
|
||||||
ConfigHolder.UNIT_REPAIR_HOLDER.getConfig().set(parentType.getKey() + "." + type.getKey(), 0.25);
|
ConfigHolder.UNIT_REPAIR_HOLDER.getConfig().set(parentType.getKey() + "." + type.getKey(), 0.25);
|
||||||
|
|
||||||
if (GuiSharedConstant.TEMPORARY_DO_SAVE_TO_DISK_EVERY_CHANGE) {
|
if (GuiSharedConstant.TEMPORARY_DO_SAVE_TO_DISK_EVERY_CHANGE) {
|
||||||
|
|
@ -92,7 +92,7 @@ public class UnitRepairElementListGui extends
|
||||||
updateValueForGeneric(type, true);
|
updateValueForGeneric(type, true);
|
||||||
this.parentGui.updateValueForGeneric(this.parentType, true);
|
this.parentGui.updateValueForGeneric(this.parentType, true);
|
||||||
|
|
||||||
// Display material edit setting
|
// Display item edit setting
|
||||||
this.factoryMap.get(type).create().show(player);
|
this.factoryMap.get(type).create().show(player);
|
||||||
},
|
},
|
||||||
true
|
true
|
||||||
|
|
@ -108,15 +108,15 @@ public class UnitRepairElementListGui extends
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected DoubleSettingGui.DoubleSettingFactory createFactory(ItemType type) {
|
protected DoubleSettingGui.DoubleSettingFactory createFactory(ItemType type) {
|
||||||
String materialDisplayName = CasedStringUtil.snakeToUpperSpacedCase(type.getKey().getKey());
|
String displayName = CasedStringUtil.snakeToUpperSpacedCase(type.getKey().getKey());
|
||||||
|
|
||||||
return new DoubleSettingGui.DoubleSettingFactory(
|
return new DoubleSettingGui.DoubleSettingFactory(
|
||||||
"§0%§8" + materialDisplayName + " Repair",
|
"§0%§8" + displayName + " Repair",
|
||||||
this,
|
this,
|
||||||
ConfigHolder.UNIT_REPAIR_HOLDER,
|
ConfigHolder.UNIT_REPAIR_HOLDER,
|
||||||
this.parentType.getKey() + "." + type.getKey(),
|
this.parentType.getKey() + "." + type.getKey(),
|
||||||
Arrays.asList(
|
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
|
"§7Should get repaired by §e" + this.typeName
|
||||||
),
|
),
|
||||||
2,
|
2,
|
||||||
|
|
|
||||||
|
|
@ -323,7 +323,7 @@ public class GroupConfigSubSettingGui extends MappedToListSubSettingGui implemen
|
||||||
// ----------------------------
|
// ----------------------------
|
||||||
// End of SelectGroupContainer related methods
|
// End of SelectGroupContainer related methods
|
||||||
// ----------------------------
|
// ----------------------------
|
||||||
// SelectMaterialContainer related methods
|
// SelectItemTypeContainer related methods
|
||||||
// ----------------------------
|
// ----------------------------
|
||||||
|
|
||||||
@Override
|
@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) {
|
private void updateDirectReferencingGroups(AbstractItemTypeGroup referenceTo) {
|
||||||
|
|
|
||||||
|
|
@ -268,7 +268,7 @@ public class DoubleSettingGui extends AbstractSettingGui {
|
||||||
protected GuiItem stepGuiItem(int stepIndex) {
|
protected GuiItem stepGuiItem(int stepIndex) {
|
||||||
BigDecimal stepValue = holder.steps[stepIndex];
|
BigDecimal stepValue = holder.steps[stepIndex];
|
||||||
|
|
||||||
// Get material properties
|
// Get item properties
|
||||||
ItemType stepType;
|
ItemType stepType;
|
||||||
StringBuilder stepName = new StringBuilder("§");
|
StringBuilder stepName = new StringBuilder("§");
|
||||||
List<String> stepLore;
|
List<String> stepLore;
|
||||||
|
|
|
||||||
|
|
@ -218,7 +218,7 @@ public class IntSettingsGui extends AbstractSettingGui {
|
||||||
protected GuiItem stepGuiItem(int stepIndex) {
|
protected GuiItem stepGuiItem(int stepIndex) {
|
||||||
int stepValue = holder.steps[stepIndex];
|
int stepValue = holder.steps[stepIndex];
|
||||||
|
|
||||||
// Get material properties
|
// Get item properties
|
||||||
ItemType stepMat;
|
ItemType stepMat;
|
||||||
StringBuilder stepName = new StringBuilder("§");
|
StringBuilder stepName = new StringBuilder("§");
|
||||||
List<String> stepLore;
|
List<String> stepLore;
|
||||||
|
|
|
||||||
|
|
@ -29,10 +29,10 @@ public class ItemTypeSelectSettingGui extends MappedElementListConfigGui<ItemTyp
|
||||||
private final Gui backGui;
|
private final Gui backGui;
|
||||||
private boolean instantRemove;
|
private boolean instantRemove;
|
||||||
|
|
||||||
private final List<ItemType> defaultMaterials;
|
private final List<ItemType> defaultItems;
|
||||||
private final Set<ItemType> illegalMaterials;
|
private final Set<ItemType> illegalItems;
|
||||||
private final int defaultMaterialHash;
|
private final int defaultItemHash;
|
||||||
private int nowMaterialHash;
|
private int nowItemHash;
|
||||||
|
|
||||||
public ItemTypeSelectSettingGui(
|
public ItemTypeSelectSettingGui(
|
||||||
@NotNull SelectItemTypeContainer selector,
|
@NotNull SelectItemTypeContainer selector,
|
||||||
|
|
@ -43,11 +43,11 @@ public class ItemTypeSelectSettingGui extends MappedElementListConfigGui<ItemTyp
|
||||||
this.backGui = backGui;
|
this.backGui = backGui;
|
||||||
this.instantRemove = false;
|
this.instantRemove = false;
|
||||||
|
|
||||||
this.defaultMaterials = new ArrayList<>(this.selector.getSelectedItems());
|
this.defaultItems = new ArrayList<>(this.selector.getSelectedItems());
|
||||||
this.illegalMaterials = this.selector.illegalItems();
|
this.illegalItems = this.selector.illegalItems();
|
||||||
|
|
||||||
this.defaultMaterialHash = hashFromItemTypeList(this.defaultMaterials);
|
this.defaultItemHash = hashFromItemTypeList(this.defaultItems);
|
||||||
this.nowMaterialHash = this.defaultMaterialHash;
|
this.nowItemHash = this.defaultItemHash;
|
||||||
|
|
||||||
init();
|
init();
|
||||||
|
|
||||||
|
|
@ -185,15 +185,15 @@ public class ItemTypeSelectSettingGui extends MappedElementListConfigGui<ItemTyp
|
||||||
HumanEntity player = event.getWhoClicked();
|
HumanEntity player = event.getWhoClicked();
|
||||||
ItemStack cursor = player.getItemOnCursor();
|
ItemStack cursor = player.getItemOnCursor();
|
||||||
|
|
||||||
// Test if cursor material allowed
|
// Test if cursor item allowed
|
||||||
ItemType cursorMat = cursor.getType().asItemType();
|
ItemType cursorMat = cursor.getType().asItemType();
|
||||||
if (cursorMat == ItemType.AIR) return;
|
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.
|
// Update gui only if item did not exist before.
|
||||||
if (!this.elementGuiMap.containsKey(cursorMat)) {
|
if (!this.elementGuiMap.containsKey(cursorMat)) {
|
||||||
updateValueForGeneric(cursorMat, true);
|
updateValueForGeneric(cursorMat, true);
|
||||||
this.nowMaterialHash ^= cursorMat.hashCode();
|
this.nowItemHash ^= cursorMat.hashCode();
|
||||||
|
|
||||||
setSaveItem();
|
setSaveItem();
|
||||||
update();
|
update();
|
||||||
|
|
@ -218,7 +218,7 @@ public class ItemTypeSelectSettingGui extends MappedElementListConfigGui<ItemTyp
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Collection<ItemType> getEveryDisplayableInstanceOfGeneric() {
|
protected Collection<ItemType> getEveryDisplayableInstanceOfGeneric() {
|
||||||
return this.defaultMaterials;
|
return this.defaultItems;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -232,12 +232,12 @@ public class ItemTypeSelectSettingGui extends MappedElementListConfigGui<ItemTyp
|
||||||
if (this.instantRemove) {
|
if (this.instantRemove) {
|
||||||
removeItemType(type);
|
removeItemType(type);
|
||||||
} else {
|
} else {
|
||||||
String materialName = CasedStringUtil.snakeToUpperSpacedCase(type.key().value().toLowerCase());
|
String name = CasedStringUtil.snakeToUpperSpacedCase(type.key().value().toLowerCase());
|
||||||
|
|
||||||
// Create and show confirm remove gui.
|
// Create and show confirm remove gui.
|
||||||
ConfirmActionGui confirmGui = new ConfirmActionGui(
|
ConfirmActionGui confirmGui = new ConfirmActionGui(
|
||||||
"Remove " + materialName,
|
"Remove " + name,
|
||||||
"§7Confirm Remove " + materialName.toLowerCase() + " from this list.",
|
"§7Confirm Remove " + name.toLowerCase() + " from this list.",
|
||||||
this, this,
|
this, this,
|
||||||
() -> {
|
() -> {
|
||||||
removeItemType(type);
|
removeItemType(type);
|
||||||
|
|
@ -253,7 +253,7 @@ public class ItemTypeSelectSettingGui extends MappedElementListConfigGui<ItemTyp
|
||||||
|
|
||||||
private void removeItemType(ItemType type) {
|
private void removeItemType(ItemType type) {
|
||||||
if (this.elementGuiMap.containsKey(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();
|
setSaveItem();
|
||||||
removeGeneric(type);
|
removeGeneric(type);
|
||||||
}
|
}
|
||||||
|
|
@ -270,11 +270,11 @@ public class ItemTypeSelectSettingGui extends MappedElementListConfigGui<ItemTyp
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int hashFromItemTypeList(List<ItemType> itemTypeList) {
|
private static int hashFromItemTypeList(List<ItemType> itemTypeList) {
|
||||||
int defaultMaterialHash = 0;
|
int hash = 0;
|
||||||
for (ItemType type : itemTypeList) {
|
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() {
|
private void setSaveItem() {
|
||||||
|
|
@ -287,7 +287,7 @@ public class ItemTypeSelectSettingGui extends MappedElementListConfigGui<ItemTyp
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean testCantSave() {
|
private boolean testCantSave() {
|
||||||
return this.defaultMaterialHash == this.nowMaterialHash;
|
return this.defaultItemHash == this.nowItemHash;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -72,11 +72,11 @@ public class GuiGlobalItems {
|
||||||
private static final ItemType DEFAULT_BACKGROUND_TYPE = ItemType.LIGHT_GRAY_STAINED_GLASS_PANE;
|
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.
|
* 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.
|
* @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) {
|
public static GuiItem backgroundItem(ItemType backgroundType) {
|
||||||
ItemStack item = backgroundType.createItemStack();
|
ItemStack item = backgroundType.createItemStack();
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,8 @@ public class GuiSharedConstant {
|
||||||
|
|
||||||
private GuiSharedConstant(){}
|
private GuiSharedConstant(){}
|
||||||
|
|
||||||
public static final ItemType SECONDARY_BACKGROUND_MATERIAL = ItemType.BLACK_STAINED_GLASS_PANE;
|
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_MATERIAL);
|
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 UPPER_FILLER_FULL_PLANE = "111111111";
|
||||||
public static final String EMPTY_GUI_FULL_LINE = "000000000";
|
public static final String EMPTY_GUI_FULL_LINE = "000000000";
|
||||||
|
|
|
||||||
|
|
@ -96,7 +96,7 @@ class EnchantmentSquaredDependency(private val enchantmentSquaredPlugin: Plugin)
|
||||||
|
|
||||||
// Write groups and conflicts
|
// Write groups and conflicts
|
||||||
writeMissingGroups()
|
writeMissingGroups()
|
||||||
writeMaterialRestriction(esEnchantments)
|
writeItemRestriction(esEnchantments)
|
||||||
writeEnchantmentConflicts(esEnchantments)
|
writeEnchantmentConflicts(esEnchantments)
|
||||||
|
|
||||||
CustomAnvil.instance.logger.info("Enchantment Squared should now work as expected !")
|
CustomAnvil.instance.logger.info("Enchantment Squared should now work as expected !")
|
||||||
|
|
@ -117,7 +117,7 @@ class EnchantmentSquaredDependency(private val enchantmentSquaredPlugin: Plugin)
|
||||||
ItemGroupApi.addItemGroup(trinkets)
|
ItemGroupApi.addItemGroup(trinkets)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun writeMaterialRestriction(esEnchantments: List<CAEnchantSquaredEnchantment>) {
|
private fun writeItemRestriction(esEnchantments: List<CAEnchantSquaredEnchantment>) {
|
||||||
for (enchantment in esEnchantments) {
|
for (enchantment in esEnchantments) {
|
||||||
val conflict = ConflictBuilder("restriction_${enchantment.key.key}", CustomAnvil.instance)
|
val conflict = ConflictBuilder("restriction_${enchantment.key.key}", CustomAnvil.instance)
|
||||||
conflict.addEnchantment(enchantment)
|
conflict.addEnchantment(enchantment)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue