Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
f0c1990
Update dependency section
theEvilReaper Apr 7, 2025
76bcdb0
Add jacoco usage
theEvilReaper Apr 7, 2025
2608d6f
Improve publish section
theEvilReaper Apr 7, 2025
69cd3dc
Update labels section
theEvilReaper Apr 8, 2025
f10e7b6
Add SetupData classes
theEvilReaper Apr 8, 2025
3de27bb
Add tests for the SetupData
theEvilReaper Apr 8, 2025
2f9fe28
Add new dependencies
theEvilReaper Apr 8, 2025
deecbb7
Add base class for some required data in tests
theEvilReaper Apr 8, 2025
ca86b01
Use new abstract base test class
theEvilReaper Apr 8, 2025
9e5df8f
Add test for the finish event
theEvilReaper Apr 8, 2025
4980ff2
Add finish event for the setup
theEvilReaper Apr 8, 2025
c2a2ecd
Update method call
theEvilReaper Apr 8, 2025
9436f52
Add SetupCreate event class
theEvilReaper Apr 8, 2025
a9beaf5
Add service structure
theEvilReaper Apr 8, 2025
29990f5
Improve gradle files
theEvilReaper Apr 10, 2025
bbace3c
Update junit5 monorepo to v5.12.2
renovate[bot] Apr 11, 2025
095b557
Merge pull request #3 from OneLiteFeatherNET/renovate/junit5-monorepo
theEvilReaper Apr 11, 2025
70efed1
Update dependency gradle to v8.14
renovate[bot] Apr 25, 2025
86eec3c
Merge pull request #6 from OneLiteFeatherNET/renovate/gradle-8.x
theEvilReaper Apr 29, 2025
2b904c5
Improve import part
theEvilReaper May 3, 2025
ef8dea1
Improve documentation
theEvilReaper May 3, 2025
2b00786
Update version part
theEvilReaper May 3, 2025
8da7641
Add readme content
theEvilReaper May 3, 2025
35ec7d4
Improve event section
theEvilReaper May 3, 2025
231297d
Remove some parts
theEvilReaper May 3, 2025
a241606
Update validation action
theEvilReaper May 5, 2025
eb3015e
Update gradle/actions action to v4
renovate[bot] May 5, 2025
48a773e
Merge pull request #7 from OneLiteFeatherNET/renovate/gradle-actions-4.x
theEvilReaper May 5, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/main-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Validate Gradle Wrapper
uses: gradle/wrapper-validation-action@v3
uses: gradle/actions/wrapper-validation@v4
- name: Setup Java
uses: actions/setup-java@v4
with:
Expand Down
43 changes: 43 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Guira

Guira is a lightweight Java library designed to help you implement flexible and robust setup processes for games, minigames, or any other custom features on a [Minestom](https://github.com/Minestom/Minestom) server. Rather than enforcing a fixed setup structure, Guira empowers you to define exactly what your setup should contain—such as maps, teams, rules, or any other configuration—by letting you design your own setup data types and logic. The library provides a solid and extensible foundation for storing, tracking, and managing this setup data, making it easy to build tailored setup flows for a wide range of server scenarios.

## Installation

Add the following to your `build.gradle.kts`:

```kotlin
dependencies {
compileOnly("net.onelitefeather.guira:guira:<version>>")
}
```

## Usage Example

```java
// Create a new SetupDataService instance
SetupDataService<MySetupData> service = SetupDataService.create();

// Add setup data
UUID uuid = UUID.randomUUID();
MySetupData data = new MySetupData(uuid, ...);
service.add(uuid, data);

// Retrieve setup data
Optional<MySetupData> retrieved = service.get(uuid);

// Remove setup data
service.remove(uuid);
```

### Event Handling

Guira provides events such as `SetupCreateEvent` and `SetupFinishEvent` for managing the setup process lifecycle.

> [!NOTE]
> **Guira does NOT automatically fire any of the provided events (`SetupCreateEvent`, `SetupFinishEvent`, etc).**
> You are responsible for triggering and handling these events in your own code/context (e.g., your Minestom server plugin or application).

## License

This project is licensed under the [Apache License 2.0](LICENSE).
78 changes: 70 additions & 8 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,19 +1,81 @@
plugins {
java
jacoco
`java-library`
`maven-publish`
alias(libs.plugins.publishdata)
}

group = "net.onelitefeather.guira"
version = "1.0-SNAPSHOT"
version = "0.1.0"

repositories {
mavenCentral()
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(21))
}
}

dependencies {
testImplementation(platform("org.junit:junit-bom:5.10.0"))
testImplementation("org.junit.jupiter:junit-jupiter")
compileOnly(libs.minestom)
compileOnly(libs.jetbrains.annotation)
compileOnly(libs.aves)

testImplementation(libs.minestom)
testImplementation(libs.minestom.test)
testImplementation(libs.aves)
testImplementation(libs.junit.api)
testRuntimeOnly(libs.junit.engine)
}

publishData {
addMainRepo("https://repo.onelitefeather.dev/onelitefeather-releases")
addMasterRepo("https://repo.onelitefeather.dev/onelitefeather-releases")
addSnapshotRepo("https://repo.onelitefeather.dev/onelitefeather-snapshots")
publishTask("jar")
}

tasks {
compileJava {
options.encoding = "UTF-8"
options.release.set(21)
}

compileTestJava {
options.encoding = "UTF-8"
options.release.set(21)
}

test {
finalizedBy(jacocoTestReport)
useJUnitPlatform()
jvmArgs("-Dminestom.inside-test=true")
testLogging {
events("passed", "skipped", "failed")
}
}
}

