Skip to content

Commit acc4c7c

Browse files
committed
Merge branch 'refs/heads/feature'
# Conflicts: # core/src/main/kotlin/de/thepixel3261/momentum/core/util/PlaceholderUtil.kt # src/main/resources/plugin.yml
2 parents 2c93d9e + a7ce10d commit acc4c7c

49 files changed

Lines changed: 1539 additions & 651 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,3 +117,6 @@ runs/
117117

118118
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
119119
!gradle-wrapper.jar
120+
121+
#Wiki
122+
wiki/

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
- 🎁 **Progressive Rewards** - Unlock better rewards the longer you play
2121
- 🔄 **Recycling System** - Reset your progress for permanent multiplier boosts
2222
-**Multipliers** - Earn more with permission-based reward multipliers
23-
-**Session Persistence** - Progress continues across server restarts
23+
-**Session Persistence** - Progress continues across server switches (Redis enabled)
2424
- 💤 **AFK Detection** - Pauses timers when players are AFK
2525

2626
### Technical Features
@@ -74,7 +74,7 @@
7474
momentum.use: true # Allows using /momentum
7575
momentum.reload: op # Allows reloading the config
7676

77-
# Multiplier permissions (grant these to players)
77+
# Multiplier permissions (grant these to players) (more possible, like 2_5)
7878
momentum.multiplier.1_0: true # 1x (default)
7979
momentum.multiplier.2_0: false # 2x multiplier
8080
momentum.multiplier.3_0: false # 3x multiplier
@@ -104,7 +104,7 @@ momentum.multiplier.3_0: false # 3x multiplier
104104
## 📥 Installation
105105

