Skip to content

Commit 177cbbe

Browse files
authored
Merge pull request #11 from simplecloudapp/refactor/cleanup
refactor: cleanup plugin
2 parents ca7ad2a + b34c876 commit 177cbbe

29 files changed

Lines changed: 943 additions & 1069 deletions

File tree

‎.github/workflows/release-dev.yml‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ jobs:
1313

1414
steps:
1515
- name: Checkout repository
16-
uses: actions/checkout@v3
16+
uses: actions/checkout@v7
1717
with:
1818
ref: main
1919

20-
- name: Set up JDK 21
21-
uses: actions/setup-java@v3
20+
- name: Set up JDK 25
21+
uses: actions/setup-java@v5
2222
with:
2323
distribution: 'adopt'
24-
java-version: '21'
24+
java-version: '25'
2525

2626
- name: Cache Gradle packages
2727
uses: actions/cache@v3

‎.gitignore‎

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,5 @@
11
.gradle
2-
**/build/
3-
!src/**/build/
4-
5-
# Ignore Gradle GUI config
6-
gradle-app.setting
7-
8-
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
9-
!gradle-wrapper.jar
10-
11-
# Avoid ignore Gradle wrappper properties
12-
!gradle-wrapper.properties
13-
14-
# Cache of project
15-
.gradletasknamecache
16-
17-
# Eclipse Gradle plugin generated files
18-
# Eclipse Core
19-
.project
20-
# JDT-specific (Eclipse Java Development Tools)
21-
.classpath
2+
build/
223

234
.idea/
245

‎LICENSE‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@
186186
same "printed page" as the copyright notice for easier
187187
identification within third-party archives.
188188

189-
Copyright [2024] [SimpleCloud]
189+
Copyright 2024-2026 SimpleCloud
190190

191191
Licensed under the Apache License, Version 2.0 (the "License");
192192
you may not use this file except in compliance with the License.

‎build.gradle.kts‎

Lines changed: 25 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,62 @@
1-
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
1+
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
2+
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
23

34
plugins {
45
alias(libs.plugins.kotlin)
56
alias(libs.plugins.shadow)
6-
alias(libs.plugins.kapt)
7-
`maven-publish`
87
}
98

10-
val baseVersion = "0.0.4"
11-
val commitHash = System.getenv("COMMIT_HASH")
12-
val snapshotversion = "${baseVersion}-dev.$commitHash"
13-
149
allprojects {
15-
group = "app.simplecloud.plugin.command"
16-
version = if (commitHash != null) snapshotversion else baseVersion
10+
group = "app.simplecloud.plugin"
11+
version = "0.0.5"
1712

1813
repositories {
19-
mavenLocal()
2014
mavenCentral()
2115
maven("https://buf.build/gen/maven")
2216
maven("https://repo.simplecloud.app/snapshots")
2317
maven("https://repo.papermc.io/repository/maven-public/")
24-
maven("https://repo.simplecloud.app/snapshots")
2518
}
2619
}
2720

