Skip to content

palmmc/VanillaFormWrapper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

view - Examples

VanillaFormWrapper

A wrapper for Endstone in python to mimic Vanilla ScriptAPI form UIs.

Usage

  1. Download the latest release.

  2. Drop it into your plugin at the same level as your entry point script.

  3. Add the following import to the top of your script:

    from .form_wrapper import (
      ActionFormData,
      ActionFormResponse,
      ModalFormData,
      ModalFormResponse,
      MessageFormData,
      MessageFormResponse
    )
  4. And you're done!

Keep in mind that (due to the language barrier) this wrapper doesn't replicate vanilla forms 1:1.

However, it will still make the form process feel a lot more familiar, and hopefully, easier to understand.

Example

def example_modal_form(player: Player):
    form = ModalFormData()
    options = ["Option 1", "Option 2", "Option 3"]
    form.title("Test Form")
    form.dropdown("Test Dropdown", options)
    form.slider("Test Slider", 0, 100, 1)
    form.text_field("Test Text Field", "Enter text here")
    form.toggle("Test Toggle", False)
    form.submit_button("Booger")

    def submit(player: Player, response: ModalFormResponse):
        if response.canceled:
            player.send_message("§cForm canceled.")
            return
        else:
            player.send_message("§aDropdown: §f" + options[response.formValues[0]])
            player.send_message("§aSlider: §f" + str(response.formValues[1]))
            player.send_message("§aText Field: §f" + response.formValues[2])
            player.send_message("§aToggle: §f" + str(response.formValues[3]))
            return

    form.show(player).then(
        lambda player=Player, response=ModalFormResponse: submit(player, response)
    )

Issues

If you experience any issues or have a suggestion, please create an Issue, and I'll try to get to it when I can!

About

A wrapper to mimic Script API forms for Endstone.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages