mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-08-28 08:25:56 +02:00
disable create item if has filter
This commit is contained in:
parent
8ea1db382f
commit
23c7b0c753
2 changed files with 10 additions and 2 deletions
|
|
@ -14,6 +14,7 @@ import org.jetbrains.annotations.Nullable;
|
||||||
import xyz.alexcrea.cuanvil.config.ConfigHolder;
|
import xyz.alexcrea.cuanvil.config.ConfigHolder;
|
||||||
import xyz.alexcrea.cuanvil.gui.util.GuiGlobalActions;
|
import xyz.alexcrea.cuanvil.gui.util.GuiGlobalActions;
|
||||||
import xyz.alexcrea.cuanvil.gui.util.GuiGlobalItems;
|
import xyz.alexcrea.cuanvil.gui.util.GuiGlobalItems;
|
||||||
|
import xyz.alexcrea.cuanvil.util.CasedStringUtil;
|
||||||
import xyz.alexcrea.cuanvil.util.MaterialUtil;
|
import xyz.alexcrea.cuanvil.util.MaterialUtil;
|
||||||
import xyz.alexcrea.cuanvil.util.UnitRepairUtil;
|
import xyz.alexcrea.cuanvil.util.UnitRepairUtil;
|
||||||
|
|
||||||
|
|
@ -27,7 +28,7 @@ public class ItemConfigGui extends ChestGui {
|
||||||
public CustomRecipeConfigGui customRecipeConfigGui;
|
public CustomRecipeConfigGui customRecipeConfigGui;
|
||||||
|
|
||||||
public ItemConfigGui(@NotNull Material display, @NotNull NamespacedKey material) {
|
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(
|
Pattern pattern = new Pattern(
|
||||||
"0000D0000",
|
"0000D0000",
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,7 @@ public abstract class ElementListConfigGui<T> extends ChestGui implements ValueU
|
||||||
protected PatternPane backgroundPane;
|
protected PatternPane backgroundPane;
|
||||||
|
|
||||||
private Predicate<T> filter = (t) -> true;
|
private Predicate<T> filter = (t) -> true;
|
||||||
|
private boolean hasDefaultFilter = true;
|
||||||
|
|
||||||
protected ElementListConfigGui(@NotNull String title, Gui parent) {
|
protected ElementListConfigGui(@NotNull String title, Gui parent) {
|
||||||
super(6, title, CustomAnvil.instance);
|
super(6, title, CustomAnvil.instance);
|
||||||
|
|
@ -51,6 +52,7 @@ public abstract class ElementListConfigGui<T> extends ChestGui implements ValueU
|
||||||
|
|
||||||
public void setFilter(Predicate<T> filter) {
|
public void setFilter(Predicate<T> filter) {
|
||||||
this.filter = filter;
|
this.filter = filter;
|
||||||
|
this.hasDefaultFilter = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Pattern getBackgroundPattern() {
|
protected Pattern getBackgroundPattern() {
|
||||||
|
|
@ -119,7 +121,12 @@ public abstract class ElementListConfigGui<T> extends ChestGui implements ValueU
|
||||||
viewer.setItemOnCursor(cursor);
|
viewer.setItemOnCursor(cursor);
|
||||||
}, CustomAnvil.instance);
|
}, CustomAnvil.instance);
|
||||||
|
|
||||||
GuiItem createNew = prepareCreateNewItem();
|
GuiItem createNew;
|
||||||
|
if(hasDefaultFilter)
|
||||||
|
createNew = prepareCreateNewItem();
|
||||||
|
else
|
||||||
|
createNew = GuiSharedConstant.SECONDARY_BACKGROUND_ITEM;
|
||||||
|
|
||||||
if (createNew != null) {
|
if (createNew != null) {
|
||||||
this.backgroundPane.bindItem('C', createNew);
|
this.backgroundPane.bindItem('C', createNew);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue