Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH-22 Release 1.3.0 update. #22

Merged
merged 15 commits into from
May 24, 2024
Merged
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
25 changes: 12 additions & 13 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,29 @@
name: 'DeathRun Build'
on:
push:
branches: [ "ver/latest" ]
pull_request:
branches: [ "ver/latest" ]
jobs:
build:
runs-on: ubuntu-latest
runs-on: 'ubuntu-latest'
steps:
- name: 'Checkout'
uses: 'actions/checkout@v3'
- name: 'Install Java Development Kit (17)'
uses: actions/setup-java@v3
uses: 'actions/setup-java@v3'
with:
java-version: '17'
distribution: 'temurin'
cache: maven
- name: 'Build (Maven)'
run: 'mvn clean package'
- name: Upload (API)
uses: actions/upload-artifact@v3
- name: 'Assign Permissions'
run: 'chmod +x ./gradlew'
- name: 'Build (Gradle)'
run: './gradlew core:build'
- name: 'Upload (API)'
uses: 'actions/upload-artifact@v3'
with:
name: 'DeathRun (API)'
path: 'api/target/*.jar'
- name: Upload (Core)
uses: actions/upload-artifact@v3
path: 'api/build/libs/*.jar'
- name: 'Upload (Core)'
uses: 'actions/upload-artifact@v3'
with:
name: 'DeathRun (Core)'
path: 'core/target/*.jar'
path: 'core/build/libs/*.jar'
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
*.iml
**/*.iml
.idea/**
target/**
**/target/**
**/build/
**/.gradle/
**.jar
66 changes: 66 additions & 0 deletions api/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import com.palantir.gradle.gitversion.VersionDetails
import groovy.lang.Closure
import java.lang.String.format
import java.lang.String.valueOf

plugins {
id("java")
id("net.kyori.blossom") version "1.3.1"
id("com.palantir.git-version") version "3.0.0"
id("com.github.johnrengelman.shadow") version "8.1.1"
}

val versionDetails: Closure<VersionDetails> by extra
fun projectVersion(): String = if (versionDetails().branchName == "ver/latest")
valueOf(project.version) else format("%s (git/%s)", project.version, versionDetails().gitHash)

project.group = project.parent?.group!!
project.version = project.parent?.version!!

java {
toolchain.languageVersion.set(JavaLanguageVersion.of(17))
}

blossom {
replaceToken("{version}", projectVersion())
replaceToken("{gitBranch}", versionDetails().branchName)
replaceToken("{gitCommitHash}", versionDetails().gitHashFull)
}

repositories {
mavenCentral()
maven("https://repo.papermc.io/repository/maven-public/")
}

dependencies {

/* Minecraft */
compileOnly("com.destroystokyo.paper:paper-api:${project.parent?.property("minecraft.version")}")

/* JetBrains Annotations */
compileOnly("org.jetbrains:annotations:${project.parent?.property("jetbrains.annotations.version")}")
annotationProcessor("org.jetbrains:annotations:${project.parent?.property("jetbrains.annotations.version")}")

}

tasks {

withType<JavaCompile> {
options.encoding = "UTF-8"
}

shadowJar {
archiveFileName.set("${project.parent?.name}-${project.name}-${project.version}.jar")
}

build {
finalizedBy("finalize")
}

register("finalize") {
doLast {
file("build/libs/${project.name}-${project.version}.jar").delete()
}
}

}
53 changes: 0 additions & 53 deletions api/pom.xml

This file was deleted.

83 changes: 59 additions & 24 deletions api/src/main/java/pl/mrstudios/deathrun/api/API.java
Original file line number Diff line number Diff line change
@@ -1,47 +1,82 @@
package pl.mrstudios.deathrun.api;

import org.bukkit.plugin.PluginDescriptionFile;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import pl.mrstudios.deathrun.api.arena.IArena;
import pl.mrstudios.deathrun.api.arena.trap.ITrapRegistry;

public class API {
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static org.jetbrains.annotations.ApiStatus.Internal;
import static org.jetbrains.annotations.ApiStatus.ScheduledForRemoval;

private final @NotNull IArena arena;
private final @NotNull ITrapRegistry trapRegistry;
public record API(
@NotNull IArena arenaInstance,
@NotNull ITrapRegistry trapRegistryInstance
) {

private final @NotNull String version;
@Deprecated(
forRemoval = true,
since = "1.3.0"
)
@ScheduledForRemoval(inVersion = "1.4.0")
public @NotNull IArena getArena() {
return this.arenaInstance();
}

public API(
@NotNull IArena arena,
@NotNull ITrapRegistry trapRegistry,
@NotNull PluginDescriptionFile pluginDescriptionFile
) {
@Deprecated(
forRemoval = true,
since = "1.3.0"
)
@ScheduledForRemoval(inVersion = "1.4.0")
public @NotNull ITrapRegistry getTrapRegistry() {
return this.trapRegistryInstance();
}

setInstance(this);
@Deprecated(
forRemoval = true,
since = "1.3.0"
)
@ScheduledForRemoval(inVersion = "1.4.0")
public @NotNull String getVersion() {
return pluginVersion();
}

this.arena = arena;
this.trapRegistry = trapRegistry;
this.version = pluginDescriptionFile.getVersion();
@Deprecated(
forRemoval = true,
since = "1.3.0"
)
@ScheduledForRemoval(inVersion = "1.4.0")
public static @Nullable API instance;

/* Version Related */
public @NotNull String pluginVersion() {
return "{version}";
}

public @NotNull IArena getArena() {
return arena;
public @NotNull String pluginGitBranch() {
return "{gitBranch}";
}

public @NotNull ITrapRegistry getTrapRegistry() {
return trapRegistry;
public @NotNull String pluginGitCommit() {
return "{gitCommitHash}";
}

public @NotNull String getVersion() {
return version;
/* Static Methods */
public static @NotNull API apiInstance() {
return checkNotNull(instance, "Instance of API is not initialized yet!");
}

public static @NotNull API instance;

protected static void setInstance(@NotNull API api) {
instance = api;
@Internal
public static void createInstance(
@NotNull IArena arenaInstance,
@NotNull ITrapRegistry trapRegistryInstance
) {
checkArgument(instance == null, "Instance of API is already initialized!");
instance = new API(
arenaInstance,
trapRegistryInstance
);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

public interface IBooster {

int slot();
float power();
int delay();
@NotNull Integer slot();
@NotNull Float power();
@NotNull Integer delay();
@NotNull IBoosterItem item();
@NotNull IBoosterItem delayItem();
@NotNull Direction direction();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

public interface ICheckpoint {

int id();
@NotNull Integer id();
@NotNull Location spawn();
@NotNull List<Location> locations();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,24 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.Collection;
import java.util.Set;

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

public interface ITrapRegistry {

@Nullable Class<? extends ITrap> get(@NotNull String identifier);

void register(@NotNull Class<? extends ITrap> trapClass);

void register(@NotNull String identifier, @NotNull Class<? extends ITrap> trapClass);

@Deprecated(
since = "1.3.0",
forRemoval = true
) @ScheduledForRemoval(inVersion = "1.4.0")
@NotNull Set<String> list();

@NotNull Collection<String> trapRegistryKeys();

}
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package pl.mrstudios.deathrun.api.arena.trap.annotations;

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

@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

@Target(FIELD)
@Retention(RUNTIME)
public @interface Serializable {}
2 changes: 2 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
project.group = "pl.mrstudios.deathrun"
project.version = "1.3.0"
Loading
Loading