Skip to content

Effortlessly manage events in your application with this lightweight and flexible event management library, designed to simplify the process of registering listeners and triggering events.

License

Notifications You must be signed in to change notification settings

SchizoidDevelopment/piko

Piko: Event Management for Kotlin

Effortlessly manage events in your Kotlin-based application with Piko, a lightweight and flexible event management library. Simplify the process of registering listeners and triggering events with ease.

Important

Piko is specifically designed for Kotlin and works best when used with Kotlin’s coding style. It’s strongly recommended to use it exclusively with Kotlin.

πŸ—οΈ Key Features

  • Lightweight Framework: Provides a streamlined framework for managing events and listeners.
  • Intuitive API: Offers an easy-to-use API for registering and triggering events.
  • Reduced Boilerplate: Minimizes boilerplate code by centralizing event management.
  • Maintainable Logic: Organizes listeners clearly to keep logic maintainable and easy to track.

πŸ“¦ Installation

Maven Central

Maven Central Version

Make sure to replace ${version} with the latest version of Piko!

Gradle (Kotlin DSL)
repositories {
    mavenCentral()
}

dependencies {
    implementation("dev.lyzev.api", "piko", "${version}")
}
Gradle (Version Catalog)
[versions]
piko = "${version}"

[libraries]
piko = { module = "dev.lyzev.api:piko", version.ref = "piko" }
Gradle (Groovy DSL)
repositories {
    mavenCentral()
}

dependencies {
    implementation 'dev.lyzev.api:piko:${version}'
}
Maven
<dependencies>
    <dependency>
        <groupId>dev.lyzev.api</groupId>
        <artifactId>piko</artifactId>
        <version>${version}</version>
    </dependency>
</dependencies>
Raw Jar
  1. Visit the Maven Central Repository and download the JAR file for the version you need.
  2. Add the downloaded JAR to your project.

πŸ’‘ Usage

Event Listener Example

Below is a simple example demonstrating how to implement an event listener.

import dev.lyzev.api.event.Event
import dev.lyzev.api.event.EventListener
import dev.lyzev.api.event.on

class TestEventListener : EventListener {

    var handle = true

    init {
        on<TestEvent>(Event.Priority.HIGH) { event ->
            if (event.a == 5)
                event.isCancelled = true
            println("TestEvent: ${event.a}")
        }
    }

    override val shouldHandleEvents
        get() = handle
}

In this example:

  1. We define a TestEventListener that implements EventListener.
  2. The handle variable determines whether the listener should process events.
  3. Changing handle allows enabling or disabling event handling.
  4. The on<TestEvent> function inside init registers the listener for TestEvent.
  5. Event.Priority.HIGH makes sure this listener runs before lower-priority ones.
  6. If event.a == 5, the event is canceled, preventing further processing.
Event Example

Below is a simple example demonstrating how to create an event.

import dev.lyzev.api.event.CancellableEvent

class TestEvent(val a: Int) : CancellableEvent()

In this example:

  1. We define a TestEvent class that extends CancellableEvent.
  2. The class has a single property, a, which stores an integer value.
  3. Since TestEvent extends CancellableEvent, it can be canceled by event listeners.

Tip

The library is quite intuitive, so it's a good idea to try it out. You'll quickly learn its capabilities.

πŸ“š Documentation

Warning

This documentation is automatically generated by Dokka.

For documentation, check out the Piko Documentation.

Documentation

🐞 Bugs and Suggestions

GitHub Issues πŸ›

For bugs or suggestions, please submit them via the GitHub Issue Tracker. Be sure to use the provided templates and include all relevant details to help us understand your issue and resolve it swiftly. Your cooperation is greatly appreciated!

GitHub Issues

Discord Community πŸ’¬

Need assistance or have minor questions? Join our welcoming community on the Discord server. Our members and staff are always ready to help!

Discord Server

🀝 Contribution Guidelines

We welcome contributions from the community! Please read our Contribution Guidelines to get started.

Pull Requests

πŸ”’ Security Policy

Please review our Security Policy to understand how we handle security vulnerabilities.

Caution

Please do not publicly disclose the vulnerability until it has been fixed.

πŸ“„ License

Copyright (C) 2025 Lyzev

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program. If not, see https://www.gnu.org/licenses/agpl-3.0.en.html.


Piko is developed and maintained by Schizoid Development. Thank you for using Piko!

About

Effortlessly manage events in your application with this lightweight and flexible event management library, designed to simplify the process of registering listeners and triggering events.

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Languages