Search in sources :

Example 1 with DropDownComponent

use of org.dragonet.common.gui.DropDownComponent in project DragonProxy by DragonetMC.

the class TestCommand method testForm.

public static void testForm(UpstreamSession player) {
    ModalFormRequestPacket p = new ModalFormRequestPacket();
    CustomFormComponent form = new CustomFormComponent("\u00a7dTest Form");
    form.addComponent(new LabelComponent("\u00a71Text \u00a7ki"));
    form.addComponent(new LabelComponent("LABEL 2"));
    form.addComponent(new DropDownComponent("DROP DOWN", Arrays.asList("option 1", "option 2")));
    System.out.println(form.serializeToJson().toString());
    p.formId = 1;
    p.formData = form.serializeToJson().toString();
    player.sendPacket(p);
}
Also used : CustomFormComponent(org.dragonet.common.gui.CustomFormComponent) DropDownComponent(org.dragonet.common.gui.DropDownComponent) LabelComponent(org.dragonet.common.gui.LabelComponent)

Example 2 with DropDownComponent

use of org.dragonet.common.gui.DropDownComponent in project DragonProxy by DragonetMC.

the class DragonProxyFormCommand method onCommand.

@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    if (cmd.getName().equalsIgnoreCase("form")) {
        if ((sender instanceof Player)) {
            Player player = (Player) sender;
            if (this.plugin.isBedrockPlayer(player.getUniqueId())) {
                CustomFormComponent form = new CustomFormComponent("This is a test form");
                form.addComponent(new LabelComponent("Test label"));
                form.addComponent(new InputComponent("Test input").setPlaceholder("placeholder"));
                List<String> dropDown = new ArrayList();
                dropDown.add("Choice 1");
                dropDown.add("Choice 2");
                dropDown.add("Choice 3");
                form.addComponent(new DropDownComponent("Test dropdown", dropDown));
                BedrockPlayer.getForPlayer(player).sendForm(0, form);
            }
        // do something
        }
        return true;
    }
    return false;
}
Also used : BedrockPlayer(org.dragonet.plugin.bukkit.BedrockPlayer) Player(org.bukkit.entity.Player) InputComponent(org.dragonet.common.gui.InputComponent) ArrayList(java.util.ArrayList) CustomFormComponent(org.dragonet.common.gui.CustomFormComponent) DropDownComponent(org.dragonet.common.gui.DropDownComponent) LabelComponent(org.dragonet.common.gui.LabelComponent)

Aggregations

CustomFormComponent (org.dragonet.common.gui.CustomFormComponent)2 DropDownComponent (org.dragonet.common.gui.DropDownComponent)2 LabelComponent (org.dragonet.common.gui.LabelComponent)2 ArrayList (java.util.ArrayList)1 Player (org.bukkit.entity.Player)1 InputComponent (org.dragonet.common.gui.InputComponent)1 BedrockPlayer (org.dragonet.plugin.bukkit.BedrockPlayer)1