mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-08-28 08:25:56 +02:00
add unit repair to item config
This commit is contained in:
parent
6178282386
commit
bc9ac1cc13
3 changed files with 22 additions and 9 deletions
|
|
@ -9,8 +9,10 @@ import org.bukkit.Material;
|
|||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import xyz.alexcrea.cuanvil.config.ConfigHolder;
|
||||
import xyz.alexcrea.cuanvil.gui.util.GuiGlobalActions;
|
||||
import xyz.alexcrea.cuanvil.gui.util.GuiGlobalItems;
|
||||
import xyz.alexcrea.cuanvil.util.UnitRepairUtil;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
|
|
@ -40,7 +42,7 @@ public class ItemConfigGui extends ChestGui {
|
|||
|
||||
displayMeta.setDisplayName("§aConfiguring " + material);
|
||||
displayItemstack.setItemMeta(displayMeta);
|
||||
pane.bindItem('D', new GuiItem(displayItemstack, GuiGlobalActions.stayInPlace, CustomAnvil.instance));
|
||||
pane.bindItem('D', new GuiItem(displayItemstack, GuiGlobalActions.stayInPlace, CustomAnvil.instance));
|
||||
|
||||
// Enchantment Conflicts item
|
||||
ItemStack enchantConflictItemstack = new ItemStack(Material.OAK_FENCE);
|
||||
|
|
@ -76,8 +78,7 @@ public class ItemConfigGui extends ChestGui {
|
|||
unitRepairMeta.setLore(Collections.singletonList("§7Click here to open anvil unit repair menu"));
|
||||
unirRepairItemstack.setItemMeta(unitRepairMeta);
|
||||
|
||||
//TODO
|
||||
GuiItem unitRepairItem = GuiGlobalItems.goToGuiItem(unirRepairItemstack, UnitRepairConfigGui.getInstance());
|
||||
GuiItem unitRepairItem = GuiGlobalItems.goToGuiItem(unirRepairItemstack, getUnitRepairConfigGui(material));
|
||||
pane.bindItem('7', unitRepairItem);
|
||||
|
||||
// Custom recipe item
|
||||
|
|
@ -118,16 +119,17 @@ public class ItemConfigGui extends ChestGui {
|
|||
return groupConfigGui;
|
||||
}
|
||||
|
||||
/*private UnitRepairConfigGui getUnitRepairConfigGui(NamespacedKey material) {
|
||||
private UnitRepairConfigGui getUnitRepairConfigGui(NamespacedKey material) {
|
||||
if (unitRepairConfigGui == null) {
|
||||
unitRepairConfigGui = new UnitRepairConfigGui(this);
|
||||
unitRepairConfigGui.setFilter(otherMat ->
|
||||
group.contain(material) //TODO check material & what inside
|
||||
otherMat.equals(material) || UnitRepairUtil.INSTANCE.findRawRepairValue(
|
||||
material, otherMat, ConfigHolder.UNIT_REPAIR_HOLDER.getConfig()) != null
|
||||
);
|
||||
unitRepairConfigGui.init();
|
||||
}
|
||||
|
||||
return unitRepairConfigGui;
|
||||
}*/
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ public class UnitRepairConfigGui extends
|
|||
protected ItemStack createItemForGeneric(@NotNull NamespacedKey material) {
|
||||
var unitConfig = ConfigHolder.UNIT_REPAIR_HOLDER.getConfig();
|
||||
var section = unitConfig.getConfigurationSection(material.toString().toLowerCase());
|
||||
var legacySection = unitConfig.getConfigurationSection(material.toString().toLowerCase());
|
||||
var legacySection = unitConfig.getConfigurationSection(material.getKey().toLowerCase());
|
||||
|
||||
String materialName = CasedStringUtil.snakeToUpperSpacedCase(material.getKey().toLowerCase());
|
||||
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ object UnitRepairUtil {
|
|||
if (other == null) return null
|
||||
val config = ConfigHolder.UNIT_REPAIR_HOLDER.config
|
||||
|
||||
val result = findRepairValue(this, other, config) ?: return null
|
||||
val result = findRawRepairValue(this, other, config) ?: return null
|
||||
|
||||
if(result > 0) return result
|
||||
|
||||
|
|
@ -36,7 +36,7 @@ object UnitRepairUtil {
|
|||
return userDefault
|
||||
}
|
||||
|
||||
private fun findRepairValue(
|
||||
private fun findRawRepairValue(
|
||||
self: ItemStack,
|
||||
other: ItemStack,
|
||||
config: FileConfiguration
|
||||
|
|
@ -50,6 +50,17 @@ object UnitRepairUtil {
|
|||
return checkSection(config, material.key, selfType)
|
||||
}
|
||||
|
||||
fun findRawRepairValue(
|
||||
self: NamespacedKey,
|
||||
other: NamespacedKey,
|
||||
config: FileConfiguration
|
||||
): Double? {
|
||||
val result = checkSection(config, other.toString(), self)
|
||||
if (result != null) return result
|
||||
|
||||
return checkSection(config, other.key, self)
|
||||
}
|
||||
|
||||
fun checkSection(
|
||||
config: FileConfiguration,
|
||||
path: String,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue