Skip to content
This repository was archived by the owner on Aug 12, 2025. It is now read-only.

Commit ca12ef1

Browse files
authored
Merge pull request #5 from NextForge-Development/master
Merge master 2 dev
2 parents 196c46f + 5b290be commit ca12ef1

17 files changed

Lines changed: 490 additions & 77 deletions
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#-------------------------------------------------------------------------------#
2+
# Discover all capabilities of Qodana in our documentation #
3+
# https://www.jetbrains.com/help/qodana/about-qodana.html #
4+
#-------------------------------------------------------------------------------#
5+
6+
name: Qodana
7+
on:
8+
workflow_dispatch:
9+
pull_request:
10+
push:
11+
branches:
12+
- dev
13+
- master
14+
15+
jobs:
16+
qodana:
17+
runs-on: ubuntu-latest
18+
permissions:
19+
contents: write
20+
pull-requests: write
21+
checks: write
22+
steps:
23+
- uses: actions/checkout@v4
24+
with:
25+
ref: ${{ github.event.pull_request.head.sha }}
26+
fetch-depth: 0
27+
- name: 'Qodana Scan'
28+
uses: JetBrains/qodana-action@v2025.2
29+
env:
30+
QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }}
31+
with:
32+
# In pr-mode: 'true' Qodana checks only changed files
33+
pr-mode: false
34+
use-caches: true
35+
post-pr-comment: true
36+
use-annotations: true
37+
# Upload Qodana results (SARIF, other artifacts, logs) as an artifact to the job
38+
upload-result: false
39+
# quick-fixes available in Ultimate and Ultimate Plus plans
40+
push-fixes: 'none'

.github/workflows/release.yml

Lines changed: 56 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,32 @@
11
name: Release
22

3+
permissions:
4+
contents: write # Allow the workflow to write to the repository contents
5+
36
on:
47
push:
5-
branches: [main]
8+
branches: [ master, main ]
9+
workflow_dispatch:
10+
inputs:
11+
firstName:
12+
description: "Your first name"
13+
type: string
14+
default: Brad
15+
required: true
616

