Package net.lenni0451.imnbt.ui
Class ContextMenu
java.lang.Object
net.lenni0451.imnbt.ui.ContextMenu
A builder for the context menu when right clicking on a tag.
-
Method Summary
Modifier and TypeMethodDescriptionallTypes(int newIndex, BiConsumer<Integer, net.lenni0451.mcstructs.nbt.NbtTag> newTagAction) Allow all types to be created.allTypes(BiConsumer<String, net.lenni0451.mcstructs.nbt.NbtTag> newTagAction, Predicate<String> overwriteCheck) Allow all types to be created.Allow the tag to be copied.
The tag is cloned before it is copied.Allow a tag to be deleted.<T extends net.lenni0451.mcstructs.nbt.NbtTag>
ContextMenuAllow editing the tag.<T extends net.lenni0451.mcstructs.nbt.NbtTag>
ContextMenuedit(T tag, int index, int maxIndex, IntConsumer indexEditConsumer, Consumer<T> tagConsumer) Allow editing the tag with an index.paste(BiConsumer<String, net.lenni0451.mcstructs.nbt.NbtTag> pasteAction) Allow the clipboard to be pasted.voidrender()Render the context menu and handle the actions.round(IntConsumer roundAction) Allow rounding the tag to a specific amount of decimals.singleType(net.lenni0451.mcstructs.nbt.NbtType newType, int newIndex, BiConsumer<Integer, net.lenni0451.mcstructs.nbt.NbtTag> newTagAction) Allow only a single type to be created.singleType(net.lenni0451.mcstructs.nbt.NbtType newType, BiConsumer<String, net.lenni0451.mcstructs.nbt.NbtTag> newTagAction) Allow only a single type to be created.sNbtParser(Supplier<net.lenni0451.mcstructs.nbt.NbtTag> sNbtSerializerListener) Allow a tag to be serialized to SNbt.Allow sorting the tag.static ContextMenustart(ImNbtDrawer drawer, Runnable modificationListener) transform(Consumer<net.lenni0451.mcstructs.nbt.NbtType> typeConsumer, net.lenni0451.mcstructs.nbt.NbtType... possibleTypes) Allow transforming the tag into another type.
-
Method Details
-
start
-
allTypes
public ContextMenu allTypes(BiConsumer<String, net.lenni0451.mcstructs.nbt.NbtTag> newTagAction, Predicate<String> overwriteCheck) Allow all types to be created.- Parameters:
newTagAction- The action to be executed when a new tag is createdoverwriteCheck- Check if a tag with the name already exists- Returns:
- The builder instance
-
singleType
public ContextMenu singleType(net.lenni0451.mcstructs.nbt.NbtType newType, BiConsumer<String, net.lenni0451.mcstructs.nbt.NbtTag> newTagAction) Allow only a single type to be created.- Parameters:
newType- The type to be creatednewTagAction- The action to be executed when a new tag is created- Returns:
- The builder instance
-
allTypes
public ContextMenu allTypes(int newIndex, BiConsumer<Integer, net.lenni0451.mcstructs.nbt.NbtTag> newTagAction) Allow all types to be created.- Parameters:
newIndex- The index of the new tagnewTagAction- The action to be executed when a new tag is created- Returns:
- The builder instance
-
singleType
public ContextMenu singleType(net.lenni0451.mcstructs.nbt.NbtType newType, int newIndex, BiConsumer<Integer, net.lenni0451.mcstructs.nbt.NbtTag> newTagAction) Allow only a single type to be created.- Parameters:
newType- The type to be creatednewIndex- The index of the new tagnewTagAction- The action to be executed when a new tag is created- Returns:
- The builder instance
-
copy
Allow the tag to be copied.
The tag is cloned before it is copied.- Parameters:
tag- The tag to be copied- Returns:
- The builder instance
-
paste
Allow the clipboard to be pasted.- Parameters:
pasteAction- The action to be executed when the tag is pasted- Returns:
- The builder instance
-
transform
public ContextMenu transform(Consumer<net.lenni0451.mcstructs.nbt.NbtType> typeConsumer, net.lenni0451.mcstructs.nbt.NbtType... possibleTypes) Allow transforming the tag into another type.- Parameters:
typeConsumer- The consumer to be executed when the tag is transformedpossibleTypes- The possible types the tag can be transformed into- Returns:
- The builder instance
-
round
Allow rounding the tag to a specific amount of decimals.- Parameters:
roundAction- The action to be executed when the tag is rounded- Returns:
- The builder instance
-
sort
Allow sorting the tag.- Parameters:
sortAction- The action to be executed when the tag is sorted- Returns:
- The builder instance
-
edit
public <T extends net.lenni0451.mcstructs.nbt.NbtTag> ContextMenu edit(String name, T tag, Consumer<String> nameEditConsumer, Consumer<T> tagConsumer) Allow editing the tag.- Type Parameters:
T- The type of the tag- Parameters:
name- The name of the tagtag- The tag to be editednameEditConsumer- The consumer to be executed when the name is editedtagConsumer- The consumer to be executed when the tag is edited- Returns:
- The builder instance
-
edit
public <T extends net.lenni0451.mcstructs.nbt.NbtTag> ContextMenu edit(T tag, int index, int maxIndex, IntConsumer indexEditConsumer, Consumer<T> tagConsumer) Allow editing the tag with an index.- Type Parameters:
T- The type of the tag- Parameters:
tag- The tag to be editedindex- The index of the tagmaxIndex- The maximum index of the tagindexEditConsumer- The consumer to be executed when the index is editedtagConsumer- The consumer to be executed when the tag is edited- Returns:
- The builder instance
-
delete
Allow a tag to be deleted.- Parameters:
deleteListener- The listener to be executed when the tag is deleted- Returns:
- The builder instance
-
sNbtParser
Allow a tag to be serialized to SNbt.- Parameters:
sNbtSerializerListener- The listener to be executed when the tag is serialized- Returns:
- The builder instance
-
render
public void render()Render the context menu and handle the actions.
-