disable create item if has filter

This commit is contained in:
alexcrea 2026-07-01 13:40:06 +02:00
parent 8b5202e562
commit 2a5eb8fdd7
Signed by: alexcrea
GPG key ID: E346CD16413450E3
2 changed files with 10 additions and 2 deletions

View file

@ -14,6 +14,7 @@ import org.jetbrains.annotations.Nullable;
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.CasedStringUtil;
import xyz.alexcrea.cuanvil.util.MaterialUtil;
import xyz.alexcrea.cuanvil.util.UnitRepairUtil;
@ -27,7 +28,7 @@ public class ItemConfigGui extends ChestGui {
public CustomRecipeConfigGui customRecipeConfigGui;
public ItemConfigGui(@NotNull Material display, @NotNull NamespacedKey material) {
super(3, material.getKey() + " Config", CustomAnvil.instance);
super(3, CasedStringUtil.snakeToUpperSpacedCase(material.getKey().toLowerCase()) + " Config", CustomAnvil.instance);
Pattern pattern = new Pattern(
"0000D0000",

View file

@ -37,6 +37,7 @@ public abstract class ElementListConfigGui<T> extends ChestGui implements ValueU
protected PatternPane backgroundPane;
private Predicate<T> filter = (t) -> true;
private boolean hasDefaultFilter = true;
protected ElementListConfigGui(@NotNull String title, Gui parent) {
super(6, title, CustomAnvil.instance);
@ -51,6 +52,7 @@ public abstract class ElementListConfigGui<T> extends ChestGui implements ValueU
public void setFilter(Predicate<T> filter) {
this.filter = filter;
this.hasDefaultFilter = false;
}
protected Pattern getBackgroundPattern() {
@ -119,7 +121,12 @@ public abstract class ElementListConfigGui<T> extends ChestGui implements ValueU
viewer.setItemOnCursor(cursor);
}, CustomAnvil.instance);
GuiItem createNew = prepareCreateNewItem();
GuiItem createNew;
if(hasDefaultFilter)
createNew = prepareCreateNewItem();
else
createNew = GuiSharedConstant.SECONDARY_BACKGROUND_ITEM;
if (createNew != null) {
this.backgroundPane.bindItem('C', createNew);
}