717
jobs:
818
release:
919
runs-on: ubuntu-latest
20+
1021
steps:
1122
- uses: actions/checkout@v4
23+
1224
- name: Set up JDK
1325
uses: actions/setup-java@v3
1426
with:
15-
java-version: '17'
27+
java-version: '23'
1628
distribution: 'temurin'
29+
1730
- name: Cache Gradle
1831
uses: actions/cache@v3
1932
with:
@@ -22,14 +35,48 @@ jobs:
2235
~/.gradle/wrapper
2336
key: gradle-${{ runner.os }}-${{ hashFiles('**/gradle-wrapper.properties') }}
2437
restore-keys: gradle-${{ runner.os }}-
38+
39+
- name: Make gradlew executable
40+
run: chmod +x gradlew
41+
2542
- name: Run tests
2643
run: ./gradlew test
44+
2745
- name: Build shadowJar
2846
run: ./gradlew shadowJar
29-
- name: Extract version
47+
48+
# 1) JAR-Pfad bestimmen
49+
- name: Find built JAR
50+
id: jar
51+
run: |
52+
JAR_PATH=$(ls build/libs/*.jar | head -n1)
53+
echo "jar_path=$JAR_PATH" >> $GITHUB_OUTPUT
54+
55+
# 2) Version aus plugin.yml im JAR extrahieren
56+
- name: Extract version from JAR
3057
id: vars
3158
run: |
32-
echo "version=$(grep -m1 '^version:' src/main/resources/plugin.yml | sed 's/version:[ ]*//')" >> $GITHUB_OUTPUT
59+
VERSION=$(unzip -p "${{ steps.jar.outputs.jar_path }}" plugin.yml \
60+
| grep '^version:' \
61+
| sed 's/version:[ ]*//')
62+
echo "version=$VERSION" >> $GITHUB_OUTPUT
63+
64+
# 3) Alle Tags holen, um lokal prüfen zu können
65+
- name: Fetch all tags
66+
run: git fetch --tags
67+
68+
# 4) Abbrechen, wenn der Tag schon existiert
69+
- name: Check if tag exists
70+
run: |
71+
TAG=${{ steps.vars.outputs.version }}
72+
if git ls-remote --tags origin "refs/tags/$TAG" | grep -q "$TAG"; then
73+
echo "❌ Tag '$TAG' existiert bereits. Breche ab."
74+
exit 1
75+
else
76+
echo "✅ Tag '$TAG' ist neu. Fortfahren..."
77+
fi
78+
79+
# 5) Release anlegen (Prerelease, wenn SNAPSHOT)
3380
- name: Create Release
3481
id: create
3582
uses: actions/create-release@v1
@@ -39,13 +86,16 @@ jobs:
3986
tag_name: ${{ steps.vars.outputs.version }}
4087
release_name: ${{ steps.vars.outputs.version }}
4188
draft: false
42-
prerelease: false
89+
# Prerelease = true, wenn Version auf "-SNAPSHOT" endet
90+
prerelease: ${{ endsWith( steps.vars.outputs.version, '-SNAPSHOT' ) }}
91+
92+
# 6) JAR hochladen
4393
- name: Upload JAR
4494
uses: actions/upload-release-asset@v1
4595
env:
4696
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4797
with:
4898
upload_url: ${{ steps.create.outputs.upload_url }}
49-
asset_path: $(ls build/libs/*.jar | head -n 1)
99+
asset_path: ${{ steps.jar.outputs.jar_path }}
50100
asset_name: nextcore-${{ steps.vars.outputs.version }}.jar
51101
asset_content_type: application/java-archive

build.gradle

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
plugins {
22
id 'java-library'
33
id 'maven-publish'
4-
id("io.papermc.paperweight.userdev") version "2.0.0-beta.17"
5-
id("com.gradleup.shadow") version "8.3.8"
4+
id "io.papermc.paperweight.userdev" version "2.0.0-beta.17"
5+
id "com.gradleup.shadow" version "8.3.8"
66
}
77

88
group = 'gg.nextforge'
9-
version = '1.0-SNAPSHOT'
10-
9+
version = '1.3-SNAPSHOT'
1110

1211
repositories {
1312
mavenCentral()
@@ -44,10 +43,17 @@ subprojects {
4443
implementation "com.google.code.gson:gson:2.10.1"
4544
implementation "org.bstats:bstats-bukkit:3.0.2"
4645
}
47-
}
4846

49-
test {
50-
useJUnitPlatform()
47+
// Version-Injection auch in Subprojects, falls benötigt
48+
tasks.withType(ProcessResources).configureEach {
49+
filesMatching("plugin.yml") {
50+
expand(
51+
version: project.version,
52+
group: project.group,
53+
name: project.name
54+
)
55+
}
56+
}
5157
}
5258

5359
java {
@@ -66,29 +72,29 @@ tasks {
6672
options.encoding = "UTF-8"
6773
}
6874

75+
// Haupt-Versionserweiterung für plugin.yml
6976
processResources {
7077
filesMatching("plugin.yml") {
7178
expand(
72-
version: project.version,
73-
group: project.group,
74-
name: project.name
79+
version: project.version,
80+
group: project.group,
81+
name: project.name
7582
)
7683
}
7784
}
7885
}
7986

8087
shadowJar {
88+
dependsOn(processResources)
8189
relocate("org.mozilla.javascript", "gg.nextforge.libraries.rhino")
8290
relocate("com.google.gson", "gg.nextforge.libraries.gson")
8391
relocate("org.bstats", "gg.nextforge.libraries.bstats")
8492
}
8593

8694
publishing {
87-
8895
repositories {
8996
mavenLocal()
9097
}
91-
9298
publications {
9399
create("mavenJava", MavenPublication) {
94100
from components.java
@@ -102,4 +108,4 @@ publishing {
102108
}
103109
}
104110
}
105-
}
111+
}

qodana.yaml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#-------------------------------------------------------------------------------#
2+
# Qodana analysis is configured by qodana.yaml file #
3+
# https://www.jetbrains.com/help/qodana/qodana-yaml.html #
4+
#-------------------------------------------------------------------------------#
5+
version: "1.0"
6+
7+
#Specify inspection profile for code analysis
8+
profile:
9+
name: qodana.starter
10+
11+
#Enable inspections
12+
#include:
13+
# - name: <SomeEnabledInspectionId>
14+
15+
#Disable inspections
16+
#exclude:
17+
# - name: <SomeDisabledInspectionId>
18+
# paths:
19+
# - <path/where/not/run/inspection>
20+
21+
projectJDK: "21" #(Applied in CI/CD pipeline)
22+
23+
#Execute shell command before Qodana execution (Applied in CI/CD pipeline)
24+
#bootstrap: sh ./prepare-qodana.sh
25+
26+
#Install IDE plugins before Qodana execution (Applied in CI/CD pipeline)
27+
#plugins:
28+
# - id: <plugin.id> #(plugin id can be found at https://plugins.jetbrains.com)
29+
30+
# Quality gate. Will fail the CI/CD pipeline if any condition is not met
31+
# severityThresholds - configures maximum thresholds for different problem severities
32+
# testCoverageThresholds - configures minimum code coverage on a whole project and newly added code
33+
# Code Coverage is available in Ultimate and Ultimate Plus plans
34+
#failureConditions:
35+
# severityThresholds:
36+
# any: 15
37+
# critical: 5
38+
# testCoverageThresholds:
39+
# fresh: 70
40+
# total: 50
41+
42+
#Qodana supports other languages, for example, Python, JavaScript, TypeScript, Go, C#, PHP
43+
#For all supported languages see https://www.jetbrains.com/help/qodana/linters.html
44+
linter: jetbrains/qodana-jvm-community:2025.2

src/main/java/gg/nextforge/NextCorePlugin.java

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,25 @@
11
package gg.nextforge;
22

3+
import gg.nextforge.command.builtin.NextCoreCommand;
4+
import gg.nextforge.config.ConfigFile;
5+
import gg.nextforge.config.ConfigManager;
36
import gg.nextforge.console.ConsoleHeader;
47
import gg.nextforge.plugin.NextForgePlugin;
8+
import gg.nextforge.scheduler.CoreScheduler;
9+
import gg.nextforge.scheduler.ScheduledTask;
10+
import gg.nextforge.updater.CoreAutoUpdater;
11+
import lombok.Getter;
512

13+
import java.io.IOException;
614
import java.util.UUID;
715

16+
@Getter
817
public class NextCorePlugin extends NextForgePlugin {
18+
19+
ConfigFile configFile;
20+
ConfigFile messagesFile;
21+
ScheduledTask updateCheckTask;
22+
923
@Override
1024
public int getMetricsId() {
1125
return 26427; // Replace with actual metrics ID if applicable
@@ -23,11 +37,65 @@ public void enable(boolean isReload) {
2337
return;
2438
}
2539

40+
configFile = getConfigManager().loadConfig("config.yml");
41+
messagesFile = getConfigManager().loadConfig("messages.yml");
42+
43+
getTextManager().placeholder("prefix", p -> {
44+
return messagesFile.getString("general.prefix", "<dark_gray>[<gradient:aqua:dark_aqua>ɴᴇxᴛᴄᴏʀᴇ<dark_gray>]</gradient></dark_gray>");
45+
});
46+
47+
new NextCoreCommand(this);
48+
2649
ConsoleHeader.send(this);
50+
51+
getSLF4JLogger().info("[NextForge] {} v{} is running as the core plugin.", getName(), getPluginVersion());
52+
53+
getSLF4JLogger().info("[NextForge] Initializing {} v{}...", getName(), getPluginVersion());
54+
55+
CoreAutoUpdater updater = new CoreAutoUpdater(getDataFolder().getParentFile());
56+
57+
int checkMillis = configFile.getInt("updater.check_interval", 7200000);
58+
int checkTicks = checkMillis / 50;
59+
if (configFile.getBoolean("updater.auto_update", true)) {
60+
updateCheckTask = CoreScheduler.runAsyncTimer(() -> {
61+
try {
62+
if (configFile.getBoolean("updater.disable_update_message", false)) {
63+
if (updater.isLatestVersion()) {
64+
getSLF4JLogger().info("[NextForge] You are running the latest version of NextCore.");
65+
} else {
66+
getSLF4JLogger().warn("[NextForge] A new version of NextForge is available! Please update to the latest version for the best experience.");
67+
getSLF4JLogger().warn("[NextForge] Current version: {}, Latest version: {}", getPluginVersion(), updater.fetchLatestVersion());
68+
getSLF4JLogger().warn("[NextForge] TIP: By changing the updater settings in config.yml, you can disable this message or change the update channel to 'dev'.");
69+
getSLF4JLogger().warn("[NextForge] TIP: By changing the updater settings in config.yml, you can automatically download the newest version.");
70+
}
71+
}
72+
if (configFile.getBoolean("updater.auto_update", true)) {
73+
if (!updater.isLatestVersion()) {
74+
getSLF4JLogger().info("[NextForge] Downloading the latest version of NextCore...");
75+
updater.downloadLatestJar(configFile.getString("updater.update_branch", "master").equalsIgnoreCase("dev")).thenAccept((file -> {
76+
getSLF4JLogger().info("[NextForge] Download complete. Please restart the server to apply the update.");
77+
}));
78+
} else {
79+
getSLF4JLogger().info("[NextForge] No updates available. You are already running the latest version.");
80+
}
81+
}
82+
} catch (IOException e) {
83+
throw new RuntimeException(e);
84+
}
85+
}, 1, checkTicks);
86+
}
87+
88+
getSLF4JLogger().info("[NextForge] {} v{} has been successfully enabled.", getName(), getPluginVersion());
2789
}
2890

2991
@Override
3092
public void disable() {
93+
if (updateCheckTask != null) {
94+
updateCheckTask.cancel();
95+
}
96+
97+
getSLF4JLogger().info("[NextForge] {} v{} is shutting down.", getName(), getPluginVersion());
3198

99+
getSLF4JLogger().info("[NextForge] {} v{} has been successfully disabled.", getName(), getPluginVersion());
32100
}
33101
}

src/main/java/gg/nextforge/command/CommandContext.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,15 @@ public void reply(String message) {
215215
sender.sendMessage(message);
216216
}
217217

218+
/**
219+
* Sends a message in minimessage format to the sender.
220+
*
221+
* @param message The message to send.
222+
*/
223+
public void replyMini(String message) {
224+
sender.sendRichMessage(message);
225+
}
226+
218227
/**
219228
* Gets the plugin instance.
220229
*

0 commit comments

Comments
 (0)