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)
    • allTypes

      public ContextMenu allTypes(BiConsumer<String,net.lenni0451.mcstructs.nbt.INbtTag> newTagAction)
      Allow all types to be created.
      Parameters:
      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, BiConsumer<String,net.lenni0451.mcstructs.nbt.INbtTag> 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
    • copy

      public ContextMenu copy(String name, net.lenni0451.mcstructs.nbt.INbtTag 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.INbtTag> 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
    • edit

      public <T extends net.lenni0451.mcstructs.nbt.INbtTag> 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
    • 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.INbtTag> 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.