106106
### Quick Start
107-
1. Download the latest release from [GitHub](https://github.com/thepixel3261/Momentum/releases) or [Modrinth](https://modrinth.com/plugin/momentum)
107+
1. Download the latest release from [GitHub](https://github.com/thepixel3261/Momentum/releases/latest) or [Modrinth](https://modrinth.com/plugin/momentum-rewards)
108108
2. Place the JAR in your server's `/plugins` folder
109109
3. Start your server to generate config files
110110
4. Configure `rewards.yml` with your desired rewards

api/build.gradle.kts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
plugins {
2+
`java-library`
3+
`maven-publish`
4+
}
5+
6+
group = "de.thepixel3261"
7+
version = rootProject.version
8+
9+
repositories {
10+
mavenCentral()
11+
}
12+
13+
java {
14+
withSourcesJar()
15+
withJavadocJar()
16+
}
17+
18+
publishing {
19+
publications {
20+
create<MavenPublication>("mavenJava") {
21+
from(components["java"])
22+
groupId = project.group.toString()
23+
artifactId = "api"
24+
version = project.version.toString()
25+
}
26+
}
27+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
package de.thepixel3261.momentum.api
2+
3+
import java.util.*
4+
5+
/**
6+
* Root service exposed by Momentum for other plugins.
7+
* Acquire via Bukkit ServicesManager or the static accessor [MomentumAPI.get()].
8+
*/
9+
interface MomentumService {
10+
fun sessions(): SessionService
11+
fun rewards(): RewardActionRegistry
12+
}
13+
14+
/** Session read/write access for other plugins. */
15+
interface SessionService {
16+
fun get(uuid: UUID): SessionSnapshot?
17+
18+
/** Modify a player's session atomically; creates a session if missing. */
19+
fun modify(uuid: UUID, modify: (MutableSession) -> Unit)
20+
}
21+
22+
/** Immutable view of a player's session. */
23+
data class SessionSnapshot(
24+
val uuid: UUID,
25+
val joinTime: Long,
26+
val lastActivity: Long,
27+
val totalPlayMinutes: Int,
28+
val claimedTiers: Set<Int>,
29+
val unlockedTiers: Set<Int>,
30+
val isAfk: Boolean,
31+
val multiplier: Double,
32+
val lastRecycle: Int,
33+
val recycles: Int,
34+
)
35+
36+
/** Mutable façade to edit selected fields of a session safely. */
37+
interface MutableSession {
38+
var totalPlayMinutes: Int
39+
var claimedTiers: MutableSet<Int>
40+
var unlockedTiers: MutableSet<Int>
41+
var isAfk: Boolean
42+
var multiplier: Double
43+
var lastRecycle: Int
44+
var recycles: Int
45+
}
46+
47+
/** Registry for reward action executors, addressable by config "type" id. */
48+
interface RewardActionRegistry {
49+
/** Register a new custom action id. Fails if id already exists unless [override] is true. */
50+
fun register(id: String, executor: RewardActionExecutor, override: Boolean = false)
51+
52+
/** Remove a previously registered action id. */
53+
fun unregister(id: String)
54+
55+
/** Fetch the executor for an id if present. */
56+
fun executorFor(id: String): RewardActionExecutor?
57+
}
58+
59+
/** Executes an action for a player; params come from rewards.yml action map. */
60+
fun interface RewardActionExecutor {
61+
fun execute(ctx: RewardActionContext)
62+
}
63+
64+
/** Context provided to executors. */
65+
data class RewardActionContext(
66+
val uuid: UUID,
67+
val session: SessionSnapshot,
68+
/** Raw parameters from config for this action (e.g., amount, command, etc.). */
69+
val params: Map<String, Any?>,
70+
/** Whether the action is visible in UI and optional lore defined in config. */
71+
val visible: Boolean,
72+
val lore: List<String>?,
73+
/** Multiplier currently applied to the player. */
74+
val multiplier: Double,
75+
)
76+
77+
/** Static accessor utility to fetch the service from Bukkit's ServicesManager. */
78+
object MomentumAPI {
79+
@Volatile
80+
private var instance: MomentumService? = null
81+
82+
fun get(): MomentumService? = instance
83+
84+
// Core sets/unsets this via reflection-safe calls; methods kept internal to avoid ABI leaks.
85+
fun internalSet(service: MomentumService?) {
86+
instance = service
87+
}
88+
}

build.gradle.kts

Lines changed: 33 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,43 @@
1+
/*
2+
* [Momentum] Rewards and More.
3+
* Copyright (C) 2025 thepixel3261
4+
* SPDX-License-Identifier: AGPL-3.0-or-later
5+
*
6+
* Additional terms (Section 7, AGPL‑3.0-or‑later):
7+
* If you modify and run this plugin on a publicly accessible Minecraft server,
8+
* you must publish the complete modified source via a public repository;
9+
* providing source “on request” does NOT satisfy this requirement.
10+
*
11+
* See LICENSE (bottom) for full additional terms.
12+
* See plugin.yml for full notice.
13+
*/
14+
115
plugins {
2-
id("java")
3-
id("org.jetbrains.kotlin.jvm") version "2.0.0"
4-
id("com.gradleup.shadow") version "8.3.0"
16+
kotlin("jvm") version "2.0.0"
517
}
618

719
group = "de.thepixel3261"
8-
version = File("src/main/resources/plugin.yml").readText(Charsets.UTF_8).substringAfter("version: '").substringBefore("'")
20+
version = "1.3.0"
921

10-
repositories {
11-
mavenCentral()
12-
maven("https://repo.papermc.io/repository/maven-public/")
13-
maven("https://jitpack.io")
14-
maven("https://repo.extendedclip.com/content/repositories/placeholderapi/")
15-
}
16-
17-
dependencies {
18-
implementation(kotlin("stdlib"))
19-
implementation(kotlin("reflect"))
20-
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.1")
21-
implementation("redis.clients:jedis:4.4.3")
22-
compileOnly("com.github.MilkBowl:VaultAPI:1.7")
23-
compileOnly("me.clip:placeholderapi:2.11.6")
24-
implementation("org.bstats:bstats-bukkit:3.1.0")
25-
implementation("net.kyori:adventure-api:4.14.0")
26-
implementation("net.kyori:adventure-platform-bukkit:4.3.0")
27-
}
22+
subprojects {
23+
apply(plugin = "org.jetbrains.kotlin.jvm")
2824

29-
tasks {
30-
shadowJar {
31-
relocate("org.bstats", "de.thepixel3261.momentum")
32-
archiveFileName.set("Momentum-$version.jar")
25+
repositories {
26+
mavenCentral()
27+
maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots/")
28+
maven("https://oss.sonatype.org/content/groups/public/")
3329
}
34-
build {
35-
dependsOn(shadowJar)
36-
}
37-
processResources {
38-
val props = mapOf("version" to version)
39-
inputs.properties(props)
40-
filteringCharset = "UTF-8"
41-
filesMatching("plugin.yml") {
42-
expand(props)
30+
31+
java {
32+
toolchain {
33+
languageVersion.set(JavaLanguageVersion.of(21))
4334
}
4435
}
4536
}
37+
38+
dependencies {
39+
implementation(kotlin("stdlib-jdk8"))
40+
}
41+
repositories {
42+
mavenCentral()
43+
}

core/build.gradle.kts

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
plugins {
2+
kotlin("jvm") version "2.0.0"
3+
id("com.gradleup.shadow") version "8.3.0"
4+
id("maven-publish")
5+
}
6+
7+
group = "de.thepixel3261"
8+
version = rootProject.version
9+
10+
repositories {
11+
mavenCentral()
12+
maven { url = uri("https://jitpack.io") }
13+
maven { url = uri("https://repo.papermc.io/repository/maven-public/") }
14+
maven { url = uri("https://repo.extendedclip.com/content/repositories/placeholderapi")}
15+
}
16+
17+
dependencies {
18+
implementation(project(":api")) //API
19+
implementation(kotlin("stdlib"))
20+
implementation(kotlin("reflect"))
21+
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.1")
22+
implementation("redis.clients:jedis:4.4.3")
23+
compileOnly("com.github.MilkBowl:VaultAPI:1.7")
24+
compileOnly("me.clip:placeholderapi:2.11.6")
25+
implementation("org.bstats:bstats-bukkit:3.1.0")
26+
implementation("net.kyori:adventure-api:4.14.0")
27+
implementation("net.kyori:adventure-platform-bukkit:4.3.0")
28+
//compileOnly("org.spigotmc:spigot-api:1.20.1-R0.1-SNAPSHOT")
29+
compileOnly("io.papermc.paper:paper-api:1.20.1-R0.1-SNAPSHOT")
30+
}
31+
32+
val targetJavaVersion = 21
33+
kotlin {
34+
jvmToolchain(targetJavaVersion)
35+
}
36+
37+
tasks.build {
38+
dependsOn("shadowJar")
39+
}
40+
41+
tasks.shadowJar {
42+
relocate("org.bstats", "de.thepixel3261.Momentum")
43+
archiveFileName.set("Momentum-${version}.jar")
44+
}
45+
46+
tasks.processResources {
47+
val props = mapOf("version" to version)
48+
inputs.properties(props)
49+
filteringCharset = "UTF-8"
50+
filesMatching("plugin.yml") {
51+
expand(props)
52+
}
53+
}
54+
55+
publishing {
56+
publications {
57+
create<MavenPublication>("mavenJava") {
58+
groupId = project.group.toString()
59+
artifactId = "core"
60+
version = project.version.toString()
61+
artifact(tasks.named("shadowJar"))
62+
}
63+
}
64+
}

0 commit comments

Comments
 (0)