Skip to content
This repository has been archived by the owner on Feb 25, 2023. It is now read-only.
/ cloudforms Public archive

☁️ A callback based form library for Cloudburst and Nukkit (and anything else)

License

Notifications You must be signed in to change notification settings

lukeeey/cloudforms

Repository files navigation

CloudForms

CloudForms Discord

A callback-based form library for Cloudburst, Nukkit and any other project you may need it for.

Note

CloudForms is NOT compatible with the Nukkit Form API. An implementation example can be seen below:

// MyPlayerSession
private final AtomicInteger formIdCounter = new AtomicInteger(0);
private final Int2ObjectMap<Form> forms = new Int2ObjectOpenHashMap<>();

public void sendForm(Form form) {
    int formId = formIdCounter.incrementAndGet();

    ModalFormRequestPacket modalFormRequestPacket = new ModalFormRequestPacket();
    modalFormRequestPacket.formId = formId;
    modalFormRequestPacket.data = form.serialize().toString();

    player.dataPacket(modalFormRequestPacket);
    forms.put(formId, form);
}


// EventListener
@EventHandler
public void onPacketReceive(DataPacketReceiveEvent event) {
    if (event.getPacket() instanceof ModalFormResponsePacket) {
        ModalFormResponsePacket packet = (ModalFormResponsePacket) event.getPacket();
        MyPlayerSession session = (MyPlayerSession) SessionManager.get(event.getPlayer().getUniqueId());

        if(!session.getForms().containsKey(packet.formId)) {
            event.getPlayer().sendMessage(C.RED + "Form id from response does not exist in the map!");
            return;
        }
        session.getForms().get(packet.formId).handleResponse(packet.data);
    }
}

Including CloudForms in your project

For now, the only way is to use JitPack:

<repository>
    <id>jitpack.io</id>
    <url>https://jitpack.io</url>
</repository>
<dependency>
    <groupId>com.github.lukeeey</groupId>
    <artifactId>cloudforms</artifactId>
    <version>e74c525d22</version>
</dependency>

About

☁️ A callback based form library for Cloudburst and Nukkit (and anything else)

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages

No packages published

Languages