2821
subprojects {
29-
apply(plugin = "org.jetbrains.kotlin.jvm")
30-
apply(plugin = "com.gradleup.shadow")
31-
apply(plugin = "org.jetbrains.kotlin.kapt")
32-
apply(plugin = "maven-publish")
22+
apply {
23+
plugin("kotlin")
24+
plugin("com.gradleup.shadow")
25+
}
3326

3427
dependencies {
3528
testImplementation(rootProject.libs.kotlin.test)
36-
implementation(rootProject.libs.kotlin.jvm)
3729
implementation(rootProject.libs.kotlinx.coroutines.core)
3830
}
3931

40-
publishing {
41-
publications {
42-
create<MavenPublication>("mavenJava") {
43-
from(components["java"])
44-
}
32+
kotlin {
33+
jvmToolchain(25)
34+
compilerOptions {
35+
jvmTarget = JvmTarget.JVM_25
36+
languageVersion = KotlinVersion.KOTLIN_2_4
37+
apiVersion = KotlinVersion.KOTLIN_2_4
4538
}
4639
}
4740

4841
java {
49-
toolchain.languageVersion.set(JavaLanguageVersion.of(21))
42+
toolchain.languageVersion.set(JavaLanguageVersion.of(25))
5043
}
5144

52-
kotlin {
53-
jvmToolchain(21)
54-
compilerOptions {
55-
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_0)
56-
jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_21)
57-
}
45+
tasks.test {
46+
useJUnitPlatform()
5847
}
5948

60-
tasks.named("shadowJar", ShadowJar::class) {
49+
tasks.shadowJar {
6150
mergeServiceFiles()
62-
relocate("org.incendo", "app.simplecloud.plugin.command.relocate.incendo")
63-
relocate("org.spongepowered", "app.simplecloud.plugin.command.relocate.spongepowered")
6451
archiveFileName.set("${project.name}.jar")
65-
archiveClassifier.set("")
6652
}
67-
}
6853

69-
tasks.test {
70-
useJUnitPlatform()
71-
}
54+
tasks.processResources {
55+
filesMatching("plugin.yml") {
56+
expand(
57+
"version" to project.version
58+
)
59+
}
60+
}
7261

73-
tasks.processResources {
74-
expand(
75-
"version" to project.version,
76-
"name" to project.name
77-
)
7862
}

‎command-bungeecord/build.gradle.kts‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ modrinth {
4040
"26.1.2",
4141
"26.2",
4242
)
43-
loaders.add("bungeecord")
44-
loaders.add("waterfall")
43+
loaders.addAll("bungeecord", "waterfall")
4544
changelog.set("https://docs.simplecloud.app/changelog")
4645
syncBodyFrom.set(rootProject.file("README.md").readText())
4746
}
Lines changed: 13 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,41 @@
11
package app.simplecloud.plugin.command.bungeecord
22

3-
import app.simplecloud.plugin.command.shared.CloudCommandHandler
4-
import app.simplecloud.plugin.command.shared.CloudSender
3+
import app.simplecloud.plugin.command.bungeecord.command.BungeeCloudSender
54
import app.simplecloud.plugin.command.shared.CommandPlugin
5+
import app.simplecloud.plugin.command.shared.command.CloudCommandHandler
66
import net.kyori.adventure.platform.bungeecord.BungeeAudiences
7-
import net.md_5.bungee.api.CommandSender
87
import net.md_5.bungee.api.plugin.Plugin
98
import org.incendo.cloud.SenderMapper
109
import org.incendo.cloud.bungee.BungeeCommandManager
1110
import org.incendo.cloud.execution.ExecutionCoordinator
12-
import kotlin.io.path.createDirectories
1311

1412
/**
1513
* @author Fynn Bauer in 2024
1614
*/
1715
class BungeeCordPlugin : Plugin() {
1816

19-
private lateinit var commandManager: BungeeCommandManager<CloudSender>
20-
private lateinit var commandPlugin: CommandPlugin
21-
17+
private val plugin = CommandPlugin(dataFolder.toPath())
2218
private val adventure = BungeeAudiences.create(this)
2319

2420
override fun onEnable() {
25-
commandPlugin = CommandPlugin(this.dataFolder.toPath())
26-
this.dataFolder.mkdirs()
27-
commandPlugin.loadConfig()
28-
29-
val executionCoordinator = ExecutionCoordinator.simpleCoordinator<CloudSender>()
30-
31-
val senderMapper = SenderMapper.create<CommandSender, CloudSender>(
32-
{ commandSender -> BungeeCordSender(commandSender, this) },
33-
{ cloudSender -> (cloudSender as BungeeCordSender).getCommandSender() }
34-
)
35-
36-
commandManager = BungeeCommandManager(
37-
this,
38-
executionCoordinator,
39-
senderMapper
40-
)
41-
42-
val cloudCommandHandler = CloudCommandHandler(commandManager, commandPlugin)
43-
cloudCommandHandler.createCloudCommand()
21+
plugin.loadConfig()
22+
CloudCommandHandler(createCommandManager(), plugin).createCloudCommand()
4423
}
4524

4625
override fun onDisable() {
4726
adventure.close()
4827
}
4928

5029
fun adventure(): BungeeAudiences {
51-
checkNotNull(this.adventure) { "Cannot retrieve audience provider while plugin is not enabled" }
5230
return this.adventure
5331
}
5432

33+
private fun createCommandManager(): BungeeCommandManager<BungeeCloudSender> {
34+
return BungeeCommandManager(
35+
this,
36+
ExecutionCoordinator.simpleCoordinator(),
37+
SenderMapper.create({ BungeeCloudSender(it, this) }, BungeeCloudSender::getCommandSender)
38+
)
39+
}
40+
5541
}

command-bungeecord/src/main/kotlin/app/simplecloud/plugin/command/bungeecord/BungeeCordSender.kt renamed to command-bungeecord/src/main/kotlin/app/simplecloud/plugin/command/bungeecord/command/BungeeCloudSender.kt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
package app.simplecloud.plugin.command.bungeecord
1+
package app.simplecloud.plugin.command.bungeecord.command
22

3-
import app.simplecloud.plugin.command.shared.CloudSender
3+
import app.simplecloud.plugin.command.bungeecord.BungeeCordPlugin
4+
import app.simplecloud.plugin.command.shared.command.CloudSender
45
import net.kyori.adventure.text.Component
56
import net.md_5.bungee.api.CommandSender
67

78
/**
89
* @author Fynn Bauer in 2024
910
*/
10-
class BungeeCordSender(private val commandSender: CommandSender, private val plugin: BungeeCordPlugin): CloudSender {
11+
class BungeeCloudSender(private val commandSender: CommandSender, private val plugin: BungeeCordPlugin): CloudSender {
1112

1213
fun getCommandSender(): CommandSender {
1314
return commandSender
@@ -20,4 +21,4 @@ class BungeeCordSender(private val commandSender: CommandSender, private val plu
2021
override fun hasPermission(permission: String): Boolean {
2122
return commandSender.hasPermission(permission)
2223
}
23-
}
24+
}

‎command-bungeecord/src/main/resources/plugin.yml‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
name: CommandPlugin
2-
version: 1.0.0
1+
name: simplecloud-command
2+
version: ${version}
33
author: SimpleCloud Maintainers
4+
description: Proxy commands for managing groups, servers, and players across the network
45
main: app.simplecloud.plugin.command.bungeecord.BungeeCordPlugin
56
depends: [simplecloud-api]
7+
68
permissions:
79
simplecloud.command.use:
810
default: false
@@ -31,4 +33,4 @@ permissions:
3133
simplecloud.command.player.message:
3234
default: false
3335
simplecloud.command.reload:
34-
default: false
36+
default: false

‎command-shared/build.gradle.kts‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
dependencies {
22
compileOnly(libs.simplecloud.api)
3-
api(libs.cloud.core)
4-
api(libs.adventure.api)
5-
api(libs.adventure.text.minimessage)
6-
api(libs.simplecloud.plugin)
7-
8-
implementation(libs.bundles.logging)
3+
implementation(libs.adventure.api)
4+
implementation(libs.adventure.text.minimessage)
5+
implementation(libs.simplecloud.plugin)
96
implementation(libs.bundles.configurate)
7+
implementation(libs.bundles.cloud.command)
108
}

‎command-shared/src/main/kotlin/app/simplecloud/plugin/command/shared/CommandPlugin.kt‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,16 @@ import java.nio.file.Path
77
/**
88
* @author Fynn Bauer in 2024
99
*/
10-
open class CommandPlugin(
10+
class CommandPlugin(
1111
dirPath: Path
1212
) {
13-
val config = ConfigurationFactory(
14-
dirPath.resolve("messages.yml").toFile(),
15-
MessageConfig::class.java,
16-
)
1713

14+
val config = ConfigurationFactory(dirPath.resolve("messages.yml").toFile(), MessageConfig::class.java)
1815
val messageConfiguration: MessageConfig
1916
get() = config.get()
2017

2118
fun loadConfig() {
2219
config.loadOrCreate(MessageConfig())
2320
}
21+
2422
}

0 commit comments

Comments
 (0)