publishing {
publications {
create<MavenPublication>("maven") {
// configure the publication as defined previously.
publishData.configurePublication(this)
version = publishData.getVersion(false)
}
}
repositories {
maven {
authentication {
credentials(PasswordCredentials::class) {
username = System.getenv("ONELITEFEATHER_MAVEN_USERNAME")
password = System.getenv("ONELITEFEATHER_MAVEN_PASSWORD")
}
}

name = "OneLiteFeatherRepository"
// Get the detected repository from the publish data
url = uri(publishData.getRepository())
}
}
}

tasks.test {
useJUnitPlatform()
}
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
4 changes: 2 additions & 2 deletions gradlew

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions gradlew.bat

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"config:recommended"
],
"rebaseWhen": "conflicted",
"label": [
"labels": [
"renovate"
]
}
50 changes: 49 additions & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,2 +1,50 @@
rootProject.name = "Guira"
rootProject.name = "guira"

pluginManagement {
repositories {
gradlePluginPortal()
maven("https://eldonexus.de/repository/maven-public/")
}
}

dependencyResolutionManagement {
repositories {
mavenCentral()
maven {
name = "OneLiteFeatherRepository"
url = uri("https://repo.onelitefeather.dev/onelitefeather")
if (System.getenv("CI") != null) {
credentials {
username = System.getenv("ONELITEFEATHER_MAVEN_USERNAME")
password = System.getenv("ONELITEFEATHER_MAVEN_PASSWORD")
}
} else {
credentials(PasswordCredentials::class)
authentication {
create<BasicAuthentication>("basic")
}
}
}
}
versionCatalogs {
create("libs") {
version("minestom", "1.5.1")
version("aves", "1.6.1")
version("junit", "5.12.2")
version("publishdata", "1.4.0")
version("jetbrains.annotation", "26.0.2")

library("minestom", "net.onelitefeather.microtus", "Microtus").versionRef("minestom")
library("minestom.test", "net.onelitefeather.microtus.testing", "testing").versionRef("minestom")

library("aves", "de.icevizion.lib", "aves").versionRef("aves")

library("junit.api", "org.junit.jupiter", "junit-jupiter-api").versionRef("junit")
library("junit.engine", "org.junit.jupiter", "junit-jupiter-engine").versionRef("junit")
library("jetbrains.annotation", "org.jetbrains", "annotations").versionRef("jetbrains.annotation")

plugin("publishdata", "de.chojo.publishdata").versionRef("publishdata")
}
}
}

68 changes: 68 additions & 0 deletions src/main/java/net/onelitefeather/guira/SetupDataService.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package net.onelitefeather.guira;

import de.icevizion.aves.map.BaseMap;
import net.onelitefeather.guira.data.SetupData;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.UnmodifiableView;

import java.util.Map;
import java.util.Optional;
import java.util.UUID;

/**
* The (@link SetupDataService} is responsible for managing setup data during a runtime session.
* It allows adding, removing, and retrieving setup data associated with a unique identifier (UUID).
*
* @param <T> the type of setup data
* @author thEvilReaper
* @version 1.0.0
* @since 0.1.0
*/
public interface SetupDataService<T extends SetupData<? extends BaseMap>> {

/**
* Creates a new instance of SetupDataService.
*
* @param <T> the type of setup data
* @return a new instance of SetupDataService
*/
@Contract(pure = true)
static @NotNull <T extends SetupData<? extends BaseMap>> SetupDataService<T> create() {
return new SetupDataServiceImpl<>();
}

/**
* Adds a new setup data to the service.
*
* @param uuid the unique identifier for the setup data
* @param data the setup data to add
*/
void add(@NotNull UUID uuid, @NotNull T data);

/**
* Removes the setup data associated with the given UUID.
*
* @param uuid the unique identifier for the setup data
* @return an optional containing the removed setup data, or empty if not found
*/
@NotNull Optional<@Nullable T> remove(@NotNull UUID uuid);

/**
* Retrieves the setup data associated with the given UUID.
*
* @param uuid the unique identifier for the setup data
* @return an optional containing the setup data, or empty if not found
*/
@NotNull Optional<@Nullable T> get(@NotNull UUID uuid);

/**
* Returns an unmodifiable view of the setup data map.
*
* @return an unmodifiable view
*/
@NotNull
@UnmodifiableView
Map<UUID, T> getView();
}
41 changes: 41 additions & 0 deletions src/main/java/net/onelitefeather/guira/SetupDataServiceImpl.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package net.onelitefeather.guira;

import de.icevizion.aves.map.BaseMap;
import net.onelitefeather.guira.data.SetupData;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.UnmodifiableView;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import java.util.UUID;

public final class SetupDataServiceImpl<T extends SetupData<? extends BaseMap>> implements SetupDataService<T> {

private final Map<UUID, T> dataMap;

SetupDataServiceImpl() {
this.dataMap = new HashMap<>();
}

@Override
public void add(@NotNull UUID uuid, @NotNull T data) {
dataMap.put(uuid, data);
}

@Override
public @NotNull Optional<T> remove(@NotNull UUID uuid) {
return Optional.ofNullable(this.dataMap.remove(uuid));
}

@Override
public @NotNull Optional<T> get(@NotNull UUID uuid) {
return Optional.ofNullable(this.dataMap.get(uuid));
}

@Override
public @NotNull @UnmodifiableView Map<UUID, T> getView() {
return Collections.unmodifiableMap(this.dataMap);
}
}
Loading
Loading