Class ContextMenu

java.lang.Object
net.lenni0451.imnbt.ui.ContextMenu

public class ContextMenu extends Object
A builder for the context menu when right clicking on a tag.
  • Method Details

    • start

      public static ContextMenu start(ImNbtDrawer drawer, Runnable modificationListener)
    • 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 created
      overwriteCheck - 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 created
      newTagAction - 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 tag
      newTagAction - 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 created
      newIndex - The index of the new tag
      newTagAction - The action to be executed when a new tag is created
      Returns:
      The builder instance
    • copy

      public ContextMenu copy(String name, net.lenni0451.mcstructs.nbt.NbtTag tag)
      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

      public ContextMenu paste(BiConsumer<String,net.lenni0451.mcstructs.nbt.NbtTag> pasteAction)
      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 transformed
      possibleTypes - The possible types the tag can be transformed into
      Returns:
      The builder instance
    • round

      public ContextMenu round(IntConsumer roundAction)
      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

      public ContextMenu sort(Runnable sortAction)
      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 tag
      tag - The tag to be edited
      nameEditConsumer - The consumer to be executed when the name is edited
      tagConsumer - 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 edited
      index - The index of the tag
      maxIndex - The maximum index of the tag
      indexEditConsumer - The consumer to be executed when the index is edited
      tagConsumer - The consumer to be executed when the tag is edited
      Returns:
      The builder instance
    • delete

      public ContextMenu delete(Runnable deleteListener)
      Allow a tag to be deleted.
      Parameters:
      deleteListener - The listener to be executed when the tag is deleted
      Returns:
      The builder instance
    • sNbtParser

      public ContextMenu sNbtParser(Supplier<net.lenni0451.mcstructs.nbt.NbtTag> sNbtSerializerListener)
      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.