Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
67 changes: 31 additions & 36 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,42 +1,37 @@
.gradle
build/
!gradle/wrapper/gradle-wrapper.jar
!**/src/main/**/build/
!**/src/test/**/build/
# Compiled class file
*.class

### IntelliJ IDEA ###
.idea/modules.xml
.idea/jarRepositories.xml
.idea/compiler.xml
.idea/libraries/
*.iws
# Log file
*.log

# BlueJ files
*.ctxt

# Gradle
/.gradle/

# IntelliJ
*.iml
*.ipr
*.iws
.idea/
out/
!**/src/main/**/out/
!**/src/test/**/out/

### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
bin/
!**/src/main/**/bin/
!**/src/test/**/bin/

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar

### VS Code ###
.vscode/

### Mac OS ###
.DS_Store
#working directories
bin
build
target
.gradle
forge-download
out
/wgrp-paper/run/
/.kotlin/
82 changes: 74 additions & 8 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,19 +1,85 @@
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
`java-library`
`maven-publish`
id("java")
id("java-library")
id("org.jetbrains.kotlin.jvm")
id("net.kyori.indra") version "3.1.3"
id("net.kyori.indra.checkstyle") version "3.1.3"
}

allprojects {
apply(plugin = "maven-publish")
}
val checkstyleVersion = "9.3"

logger.lifecycle("""
logger.lifecycle(
"""
*******************************************
You are building DonateCase!
You are building WorldGuardRegionProtect!
If you encounter trouble:
1) Try running 'build' in a separate Gradle run
2) Use gradlew and not gradle
3) If you have a problem, you can join us discord https://discord.gg/kvqvA3GTVF

Output files will be in [subproject]/build/libs
*******************************************
""")
"""
)

repositories {
mavenCentral()
}

allprojects {
plugins.apply("java")
plugins.apply("java-library")
plugins.apply("org.jetbrains.kotlin.jvm")
plugins.apply("net.kyori.indra")
plugins.apply("net.kyori.indra.checkstyle")
plugins.apply("maven-publish")

indra {
checkstyle(checkstyleVersion)

kotlin {
jvmToolchain(21)
}

javaVersions {
target(21)
}
}
}

subprojects {
tasks.withType<JavaCompile> {
options.encoding = Charsets.UTF_8.name()
options.release.set(21)
}

tasks.withType<KotlinCompile> {
compilerOptions {
jvmTarget.set(JvmTarget.JVM_21)
languageVersion.set(KotlinVersion.KOTLIN_2_0)
}
}

tasks.withType<Test> {
testLogging {
events = mutableSetOf(TestLogEvent.PASSED, TestLogEvent.FAILED, TestLogEvent.SKIPPED)
exceptionFormat = TestExceptionFormat.FULL
showExceptions = true
showCauses = true
showStackTraces = true
}
}

tasks.test {
testLogging {
events("PASSED", "SKIPPED", "FAILED")
}
}

}
50 changes: 50 additions & 0 deletions donatecase-api/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
tasks.jar {
manifest {
attributes("Automatic-Module-Name" to "net.ritasister.dc.api")
}
}

publishing {
publications {
create<MavenPublication>("mavenJava") {
artifactId = "donatecase-api"
groupId = rootProject.group as String?
version = "1.0.21"

from(components["java"])
}
}

/*repositories {
val mavenUrl = "https://repo.codemc.io/repository/maven-releases/"

maven(mavenUrl) {
val mavenUsername: String? by project
val mavenPassword: String? by project
if (mavenUsername != null && mavenPassword != null) {
credentials {
username = mavenUsername
password = mavenPassword
}
}
}
}*/
}

repositories {
mavenCentral()
}

dependencies {
compileOnly("org.checkerframework:checker-qual:3.42.0")
compileOnly("org.jetbrains:annotations:24.1.0")
compileOnly("org.slf4j:slf4j-api:2.0.12")
}

tasks.withType<Javadoc> {
options.encoding = Charsets.UTF_8.name()
}

java {
withSourcesJar()
}
30 changes: 30 additions & 0 deletions donatecase-api/src/main/java/net/ritasister/dc/api/DonateCase.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package net.ritasister.dc.api;

import net.ritasister.dc.api.metadata.DonateCaseMetadata;
import net.ritasister.dc.api.platform.Platform;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.jetbrains.annotations.NotNull;

/**
* <p>The main interface for interacting with the DonateCase API.
* Provides access to various managers and utilities for region interaction,
* metadata retrieval, platform information, and more.</p>
*
* <p>For platforms without a Service Manager, this interface can be accessed through
* the static singleton accessor in {@link DonateCaseProvider}.</p>
*/
public interface DonateCase {

@NonNull
DonateCaseMetadata getMetaData();

/**
* Provides the {@link Platform} the plugin is running on.
* This includes details about the server platform type and its version.
*
* @return the platform information.
*/
@NotNull
Platform getPlatform();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
package net.ritasister.dc.api;

import org.checkerframework.checker.nullness.qual.NonNull;

import java.io.Serial;

import static org.jetbrains.annotations.ApiStatus.Internal;

/**
* The DonateCase API.
*
* <p>Provider to get the DonateCase api instance.</p>
*/
public final class DonateCaseProvider {

private static DonateCase instance = null;

/**
* Gets an instance of the {@link DonateCase} API,
* throwing {@link IllegalStateException} if the API is not loaded yet.
*
* <p>This method will never return null.</p>
*
* @return an instance of the DonateCase API
* @throws IllegalStateException if the API is not loaded yet
*/
public static @NonNull DonateCase get() {
final DonateCase instance = DonateCaseProvider.instance;
if (instance == null) {
throw new NotLoadedException();
}
return instance;
}

@Internal
static void register(final DonateCase donateCase) {
DonateCaseProvider.instance = donateCase;
}

@Internal
static void unregister() {
DonateCaseProvider.instance = null;
}

@Internal
private DonateCaseProvider() {
throw new UnsupportedOperationException("This class cannot be instantiated.");
}

/**
* Exception thrown when the API is requested before it has been loaded.
*/
private static final class NotLoadedException extends IllegalStateException {

@Serial
private static final long serialVersionUID = 1L;

private static final String MESSAGE = """
The DonateCase API isn't loaded yet!
This could be because:
a) the DonateCase plugin is not installed or it failed to enable
b) the plugin in the stacktrace does not declare a dependency on DonateCase
c) the plugin in the stacktrace is retrieving the API before the plugin 'enable' phase
(call the #get method in onEnable, not the constructor!)
""";

NotLoadedException() {
super(MESSAGE);
}

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package net.ritasister.dc.api.annotation;

import net.ritasister.wgrp.rslibs.permissions.UtilPermissions;
import org.jetbrains.annotations.NotNull;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
* Annotation for create subcommands.
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface SubCommand {

/**
* Set a subcommand name.
* @return subcommand name.
*/
String name();

/**
* Set a permissions for subcommand.
* @return permission for subcommand.
*/
@NotNull UtilPermissions permission() default UtilPermissions.NULL_PERM;

/**
* Create aliases for subcommand.
* @return aliases of subcommand.
*/
String[] aliases() default {};

/**
* Args
* @return tab complete arguments of subcommand.
*/
String[] tabArgs() default {};

/**
* Set description of subcommand.
* @return description.
*/
String description();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package net.ritasister.dc.api.annotation;
Loading