mirror of
https://github.com/jpenilla/MiniMOTD.git
synced 2026-11-06 09:32:33 -05:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1445370dc7 | ||
|
|
8703ac088f | ||
|
|
6b63fa9056 | ||
|
|
82e6dbe652 | ||
|
|
a45edc8831 | ||
|
|
4d65294991 | ||
|
|
73f758b64e | ||
|
|
63eaa9b736 | ||
|
|
b4e4db5c03 | ||
|
|
51b24eb23a | ||
|
|
effbc28d63 | ||
|
|
e9b1bec8ad | ||
|
|
2e6ad4ef6b | ||
|
|
dc0a82dbd1 | ||
|
|
53e5310f20 | ||
|
|
3b826d9bd8 | ||
|
|
08e61cae76 | ||
|
|
f4b611470d | ||
|
|
e9f72077dd | ||
|
|
29893c6d4a | ||
|
|
a4faabdcf7 | ||
|
|
b0ffd89ac1 | ||
|
|
2c3a9e910a | ||
|
|
08be102527 | ||
|
|
6bfd5a8d4b | ||
|
|
6647d18939 | ||
|
|
91d680530e | ||
|
|
1623e05602 | ||
|
|
6527c8a4ea | ||
|
|
ccfa6d6668 | ||
|
|
78584b29e1 | ||
|
|
708fdb792f | ||
|
|
236be5c2c4 | ||
|
|
b1e7105fc1 | ||
|
|
f4d4936622 | ||
|
|
848868565d | ||
|
|
418292d982 | ||
|
|
439f944ef9 | ||
|
|
bd95a09c0a | ||
|
|
f90b3f17b1 | ||
|
|
8c70ec3ea7 | ||
|
|
7f43d73230 | ||
|
|
1d4840e55f | ||
|
|
3bbb2dd18b | ||
|
|
ff5d418387 | ||
|
|
17af4ab03a | ||
|
|
a6d029d56b | ||
|
|
1edfa4b53a | ||
|
|
3f3cd43ab1 | ||
|
|
9728220a65 | ||
|
|
0e23a15f3d | ||
|
|
43cbc6aaf4 | ||
|
|
811be6e946 | ||
|
|
4a888a6032 | ||
|
|
1854f552fe | ||
|
|
dd60234690 | ||
|
|
2faeb581f1 | ||
|
|
e5447dd94e | ||
|
|
11c2dab22b | ||
|
|
c4b9c6e842 | ||
|
|
7cfb191e2c | ||
|
|
110d409fa2 | ||
|
|
facc10af69 | ||
|
|
ec1ef8b2e7 | ||
|
|
57e2dbb731 | ||
|
|
931fa06d55 | ||
|
|
47e642848e | ||
|
|
8b17cd0b8c | ||
|
|
030d144e51 | ||
|
|
14713f1585 | ||
|
|
a5f4855a64 | ||
|
|
1e979808c3 | ||
|
|
c113cc991e | ||
|
|
6f44b52c03 | ||
|
|
2cb658c3ba | ||
|
|
7e0dcf45a1 | ||
|
|
7230c27764 | ||
|
|
7f0b547b17 | ||
|
|
f0fea9c45a | ||
|
|
950de09b40 | ||
|
|
7a35dcf3ab | ||
|
|
84b5557d30 | ||
|
|
658178c477 | ||
|
|
ad529ec914 | ||
|
|
51b490be18 | ||
|
|
cd61adab95 | ||
|
|
fff3fc0711 | ||
|
|
5bd936ebe8 | ||
|
|
58566c4c73 | ||
|
|
be16547182 | ||
|
|
2fb0648c93 | ||
|
|
049e61df50 | ||
|
|
d4396a20bb | ||
|
|
2ef09d0669 | ||
|
|
f7c7afd7e5 | ||
|
|
d05dc770a5 | ||
|
|
f8ade792bf | ||
|
|
7dba88c9d2 | ||
|
|
b24955e113 | ||
|
|
89b8cbb26e | ||
|
|
25902d132b | ||
|
|
b1308e92ef | ||
|
|
410272d025 | ||
|
|
e065283ae9 | ||
|
|
c7a27a212f | ||
|
|
ff99a0c231 | ||
|
|
f8e8e81ace | ||
|
|
01a1091c5e | ||
|
|
77a200203c | ||
|
|
cd88a2b73d | ||
|
|
6a9bb08a1b | ||
|
|
eab3617449 | ||
|
|
73de0a0cff | ||
|
|
ae1ea24c97 | ||
|
|
77e64e78bc | ||
|
|
a1bacb1747 | ||
|
|
8e6f9ea77d | ||
|
|
03a95129f7 | ||
|
|
6fc1f06fd9 | ||
|
|
cf918948c8 | ||
|
|
96254e790f | ||
|
|
ba6613e622 | ||
|
|
1a1a4359c8 | ||
|
|
3e01f4a40c | ||
|
|
31c24fc0f7 | ||
|
|
87b74f6343 | ||
|
|
558e0a1b2c | ||
|
|
3fd8465433 | ||
|
|
689563a56e | ||
|
|
180002e0e1 | ||
|
|
b39cfdeb56 | ||
|
|
9a74c14f00 | ||
|
|
ad8233a4d2 | ||
|
|
0df4bc3c59 | ||
|
|
9f216d90e6 | ||
|
|
4c3f049e06 | ||
|
|
095841448d | ||
|
|
9378ea4d5d | ||
|
|
88a45eff62 | ||
|
|
a5a8d10940 | ||
|
|
79637815f6 | ||
|
|
7f5a43f89f | ||
|
|
c7a8656d3f | ||
|
|
a8a046d3ba | ||
|
|
cb8ffffe6f | ||
|
|
3b15660097 | ||
|
|
80d16d2b13 | ||
|
|
16e8253fa0 | ||
|
|
a7042a8263 | ||
|
|
9a77ed8b88 | ||
|
|
9a2bba7fc3 | ||
|
|
a8c8848420 | ||
|
|
1ae536586e | ||
|
|
b8a865a16f | ||
|
|
7de803fda2 | ||
|
|
8d27f17184 | ||
|
|
949ba5f21c | ||
|
|
10c0e521c3 | ||
|
|
831894876c | ||
|
|
d0618af8ea | ||
|
|
d79ead8b13 | ||
|
|
9c17676b74 | ||
|
|
230ed8142a | ||
|
|
f155500f49 | ||
|
|
5afd801850 | ||
|
|
2681390aad | ||
|
|
3a56d24107 | ||
|
|
13260762d4 | ||
|
|
42a2c56770 | ||
|
|
921055f2b0 | ||
|
|
a6af02ae63 | ||
|
|
22ff761ee0 | ||
|
|
9a274d1550 | ||
|
|
af6610cdb2 | ||
|
|
d9a6d9eb74 | ||
|
|
656f153bec | ||
|
|
266d3ff7dc | ||
|
|
7d682d8121 | ||
|
|
11886270a8 | ||
|
|
60e2e9ceee | ||
|
|
f9482769b8 | ||
|
|
98d12c4e39 | ||
|
|
4658d70e45 | ||
|
|
f9355a6fb1 | ||
|
|
c8a94b738a | ||
|
|
596c07e11f | ||
|
|
f60d66673f | ||
|
|
40bf7d13d6 | ||
|
|
25ef13dc69 | ||
|
|
1d53ffedd1 | ||
|
|
e3e99577d1 | ||
|
|
59a8b3d82a | ||
|
|
a30d1bf7fb | ||
|
|
6be04f7700 | ||
|
|
91c33014ba | ||
|
|
19917d4eaa | ||
|
|
77283d0c84 | ||
|
|
376682eac8 | ||
|
|
f5c576e839 | ||
|
|
6bc70cf054 | ||
|
|
12993bb866 | ||
|
|
5a742f62e5 | ||
|
|
000dfda192 | ||
|
|
8c66bcd408 | ||
|
|
2d47e73d3b | ||
|
|
f500c9fb8f | ||
|
|
922079cc7d | ||
|
|
798946390b | ||
|
|
743a149f3b | ||
|
|
316945b30f | ||
|
|
c8bf42463c | ||
|
|
a9bf505028 | ||
|
|
60bfb21444 | ||
|
|
fb13022642 | ||
|
|
1bbf3abd9a | ||
|
|
1967d9802f | ||
|
|
6b3d7aeab6 | ||
|
|
267c0426fe | ||
|
|
c3d5afa680 | ||
|
|
2009684fb5 | ||
|
|
56202f3f26 | ||
|
|
f2be2062e5 | ||
|
|
4cbe7d4bf9 | ||
|
|
fd20b5e583 | ||
|
|
e495e76a2d | ||
|
|
a37e7d8b7c | ||
|
|
b97ebcbbd6 | ||
|
|
2abf0c1eba | ||
|
|
80df7d0500 | ||
|
|
b7318a1ac8 | ||
|
|
b5e5848bd9 | ||
|
|
22064b8576 | ||
|
|
aac6cab5f6 | ||
|
|
7197cf9100 | ||
|
|
b3c448136d | ||
|
|
25ad706ebf | ||
|
|
3c04370488 | ||
|
|
5a3c52481a | ||
|
|
2eb0ba1e98 | ||
|
|
b38e08daa0 | ||
|
|
3c61a2d24b | ||
|
|
611772f4bb | ||
|
|
118cef163a | ||
|
|
d17e4af825 | ||
|
|
19a21d988f | ||
|
|
0cd04574f9 | ||
|
|
5acc5d285d | ||
|
|
3d9e90d7bf | ||
|
|
c39cad4017 | ||
|
|
9c9c67776b | ||
|
|
2858de84ae | ||
|
|
64b023fad7 | ||
|
|
f59de86c5e | ||
|
|
0f1c69f8b2 | ||
|
|
f8deb9b7fb | ||
|
|
8428e2b124 | ||
|
|
8f91a1b445 | ||
|
|
0ca1f8f19d | ||
|
|
2fd3d41cbd | ||
|
|
ce201ba89e | ||
|
|
e33135d3c6 | ||
|
|
5f6e2789e2 | ||
|
|
add32b31e7 | ||
|
|
b2b2801907 | ||
|
|
c919c40a59 | ||
|
|
b3cc4bce5c | ||
|
|
6fdf75dd3d | ||
|
|
a8c2b0f23e | ||
|
|
0ee99d90f2 | ||
|
|
6623a5928e | ||
|
|
6532c03706 | ||
|
|
0bf3bfba7f | ||
|
|
f7094e0a77 | ||
|
|
563da7f255 | ||
|
|
51e599838d | ||
|
|
e4970016e4 | ||
|
|
2a04d0b2c8 | ||
|
|
f8c6c2db6f | ||
|
|
9e25b68d00 | ||
|
|
96b7d12743 | ||
|
|
328ad6cd39 | ||
|
|
c0ee968e5b | ||
|
|
bc4d1e3cdd | ||
|
|
2626ed4551 | ||
|
|
a1f51db093 | ||
|
|
59ab61825b | ||
|
|
5d7f79ce8a | ||
|
|
a5145384f6 | ||
|
|
fba4066522 | ||
|
|
3c9261a92d | ||
|
|
ab409537ac | ||
|
|
98a5bba407 | ||
|
|
87bec5315b | ||
|
|
bf9d92150c | ||
|
|
4cad4d461b | ||
|
|
fc7b78f7a8 | ||
|
|
15cffc2d71 | ||
|
|
28cb91a40c | ||
|
|
4ab6567fd2 | ||
|
|
bdac395c2d | ||
|
|
ffb475f529 | ||
|
|
d690104a9e | ||
|
|
efa0c69840 | ||
|
|
369e387a39 | ||
|
|
2f98e67a93 | ||
|
|
e2894e211c | ||
|
|
58ff03aa95 | ||
|
|
4155249878 | ||
|
|
de0936c5d2 | ||
|
|
a8e5e910ee | ||
|
|
0d48b46621 | ||
|
|
2a18bc156d | ||
|
|
0dd650dacb | ||
|
|
624a97346d | ||
|
|
3d4fdc1f53 | ||
|
|
286f72f746 | ||
|
|
0cc8d9a98d | ||
|
|
80ae413c9d |
No files matched your search
@@ -6,3 +6,4 @@ indent_size = 2
|
||||
indent_style = space
|
||||
insert_final_newline = true
|
||||
max_line_length = off
|
||||
ij_java_imports_layout=*,|,$*
|
||||
@@ -0,0 +1,20 @@
|
||||
name: "build"
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "**" ]
|
||||
tags-ignore: [ "**" ]
|
||||
pull_request:
|
||||
release:
|
||||
types: [ released ]
|
||||
|
||||
jobs:
|
||||
call-build:
|
||||
uses: "jpenilla/actions/.github/workflows/shared-ci.yml@master"
|
||||
secrets: inherit
|
||||
with:
|
||||
artifacts-path: 'build/libs/*.jar'
|
||||
modrinth-publish: true
|
||||
hangar-publish: true
|
||||
loom: true
|
||||
jdk-version: 25
|
||||
@@ -1,22 +0,0 @@
|
||||
name: Build MiniMOTD
|
||||
on: [ push, pull_request ]
|
||||
jobs:
|
||||
build:
|
||||
# Only run on PRs if the source branch is on someone else's repo
|
||||
if: ${{ github.event_name != 'pull_request' || github.repository != github.event.pull_request.head.repo.full_name }}
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: gradle/wrapper-validation-action@v1
|
||||
- name: Set up JDK
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: '17'
|
||||
- name: Build with Gradle
|
||||
run: ./gradlew build
|
||||
- run: mkdir staging && cp build/libs/*.jar staging
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: Package
|
||||
path: staging
|
||||
@@ -117,3 +117,5 @@ run/
|
||||
|
||||
# Ignore Gradle build output directory
|
||||
build/
|
||||
|
||||
.kotlin/
|
||||
@@ -1,30 +1,37 @@
|
||||

|
||||

|
||||
|
||||
[](https://github.com/jpenilla/MiniMOTD/actions) [](https://github.com/jpenilla/MiniMOTD/releases)
|
||||
|
||||
### MiniMOTD is a basic server list MOTD plugin/mod for Minecraft servers and proxies
|
||||
|
||||
- MiniMOTD supports RGB colors and gradients through [MiniMessage](https://github.com/KyoriPowered/adventure-text-minimessage), which is also where MiniMOTD gets it's name.
|
||||
- For more detailed info on formatting text, refer to the [MiniMessage docs](https://docs.adventure.kyori.net/minimessage.html).
|
||||
- MiniMOTD supports RGB colors and gradients through [MiniMessage](https://docs.papermc.io/adventure/minimessage/), which is also where MiniMOTD gets its name.
|
||||
- For more detailed info on formatting text, refer to the [MiniMessage docs](https://docs.papermc.io/adventure/minimessage/format/).
|
||||
- RGB colors are automatically downsampled for outdated clients.
|
||||
- RGB colors are only able to be sent by proxies and 1.16+ servers, and can only be seen by 1.16+ clients.
|
||||
|
||||
#### Server Platforms
|
||||
- [Paper](https://papermc.io/) / Spigot
|
||||
- MiniMOTD is compatible with Spigot, however many features will not work. It is recommended to use Paper for full compatibility.
|
||||
- [Paper](https://papermc.io/)
|
||||
- [Sponge API 8](https://www.spongepowered.org/)
|
||||
- [Sponge API 7](https://www.spongepowered.org/)
|
||||
- [Fabric](https://fabricmc.net/) (requires [Fabric API](https://www.curseforge.com/minecraft/mc-mods/fabric-api))
|
||||
- [Fabric](https://fabricmc.net/) (requires [Fabric API](https://modrinth.com/mod/fabric-api))
|
||||
- [NeoForge](https://neoforged.net/)
|
||||
|
||||
#### Proxy Platforms
|
||||
- [Velocity](https://velocitypowered.com/)
|
||||
- [Waterfall](https://papermc.io/downloads#Waterfall) / Bungeecord
|
||||
|
||||
#### Downloads
|
||||
Downloads can be obtained from [GitHub releases](https://github.com/jpenilla/MiniMOTD/releases). There is a separate jar for each platform, as well as a universal jar for all platforms. Paper and Spigot share the same jar, as do Waterfall and Bungeecord.
|
||||
Downloads can be obtained from any of:
|
||||
- [Modrinth](https://modrinth.com/plugin/minimotd)
|
||||
- [Hangar](https://hangar.papermc.io/jmp/MiniMOTD)
|
||||
- [GitHub releases](https://github.com/jpenilla/MiniMOTD/releases)
|
||||
|
||||
There is a separate jar for each platform. Waterfall and Bungeecord share the same jar.
|
||||
There are two distributions for Bukkit-based servers: one for Paper >=1.21.8 only (`-paper` jar),
|
||||
and one for all other supported versions (1.8.8 - 1.21.7, Spigot and Paper) (`-bukkit` jar).
|
||||
|
||||
#### Configuration
|
||||
See the [wiki](https://github.com/jpenilla/MiniMOTD/wiki) for configuration details
|
||||
|
||||
#### Screenshots
|
||||

|
||||

|
||||
@@ -1,10 +0,0 @@
|
||||
import ca.stellardrift.build.configurate.ConfigFormats
|
||||
import ca.stellardrift.build.configurate.catalog.PolyglotVersionCatalogExtension
|
||||
|
||||
plugins {
|
||||
id("ca.stellardrift.polyglot-version-catalogs") version "5.0.1"
|
||||
}
|
||||
|
||||
extensions.configure<PolyglotVersionCatalogExtension> {
|
||||
from(ConfigFormats.YAML, file("../gradle/libs.versions.yml"))
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.provider.Property
|
||||
import org.gradle.api.tasks.bundling.AbstractArchiveTask
|
||||
import org.gradle.kotlin.dsl.property
|
||||
|
||||
abstract class MiniMOTDPlatformExtension(project: Project) {
|
||||
val jarTask: Property<AbstractArchiveTask> = project.objects.property()
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
import net.kyori.indra.git.IndraGitExtension
|
||||
import org.gradle.accessors.dm.LibrariesForLibs
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.kotlin.dsl.the
|
||||
|
||||
fun Project.lastCommitHash(): String =
|
||||
the<IndraGitExtension>().commit()?.name?.substring(0, 7) ?: "unknown"
|
||||
|
||||
val Project.libs: LibrariesForLibs
|
||||
get() = the()
|
||||
@@ -1,44 +0,0 @@
|
||||
import com.adarshr.gradle.testlogger.theme.ThemeType
|
||||
|
||||
plugins {
|
||||
id("java-library")
|
||||
id("net.kyori.indra")
|
||||
id("net.kyori.indra.publishing")
|
||||
id("net.kyori.indra.checkstyle")
|
||||
id("net.kyori.indra.license-header")
|
||||
id("com.adarshr.test-logger")
|
||||
}
|
||||
|
||||
version = (version as String)
|
||||
.run { if (this.endsWith("-SNAPSHOT")) "$this+${lastCommitHash()}" else this }
|
||||
|
||||
indra {
|
||||
javaVersions {
|
||||
minimumToolchain(17)
|
||||
target(8)
|
||||
}
|
||||
github(Constants.GITHUB_USER, Constants.GITHUB_REPO)
|
||||
mitLicense()
|
||||
}
|
||||
|
||||
testlogger {
|
||||
theme = ThemeType.MOCHA_PARALLEL
|
||||
showPassed = false
|
||||
}
|
||||
|
||||
dependencies {
|
||||
testImplementation(libs.jupiterEngine)
|
||||
}
|
||||
|
||||
tasks {
|
||||
tasks {
|
||||
withType<JavaCompile> {
|
||||
options.compilerArgs.add("-Xlint:-processing")
|
||||
}
|
||||
sequenceOf(javadocJar, javadoc).forEach {
|
||||
it.configure {
|
||||
onlyIf { false }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
plugins {
|
||||
base
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
plugins {
|
||||
id("minimotd.base-conventions")
|
||||
id("net.kyori.indra.git")
|
||||
}
|
||||
|
||||
val platformExtension = extensions.create<MiniMOTDPlatformExtension>("miniMOTDPlatform", project)
|
||||
|
||||
tasks {
|
||||
val copyJar = register<FileCopyTask>("copyJar") {
|
||||
fileToCopy.set(platformExtension.jarTask.flatMap { it.archiveFile })
|
||||
destination.set(rootProject.layout.buildDirectory.dir("libs").flatMap {
|
||||
it.file(fileToCopy.map { file -> file.asFile.name })
|
||||
})
|
||||
}
|
||||
build {
|
||||
dependsOn(copyJar)
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
plugins {
|
||||
id("minimotd.build-logic")
|
||||
alias(libs.plugins.run.paper) apply false
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
plugins {
|
||||
id("minimotd.shadow-platform")
|
||||
id("net.minecrell.plugin-yml.bungee")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(projects.minimotdCommon)
|
||||
implementation(libs.adventurePlatformBungeecord)
|
||||
implementation(libs.bstatsBungeecord)
|
||||
compileOnly(libs.waterfallApi)
|
||||
}
|
||||
|
||||
tasks {
|
||||
shadowJar {
|
||||
commonRelocation("io.leangen.geantyref")
|
||||
commonRelocation("net.kyori")
|
||||
commonRelocation("org.bstats")
|
||||
}
|
||||
}
|
||||
|
||||
bungee {
|
||||
name = rootProject.name
|
||||
main = "xyz.jpenilla.minimotd.bungee.MiniMOTDPlugin"
|
||||
author = "jmp"
|
||||
}
|
||||
+14
-14
@@ -1,11 +1,11 @@
|
||||
plugins {
|
||||
id("net.kyori.blossom")
|
||||
alias(libs.plugins.blossom)
|
||||
id("minimotd.base-conventions")
|
||||
}
|
||||
|
||||
tasks.jar {
|
||||
from(rootProject.file("license.txt")) {
|
||||
rename { "license_${rootProject.name.toLowerCase()}.txt" }
|
||||
rename { "license_${rootProject.name.lowercase()}.txt" }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,21 +19,21 @@ dependencies {
|
||||
}
|
||||
api(libs.minimessage)
|
||||
compileOnlyApi(libs.slf4jApi)
|
||||
compileOnlyApi(libs.checkerQual)
|
||||
compileOnlyApi(libs.jspecify)
|
||||
compileOnlyApi(libs.gson)
|
||||
testImplementation(libs.gson)
|
||||
compileOnlyApi(libs.guava)
|
||||
compileOnly(libs.brigadier)
|
||||
compileOnly(libs.miniplaceholders)
|
||||
}
|
||||
|
||||
blossom {
|
||||
val file = "src/main/java/xyz/jpenilla/minimotd/common/Constants.java"
|
||||
mapOf(
|
||||
"PLUGIN_NAME" to rootProject.name,
|
||||
"PLUGIN_VERSION" to project.version.toString(),
|
||||
"PLUGIN_WEBSITE" to Constants.GITHUB_URL,
|
||||
"GITHUB_USER" to Constants.GITHUB_USER,
|
||||
"GITHUB_REPO" to Constants.GITHUB_REPO
|
||||
).forEach { (k, v) ->
|
||||
replaceToken("\${$k}", v, file)
|
||||
sourceSets.main {
|
||||
blossom {
|
||||
javaSources {
|
||||
property("PLUGIN_NAME", rootProject.name)
|
||||
property("PLUGIN_VERSION", project.version.toString())
|
||||
property("PLUGIN_WEBSITE", Constants.GITHUB_URL)
|
||||
property("GITHUB_USER", Constants.GITHUB_USER)
|
||||
property("GITHUB_REPO", Constants.GITHUB_REPO)
|
||||
}
|
||||
}
|
||||
}
|
||||
+6
-6
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2022 Jason Penilla
|
||||
* Copyright (c) 2020-2025 Jason Penilla
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -34,11 +34,11 @@ public final class Constants {
|
||||
private PluginMetadata() {
|
||||
}
|
||||
|
||||
public static final String NAME = "${PLUGIN_NAME}";
|
||||
public static final String VERSION = "${PLUGIN_VERSION}";
|
||||
public static final String WEBSITE = "${PLUGIN_WEBSITE}";
|
||||
public static final String GITHUB_USER = "${GITHUB_USER}";
|
||||
public static final String GITHUB_REPO = "${GITHUB_REPO}";
|
||||
public static final String NAME = "{{ PLUGIN_NAME }}";
|
||||
public static final String VERSION = "{{ PLUGIN_VERSION }}";
|
||||
public static final String WEBSITE = "{{ PLUGIN_WEBSITE }}";
|
||||
public static final String GITHUB_USER = "{{ GITHUB_USER }}";
|
||||
public static final String GITHUB_REPO = "{{ GITHUB_REPO }}";
|
||||
public static final String GITHUB_REPO_URL = "https://github.com/" + GITHUB_USER + "/" + GITHUB_REPO;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2022 Jason Penilla
|
||||
* Copyright (c) 2020-2025 Jason Penilla
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -27,9 +27,7 @@ import java.util.stream.Stream;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.framework.qual.DefaultQualifier;
|
||||
import xyz.jpenilla.minimotd.common.util.Components;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
import static net.kyori.adventure.text.Component.space;
|
||||
import static net.kyori.adventure.text.Component.text;
|
||||
@@ -43,7 +41,7 @@ import static net.kyori.adventure.text.format.NamedTextColor.WHITE;
|
||||
import static net.kyori.adventure.text.format.TextColor.color;
|
||||
import static net.kyori.adventure.text.format.TextDecoration.STRIKETHROUGH;
|
||||
|
||||
@DefaultQualifier(NonNull.class)
|
||||
@NullMarked
|
||||
public final class CommandHandler {
|
||||
private final MiniMOTD<?> miniMOTD;
|
||||
|
||||
@@ -77,7 +75,7 @@ public final class CommandHandler {
|
||||
this.miniMOTD.reload();
|
||||
} catch (final Exception ex) {
|
||||
this.miniMOTD.logger().warn("Failed to reload MiniMOTD. Ensure there are no errors in your config files.", ex);
|
||||
audience.sendMessage(Components.ofChildren(
|
||||
audience.sendMessage(Component.textOfChildren(
|
||||
Constants.COMMAND_PREFIX,
|
||||
space(),
|
||||
text("Failed to reload MiniMOTD. Ensure there are no errors in your config files. See console for more details.", RED)
|
||||
@@ -85,7 +83,7 @@ public final class CommandHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
audience.sendMessage(Components.ofChildren(
|
||||
audience.sendMessage(Component.textOfChildren(
|
||||
Constants.COMMAND_PREFIX,
|
||||
space(),
|
||||
text("Done reloading configuration.", GREEN)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2022 Jason Penilla
|
||||
* Copyright (c) 2020-2025 Jason Penilla
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -28,17 +28,17 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
import java.util.stream.Stream;
|
||||
import javax.imageio.ImageIO;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import org.jspecify.annotations.NonNull;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
public final class IconManager<I> {
|
||||
private final Map<String, I> icons = new HashMap<>();
|
||||
private final Map<String, I> icons = new ConcurrentHashMap<>();
|
||||
private final MiniMOTD<I> miniMOTD;
|
||||
private final Path iconsDirectory;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2022 Jason Penilla
|
||||
* Copyright (c) 2020-2025 Jason Penilla
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -29,17 +29,15 @@ import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import org.checkerframework.framework.qual.DefaultQualifier;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.slf4j.Logger;
|
||||
import xyz.jpenilla.minimotd.common.config.ConfigManager;
|
||||
import xyz.jpenilla.minimotd.common.config.MiniMOTDConfig;
|
||||
import xyz.jpenilla.minimotd.common.util.Components;
|
||||
import xyz.jpenilla.minimotd.common.config.MOTDConfig;
|
||||
import xyz.jpenilla.minimotd.common.util.MiniPlaceholdersUtil;
|
||||
|
||||
import static net.kyori.adventure.text.Component.newline;
|
||||
|
||||
@DefaultQualifier(NonNull.class)
|
||||
@NullMarked
|
||||
public final class MiniMOTD<I> {
|
||||
private final ConfigManager configManager;
|
||||
private final IconManager<I> iconManager;
|
||||
@@ -77,21 +75,21 @@ public final class MiniMOTD<I> {
|
||||
return this.configManager;
|
||||
}
|
||||
|
||||
public PingResponse<I> createMOTD(final MiniMOTDConfig config, final int onlinePlayers, final int maxPlayers) {
|
||||
public PingResponse<I> createMOTD(final MOTDConfig config, final int onlinePlayers, final int maxPlayers) {
|
||||
final PingResponse.PlayerCount count = config.modifyPlayerCount(onlinePlayers, maxPlayers);
|
||||
final PingResponse.Builder<I> response = PingResponse.<I>builder()
|
||||
.playerCount(count)
|
||||
.disablePlayerListHover(config.disablePlayerListHover())
|
||||
.hidePlayerCount(config.hidePlayerCount());
|
||||
|
||||
@Nullable String iconString = null;
|
||||
String iconString = null;
|
||||
if (config.motdEnabled()) {
|
||||
if (config.motds().isEmpty()) {
|
||||
throw new IllegalStateException("MOTD is enabled, but there are no MOTDs in the config file?");
|
||||
}
|
||||
final int index = config.motds().size() == 1 ? 0 : ThreadLocalRandom.current().nextInt(config.motds().size());
|
||||
final MiniMOTDConfig.MOTD motdConfig = config.motds().get(index);
|
||||
final Component motd = Components.ofChildren(
|
||||
final MOTDConfig.MOTD motdConfig = config.motds().get(index);
|
||||
final Component motd = Component.textOfChildren(
|
||||
parse(motdConfig.line1(), count),
|
||||
newline(),
|
||||
parse(motdConfig.line2(), count)
|
||||
@@ -112,7 +110,11 @@ public final class MiniMOTD<I> {
|
||||
final String max = Integer.toString(count.maxPlayers());
|
||||
return MiniMessage.miniMessage().deserialize(
|
||||
replacePlayerCount(input, online, max),
|
||||
TagResolver.resolver(Placeholder.unparsed("online_players", online), Placeholder.unparsed("max_players", max))
|
||||
TagResolver.resolver(
|
||||
Placeholder.unparsed("online_players", online),
|
||||
Placeholder.unparsed("max_players", max),
|
||||
MiniPlaceholdersUtil.tagResolver()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -120,7 +122,7 @@ public final class MiniMOTD<I> {
|
||||
return input.replace("{onlinePlayers}", online).replace("{maxPlayers}", max);
|
||||
}
|
||||
|
||||
public void reload() {
|
||||
public synchronized void reload() {
|
||||
this.iconManager.loadIcons();
|
||||
this.configManager.loadConfigs();
|
||||
this.platform.onReload();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2022 Jason Penilla
|
||||
* Copyright (c) 2020-2025 Jason Penilla
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -25,7 +25,7 @@ package xyz.jpenilla.minimotd.common;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.nio.file.Path;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.jspecify.annotations.NonNull;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
public interface MiniMOTDPlatform<I> {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2022 Jason Penilla
|
||||
* Copyright (c) 2020-2025 Jason Penilla
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -26,13 +26,12 @@ package xyz.jpenilla.minimotd.common;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.IntConsumer;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import org.checkerframework.framework.qual.DefaultQualifier;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
@DefaultQualifier(NonNull.class)
|
||||
@NullMarked
|
||||
public final class PingResponse<I> {
|
||||
private final @Nullable I icon;
|
||||
private final @Nullable Component motd;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2022 Jason Penilla
|
||||
* Copyright (c) 2020-2025 Jason Penilla
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -23,9 +23,13 @@
|
||||
*/
|
||||
package xyz.jpenilla.minimotd.common.config;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.UnaryOperator;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.spongepowered.configurate.CommentedConfigurationNode;
|
||||
import org.spongepowered.configurate.ConfigurateException;
|
||||
import org.spongepowered.configurate.ConfigurationOptions;
|
||||
@@ -34,6 +38,7 @@ import org.spongepowered.configurate.objectmapping.ObjectMapper;
|
||||
import org.spongepowered.configurate.serialize.SerializationException;
|
||||
import org.spongepowered.configurate.serialize.TypeSerializerCollection;
|
||||
|
||||
@NullMarked
|
||||
public final class ConfigLoader<C> {
|
||||
private static final TypeSerializerCollection SERIALIZERS;
|
||||
|
||||
@@ -45,12 +50,14 @@ public final class ConfigLoader<C> {
|
||||
|
||||
private final HoconConfigurationLoader loader;
|
||||
private final ObjectMapper<C> mapper;
|
||||
private final List<Consumer<C>> postProcess;
|
||||
|
||||
public ConfigLoader(
|
||||
final @NonNull Class<C> configClass,
|
||||
final @NonNull Path configPath,
|
||||
final @NonNull UnaryOperator<ConfigurationOptions> optionsModifier
|
||||
final Class<C> configClass,
|
||||
final Path configPath,
|
||||
final UnaryOperator<ConfigurationOptions> optionsModifier
|
||||
) {
|
||||
this.postProcess = this.findPostProcessors(configClass);
|
||||
this.loader = HoconConfigurationLoader.builder()
|
||||
.path(configPath)
|
||||
.defaultOptions(options ->
|
||||
@@ -67,19 +74,41 @@ public final class ConfigLoader<C> {
|
||||
}
|
||||
}
|
||||
|
||||
private List<Consumer<C>> findPostProcessors(final Class<C> configClass) {
|
||||
final List<Consumer<C>> ret = new ArrayList<>();
|
||||
for (final Method method : configClass.getDeclaredMethods()) {
|
||||
if (method.getAnnotation(PostProcessor.class) == null) {
|
||||
continue;
|
||||
}
|
||||
ret.add(config -> {
|
||||
try {
|
||||
method.setAccessible(true);
|
||||
method.invoke(config);
|
||||
} catch (final ReflectiveOperationException ex) {
|
||||
throw new RuntimeException("Failed to invoke post processor method", ex);
|
||||
}
|
||||
});
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public ConfigLoader(
|
||||
final @NonNull Class<C> configClass,
|
||||
final @NonNull Path configPath
|
||||
final Class<C> configClass,
|
||||
final Path configPath
|
||||
) {
|
||||
this(configClass, configPath, options -> options);
|
||||
}
|
||||
|
||||
public @NonNull C load() throws ConfigurateException {
|
||||
public C load() throws ConfigurateException {
|
||||
final CommentedConfigurationNode node = this.loader.load();
|
||||
return this.mapper.load(node);
|
||||
final C config = this.mapper.load(node);
|
||||
for (final Consumer<C> processor : this.postProcess) {
|
||||
processor.accept(config);
|
||||
}
|
||||
return config;
|
||||
}
|
||||
|
||||
public void save(final @NonNull C config) throws ConfigurateException {
|
||||
public void save(final C config) throws ConfigurateException {
|
||||
final CommentedConfigurationNode node = this.loader.createNode();
|
||||
this.mapper.save(config, node);
|
||||
this.loader.save(node);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2022 Jason Penilla
|
||||
* Copyright (c) 2020-2025 Jason Penilla
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -23,18 +23,19 @@
|
||||
*/
|
||||
package xyz.jpenilla.minimotd.common.config;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import org.jspecify.annotations.NonNull;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import org.spongepowered.configurate.ConfigurateException;
|
||||
import xyz.jpenilla.minimotd.common.MiniMOTD;
|
||||
import xyz.jpenilla.minimotd.common.util.Pair;
|
||||
@@ -45,18 +46,18 @@ public final class ConfigManager {
|
||||
|
||||
private final MiniMOTD<?> miniMOTD;
|
||||
|
||||
private final ConfigLoader<MiniMOTDConfig> mainConfigLoader;
|
||||
private MiniMOTDConfig mainConfig;
|
||||
private final ConfigLoader<MOTDConfig> mainConfigLoader;
|
||||
private MOTDConfig mainConfig;
|
||||
|
||||
private final ConfigLoader<PluginSettings> pluginSettingsLoader;
|
||||
private PluginSettings pluginSettings;
|
||||
|
||||
private final Map<String, MiniMOTDConfig> extraConfigs = new HashMap<>();
|
||||
private final Map<String, MOTDConfig> extraConfigs = new HashMap<>();
|
||||
|
||||
public ConfigManager(final @NonNull MiniMOTD<?> miniMOTD) {
|
||||
this.miniMOTD = miniMOTD;
|
||||
this.mainConfigLoader = new ConfigLoader<>(
|
||||
MiniMOTDConfig.class,
|
||||
MOTDConfig.class,
|
||||
this.miniMOTD.dataDirectory().resolve("main.conf"),
|
||||
options -> options.header("MiniMOTD Main Configuration")
|
||||
);
|
||||
@@ -93,12 +94,12 @@ public final class ConfigManager {
|
||||
continue;
|
||||
}
|
||||
final String name = path.getFileName().toString().replace(".conf", "");
|
||||
final ConfigLoader<MiniMOTDConfig> loader = new ConfigLoader<>(
|
||||
MiniMOTDConfig.class,
|
||||
final ConfigLoader<MOTDConfig> loader = new ConfigLoader<>(
|
||||
MOTDConfig.class,
|
||||
path,
|
||||
options -> options.header(String.format("Extra MiniMOTD config '%s'", name))
|
||||
);
|
||||
final MiniMOTDConfig config = loader.load();
|
||||
final MOTDConfig config = loader.load();
|
||||
loader.save(config);
|
||||
this.extraConfigs.put(name, config);
|
||||
}
|
||||
@@ -109,20 +110,20 @@ public final class ConfigManager {
|
||||
}
|
||||
|
||||
private void createDefaultExtraConfigs(final @NonNull Path extraConfigsDir) throws ConfigurateException {
|
||||
final List<Pair<Path, MiniMOTDConfig.MOTD>> defaults = ImmutableList.of(
|
||||
pair(extraConfigsDir.resolve("skyblock.conf"), new MiniMOTDConfig.MOTD("<green><italic>Skyblock</green>", "<bold><rainbow>MiniMOTD Skyblock Server")),
|
||||
pair(extraConfigsDir.resolve("survival.conf"), new MiniMOTDConfig.MOTD("<gradient:blue:red>Survival Mode Hardcore", "<green><bold>MiniMOTD Survival Server"))
|
||||
);
|
||||
for (final Pair<Path, MiniMOTDConfig.MOTD> pair : defaults) {
|
||||
final ConfigLoader<MiniMOTDConfig> loader = new ConfigLoader<>(
|
||||
MiniMOTDConfig.class,
|
||||
final List<Pair<Path, MOTDConfig.MOTD>> defaults = Collections.unmodifiableList(Arrays.asList(
|
||||
pair(extraConfigsDir.resolve("skyblock.conf"), new MOTDConfig.MOTD("<green><italic>Skyblock</green>", "<bold><rainbow>MiniMOTD Skyblock Server")),
|
||||
pair(extraConfigsDir.resolve("survival.conf"), new MOTDConfig.MOTD("<gradient:blue:red>Survival Mode Hardcore", "<green><bold>MiniMOTD Survival Server"))
|
||||
));
|
||||
for (final Pair<Path, MOTDConfig.MOTD> pair : defaults) {
|
||||
final ConfigLoader<MOTDConfig> loader = new ConfigLoader<>(
|
||||
MOTDConfig.class,
|
||||
pair.left()
|
||||
);
|
||||
loader.save(new MiniMOTDConfig(pair.right()));
|
||||
loader.save(new MOTDConfig(pair.right()));
|
||||
}
|
||||
}
|
||||
|
||||
public @NonNull MiniMOTDConfig mainConfig() {
|
||||
public @NonNull MOTDConfig mainConfig() {
|
||||
if (this.mainConfig == null) {
|
||||
throw new IllegalStateException("Config has not yet been loaded");
|
||||
}
|
||||
@@ -136,15 +137,14 @@ public final class ConfigManager {
|
||||
return this.pluginSettings;
|
||||
}
|
||||
|
||||
public @NonNull MiniMOTDConfig resolveConfig(final @Nullable InetSocketAddress address) {
|
||||
public @NonNull MOTDConfig resolveConfig(final @Nullable InetSocketAddress address) {
|
||||
if (address == null) {
|
||||
return this.mainConfig();
|
||||
}
|
||||
final String hostString = address.getHostString() + ":" + address.getPort();
|
||||
final String configString = this.pluginSettings().proxySettings().findConfigStringForHost(hostString);
|
||||
final String configString = this.pluginSettings().proxySettings().findConfigStringForHost(address.getHostString(), address.getPort());
|
||||
|
||||
if (this.pluginSettings().proxySettings().virtualHostTestMode()) {
|
||||
this.miniMOTD.platform().logger().info("[virtual-host-debug] Virtual Host: '{}', Selected Config: '{}'", hostString, configString == null ? "default" : configString);
|
||||
this.miniMOTD.platform().logger().info("[virtual-host-debug] Virtual Host: '{}:{}', Selected Config: '{}'", address.getHostString(), address.getPort(), configString == null ? "default" : configString);
|
||||
}
|
||||
|
||||
if (configString == null) {
|
||||
@@ -153,11 +153,11 @@ public final class ConfigManager {
|
||||
return this.resolveConfig(configString);
|
||||
}
|
||||
|
||||
public @NonNull MiniMOTDConfig resolveConfig(final @NonNull String name) {
|
||||
public @NonNull MOTDConfig resolveConfig(final @NonNull String name) {
|
||||
if ("default".equals(name)) {
|
||||
return this.mainConfig();
|
||||
}
|
||||
final MiniMOTDConfig cfg = this.extraConfigs.get(name);
|
||||
final MOTDConfig cfg = this.extraConfigs.get(name);
|
||||
if (cfg != null) {
|
||||
return cfg;
|
||||
}
|
||||
|
||||
+15
-6
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2022 Jason Penilla
|
||||
* Copyright (c) 2020-2025 Jason Penilla
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -26,7 +26,7 @@ package xyz.jpenilla.minimotd.common.config;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.jspecify.annotations.NonNull;
|
||||
import org.spongepowered.configurate.objectmapping.ConfigSerializable;
|
||||
import org.spongepowered.configurate.objectmapping.meta.Comment;
|
||||
import xyz.jpenilla.minimotd.common.PingResponse;
|
||||
@@ -34,22 +34,22 @@ import xyz.jpenilla.minimotd.common.PingResponse;
|
||||
import static xyz.jpenilla.minimotd.common.PingResponse.PlayerCount.playerCount;
|
||||
|
||||
@ConfigSerializable
|
||||
public final class MiniMOTDConfig {
|
||||
public final class MOTDConfig {
|
||||
|
||||
public MiniMOTDConfig() {
|
||||
public MOTDConfig() {
|
||||
this(
|
||||
new MOTD(),
|
||||
new MOTD("<blue>Another <bold><red>MOTD", "<italic><underlined><gradient:red:green>much wow")
|
||||
);
|
||||
}
|
||||
|
||||
public MiniMOTDConfig(final @NonNull MOTD @NonNull ... defaults) {
|
||||
public MOTDConfig(final @NonNull MOTD @NonNull ... defaults) {
|
||||
this.motds.addAll(Arrays.asList(defaults));
|
||||
}
|
||||
|
||||
@Comment("The list of MOTDs to display\n"
|
||||
+ "\n"
|
||||
+ " - Supported placeholders: {onlinePlayers}, {maxPlayers}\n"
|
||||
+ " - Supported placeholders: <online_players>, <max_players>\n"
|
||||
+ " - Putting more than one will cause one to be randomly chosen each refresh")
|
||||
private final List<MOTD> motds = new ArrayList<>();
|
||||
|
||||
@@ -123,6 +123,11 @@ public final class MiniMOTDConfig {
|
||||
+ "If false, the online player count will be capped at the maximum player count")
|
||||
private boolean allowExceedingMaximum = false;
|
||||
|
||||
@Comment("The list of server names that affect player counts/listing.\n"
|
||||
+ "Only applicable when running the plugin on a proxy (Velocity or Waterfall/Bungeecord).\n"
|
||||
+ "When set to an empty list, the default count & list as determined by the proxy will be used.")
|
||||
private final List<String> servers = new ArrayList<>();
|
||||
|
||||
@ConfigSerializable
|
||||
public static final class JustXMore {
|
||||
|
||||
@@ -157,6 +162,10 @@ public final class MiniMOTDConfig {
|
||||
|
||||
}
|
||||
|
||||
public List<String> targetServers() {
|
||||
return this.playerCountSettings.servers;
|
||||
}
|
||||
|
||||
public boolean iconEnabled() {
|
||||
return this.iconEnabled;
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2022 Jason Penilla
|
||||
* Copyright (c) 2020-2025 Jason Penilla
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -26,8 +26,8 @@ package xyz.jpenilla.minimotd.common.config;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
import java.util.function.Predicate;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import org.jspecify.annotations.NonNull;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import org.spongepowered.configurate.serialize.ScalarSerializer;
|
||||
import org.spongepowered.configurate.serialize.SerializationException;
|
||||
import xyz.jpenilla.minimotd.common.util.Int2IntFunction;
|
||||
@@ -46,7 +46,7 @@ public final class PlayerCountModifier implements Int2IntFunction {
|
||||
return this.function.apply(actualPlayers);
|
||||
}
|
||||
|
||||
public final @NonNull String input() {
|
||||
public @NonNull String input() {
|
||||
return this.input;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2022 Jason Penilla
|
||||
* Copyright (c) 2020-2025 Jason Penilla
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -23,10 +23,12 @@
|
||||
*/
|
||||
package xyz.jpenilla.minimotd.common.config;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import java.util.Objects;
|
||||
import org.jspecify.annotations.NonNull;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import org.spongepowered.configurate.objectmapping.ConfigSerializable;
|
||||
import org.spongepowered.configurate.objectmapping.meta.Comment;
|
||||
|
||||
@@ -49,11 +51,19 @@ public final class PluginSettings {
|
||||
this.virtualHostConfigs.put("skyblock.example.com:25565", "skyblock");
|
||||
}
|
||||
|
||||
public ProxySettings(final Map<String, String> virtualHostConfigs) {
|
||||
this.virtualHostConfigs.putAll(virtualHostConfigs);
|
||||
}
|
||||
|
||||
@Comment("Here you can assign configs in the 'extra-configs' folder to specific virtual hosts\n"
|
||||
+ "Either use the name of the config in 'extra-configs', or use \"default\" to use the configuration in main.conf\n"
|
||||
+ "\n"
|
||||
+ "Format is \"hostname:port\"=\"configName|default\"")
|
||||
private final Map<String, String> virtualHostConfigs = new HashMap<>();
|
||||
+ "Format is \"hostname:port\"=\"configName|default\"\n"
|
||||
+ "Parts of domains can be substituted for wildcards, i.e. \"*.mydomain.com:25565\". Wildcard-containing configs are\n"
|
||||
+ "checked in the order they are declared if there are no exact matches.")
|
||||
private final Map<String, String> virtualHostConfigs = new LinkedHashMap<>();
|
||||
|
||||
private transient @Nullable Map<String[], String> splitVirtualHostConfigs;
|
||||
|
||||
@Comment("Set whether to enable virtual host testing mode.\n"
|
||||
+ "When enabled, MiniMOTD will print virtual host debug info to the console on each server ping.")
|
||||
@@ -63,8 +73,62 @@ public final class PluginSettings {
|
||||
return this.virtualHostTestMode;
|
||||
}
|
||||
|
||||
public @Nullable String findConfigStringForHost(final @NonNull String host) {
|
||||
return this.virtualHostConfigs.get(host);
|
||||
public @Nullable String findConfigStringForHost(@NonNull String host, final int port) {
|
||||
Objects.requireNonNull(this.splitVirtualHostConfigs, "processVirtualHosts must be called first");
|
||||
host = processTcpShieldHostname(host).toLowerCase(Locale.ENGLISH) + ':' + port;
|
||||
|
||||
final @Nullable String exactMatch = this.virtualHostConfigs.get(host);
|
||||
if (exactMatch != null) {
|
||||
return exactMatch;
|
||||
}
|
||||
|
||||
if (this.splitVirtualHostConfigs.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final String[] splitHost = host.split("\\.");
|
||||
|
||||
configs:
|
||||
for (final Map.Entry<String[], String> e : this.splitVirtualHostConfigs.entrySet()) {
|
||||
final String[] splitKey = e.getKey();
|
||||
if (splitKey.length != splitHost.length) {
|
||||
continue;
|
||||
}
|
||||
for (int i = 0; i < splitHost.length; i++) {
|
||||
final String keyPart = splitKey[i];
|
||||
if (!keyPart.equals(splitHost[i]) && !keyPart.equals("*")) {
|
||||
continue configs;
|
||||
}
|
||||
}
|
||||
return e.getValue();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static String processTcpShieldHostname(final String hostname) {
|
||||
if (hostname.contains("///")) {
|
||||
final String[] split = hostname.split("///");
|
||||
if (split.length == 4) {
|
||||
// <actual hostname>///<user-ip>:<user-port>///<unix timestamp>///<signature>
|
||||
return split[0];
|
||||
}
|
||||
}
|
||||
return hostname;
|
||||
}
|
||||
|
||||
public void processVirtualHosts() {
|
||||
final Map<String, String> virtualHosts = new LinkedHashMap<>(this.virtualHostConfigs);
|
||||
this.virtualHostConfigs.clear();
|
||||
virtualHosts.forEach((host, config) -> this.virtualHostConfigs.put(host.toLowerCase(Locale.ENGLISH), config));
|
||||
|
||||
this.splitVirtualHostConfigs = new LinkedHashMap<>();
|
||||
this.virtualHostConfigs.forEach((host, config) -> {
|
||||
if (!host.contains("*")) {
|
||||
return;
|
||||
}
|
||||
this.splitVirtualHostConfigs.put(host.split("\\."), config);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,4 +140,8 @@ public final class PluginSettings {
|
||||
return this.updateChecker;
|
||||
}
|
||||
|
||||
@PostProcessor
|
||||
private void processVirtualHosts() {
|
||||
this.proxySettings.processVirtualHosts();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2025 Jason Penilla
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package xyz.jpenilla.minimotd.common.config;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.METHOD)
|
||||
public @interface PostProcessor {
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2025 Jason Penilla
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package xyz.jpenilla.minimotd.common.util;
|
||||
|
||||
import com.mojang.brigadier.Command;
|
||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Predicate;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import xyz.jpenilla.minimotd.common.CommandHandler;
|
||||
|
||||
@NullMarked
|
||||
public final class BrigadierUtil {
|
||||
private BrigadierUtil() {
|
||||
}
|
||||
|
||||
public static <S> LiteralArgumentBuilder<S> buildTree(
|
||||
final CommandHandler handler,
|
||||
final Function<S, Audience> audienceExtractor,
|
||||
final Predicate<S> permissionChecker
|
||||
) {
|
||||
final class WrappingExecutor implements Command<S> {
|
||||
private final CommandHandler.Executor handler;
|
||||
|
||||
WrappingExecutor(final CommandHandler.Executor handler) {
|
||||
this.handler = handler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int run(final CommandContext<S> context) {
|
||||
this.handler.execute(audienceExtractor.apply(context.getSource()));
|
||||
return Command.SINGLE_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
return LiteralArgumentBuilder.<S>literal("minimotd")
|
||||
.requires(permissionChecker)
|
||||
.executes(new WrappingExecutor(handler::help))
|
||||
.then(LiteralArgumentBuilder.<S>literal("help").executes(new WrappingExecutor(handler::help)))
|
||||
.then(LiteralArgumentBuilder.<S>literal("about").executes(new WrappingExecutor(handler::about)))
|
||||
.then(LiteralArgumentBuilder.<S>literal("reload").executes(new WrappingExecutor(handler::reload)));
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2022 Jason Penilla
|
||||
* Copyright (c) 2020-2025 Jason Penilla
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -25,7 +25,7 @@ package xyz.jpenilla.minimotd.common.util;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.jspecify.annotations.NonNull;
|
||||
|
||||
public interface ComponentColorDownsampler {
|
||||
static @NonNull ComponentColorDownsampler downsampler() {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2022 Jason Penilla
|
||||
* Copyright (c) 2020-2025 Jason Penilla
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2025 Jason Penilla
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package xyz.jpenilla.minimotd.common.util;
|
||||
|
||||
import io.github.miniplaceholders.api.MiniPlaceholders;
|
||||
import java.util.Objects;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@NullMarked
|
||||
public final class MiniPlaceholdersUtil {
|
||||
private static final String KYORI_PREFIX = new String(new char[]{'n', 'e', 't', '.', 'k', 'y', 'o', 'r', 'i'});
|
||||
private static byte miniPlaceholdersLoaded = -1;
|
||||
|
||||
private MiniPlaceholdersUtil() {
|
||||
}
|
||||
|
||||
private static boolean miniPlaceholdersLoaded() {
|
||||
if (miniPlaceholdersLoaded == -1) {
|
||||
if (!TagResolver.class.getName().startsWith(KYORI_PREFIX)) {
|
||||
miniPlaceholdersLoaded = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
final String name = MiniPlaceholders.class.getName();
|
||||
Objects.requireNonNull(name);
|
||||
miniPlaceholdersLoaded = 1;
|
||||
} catch (final NoClassDefFoundError error) {
|
||||
miniPlaceholdersLoaded = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return miniPlaceholdersLoaded == 1;
|
||||
}
|
||||
|
||||
public static TagResolver tagResolver() {
|
||||
if (!miniPlaceholdersLoaded()) {
|
||||
return TagResolver.empty();
|
||||
}
|
||||
return tagResolver_();
|
||||
}
|
||||
|
||||
private static TagResolver tagResolver_() {
|
||||
return MiniPlaceholders.globalPlaceholders();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2025 Jason Penilla
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package xyz.jpenilla.minimotd.common.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
public abstract class Nag {
|
||||
private static final String EQUALS_LINE = "====================================================";
|
||||
|
||||
private final List<String> lines = new ArrayList<>();
|
||||
private boolean exception = false;
|
||||
private boolean error = false;
|
||||
|
||||
public Nag lines(final String... lines) {
|
||||
this.lines.addAll(Arrays.asList(lines));
|
||||
return this;
|
||||
}
|
||||
|
||||
public Nag line(final String line) {
|
||||
this.lines.add(line);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Nag error(final boolean withException) {
|
||||
this.error = true;
|
||||
this.exception = withException;
|
||||
return this;
|
||||
}
|
||||
|
||||
protected abstract void logError(String message, @Nullable Throwable throwable);
|
||||
|
||||
protected abstract void logWarn(String message, @Nullable Throwable throwable);
|
||||
|
||||
public void logBanner() {
|
||||
final List<String> toLog = new ArrayList<>();
|
||||
toLog.add(EQUALS_LINE);
|
||||
toLog.addAll(this.lines);
|
||||
toLog.add(EQUALS_LINE);
|
||||
|
||||
for (final String line : toLog) {
|
||||
if (this.error) {
|
||||
this.logError(line, null);
|
||||
} else {
|
||||
this.logWarn(line, null);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.exception) {
|
||||
// this.exception implies this.error
|
||||
this.logError("Please see the above notice.", new RuntimeException("Please see the above notice."));
|
||||
}
|
||||
}
|
||||
|
||||
public static final class Slf4J extends Nag {
|
||||
private final org.slf4j.Logger logger;
|
||||
|
||||
public Slf4J(final org.slf4j.Logger logger) {
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void logError(final String message, @Nullable final Throwable throwable) {
|
||||
if (throwable != null) {
|
||||
this.logger.error(message, throwable);
|
||||
} else {
|
||||
this.logger.error(message);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void logWarn(final String message, @Nullable final Throwable throwable) {
|
||||
if (throwable != null) {
|
||||
this.logger.warn(message, throwable);
|
||||
} else {
|
||||
this.logger.warn(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static final class JavaUtilLogging extends Nag {
|
||||
private final java.util.logging.Logger logger;
|
||||
|
||||
public JavaUtilLogging(final java.util.logging.Logger logger) {
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void logError(final String message, @Nullable final Throwable throwable) {
|
||||
if (throwable != null) {
|
||||
this.logger.log(java.util.logging.Level.SEVERE, message, throwable);
|
||||
} else {
|
||||
this.logger.severe(message);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void logWarn(final String message, @Nullable final Throwable throwable) {
|
||||
if (throwable != null) {
|
||||
this.logger.log(java.util.logging.Level.WARNING, message, throwable);
|
||||
} else {
|
||||
this.logger.warning(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2022 Jason Penilla
|
||||
* Copyright (c) 2020-2025 Jason Penilla
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -24,8 +24,8 @@
|
||||
package xyz.jpenilla.minimotd.common.util;
|
||||
|
||||
import java.util.Objects;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import org.jspecify.annotations.NonNull;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
public final class Pair<L, R> {
|
||||
private final L left;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2022 Jason Penilla
|
||||
* Copyright (c) 2020-2025 Jason Penilla
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -23,20 +23,20 @@
|
||||
*/
|
||||
package xyz.jpenilla.minimotd.common.util;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonParser;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.jspecify.annotations.NonNull;
|
||||
import xyz.jpenilla.minimotd.common.Constants;
|
||||
|
||||
public final class UpdateChecker {
|
||||
@@ -45,7 +45,7 @@ public final class UpdateChecker {
|
||||
public @NonNull List<String> checkVersion() {
|
||||
final JsonArray result;
|
||||
final String url = String.format("https://api.github.com/repos/%s/%s/releases", Constants.PluginMetadata.GITHUB_USER, Constants.PluginMetadata.GITHUB_REPO);
|
||||
try (final InputStream is = new URL(url).openStream(); InputStreamReader reader = new InputStreamReader(is, Charsets.UTF_8)) {
|
||||
try (final InputStream is = new URL(url).openStream(); InputStreamReader reader = new InputStreamReader(is, StandardCharsets.UTF_8)) {
|
||||
result = this.parser.parse(reader).getAsJsonArray();
|
||||
} catch (final IOException ex) {
|
||||
return Collections.singletonList("Cannot look for updates: " + ex.getMessage());
|
||||
@@ -58,17 +58,17 @@ public final class UpdateChecker {
|
||||
return Collections.emptyList(); // Up to date, do nothing
|
||||
}
|
||||
if (currentVersion.contains("SNAPSHOT")) {
|
||||
return ImmutableList.of(
|
||||
return Arrays.asList(
|
||||
"This server is running a development build of " + Constants.PluginMetadata.NAME + "! (" + currentVersion + ")",
|
||||
"The latest official release is " + versionList.get(0)
|
||||
);
|
||||
}
|
||||
final int versionsBehind = versionList.indexOf(currentVersion);
|
||||
return ImmutableList.of(
|
||||
return Arrays.asList(
|
||||
"There is an update available for " + Constants.PluginMetadata.NAME + "!",
|
||||
"This server is running version " + currentVersion + ", which is " + (versionsBehind == -1 ? "UNKNOWN" : versionsBehind) + " versions outdated.",
|
||||
"Download the latest version, " + versionList.get(0) + " from GitHub at the link below:",
|
||||
versionMap.get(versionList.get(0))
|
||||
"Download the latest version, " + versionList.get(0) + " from Modrinth at the link below:",
|
||||
"https://modrinth.com/plugin/minimotd"
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2025 Jason Penilla
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package xyz.jpenilla.minimotd.common;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import xyz.jpenilla.minimotd.common.config.PluginSettings;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
|
||||
class VirtualHostMatchingTest {
|
||||
@Test
|
||||
void testMatching() {
|
||||
final Map<String, String> map = new LinkedHashMap<>();
|
||||
map.put("abc.xyz:25565", "1");
|
||||
map.put("subdomain.abc.xyz:25565", "2");
|
||||
map.put("*.abc.xyz:25565", "3");
|
||||
map.put("abc.*.*.domain.com:25565", "4");
|
||||
map.put("*.*.*.domain.com:25565", "5");
|
||||
final PluginSettings.ProxySettings proxySettings = new PluginSettings.ProxySettings(map);
|
||||
proxySettings.processVirtualHosts();
|
||||
|
||||
assertEquals("1", proxySettings.findConfigStringForHost("abc.xyz", 25565));
|
||||
assertEquals("2", proxySettings.findConfigStringForHost("subdomain.abc.xyz", 25565));
|
||||
assertEquals("3", proxySettings.findConfigStringForHost("other_subdomain.abc.xyz", 25565));
|
||||
assertEquals("4", proxySettings.findConfigStringForHost("abc.2.3.domain.com", 25565));
|
||||
assertEquals("5", proxySettings.findConfigStringForHost("1.2.3.domain.com", 25565));
|
||||
// TCPShield-mangled hostname
|
||||
assertEquals("5", proxySettings.findConfigStringForHost("1.2.3.domain.com///127.0.0.1:25565///1681016669///MGQCMAW5X13a9cF5ysnWdrBLovH4wfVu60l7eBUwWsCI8vw0cuZ9aj+UM7+y1wC//qGHngIwRsCke7eCpO99HTHOVdvZKjx9G0E51ALqRFGWH7kxMhVKYNF2IfMaT1FfbS0/D0du", 25565));
|
||||
assertNull(proxySettings.findConfigStringForHost("subdomain.subdomain.abc.xyz", 25565));
|
||||
assertNull(proxySettings.findConfigStringForHost("google.com", 25565));
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2022 Jason Penilla
|
||||
* Copyright (c) 2020-2025 Jason Penilla
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -41,14 +41,14 @@ class ComponentColorDownsamplerTest {
|
||||
|
||||
@Test
|
||||
void testColorDownsampling() {
|
||||
final Component fullColor = Components.ofChildren(
|
||||
final Component fullColor = Component.textOfChildren(
|
||||
text("Green ", GREEN),
|
||||
text("Orange Yellow ", ORANGE_YELLOW),
|
||||
text("Pink ", PINK),
|
||||
text("Blue ", BLUE),
|
||||
text("Lime Green", LIME_GREEN)
|
||||
);
|
||||
final Component expectedDownsample = Components.ofChildren(
|
||||
final Component expectedDownsample = Component.textOfChildren(
|
||||
text("Green ", nearestTo(GREEN)),
|
||||
text("Orange Yellow ", nearestTo(ORANGE_YELLOW)),
|
||||
text("Pink ", nearestTo(PINK)),
|
||||
|
||||
+1
-2
@@ -1,8 +1,7 @@
|
||||
group=xyz.jpenilla
|
||||
version=2.0.6
|
||||
version=2.2.6-SNAPSHOT
|
||||
description=Use MiniMessage text formatting in the server list MOTD.
|
||||
|
||||
org.gradle.caching=true
|
||||
org.gradle.configureondemand=true
|
||||
org.gradle.jvmargs=-Xmx2G
|
||||
org.gradle.parallel=true
|
||||
@@ -8,8 +8,10 @@ repositories {
|
||||
|
||||
dependencies {
|
||||
implementation(libs.indraCommon)
|
||||
implementation(libs.indraLicenser)
|
||||
implementation(libs.shadow)
|
||||
implementation(libs.testLogger)
|
||||
implementation(libs.mod.publish.plugin)
|
||||
implementation(libs.hangarPublishPlugin)
|
||||
|
||||
// https://github.com/gradle/gradle/issues/15383#issuecomment-779893192
|
||||
implementation(files(libs.javaClass.superclass.protectionDomain.codeSource.location))
|
||||
@@ -0,0 +1,9 @@
|
||||
rootProject.name = "build-logic"
|
||||
|
||||
dependencyResolutionManagement {
|
||||
versionCatalogs {
|
||||
create("libs") {
|
||||
from(files("../libs.versions.toml"))
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -2,5 +2,5 @@ object Constants {
|
||||
const val GITHUB_USER = "jpenilla"
|
||||
const val GITHUB_REPO = "MiniMOTD"
|
||||
const val GITHUB_URL = "https://github.com/$GITHUB_USER/$GITHUB_REPO"
|
||||
const val RELOCATION_BASE_PACKAGE = "xyz.jpenilla.minimotd.lib"
|
||||
const val RELOCATION_BASE_PACKAGE = "minimotd"
|
||||
}
|
||||
File renamed without changes.
@@ -0,0 +1,7 @@
|
||||
import org.gradle.api.provider.Property
|
||||
import org.gradle.api.tasks.bundling.AbstractArchiveTask
|
||||
|
||||
interface MiniMOTDPlatformExtension {
|
||||
val jarTask: Property<AbstractArchiveTask>
|
||||
val hangar: Property<Boolean>
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
import net.kyori.indra.git.IndraGitExtension
|
||||
import org.gradle.accessors.dm.LibrariesForLibs
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.attributes.Attribute
|
||||
import org.gradle.api.provider.Provider
|
||||
import org.gradle.kotlin.dsl.getByType
|
||||
|
||||
fun Project.lastCommitHash(): String =
|
||||
extensions.getByType<IndraGitExtension>().commit().orNull?.name?.substring(0, 7) ?: "unknown"
|
||||
|
||||
val Project.libs: LibrariesForLibs
|
||||
get() = extensions.getByType()
|
||||
|
||||
val Project.releaseNotes: Provider<String>
|
||||
get() = providers.environmentVariable("RELEASE_NOTES")
|
||||
|
||||
val Project.minecraftVersion: String
|
||||
get() = libs.versions.minecraft.get()
|
||||
|
||||
val bukkitVersions = listOf(
|
||||
"1.8.8",
|
||||
"1.8.9",
|
||||
"1.9.4",
|
||||
"1.10.2",
|
||||
"1.11.2",
|
||||
"1.12.2",
|
||||
"1.13.2",
|
||||
"1.14.4",
|
||||
"1.15.2",
|
||||
"1.16.5",
|
||||
"1.17.1",
|
||||
"1.18.2",
|
||||
"1.19.4",
|
||||
"1.20.4",
|
||||
"1.20.5",
|
||||
"1.20.6",
|
||||
"1.21.1",
|
||||
"1.21.2",
|
||||
"1.21.3",
|
||||
"1.21.4",
|
||||
"1.21.5",
|
||||
"1.21.6",
|
||||
"1.21.7",
|
||||
)
|
||||
|
||||
val paperVersions = listOf(
|
||||
"1.21.8",
|
||||
"1.21.9",
|
||||
"1.21.10",
|
||||
"1.21.11",
|
||||
"26.1",
|
||||
"26.1.1",
|
||||
"26.1.2",
|
||||
"26.2",
|
||||
"26.3",
|
||||
)
|
||||
|
||||
val productionJarAttribute = Attribute.of("minimotd.productionJar", String::class.java)
|
||||
@@ -0,0 +1,60 @@
|
||||
plugins {
|
||||
id("java-library")
|
||||
id("net.kyori.indra")
|
||||
id("net.kyori.indra.git")
|
||||
id("net.kyori.indra.checkstyle")
|
||||
id("net.kyori.indra.licenser.spotless")
|
||||
}
|
||||
|
||||
version = (version as String)
|
||||
.run { if (this.endsWith("-SNAPSHOT")) "$this+${lastCommitHash()}" else this }
|
||||
|
||||
indra {
|
||||
javaVersions {
|
||||
target(17)
|
||||
minimumToolchain(25)
|
||||
testWith(17, 21, 25)
|
||||
}
|
||||
github(Constants.GITHUB_USER, Constants.GITHUB_REPO)
|
||||
mitLicense()
|
||||
}
|
||||
|
||||
java.disableAutoTargetJvm()
|
||||
|
||||
repositories {
|
||||
mavenCentral {
|
||||
mavenContent { releasesOnly() }
|
||||
}
|
||||
maven("https://repo.jpenilla.xyz/snapshots/") {
|
||||
mavenContent {
|
||||
snapshotsOnly()
|
||||
includeGroup("xyz.jpenilla")
|
||||
}
|
||||
}
|
||||
maven("https://central.sonatype.com/repository/maven-snapshots/") {
|
||||
mavenContent { snapshotsOnly() }
|
||||
}
|
||||
maven("https://repo.papermc.io/repository/maven-public/")
|
||||
maven("https://repo.spongepowered.org/repository/maven-public/")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
testImplementation(libs.junitJupiter)
|
||||
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
|
||||
}
|
||||
|
||||
tasks {
|
||||
withType<JavaCompile> {
|
||||
options.compilerArgs.add("-Xlint:-processing")
|
||||
}
|
||||
listOf(javadocJar, javadoc).forEach {
|
||||
it.configure {
|
||||
onlyIf { false }
|
||||
}
|
||||
}
|
||||
test {
|
||||
testLogging {
|
||||
events("passed")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
plugins {
|
||||
base
|
||||
id("io.papermc.hangar-publish-plugin")
|
||||
}
|
||||
|
||||
fun jar(platform: String) = project(":minimotd-$platform")
|
||||
.extensions.getByType<MiniMOTDPlatformExtension>().jarTask.flatMap { it.archiveFile }
|
||||
|
||||
hangarPublish.publications.register("plugin") {
|
||||
version.set(project.version as String)
|
||||
id.set("MiniMOTD")
|
||||
channel.set("Release")
|
||||
changelog.set(releaseNotes)
|
||||
apiKey.set(providers.environmentVariable("HANGAR_UPLOAD_KEY"))
|
||||
platforms {
|
||||
paper {
|
||||
jar.set(jar("paper"))
|
||||
platformVersions = paperVersions
|
||||
dependencies.hangar("MiniPlaceholders") {
|
||||
required = false
|
||||
}
|
||||
}
|
||||
velocity {
|
||||
jar.set(jar("velocity"))
|
||||
platformVersions.addAll("3.4")
|
||||
dependencies.hangar("MiniPlaceholders") {
|
||||
required = false
|
||||
}
|
||||
}
|
||||
waterfall {
|
||||
jar.set(jar("bungeecord"))
|
||||
platformVersions.addAll("1.21")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
import me.modmuss50.mpp.ModPublishExtension
|
||||
|
||||
plugins {
|
||||
id("minimotd.base-conventions")
|
||||
id("net.kyori.indra.git")
|
||||
}
|
||||
|
||||
val platformExtension = extensions.create<MiniMOTDPlatformExtension>("miniMOTDPlatform")
|
||||
|
||||
tasks {
|
||||
val copyJar = register<FileCopyTask>("copyJar") {
|
||||
fileToCopy.set(platformExtension.jarTask.flatMap { it.archiveFile })
|
||||
destination.set(rootProject.layout.buildDirectory.dir("libs").flatMap {
|
||||
it.file(fileToCopy.map { file -> file.asFile.name })
|
||||
})
|
||||
}
|
||||
build {
|
||||
dependsOn(copyJar)
|
||||
}
|
||||
}
|
||||
|
||||
if (name != "minimotd-bukkit-bungeecord") {
|
||||
plugins.apply("me.modmuss50.mod-publish-plugin")
|
||||
|
||||
extensions.configure(ModPublishExtension::class) {
|
||||
modrinth {
|
||||
projectId.set("16vhQOQN")
|
||||
type = STABLE
|
||||
file.set(platformExtension.jarTask.flatMap { it.archiveFile })
|
||||
changelog.set(releaseNotes)
|
||||
accessToken.set(providers.environmentVariable("MODRINTH_TOKEN"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
configurations.consumable("productionJar") {
|
||||
outgoing {
|
||||
artifact(platformExtension.jarTask)
|
||||
}
|
||||
attributes.attribute(productionJarAttribute, "true")
|
||||
}
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
plugins {
|
||||
id("minimotd.platform-conventions")
|
||||
id("com.github.johnrengelman.shadow")
|
||||
id("com.gradleup.shadow")
|
||||
}
|
||||
|
||||
tasks {
|
||||
+7
-5
@@ -1,15 +1,17 @@
|
||||
import com.github.jengelman.gradle.plugins.shadow.internal.DependencyFilter
|
||||
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
||||
import org.gradle.api.file.DuplicatesStrategy
|
||||
|
||||
fun ShadowJar.commonRelocation(pkg: String) {
|
||||
relocate(pkg, "${Constants.RELOCATION_BASE_PACKAGE}.$pkg")
|
||||
}
|
||||
|
||||
fun ShadowJar.platformRelocation(platform: String, pkg: String) {
|
||||
relocate(pkg, "${Constants.RELOCATION_BASE_PACKAGE}.platform_$platform.$pkg")
|
||||
}
|
||||
|
||||
fun ShadowJar.commonConfiguration() {
|
||||
mergeServiceFiles()
|
||||
// Needed for mergeServiceFiles to work properly in Shadow 9+
|
||||
filesMatching("META-INF/services/**") {
|
||||
duplicatesStrategy = DuplicatesStrategy.INCLUDE
|
||||
}
|
||||
|
||||
commonRelocation("org.spongepowered.configurate")
|
||||
commonRelocation("com.typesafe.config")
|
||||
dependencies {
|
||||
@@ -0,0 +1,91 @@
|
||||
[versions]
|
||||
run-task = "3.1.0"
|
||||
resource-factory = "1.3.1"
|
||||
mod-publish-plugin = "2.2.0"
|
||||
hangarPublishPlugin = "0.1.4"
|
||||
indra = "4.1.0"
|
||||
shadow = "9.6.1"
|
||||
adventure = "4.26.1"
|
||||
adventurePlatform = "4.4.1"
|
||||
adventurePlatformMod = "7.2.0"
|
||||
configurate = "4.2.0"
|
||||
slf4j = "1.7.36"
|
||||
gson = "2.8.0"
|
||||
bstats = "3.2.1"
|
||||
paperApiLegacy = "1.16.5-R0.1-SNAPSHOT"
|
||||
paperApi = "1.21.11-R0.1-SNAPSHOT"
|
||||
paperlib = "1.0.8"
|
||||
waterfallApi = "1.16-R0.5-SNAPSHOT"
|
||||
fabricApi = "0.160.7+26.3"
|
||||
fabricLoader = "0.19.5"
|
||||
minecraft = "26.3"
|
||||
spongeApi7 = "7.4.0"
|
||||
velocityApi = "3.4.0"
|
||||
neoforge = "26.3.0.4-beta"
|
||||
|
||||
[plugins]
|
||||
blossom = { id = "net.kyori.blossom", version = "2.2.0" }
|
||||
sponge-gradle-plugin = { id = "org.spongepowered.gradle.plugin", version = "2.3.0" }
|
||||
run-paper = { id = "xyz.jpenilla.run-paper", version.ref = "run-task" }
|
||||
run-velocity = { id = "xyz.jpenilla.run-velocity" }
|
||||
run-waterfall = { id = "xyz.jpenilla.run-waterfall" }
|
||||
resource-factory-bukkit = { id = "xyz.jpenilla.resource-factory-bukkit-convention", version.ref = "resource-factory" }
|
||||
resource-factory-paper = { id = "xyz.jpenilla.resource-factory-paper-convention", version.ref = "resource-factory" }
|
||||
resource-factory-velocity = { id = "xyz.jpenilla.resource-factory-velocity-convention", version.ref = "resource-factory" }
|
||||
|
||||
[libraries]
|
||||
adventureBom = { group = "net.kyori", name = "adventure-bom", version.ref = "adventure" }
|
||||
adventureApi = { group = "net.kyori", name = "adventure-api" }
|
||||
adventureTextSerializerPlain = { group = "net.kyori", name = "adventure-text-serializer-plain" }
|
||||
adventureTextSerializerGson = { group = "net.kyori", name = "adventure-text-serializer-gson" }
|
||||
adventurePlatformBungeecord = { group = "net.kyori", name = "adventure-platform-bungeecord", version.ref = "adventurePlatform" }
|
||||
adventurePlatformBukkit = { group = "net.kyori", name = "adventure-platform-bukkit", version.ref = "adventurePlatform" }
|
||||
adventurePlatformFabric = { group = "net.kyori", name = "adventure-platform-fabric", version.ref = "adventurePlatformMod" }
|
||||
adventurePlatformNeoforge = { group = "net.kyori", name = "adventure-platform-neoforge", version.ref = "adventurePlatformMod" }
|
||||
adventurePlatformSpongeApi = { group = "net.kyori", name = "adventure-platform-spongeapi", version.ref = "adventurePlatform" }
|
||||
minimessage = { group = "net.kyori", name = "adventure-text-minimessage" }
|
||||
miniplaceholders = "io.github.miniplaceholders:miniplaceholders-api:3.2.0"
|
||||
|
||||
brigadier = "com.mojang:brigadier:1.3.10"
|
||||
|
||||
configurateHocon = { group = "org.spongepowered", name = "configurate-hocon", version.ref = "configurate" }
|
||||
|
||||
jspecify = "org.jspecify:jspecify:1.0.0"
|
||||
|
||||
slf4jApi = { group = "org.slf4j", name = "slf4j-api", version.ref = "slf4j" }
|
||||
slf4jJdk14 = { group = "org.slf4j", name = "slf4j-jdk14", version.ref = "slf4j" }
|
||||
|
||||
gson = { group = "com.google.code.gson", name = "gson", version.ref = "gson" }
|
||||
|
||||
bstatsBukkit = { group = "org.bstats", name = "bstats-bukkit", version.ref = "bstats" }
|
||||
bstatsBungeecord = { group = "org.bstats", name = "bstats-bungeecord", version.ref = "bstats" }
|
||||
bstatsVelocity = { group = "org.bstats", name = "bstats-velocity", version.ref = "bstats" }
|
||||
bstatsSponge = { group = "org.bstats", name = "bstats-sponge", version.ref = "bstats" }
|
||||
|
||||
paperApiLegacy = { group = "com.destroystokyo.paper", name = "paper-api", version.ref = "paperApiLegacy" }
|
||||
paperApi = { group = "io.papermc.paper", name = "paper-api", version.ref = "paperApi" }
|
||||
paperlib = { group = "io.papermc", name = "paperlib", version.ref = "paperlib" }
|
||||
|
||||
waterfallApi = { group = "io.github.waterfallmc", name = "waterfall-api", version.ref = "waterfallApi" }
|
||||
|
||||
fabricApi = { group = "net.fabricmc.fabric-api", name = "fabric-api", version.ref = "fabricApi" }
|
||||
fabricLoader = { group = "net.fabricmc", name = "fabric-loader", version.ref = "fabricLoader" }
|
||||
minecraft = { group = "com.mojang", name = "minecraft", version.ref = "minecraft" }
|
||||
|
||||
# for renovate
|
||||
zNeoforge = { module = "net.neoforged:neoforge", version.ref = "neoforge" }
|
||||
|
||||
spongeApi7 = { group = "org.spongepowered", name = "spongeapi", version.ref = "spongeApi7" }
|
||||
|
||||
velocityApi = { group = "com.velocitypowered", name = "velocity-api", version.ref = "velocityApi" }
|
||||
|
||||
junitJupiter = "org.junit.jupiter:junit-jupiter:6.1.3"
|
||||
|
||||
# build-logic
|
||||
indraCommon = { group = "net.kyori", name = "indra-common", version.ref = "indra" }
|
||||
indraLicenser = { group = "net.kyori", name = "indra-licenser-spotless", version.ref = "indra" }
|
||||
shadow = { group = "com.gradleup.shadow", name = "shadow-gradle-plugin", version.ref = "shadow" }
|
||||
mod-publish-plugin = { module = "me.modmuss50:mod-publish-plugin", version.ref = "mod-publish-plugin" }
|
||||
hangarPublishPlugin = { group = "io.papermc", name = "hangar-publish-plugin", version.ref = "hangarPublishPlugin" }
|
||||
|
||||
[bundles]
|
||||
@@ -1,171 +0,0 @@
|
||||
metadata:
|
||||
format: { version: 1.0 }
|
||||
polyglot-extensions:
|
||||
- plugins
|
||||
|
||||
plugins:
|
||||
net.kyori.blossom: 1.3.0
|
||||
org.spongepowered.gradle.plugin: 2.0.1
|
||||
net.minecrell.plugin-yml.bungee: &plugin-yml 0.5.1
|
||||
net.minecrell.plugin-yml.bukkit: *plugin-yml
|
||||
xyz.jpenilla.run-paper: 1.0.6
|
||||
|
||||
versions:
|
||||
indra: 2.1.1
|
||||
shadow: 7.1.2
|
||||
testLoggerPlugin: 3.2.0
|
||||
adventure: 4.10.1
|
||||
adventurePlatform: 4.1.0
|
||||
adventurePlatformFabric: 5.2.0
|
||||
configurate: 4.1.2
|
||||
checkerQual: 3.21.3
|
||||
slf4j: 1.7.32
|
||||
gson: 2.8.0
|
||||
guava: 21.0
|
||||
bstats: 2.2.1
|
||||
paperApi: 1.16.5-R0.1-SNAPSHOT
|
||||
paperlib: 1.0.8-SNAPSHOT
|
||||
waterfallApi: 1.16-R0.4-SNAPSHOT
|
||||
fabricApi: 0.47.8+1.18.2
|
||||
fabricLoader: 0.13.3
|
||||
fabricMinecraft: 1.18.2
|
||||
spongeApi7: 7.2.0
|
||||
velocityApi: 3.1.2-SNAPSHOT
|
||||
jupiterEngine: 5.8.2
|
||||
|
||||
dependencies:
|
||||
adventureBom:
|
||||
group: net.kyori
|
||||
name: adventure-bom
|
||||
version: { ref: adventure }
|
||||
adventureApi:
|
||||
group: net.kyori
|
||||
name: adventure-api
|
||||
adventureTextSerializerPlain:
|
||||
group: net.kyori
|
||||
name: adventure-text-serializer-plain
|
||||
adventureTextSerializerGson:
|
||||
group: net.kyori
|
||||
name: adventure-text-serializer-gson
|
||||
adventurePlatformBungeecord:
|
||||
group: net.kyori
|
||||
name: adventure-platform-bungeecord
|
||||
version: { ref: adventurePlatform }
|
||||
adventurePlatformBukkit:
|
||||
group: net.kyori
|
||||
name: adventure-platform-bukkit
|
||||
version: { ref: adventurePlatform }
|
||||
adventurePlatformFabric:
|
||||
group: net.kyori
|
||||
name: adventure-platform-fabric
|
||||
version: { ref: adventurePlatformFabric }
|
||||
adventurePlatformSpongeApi:
|
||||
group: net.kyori
|
||||
name: adventure-platform-spongeapi
|
||||
version: { ref: adventurePlatform }
|
||||
minimessage:
|
||||
group: net.kyori
|
||||
name: adventure-text-minimessage
|
||||
|
||||
configurateHocon:
|
||||
group: org.spongepowered
|
||||
name: configurate-hocon
|
||||
version: { ref: configurate }
|
||||
|
||||
checkerQual:
|
||||
group: org.checkerframework
|
||||
name: checker-qual
|
||||
version: { ref: checkerQual }
|
||||
|
||||
slf4jApi:
|
||||
group: org.slf4j
|
||||
name: slf4j-api
|
||||
version: { ref: slf4j }
|
||||
slf4jJdk14:
|
||||
group: org.slf4j
|
||||
name: slf4j-jdk14
|
||||
version: { ref: slf4j }
|
||||
|
||||
gson:
|
||||
group: com.google.code.gson
|
||||
name: gson
|
||||
version: { ref: gson }
|
||||
guava:
|
||||
group: com.google.guava
|
||||
name: guava
|
||||
version: { ref: guava }
|
||||
|
||||
bstatsBukkit:
|
||||
group: org.bstats
|
||||
name: bstats-bukkit
|
||||
version: { ref: bstats }
|
||||
bstatsBungeecord:
|
||||
group: org.bstats
|
||||
name: bstats-bungeecord
|
||||
version: { ref: bstats }
|
||||
bstatsVelocity:
|
||||
group: org.bstats
|
||||
name: bstats-velocity
|
||||
version: { ref: bstats }
|
||||
bstatsSponge:
|
||||
group: org.bstats
|
||||
name: bstats-sponge
|
||||
version: { ref: bstats }
|
||||
|
||||
paperApi:
|
||||
group: com.destroystokyo.paper
|
||||
name: paper-api
|
||||
version: { ref: paperApi }
|
||||
paperlib:
|
||||
group: io.papermc
|
||||
name: paperlib
|
||||
version: { ref: paperlib }
|
||||
|
||||
waterfallApi:
|
||||
group: io.github.waterfallmc
|
||||
name: waterfall-api
|
||||
version: { ref: waterfallApi }
|
||||
|
||||
fabricApi:
|
||||
group: net.fabricmc.fabric-api
|
||||
name: fabric-api
|
||||
version: { ref: fabricApi }
|
||||
fabricLoader:
|
||||
group: net.fabricmc
|
||||
name: fabric-loader
|
||||
version: { ref: fabricLoader }
|
||||
fabricMinecraft:
|
||||
group: com.mojang
|
||||
name: minecraft
|
||||
version: { ref: fabricMinecraft }
|
||||
|
||||
spongeApi7:
|
||||
group: org.spongepowered
|
||||
name: spongeapi
|
||||
version: { ref: spongeApi7 }
|
||||
|
||||
velocityApi:
|
||||
group: com.velocitypowered
|
||||
name: velocity-api
|
||||
version: { ref: velocityApi }
|
||||
|
||||
jupiterEngine:
|
||||
group: org.junit.jupiter
|
||||
name: junit-jupiter-engine
|
||||
version: { ref: jupiterEngine }
|
||||
|
||||
# build-logic
|
||||
indraCommon:
|
||||
group: net.kyori
|
||||
name: indra-common
|
||||
version: { ref: indra }
|
||||
shadow:
|
||||
group: gradle.plugin.com.github.johnrengelman
|
||||
name: shadow
|
||||
version: { ref: shadow }
|
||||
testLogger:
|
||||
group: com.adarshr
|
||||
name: gradle-test-logger-plugin
|
||||
version: { ref: testLoggerPlugin }
|
||||
|
||||
bundles:
|
||||
Vendored
BIN
Binary file not shown.
+5
-1
@@ -1,5 +1,9 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.1-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-9.7.1-bin.zip
|
||||
networkTimeout=10000
|
||||
retries=0
|
||||
retryBackOffMs=500
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright © 2015-2021 the original authors.
|
||||
# Copyright © 2015 the original authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
@@ -15,10 +15,12 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
# Gradle start up script for POSIX generated by Gradle.
|
||||
# gradlew start up script for POSIX generated by Gradle.
|
||||
#
|
||||
# Important for running:
|
||||
#
|
||||
@@ -27,7 +29,7 @@
|
||||
# bash, then to run this script, type that shell name before the whole
|
||||
# command line, like:
|
||||
#
|
||||
# ksh Gradle
|
||||
# ksh gradlew
|
||||
#
|
||||
# Busybox and similar reduced shells will NOT work, because this script
|
||||
# requires all of these POSIX shell features:
|
||||
@@ -55,7 +57,7 @@
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
@@ -80,13 +82,11 @@ do
|
||||
esac
|
||||
done
|
||||
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||
|
||||
APP_NAME="Gradle"
|
||||
# This is normally unused
|
||||
# shellcheck disable=SC2034
|
||||
APP_BASE_NAME=${0##*/}
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
@@ -114,7 +114,6 @@ case "$( uname )" in #(
|
||||
NONSTOP* ) nonstop=true ;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
@@ -133,22 +132,29 @@ location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD=java
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
if ! command -v java >/dev/null 2>&1
|
||||
then
|
||||
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
case $MAX_FD in #(
|
||||
'' | soft) :;; #(
|
||||
*)
|
||||
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
@@ -165,7 +171,6 @@ fi
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if "$cygwin" || "$msys" ; then
|
||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||
|
||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||
|
||||
@@ -193,18 +198,27 @@ if "$cygwin" || "$msys" ; then
|
||||
done
|
||||
fi
|
||||
|
||||
# Collect all arguments for the java command;
|
||||
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
||||
# shell script including quotes and variable substitutions, so put them in
|
||||
# double quotes to make sure that they get re-expanded; and
|
||||
# * put everything else in single quotes, so that it's not re-expanded.
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Collect all arguments for the java command:
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||
# and any embedded shellness will be escaped.
|
||||
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
||||
# treated as '${Hostname}' itself on the command line.
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
-classpath "$CLASSPATH" \
|
||||
org.gradle.wrapper.GradleWrapperMain \
|
||||
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
|
||||
"$@"
|
||||
|
||||
# Stop when "xargs" is not available.
|
||||
if ! command -v xargs >/dev/null 2>&1
|
||||
then
|
||||
die "xargs is not available"
|
||||
fi
|
||||
|
||||
# Use "xargs" to parse quoted args.
|
||||
#
|
||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||
|
||||
Vendored
+28
-35
@@ -13,19 +13,22 @@
|
||||
@rem See the License for the specific language governing permissions and
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
@rem SPDX-License-Identifier: Apache-2.0
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%" == "" @echo off
|
||||
@if "%DEBUG%"=="" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem gradlew startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
@rem Set local scope for the variables, and ensure extensions are enabled
|
||||
setlocal EnableExtensions
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
if "%DIRNAME%"=="" set DIRNAME=.
|
||||
@rem This is normally unused
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@@ -40,15 +43,15 @@ if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto execute
|
||||
if %ERRORLEVEL% equ 0 goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
echo. 1>&2
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
|
||||
echo. 1>&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||
echo location of your Java installation. 1>&2
|
||||
|
||||
goto fail
|
||||
"%COMSPEC%" /c exit 1
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
@@ -56,34 +59,24 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
echo. 1>&2
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
|
||||
echo. 1>&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||
echo location of your Java installation. 1>&2
|
||||
|
||||
goto fail
|
||||
"%COMSPEC%" /c exit 1
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||
@rem Execute gradlew
|
||||
@rem endlocal doesn't take effect until after the line is parsed and variables are expanded
|
||||
@rem which allows us to clear the local environment before executing the java command
|
||||
endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
:exitWithErrorLevel
|
||||
@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts
|
||||
"%COMSPEC%" /c exit %ERRORLEVEL%
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2020-2022 Jason Penilla
|
||||
Copyright (c) 2020-2025 Jason Penilla
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
This file is part of MiniMOTD, licensed under the MIT License.
|
||||
|
||||
Copyright (c) 2020-2022 Jason Penilla
|
||||
Copyright (c) 2020-2025 Jason Penilla
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
plugins {
|
||||
id("minimotd.shadow-platform")
|
||||
id("net.minecrell.plugin-yml.bukkit")
|
||||
id("xyz.jpenilla.run-paper")
|
||||
alias(libs.plugins.run.paper)
|
||||
alias(libs.plugins.resource.factory.bukkit)
|
||||
}
|
||||
|
||||
dependencies {
|
||||
@@ -10,12 +10,12 @@ dependencies {
|
||||
implementation(libs.adventurePlatformBukkit)
|
||||
implementation(libs.bstatsBukkit)
|
||||
implementation(libs.paperlib)
|
||||
compileOnly(libs.paperApi)
|
||||
compileOnly(libs.paperApiLegacy)
|
||||
}
|
||||
|
||||
tasks {
|
||||
runServer {
|
||||
minecraftVersion("1.18.2")
|
||||
minecraftVersion("1.21.7")
|
||||
}
|
||||
shadowJar {
|
||||
commonRelocation("org.slf4j")
|
||||
@@ -23,21 +23,30 @@ tasks {
|
||||
commonRelocation("net.kyori")
|
||||
commonRelocation("org.bstats")
|
||||
commonRelocation("io.papermc.lib")
|
||||
}
|
||||
}
|
||||
|
||||
bukkit {
|
||||
name = rootProject.name
|
||||
main = "xyz.jpenilla.minimotd.bukkit.MiniMOTDPlugin"
|
||||
apiVersion = "1.13"
|
||||
website = Constants.GITHUB_URL
|
||||
authors = listOf("jmp")
|
||||
softDepend = listOf("ViaVersion")
|
||||
commands {
|
||||
register("minimotd") {
|
||||
description = "MiniMOTD Command"
|
||||
usage = "/minimotd help"
|
||||
permission = "minimotd.admin"
|
||||
manifest {
|
||||
attributes("paperweight-mappings-namespace" to "mojang")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bukkitPluginYaml {
|
||||
name = "MiniMOTD"
|
||||
main = "xyz.jpenilla.minimotd.bukkit.MiniMOTDBukkit"
|
||||
foliaSupported = true
|
||||
authors = listOf("jmp")
|
||||
website = Constants.GITHUB_URL
|
||||
commands.register("minimotd") {
|
||||
description = "MiniMOTD Command"
|
||||
permission = "minimotd.admin"
|
||||
usage = "/minimotd help"
|
||||
}
|
||||
apiVersion = "1.13"
|
||||
softDepend = listOf("ViaVersion")
|
||||
}
|
||||
|
||||
runPaper.folia.registerTask()
|
||||
|
||||
publishMods.modrinth {
|
||||
modLoaders.addAll("paper", "folia")
|
||||
minecraftVersions = bukkitVersions
|
||||
}
|
||||
+4
-4
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2022 Jason Penilla
|
||||
* Copyright (c) 2020-2025 Jason Penilla
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -31,7 +31,7 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.jspecify.annotations.NonNull;
|
||||
import xyz.jpenilla.minimotd.common.CommandHandler;
|
||||
|
||||
import static net.kyori.adventure.text.Component.text;
|
||||
@@ -39,10 +39,10 @@ import static net.kyori.adventure.text.event.ClickEvent.runCommand;
|
||||
import static net.kyori.adventure.text.format.NamedTextColor.RED;
|
||||
|
||||
final class BukkitCommand implements CommandExecutor, TabCompleter {
|
||||
private final MiniMOTDPlugin plugin;
|
||||
private final MiniMOTDBukkit plugin;
|
||||
private final CommandHandler handler;
|
||||
|
||||
BukkitCommand(final @NonNull MiniMOTDPlugin plugin) {
|
||||
BukkitCommand(final @NonNull MiniMOTDBukkit plugin) {
|
||||
this.plugin = plugin;
|
||||
this.handler = new CommandHandler(plugin.miniMOTD());
|
||||
}
|
||||
+34
-6
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2022 Jason Penilla
|
||||
* Copyright (c) 2020-2025 Jason Penilla
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -26,20 +26,23 @@ package xyz.jpenilla.minimotd.bukkit;
|
||||
import io.papermc.lib.PaperLib;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.nio.file.Path;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
|
||||
import org.bstats.bukkit.Metrics;
|
||||
import org.bstats.charts.SimplePie;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.util.CachedServerIcon;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import org.jspecify.annotations.NonNull;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import xyz.jpenilla.minimotd.common.MiniMOTD;
|
||||
import xyz.jpenilla.minimotd.common.MiniMOTDPlatform;
|
||||
import xyz.jpenilla.minimotd.common.util.Nag;
|
||||
import xyz.jpenilla.minimotd.common.util.UpdateChecker;
|
||||
|
||||
public final class MiniMOTDPlugin extends JavaPlugin implements MiniMOTDPlatform<CachedServerIcon> {
|
||||
public final class MiniMOTDBukkit extends JavaPlugin implements MiniMOTDPlatform<CachedServerIcon> {
|
||||
private static final boolean PAPER_PING_EVENT_EXISTS = findClass("com.destroystokyo.paper.event.server.PaperServerListPingEvent") != null;
|
||||
|
||||
private Logger logger;
|
||||
@@ -49,6 +52,21 @@ public final class MiniMOTDPlugin extends JavaPlugin implements MiniMOTDPlatform
|
||||
@Override
|
||||
public void onEnable() {
|
||||
this.logger = LoggerFactory.getLogger(this.getName());
|
||||
|
||||
if (PaperLib.getMinecraftVersion() > 21 || PaperLib.getMinecraftVersion() == 21 && PaperLib.getMinecraftPatchVersion() > 7) {
|
||||
new Nag.Slf4J(this.logger).lines(
|
||||
"You are using the incorrect MiniMOTD build for your server software.",
|
||||
"This build is for Spigot/Paper 1.8.8 through 1.21.7.",
|
||||
"Builds for Paper 1.21.8+ are available on Modrinth (https://modrinth.com/plugin/minimotd)",
|
||||
"and Hangar (https://hangar.papermc.io/jmp/MiniMOTD).",
|
||||
"When downloading be sure to check the supported versions/platforms",
|
||||
"field on the versions page, and/or make the correct selections in",
|
||||
"the download menu."
|
||||
).error(true).logBanner();
|
||||
this.getServer().getPluginManager().disablePlugin(this);
|
||||
return;
|
||||
}
|
||||
|
||||
this.miniMOTD = new MiniMOTD<>(this);
|
||||
this.audiences = BukkitAudiences.create(this);
|
||||
|
||||
@@ -69,10 +87,20 @@ public final class MiniMOTDPlugin extends JavaPlugin implements MiniMOTDPlatform
|
||||
}
|
||||
|
||||
final Metrics metrics = new Metrics(this, 8132);
|
||||
metrics.addCustomChart(new SimplePie("variant", () -> "bukkit"));
|
||||
|
||||
if (this.miniMOTD.configManager().pluginSettings().updateChecker()) {
|
||||
this.getServer().getScheduler().runTaskAsynchronously(this, () ->
|
||||
new UpdateChecker().checkVersion().forEach(this.logger::info));
|
||||
try {
|
||||
Class.forName("io.papermc.paper.threadedregions.RegionizedServer");
|
||||
CompletableFuture.runAsync(() -> new UpdateChecker().checkVersion().forEach(this.logger::info)).whenComplete(($, thr) -> {
|
||||
if (thr != null) {
|
||||
this.logger.warn("Exception checking for updates", thr);
|
||||
}
|
||||
});
|
||||
} catch (final ReflectiveOperationException ex) {
|
||||
this.getServer().getScheduler().runTaskAsynchronously(this, () ->
|
||||
new UpdateChecker().checkVersion().forEach(this.logger::info));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+30
-5
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2022 Jason Penilla
|
||||
* Copyright (c) 2020-2025 Jason Penilla
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -25,17 +25,32 @@ package xyz.jpenilla.minimotd.bukkit;
|
||||
|
||||
import com.destroystokyo.paper.event.server.PaperServerListPingEvent;
|
||||
import io.papermc.lib.PaperLib;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.List;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.util.CachedServerIcon;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.jspecify.annotations.NonNull;
|
||||
import xyz.jpenilla.minimotd.common.Constants;
|
||||
import xyz.jpenilla.minimotd.common.MiniMOTD;
|
||||
import xyz.jpenilla.minimotd.common.PingResponse;
|
||||
import xyz.jpenilla.minimotd.common.config.MiniMOTDConfig;
|
||||
import xyz.jpenilla.minimotd.common.config.MOTDConfig;
|
||||
|
||||
public final class PaperPingListener implements Listener {
|
||||
private static final Method WORK_AROUND_PAPER_BUG;
|
||||
|
||||
static {
|
||||
Method paperWorkaround;
|
||||
try {
|
||||
paperWorkaround = PaperServerListPingEvent.class.getMethod("getListedPlayers");
|
||||
} catch (final NoSuchMethodException e) {
|
||||
paperWorkaround = null;
|
||||
}
|
||||
WORK_AROUND_PAPER_BUG = paperWorkaround;
|
||||
}
|
||||
|
||||
private final LegacyComponentSerializer unusualHexSerializer = LegacyComponentSerializer.builder().hexColors().useUnusualXRepeatedCharacterHexFormat().build();
|
||||
private final MiniMOTD<CachedServerIcon> miniMOTD;
|
||||
|
||||
@@ -45,7 +60,7 @@ public final class PaperPingListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void handlePing(final @NonNull PaperServerListPingEvent event) {
|
||||
final MiniMOTDConfig cfg = this.miniMOTD.configManager().mainConfig();
|
||||
final MOTDConfig cfg = this.miniMOTD.configManager().mainConfig();
|
||||
|
||||
final PingResponse<CachedServerIcon> response = this.miniMOTD.createMOTD(cfg, event.getNumPlayers(), event.getMaxPlayers());
|
||||
|
||||
@@ -60,7 +75,17 @@ public final class PaperPingListener implements Listener {
|
||||
response.icon(event::setServerIcon);
|
||||
|
||||
if (response.disablePlayerListHover()) {
|
||||
event.getPlayerSample().clear();
|
||||
if (WORK_AROUND_PAPER_BUG != null) {
|
||||
// Newer Paper replaces getPlayerSample with getListedPlayers,
|
||||
// the old method is supposed to still work, but it just silently does nothing on 1.20.6 (fixed in 1.21.1)
|
||||
try {
|
||||
((List) WORK_AROUND_PAPER_BUG.invoke(event)).clear();
|
||||
} catch (final IllegalAccessException | InvocationTargetException e) {
|
||||
throw new RuntimeException("Failed to invoke " + WORK_AROUND_PAPER_BUG.getName(), e);
|
||||
}
|
||||
} else {
|
||||
event.getPlayerSample().clear();
|
||||
}
|
||||
}
|
||||
if (response.hidePlayerCount()) {
|
||||
event.setHidePlayers(true);
|
||||
+10
-5
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2022 Jason Penilla
|
||||
* Copyright (c) 2020-2025 Jason Penilla
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -29,10 +29,10 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.server.ServerListPingEvent;
|
||||
import org.bukkit.util.CachedServerIcon;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.jspecify.annotations.NonNull;
|
||||
import xyz.jpenilla.minimotd.common.MiniMOTD;
|
||||
import xyz.jpenilla.minimotd.common.PingResponse;
|
||||
import xyz.jpenilla.minimotd.common.config.MiniMOTDConfig;
|
||||
import xyz.jpenilla.minimotd.common.config.MOTDConfig;
|
||||
|
||||
public final class PingListener implements Listener {
|
||||
private final MiniMOTD<CachedServerIcon> miniMOTD;
|
||||
@@ -44,7 +44,7 @@ public final class PingListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void handlePing(final @NonNull ServerListPingEvent event) {
|
||||
final MiniMOTDConfig cfg = this.miniMOTD.configManager().mainConfig();
|
||||
final MOTDConfig cfg = this.miniMOTD.configManager().mainConfig();
|
||||
|
||||
final PingResponse<CachedServerIcon> response = this.miniMOTD.createMOTD(cfg, event.getNumPlayers(), event.getMaxPlayers());
|
||||
|
||||
@@ -56,6 +56,11 @@ public final class PingListener implements Listener {
|
||||
event.setMotd(LegacyComponentSerializer.legacySection().serialize(motd));
|
||||
}
|
||||
});
|
||||
response.icon(event::setServerIcon);
|
||||
response.icon(icon -> {
|
||||
try {
|
||||
event.setServerIcon(icon);
|
||||
} catch (final UnsupportedOperationException ignore) {
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
plugins {
|
||||
id("minimotd.shadow-platform")
|
||||
alias(libs.plugins.run.waterfall)
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(projects.minimotdCommon)
|
||||
implementation(libs.adventurePlatformBungeecord)
|
||||
implementation(libs.bstatsBungeecord)
|
||||
compileOnly(libs.waterfallApi)
|
||||
}
|
||||
|
||||
tasks {
|
||||
shadowJar {
|
||||
commonRelocation("io.leangen.geantyref")
|
||||
commonRelocation("net.kyori")
|
||||
commonRelocation("org.bstats")
|
||||
}
|
||||
runWaterfall {
|
||||
waterfallVersion("1.21")
|
||||
}
|
||||
processResources {
|
||||
val props = mapOf(
|
||||
"version" to project.version,
|
||||
"description" to project.description
|
||||
)
|
||||
inputs.properties(props)
|
||||
filesMatching("bungee.yml") {
|
||||
expand(props)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
publishMods.modrinth {
|
||||
modLoaders.add("waterfall")
|
||||
minecraftVersions.addAll(minecraftVersion)
|
||||
}
|
||||
+4
-4
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2022 Jason Penilla
|
||||
* Copyright (c) 2020-2025 Jason Penilla
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -26,7 +26,7 @@ package xyz.jpenilla.minimotd.bungee;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.plugin.Command;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.jspecify.annotations.NonNull;
|
||||
import xyz.jpenilla.minimotd.common.CommandHandler;
|
||||
|
||||
import static net.kyori.adventure.text.Component.text;
|
||||
@@ -34,10 +34,10 @@ import static net.kyori.adventure.text.event.ClickEvent.runCommand;
|
||||
import static net.kyori.adventure.text.format.NamedTextColor.RED;
|
||||
|
||||
final class BungeeCommand extends Command {
|
||||
private final MiniMOTDPlugin plugin;
|
||||
private final MiniMOTDBungee plugin;
|
||||
private final CommandHandler handler;
|
||||
|
||||
BungeeCommand(final @NonNull MiniMOTDPlugin plugin) {
|
||||
BungeeCommand(final @NonNull MiniMOTDBungee plugin) {
|
||||
super("minimotd");
|
||||
this.plugin = plugin;
|
||||
this.handler = new CommandHandler(plugin.miniMOTD());
|
||||
+15
-4
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2022 Jason Penilla
|
||||
* Copyright (c) 2020-2025 Jason Penilla
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -33,15 +33,17 @@ import net.md_5.bungee.api.Favicon;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.plugin.Plugin;
|
||||
import org.bstats.bungeecord.Metrics;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import org.jspecify.annotations.NonNull;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import xyz.jpenilla.minimotd.common.MiniMOTD;
|
||||
import xyz.jpenilla.minimotd.common.MiniMOTDPlatform;
|
||||
import xyz.jpenilla.minimotd.common.PingResponse;
|
||||
import xyz.jpenilla.minimotd.common.config.MOTDConfig;
|
||||
import xyz.jpenilla.minimotd.common.util.UpdateChecker;
|
||||
|
||||
public final class MiniMOTDPlugin extends Plugin implements MiniMOTDPlatform<Favicon> {
|
||||
public final class MiniMOTDBungee extends Plugin implements MiniMOTDPlatform<Favicon> {
|
||||
private Logger logger;
|
||||
private BungeeAudiences audiences;
|
||||
private MiniMOTD<Favicon> miniMOTD;
|
||||
@@ -65,6 +67,9 @@ public final class MiniMOTDPlugin extends Plugin implements MiniMOTDPlatform<Fav
|
||||
this.getProxy().getScheduler().runAsync(this, () ->
|
||||
new UpdateChecker().checkVersion().forEach(this.logger::info));
|
||||
}
|
||||
|
||||
// preload some stuff, so the first ping is as fast as the rest
|
||||
this.preload();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -109,4 +114,10 @@ public final class MiniMOTDPlugin extends Plugin implements MiniMOTDPlatform<Fav
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private void preload() {
|
||||
final MOTDConfig cfg = this.miniMOTD.configManager().mainConfig();
|
||||
final PingResponse<Favicon> mini = this.miniMOTD.createMOTD(cfg, 0, 0);
|
||||
mini.motd(motd -> BungeeComponentSerializer.get().serialize(motd));
|
||||
}
|
||||
}
|
||||
+4
-4
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2022 Jason Penilla
|
||||
* Copyright (c) 2020-2025 Jason Penilla
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -31,11 +31,11 @@ import net.md_5.bungee.api.chat.TextComponent;
|
||||
import net.md_5.bungee.api.event.ProxyPingEvent;
|
||||
import net.md_5.bungee.api.plugin.Listener;
|
||||
import net.md_5.bungee.event.EventHandler;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.jspecify.annotations.NonNull;
|
||||
import xyz.jpenilla.minimotd.common.Constants;
|
||||
import xyz.jpenilla.minimotd.common.MiniMOTD;
|
||||
import xyz.jpenilla.minimotd.common.PingResponse;
|
||||
import xyz.jpenilla.minimotd.common.config.MiniMOTDConfig;
|
||||
import xyz.jpenilla.minimotd.common.config.MOTDConfig;
|
||||
|
||||
public final class PingListener implements Listener {
|
||||
private final MiniMOTD<Favicon> miniMOTD;
|
||||
@@ -52,7 +52,7 @@ public final class PingListener implements Listener {
|
||||
}
|
||||
|
||||
final ServerPing.Players players = response.getPlayers();
|
||||
final MiniMOTDConfig cfg = this.miniMOTD.configManager().resolveConfig(e.getConnection().getVirtualHost());
|
||||
final MOTDConfig cfg = this.miniMOTD.configManager().resolveConfig(e.getConnection().getVirtualHost());
|
||||
final PingResponse<Favicon> mini = this.miniMOTD.createMOTD(cfg, players.getOnline(), players.getMax());
|
||||
|
||||
if (mini.hidePlayerCount()) {
|
||||
@@ -0,0 +1,5 @@
|
||||
name: MiniMOTD
|
||||
main: xyz.jpenilla.minimotd.bungee.MiniMOTDBungee
|
||||
version: $version
|
||||
author: jmp
|
||||
description: $description
|
||||
@@ -1,50 +1,43 @@
|
||||
import me.modmuss50.mpp.platforms.modrinth.ModrinthEnvironment
|
||||
|
||||
plugins {
|
||||
id("xyz.jpenilla.quiet-fabric-loom")
|
||||
id("minimotd.platform-conventions")
|
||||
id("com.github.johnrengelman.shadow")
|
||||
id("quiet-fabric-loom")
|
||||
id("com.gradleup.shadow")
|
||||
}
|
||||
|
||||
val shade: Configuration by configurations.creating
|
||||
|
||||
val minecraftVersion = libs.versions.fabricMinecraft.get()
|
||||
|
||||
dependencies {
|
||||
minecraft(libs.fabricMinecraft)
|
||||
mappings(loom.officialMojangMappings())
|
||||
modImplementation(libs.fabricLoader)
|
||||
modImplementation(libs.fabricApi)
|
||||
minecraft(libs.minecraft)
|
||||
implementation(libs.fabricLoader)
|
||||
implementation(libs.fabricApi)
|
||||
|
||||
shade(implementation(projects.minimotdCommon) {
|
||||
exclude("net.kyori")
|
||||
exclude("com.google.errorprone")
|
||||
})
|
||||
|
||||
modImplementation(libs.adventurePlatformFabric)
|
||||
implementation(libs.adventurePlatformFabric)
|
||||
include(libs.adventurePlatformFabric)
|
||||
}
|
||||
|
||||
miniMOTDPlatform {
|
||||
jarTask.set(tasks.remapJar)
|
||||
jarTask.set(tasks.shadowJar)
|
||||
}
|
||||
|
||||
indra {
|
||||
javaVersions {
|
||||
target(17)
|
||||
target(25)
|
||||
}
|
||||
}
|
||||
|
||||
loom {
|
||||
serverOnlyMinecraftJar()
|
||||
}
|
||||
|
||||
tasks {
|
||||
shadowJar {
|
||||
archiveFileName.set("${project.name}-mc$minecraftVersion-${project.version}.jar")
|
||||
configurations = listOf(shade)
|
||||
commonConfiguration()
|
||||
commonRelocation("io.leangen.geantyref")
|
||||
platformRelocation("fabric", "xyz.jpenilla.minimotd.common")
|
||||
}
|
||||
remapJar {
|
||||
archiveFileName.set("${project.name}-mc$minecraftVersion-${project.version}.jar")
|
||||
}
|
||||
processResources {
|
||||
val replacements = mapOf(
|
||||
@@ -60,3 +53,10 @@ tasks {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
publishMods.modrinth {
|
||||
environment = ModrinthEnvironment.DEDICATED_SERVER_ONLY
|
||||
modLoaders.add("fabric")
|
||||
minecraftVersions.addAll(minecraftVersion)
|
||||
optional("miniplaceholders")
|
||||
}
|
||||
+44
-37
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2022 Jason Penilla
|
||||
* Copyright (c) 2020-2025 Jason Penilla
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -25,40 +25,39 @@ package xyz.jpenilla.minimotd.fabric;
|
||||
|
||||
import com.mojang.brigadier.Command;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.ByteBufOutputStream;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Base64;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import javax.imageio.ImageIO;
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
import net.fabricmc.fabric.api.command.v1.CommandRegistrationCallback;
|
||||
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
|
||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.kyori.adventure.platform.fabric.FabricServerAudiences;
|
||||
import net.kyori.adventure.platform.modcommon.MinecraftServerAudiences;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.network.protocol.status.ServerStatus;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import org.jspecify.annotations.NonNull;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import xyz.jpenilla.minimotd.common.CommandHandler;
|
||||
import xyz.jpenilla.minimotd.common.MiniMOTD;
|
||||
import xyz.jpenilla.minimotd.common.MiniMOTDPlatform;
|
||||
import xyz.jpenilla.minimotd.common.util.BrigadierUtil;
|
||||
import xyz.jpenilla.minimotd.common.util.UpdateChecker;
|
||||
import xyz.jpenilla.minimotd.fabric.access.ServerStatusFaviconAccess;
|
||||
|
||||
import static net.minecraft.commands.Commands.literal;
|
||||
|
||||
public final class MiniMOTDFabric implements ModInitializer, MiniMOTDPlatform<String> {
|
||||
public final class MiniMOTDFabric implements ModInitializer, MiniMOTDPlatform<ServerStatus.Favicon> {
|
||||
private static MiniMOTDFabric instance = null;
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(MiniMOTD.class);
|
||||
private final Path dataDirectory = FabricLoader.getInstance().getConfigDir().resolve("MiniMOTD");
|
||||
private final MiniMOTD<String> miniMOTD = new MiniMOTD<>(this);
|
||||
private final MiniMOTD<ServerStatus.Favicon> miniMOTD = new MiniMOTD<>(this);
|
||||
|
||||
private FabricServerAudiences audiences;
|
||||
private MinecraftServer server;
|
||||
private MinecraftServerAudiences audiences;
|
||||
|
||||
public MiniMOTDFabric() {
|
||||
if (instance != null) {
|
||||
@@ -67,19 +66,26 @@ public final class MiniMOTDFabric implements ModInitializer, MiniMOTDPlatform<St
|
||||
instance = this;
|
||||
}
|
||||
|
||||
public @NonNull MiniMOTD<String> miniMOTD() {
|
||||
public @NonNull MiniMOTD<ServerStatus.Favicon> miniMOTD() {
|
||||
return this.miniMOTD;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInitialize() {
|
||||
this.registerCommand();
|
||||
ServerLifecycleEvents.SERVER_STARTING.register(minecraftServer -> {
|
||||
this.server = minecraftServer;
|
||||
this.audiences = MinecraftServerAudiences.of(minecraftServer);
|
||||
});
|
||||
ServerLifecycleEvents.SERVER_STARTED.register(minecraftServer -> {
|
||||
this.audiences = FabricServerAudiences.of(minecraftServer);
|
||||
if (this.miniMOTD.configManager().pluginSettings().updateChecker()) {
|
||||
CompletableFuture.runAsync(() -> new UpdateChecker().checkVersion().forEach(this.logger()::info));
|
||||
}
|
||||
});
|
||||
ServerLifecycleEvents.SERVER_STOPPED.register($ -> {
|
||||
this.server = null;
|
||||
this.audiences = null;
|
||||
});
|
||||
this.miniMOTD.logger().info("Done initializing MiniMOTD");
|
||||
}
|
||||
|
||||
@@ -93,22 +99,21 @@ public final class MiniMOTDFabric implements ModInitializer, MiniMOTDPlatform<St
|
||||
|
||||
@Override
|
||||
public int run(final @NonNull CommandContext<CommandSourceStack> context) {
|
||||
this.handler.execute(MiniMOTDFabric.this.audiences.audience(context.getSource()));
|
||||
this.handler.execute(context.getSource());
|
||||
return Command.SINGLE_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
final CommandHandler handler = new CommandHandler(this.miniMOTD);
|
||||
CommandRegistrationCallback.EVENT.register((dispatcher, $) -> dispatcher.register(
|
||||
literal("minimotd")
|
||||
.requires(source -> source.hasPermission(4))
|
||||
.then(literal("reload").executes(new WrappingExecutor(handler::reload)))
|
||||
.then(literal("about").executes(new WrappingExecutor(handler::about)))
|
||||
.then(literal("help").executes(new WrappingExecutor(handler::help)))
|
||||
CommandRegistrationCallback.EVENT.register((dispatcher, commandBuildContext, commandSelection) -> dispatcher.register(
|
||||
BrigadierUtil.buildTree(
|
||||
new CommandHandler(this.miniMOTD),
|
||||
sourceStack -> this.audiences().audience(sourceStack),
|
||||
Commands.hasPermission(Commands.LEVEL_ADMINS)
|
||||
)
|
||||
));
|
||||
}
|
||||
|
||||
public @NonNull FabricServerAudiences audiences() {
|
||||
public @NonNull MinecraftServerAudiences audiences() {
|
||||
return this.audiences;
|
||||
}
|
||||
|
||||
@@ -116,6 +121,13 @@ public final class MiniMOTDFabric implements ModInitializer, MiniMOTDPlatform<St
|
||||
return instance;
|
||||
}
|
||||
|
||||
public @NonNull MinecraftServer requireServer() {
|
||||
if (this.server == null) {
|
||||
throw new IllegalStateException("Server requested before started");
|
||||
}
|
||||
return this.server;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull Path dataDirectory() {
|
||||
return this.dataDirectory;
|
||||
@@ -127,16 +139,11 @@ public final class MiniMOTDFabric implements ModInitializer, MiniMOTDPlatform<St
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull String loadIcon(final @NonNull BufferedImage bufferedImage) throws Exception {
|
||||
final ByteBuf byteBuf = Unpooled.buffer();
|
||||
final String icon;
|
||||
try {
|
||||
ImageIO.write(bufferedImage, "PNG", new ByteBufOutputStream(byteBuf));
|
||||
final ByteBuffer base64 = Base64.getEncoder().encode(byteBuf.nioBuffer());
|
||||
icon = "data:image/png;base64," + StandardCharsets.UTF_8.decode(base64);
|
||||
} finally {
|
||||
byteBuf.release();
|
||||
}
|
||||
return icon;
|
||||
public ServerStatus.@NonNull Favicon loadIcon(final @NonNull BufferedImage bufferedImage) throws Exception {
|
||||
final ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
ImageIO.write(bufferedImage, "PNG", out);
|
||||
final ServerStatus.Favicon favicon = new ServerStatus.Favicon(out.toByteArray());
|
||||
((ServerStatusFaviconAccess) (Object) favicon).cacheEncodedIcon();
|
||||
return favicon;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2022 Jason Penilla
|
||||
* Copyright (c) 2020-2025 Jason Penilla
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
+6
-21
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2022 Jason Penilla
|
||||
* Copyright (c) 2020-2025 Jason Penilla
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -21,27 +21,12 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package xyz.jpenilla.minimotd.common.util;
|
||||
package xyz.jpenilla.minimotd.fabric.access;
|
||||
|
||||
import net.kyori.adventure.text.ComponentLike;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.framework.qual.DefaultQualifier;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import static net.kyori.adventure.text.Component.empty;
|
||||
import static net.kyori.adventure.text.Component.text;
|
||||
public interface ServerStatusFaviconAccess {
|
||||
@Nullable String cachedEncodedIcon();
|
||||
|
||||
@DefaultQualifier(NonNull.class)
|
||||
public final class Components {
|
||||
private Components() {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
public static TextComponent ofChildren(final ComponentLike... children) {
|
||||
if (children.length == 0) {
|
||||
return empty();
|
||||
}
|
||||
|
||||
return text().append(children).build();
|
||||
}
|
||||
void cacheEncodedIcon();
|
||||
}
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2022 Jason Penilla
|
||||
* Copyright (c) 2020-2025 Jason Penilla
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2022 Jason Penilla
|
||||
* Copyright (c) 2020-2025 Jason Penilla
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -40,6 +40,6 @@ abstract class ServerHandshakePacketListenerImplMixin {
|
||||
|
||||
@Inject(method = "handleIntention", at = @At("HEAD"))
|
||||
public void injectHandleIntention(final ClientIntentionPacket packet, final CallbackInfo ci) {
|
||||
((ConnectionAccess) this.connection).protocolVersion(packet.getProtocolVersion());
|
||||
((ConnectionAccess) this.connection).protocolVersion(packet.protocolVersion());
|
||||
}
|
||||
}
|
||||
+78
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2025 Jason Penilla
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package xyz.jpenilla.minimotd.fabric.mixin;
|
||||
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.DataResult;
|
||||
import com.mojang.serialization.codecs.PrimitiveCodec;
|
||||
import java.util.function.Function;
|
||||
import net.minecraft.network.protocol.status.ServerStatus;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import xyz.jpenilla.minimotd.fabric.access.ServerStatusFaviconAccess;
|
||||
|
||||
@Mixin(ServerStatus.Favicon.class)
|
||||
abstract class ServerStatusFaviconMixin implements ServerStatusFaviconAccess {
|
||||
@Unique
|
||||
private static Function<ServerStatus.Favicon, String> VANILLA_ENCODE_TO_STRING;
|
||||
|
||||
@Redirect(
|
||||
method = "<clinit>",
|
||||
at = @At(
|
||||
target = "Lcom/mojang/serialization/codecs/PrimitiveCodec;comapFlatMap(Ljava/util/function/Function;Ljava/util/function/Function;)Lcom/mojang/serialization/Codec;",
|
||||
value = "INVOKE"
|
||||
),
|
||||
remap = false
|
||||
)
|
||||
private static Codec<ServerStatus.Favicon> makeCodec(
|
||||
final PrimitiveCodec<String> stringCodec,
|
||||
final Function<String, DataResult<ServerStatus.Favicon>> decode,
|
||||
final Function<ServerStatus.Favicon, String> encode
|
||||
) {
|
||||
VANILLA_ENCODE_TO_STRING = encode;
|
||||
return stringCodec.comapFlatMap(decode, favicon -> {
|
||||
final @Nullable String encodedIcon = ((ServerStatusFaviconAccess) (Object) favicon).cachedEncodedIcon();
|
||||
if (encodedIcon != null) {
|
||||
return encodedIcon;
|
||||
}
|
||||
return encode.apply(favicon);
|
||||
});
|
||||
}
|
||||
|
||||
@Unique
|
||||
private String encodedIcon;
|
||||
|
||||
@Override
|
||||
public @Nullable String cachedEncodedIcon() {
|
||||
return this.encodedIcon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cacheEncodedIcon() {
|
||||
this.encodedIcon = VANILLA_ENCODE_TO_STRING.apply((ServerStatus.Favicon) (Object) this);
|
||||
}
|
||||
}
|
||||
+37
-28
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2022 Jason Penilla
|
||||
* Copyright (c) 2020-2025 Jason Penilla
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -23,7 +23,9 @@
|
||||
*/
|
||||
package xyz.jpenilla.minimotd.fabric.mixin;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import java.util.Collections;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import net.minecraft.network.Connection;
|
||||
import net.minecraft.network.protocol.status.ServerStatus;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
@@ -36,50 +38,57 @@ import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import xyz.jpenilla.minimotd.common.Constants;
|
||||
import xyz.jpenilla.minimotd.common.MiniMOTD;
|
||||
import xyz.jpenilla.minimotd.common.PingResponse;
|
||||
import xyz.jpenilla.minimotd.common.config.MiniMOTDConfig;
|
||||
import xyz.jpenilla.minimotd.common.config.MOTDConfig;
|
||||
import xyz.jpenilla.minimotd.common.util.ComponentColorDownsampler;
|
||||
import xyz.jpenilla.minimotd.fabric.MiniMOTDFabric;
|
||||
import xyz.jpenilla.minimotd.fabric.access.ConnectionAccess;
|
||||
import xyz.jpenilla.minimotd.fabric.util.MutableServerStatus;
|
||||
|
||||
@Mixin(ServerStatusPacketListenerImpl.class)
|
||||
abstract class ServerStatusPacketListenerImplMixin {
|
||||
@Shadow @Final private Connection connection;
|
||||
|
||||
@Redirect(method = "handleStatusRequest", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/MinecraftServer;getStatus()Lnet/minecraft/network/protocol/status/ServerStatus;"))
|
||||
public ServerStatus injectHandleStatusRequest(final MinecraftServer minecraftServer) {
|
||||
final ServerStatus vanillaStatus = minecraftServer.getStatus();
|
||||
|
||||
final ServerStatus modifiedStatus = new ServerStatus();
|
||||
modifiedStatus.setDescription(vanillaStatus.getDescription());
|
||||
modifiedStatus.setFavicon(vanillaStatus.getFavicon());
|
||||
modifiedStatus.setVersion(vanillaStatus.getVersion());
|
||||
|
||||
@Redirect(
|
||||
method = "handleStatusRequest",
|
||||
at = @At(value = "FIELD", target = "Lnet/minecraft/server/network/ServerStatusPacketListenerImpl;status:Lnet/minecraft/network/protocol/status/ServerStatus;")
|
||||
)
|
||||
public ServerStatus injectHandleStatusRequest(final ServerStatusPacketListenerImpl instance) {
|
||||
final MiniMOTDFabric miniMOTDFabric = MiniMOTDFabric.get();
|
||||
final MiniMOTD<String> miniMOTD = miniMOTDFabric.miniMOTD();
|
||||
final MiniMOTDConfig config = miniMOTD.configManager().mainConfig();
|
||||
final MinecraftServer minecraftServer = miniMOTDFabric.requireServer();
|
||||
final ServerStatus vanillaStatus = Objects.requireNonNull(minecraftServer.getStatus(), "vanillaStatus");
|
||||
|
||||
final PingResponse<String> response = miniMOTD.createMOTD(config, minecraftServer.getPlayerCount(), vanillaStatus.getPlayers().getMaxPlayers());
|
||||
final MiniMOTD<ServerStatus.Favicon> miniMOTD = miniMOTDFabric.miniMOTD();
|
||||
final MOTDConfig config = miniMOTD.configManager().mainConfig();
|
||||
|
||||
final PingResponse<ServerStatus.Favicon> response = miniMOTD.createMOTD(
|
||||
config,
|
||||
minecraftServer.getPlayerCount(),
|
||||
vanillaStatus.players().map(ServerStatus.Players::max).orElseGet(minecraftServer::getMaxPlayers)
|
||||
);
|
||||
|
||||
final MutableServerStatus modifiedStatus = new MutableServerStatus(vanillaStatus);
|
||||
response.motd(motd -> {
|
||||
if (((ConnectionAccess) this.connection).protocolVersion() >= Constants.MINECRAFT_1_16_PROTOCOL_VERSION) {
|
||||
modifiedStatus.setDescription(miniMOTDFabric.audiences().toNative(motd));
|
||||
modifiedStatus.description(miniMOTDFabric.audiences().asNative(motd));
|
||||
} else {
|
||||
modifiedStatus.setDescription(miniMOTDFabric.audiences().toNative(ComponentColorDownsampler.downsampler().downsample(motd)));
|
||||
modifiedStatus.description(miniMOTDFabric.audiences().asNative(ComponentColorDownsampler.downsampler().downsample(motd)));
|
||||
}
|
||||
});
|
||||
response.icon(modifiedStatus::setFavicon);
|
||||
response.icon(favicon -> modifiedStatus.favicon(Optional.of(favicon)));
|
||||
|
||||
if (!response.hidePlayerCount()) {
|
||||
final GameProfile[] oldSample = vanillaStatus.getPlayers().getSample();
|
||||
final ServerStatus.Players newPlayers = new ServerStatus.Players(response.playerCount().maxPlayers(), response.playerCount().onlinePlayers());
|
||||
if (response.disablePlayerListHover()) {
|
||||
newPlayers.setSample(new GameProfile[]{});
|
||||
} else {
|
||||
newPlayers.setSample(oldSample);
|
||||
}
|
||||
modifiedStatus.setPlayers(newPlayers);
|
||||
if (response.hidePlayerCount()) {
|
||||
modifiedStatus.players(Optional.empty());
|
||||
} else {
|
||||
final ServerStatus.Players newPlayers = new ServerStatus.Players(
|
||||
response.playerCount().maxPlayers(),
|
||||
response.playerCount().onlinePlayers(),
|
||||
response.disablePlayerListHover()
|
||||
? Collections.emptyList()
|
||||
: vanillaStatus.players().map(ServerStatus.Players::sample).orElse(Collections.emptyList())
|
||||
);
|
||||
modifiedStatus.players(Optional.of(newPlayers));
|
||||
}
|
||||
|
||||
return modifiedStatus;
|
||||
return modifiedStatus.toServerStatus();
|
||||
}
|
||||
}
|
||||
+96
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2025 Jason Penilla
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package xyz.jpenilla.minimotd.fabric.util;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.protocol.status.ServerStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@SuppressWarnings({"OptionalUsedAsFieldOrParameterType", "unused"})
|
||||
@NullMarked
|
||||
public final class MutableServerStatus {
|
||||
private Component description;
|
||||
private Optional<ServerStatus.Players> players;
|
||||
private Optional<ServerStatus.Version> version;
|
||||
private Optional<ServerStatus.Favicon> favicon;
|
||||
private boolean enforcesSecureChat;
|
||||
|
||||
public MutableServerStatus(final ServerStatus status) {
|
||||
this.description = status.description();
|
||||
this.players = status.players();
|
||||
this.version = status.version();
|
||||
this.favicon = status.favicon();
|
||||
this.enforcesSecureChat = status.enforcesSecureChat();
|
||||
}
|
||||
|
||||
public ServerStatus toServerStatus() {
|
||||
return new ServerStatus(this.description, this.players, this.version, this.favicon, this.enforcesSecureChat);
|
||||
}
|
||||
|
||||
public Component description() {
|
||||
return this.description;
|
||||
}
|
||||
|
||||
public void description(final Component description) {
|
||||
Objects.requireNonNull(description, "description");
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public Optional<ServerStatus.Players> players() {
|
||||
return this.players;
|
||||
}
|
||||
|
||||
public void players(final Optional<ServerStatus.Players> players) {
|
||||
Objects.requireNonNull(players, "players");
|
||||
this.players = players;
|
||||
}
|
||||
|
||||
public Optional<ServerStatus.Version> version() {
|
||||
return this.version;
|
||||
}
|
||||
|
||||
public void version(final Optional<ServerStatus.Version> version) {
|
||||
Objects.requireNonNull(version, "version");
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public Optional<ServerStatus.Favicon> favicon() {
|
||||
return this.favicon;
|
||||
}
|
||||
|
||||
public void favicon(final Optional<ServerStatus.Favicon> favicon) {
|
||||
Objects.requireNonNull(favicon, "favicon");
|
||||
this.favicon = favicon;
|
||||
}
|
||||
|
||||
public boolean enforcesSecureChat() {
|
||||
return this.enforcesSecureChat;
|
||||
}
|
||||
|
||||
public void enforcesSecureChat(final boolean enforcesSecureChat) {
|
||||
this.enforcesSecureChat = enforcesSecureChat;
|
||||
}
|
||||
}
|
||||
+4
-3
@@ -23,8 +23,9 @@
|
||||
"minimotd-fabric.mixins.json"
|
||||
],
|
||||
"depends": {
|
||||
"fabricloader": ">=0.12.8",
|
||||
"fabric": ">=0.31.0",
|
||||
"minecraft": ">=1.18"
|
||||
"fabricloader": ">=0.19.5",
|
||||
"fabric-api": "*",
|
||||
"minecraft": ">=26.3",
|
||||
"adventure-platform-fabric": "*"
|
||||
}
|
||||
}
|
||||
+2
-1
@@ -2,10 +2,11 @@
|
||||
"required": true,
|
||||
"minVersion": "0.8.4",
|
||||
"package": "xyz.jpenilla.minimotd.fabric.mixin",
|
||||
"compatibilityLevel": "JAVA_16",
|
||||
"compatibilityLevel": "JAVA_21",
|
||||
"mixins": [
|
||||
"ConnectionMixin",
|
||||
"ServerHandshakePacketListenerImplMixin",
|
||||
"ServerStatusFaviconMixin",
|
||||
"ServerStatusPacketListenerImplMixin"
|
||||
],
|
||||
"client": [
|
||||
@@ -0,0 +1,68 @@
|
||||
import me.modmuss50.mpp.platforms.modrinth.ModrinthEnvironment
|
||||
|
||||
plugins {
|
||||
id("net.neoforged.moddev")
|
||||
id("minimotd.platform-conventions")
|
||||
id("com.gradleup.shadow")
|
||||
}
|
||||
|
||||
neoForge {
|
||||
enable {
|
||||
version = libs.versions.neoforge.get()
|
||||
}
|
||||
}
|
||||
|
||||
val shade: Configuration by configurations.creating
|
||||
|
||||
dependencies {
|
||||
shade(implementation(projects.minimotdCommon) {
|
||||
exclude("net.kyori")
|
||||
exclude("com.google.errorprone")
|
||||
})
|
||||
|
||||
implementation(libs.adventurePlatformNeoforge)
|
||||
jarJar(libs.adventurePlatformNeoforge)
|
||||
}
|
||||
|
||||
indra {
|
||||
javaVersions {
|
||||
target(25)
|
||||
}
|
||||
}
|
||||
|
||||
tasks {
|
||||
shadowJar {
|
||||
configurations = listOf(shade)
|
||||
commonConfiguration()
|
||||
commonRelocation("io.leangen.geantyref")
|
||||
}
|
||||
processResources {
|
||||
val replacements = mapOf(
|
||||
"version" to project.version.toString(),
|
||||
"description" to project.description.toString(),
|
||||
"github_url" to Constants.GITHUB_URL
|
||||
)
|
||||
inputs.properties(replacements)
|
||||
filesMatching("META-INF/neoforge.mods.toml") {
|
||||
expand(replacements)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val productionJar = tasks.register<Zip>("productionJar") {
|
||||
archiveFileName = "${project.name}-mc$minecraftVersion-${project.version}.jar"
|
||||
destinationDirectory = layout.buildDirectory.dir("libs")
|
||||
from(zipTree(tasks.shadowJar.flatMap { it.archiveFile }))
|
||||
from(tasks.jarJar.flatMap { it.outputDirectory })
|
||||
}
|
||||
|
||||
miniMOTDPlatform {
|
||||
jarTask.set(productionJar)
|
||||
}
|
||||
|
||||
publishMods.modrinth {
|
||||
environment = ModrinthEnvironment.DEDICATED_SERVER_ONLY
|
||||
modLoaders.add("neoforge")
|
||||
minecraftVersions.addAll(minecraftVersion)
|
||||
optional("miniplaceholders")
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2025 Jason Penilla
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package xyz.jpenilla.minimotd.neoforge;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.nio.file.Path;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import javax.imageio.ImageIO;
|
||||
import net.kyori.adventure.platform.modcommon.MinecraftServerAudiences;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.network.protocol.status.ServerStatus;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.neoforged.fml.common.Mod;
|
||||
import net.neoforged.neoforge.common.NeoForge;
|
||||
import net.neoforged.neoforge.event.RegisterCommandsEvent;
|
||||
import net.neoforged.neoforge.event.server.ServerStartedEvent;
|
||||
import net.neoforged.neoforge.event.server.ServerStartingEvent;
|
||||
import net.neoforged.neoforge.event.server.ServerStoppedEvent;
|
||||
import org.jspecify.annotations.NonNull;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import xyz.jpenilla.minimotd.common.CommandHandler;
|
||||
import xyz.jpenilla.minimotd.common.MiniMOTD;
|
||||
import xyz.jpenilla.minimotd.common.MiniMOTDPlatform;
|
||||
import xyz.jpenilla.minimotd.common.util.BrigadierUtil;
|
||||
import xyz.jpenilla.minimotd.common.util.UpdateChecker;
|
||||
import xyz.jpenilla.minimotd.neoforge.access.ServerStatusFaviconAccess;
|
||||
|
||||
@Mod("minimotd")
|
||||
public final class MiniMOTDNeoForge implements MiniMOTDPlatform<ServerStatus.Favicon> {
|
||||
private static MiniMOTDNeoForge instance = null;
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(MiniMOTD.class);
|
||||
private final Path dataDirectory = Path.of("config", "MiniMOTD");
|
||||
private final MiniMOTD<ServerStatus.Favicon> miniMOTD = new MiniMOTD<>(this);
|
||||
|
||||
private MinecraftServer server;
|
||||
private MinecraftServerAudiences audiences;
|
||||
|
||||
public MiniMOTDNeoForge() {
|
||||
if (instance != null) {
|
||||
throw new IllegalStateException("Cannot create a second instance of " + this.getClass().getName());
|
||||
}
|
||||
instance = this;
|
||||
|
||||
this.registerCommand();
|
||||
NeoForge.EVENT_BUS.addListener((ServerStartingEvent event) -> {
|
||||
this.server = event.getServer();
|
||||
this.audiences = MinecraftServerAudiences.of(event.getServer());
|
||||
});
|
||||
NeoForge.EVENT_BUS.addListener((ServerStartedEvent event) -> {
|
||||
if (this.miniMOTD.configManager().pluginSettings().updateChecker()) {
|
||||
CompletableFuture.runAsync(() -> new UpdateChecker().checkVersion().forEach(this.logger()::info));
|
||||
}
|
||||
});
|
||||
NeoForge.EVENT_BUS.addListener((ServerStoppedEvent event) -> {
|
||||
this.server = null;
|
||||
this.audiences = null;
|
||||
});
|
||||
this.miniMOTD.logger().info("Done initializing MiniMOTD");
|
||||
}
|
||||
|
||||
public @NonNull MiniMOTD<ServerStatus.Favicon> miniMOTD() {
|
||||
return this.miniMOTD;
|
||||
}
|
||||
|
||||
private void registerCommand() {
|
||||
NeoForge.EVENT_BUS.addListener((RegisterCommandsEvent event) -> {
|
||||
event.getDispatcher().register(
|
||||
BrigadierUtil.buildTree(
|
||||
new CommandHandler(this.miniMOTD),
|
||||
sourceStack -> this.audiences().audience(sourceStack),
|
||||
Commands.hasPermission(Commands.LEVEL_ADMINS)
|
||||
)
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
public @NonNull MinecraftServerAudiences audiences() {
|
||||
return this.audiences;
|
||||
}
|
||||
|
||||
public static @NonNull MiniMOTDNeoForge get() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public @NonNull MinecraftServer requireServer() {
|
||||
if (this.server == null) {
|
||||
throw new IllegalStateException("Server requested before started");
|
||||
}
|
||||
return this.server;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull Path dataDirectory() {
|
||||
return this.dataDirectory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull Logger logger() {
|
||||
return this.logger;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServerStatus.@NonNull Favicon loadIcon(final @NonNull BufferedImage bufferedImage) throws Exception {
|
||||
final ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
ImageIO.write(bufferedImage, "PNG", out);
|
||||
final ServerStatus.Favicon favicon = new ServerStatus.Favicon(out.toByteArray());
|
||||
((ServerStatusFaviconAccess) (Object) favicon).cacheEncodedIcon();
|
||||
return favicon;
|
||||
}
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2025 Jason Penilla
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package xyz.jpenilla.minimotd.neoforge.access;
|
||||
|
||||
public interface ConnectionAccess {
|
||||
void protocolVersion(int protocolVersion);
|
||||
|
||||
int protocolVersion();
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2025 Jason Penilla
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package xyz.jpenilla.minimotd.neoforge.access;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
public interface ServerStatusFaviconAccess {
|
||||
@Nullable String cachedEncodedIcon();
|
||||
|
||||
void cacheEncodedIcon();
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2025 Jason Penilla
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package xyz.jpenilla.minimotd.neoforge.mixin;
|
||||
|
||||
import net.minecraft.network.Connection;
|
||||
import org.spongepowered.asm.mixin.Implements;
|
||||
import org.spongepowered.asm.mixin.Interface;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import xyz.jpenilla.minimotd.neoforge.access.ConnectionAccess;
|
||||
|
||||
@Unique
|
||||
@Mixin(Connection.class)
|
||||
@Implements({@Interface(iface = ConnectionAccess.class, prefix = "miniMOTD$")})
|
||||
abstract class ConnectionMixin {
|
||||
private int miniMOTD$protocolVersion = -1;
|
||||
|
||||
public void miniMOTD$protocolVersion(final int protocolVersion) {
|
||||
this.miniMOTD$protocolVersion = protocolVersion;
|
||||
}
|
||||
|
||||
public int miniMOTD$protocolVersion() {
|
||||
return this.miniMOTD$protocolVersion;
|
||||
}
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2025 Jason Penilla
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package xyz.jpenilla.minimotd.neoforge.mixin;
|
||||
|
||||
import net.minecraft.network.Connection;
|
||||
import net.minecraft.network.protocol.handshake.ClientIntentionPacket;
|
||||
import net.minecraft.server.network.ServerHandshakePacketListenerImpl;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import xyz.jpenilla.minimotd.neoforge.access.ConnectionAccess;
|
||||
|
||||
@Mixin(ServerHandshakePacketListenerImpl.class)
|
||||
abstract class ServerHandshakePacketListenerImplMixin {
|
||||
@Shadow @Final private Connection connection;
|
||||
|
||||
@Inject(method = "handleIntention", at = @At("HEAD"))
|
||||
public void injectHandleIntention(final ClientIntentionPacket packet, final CallbackInfo ci) {
|
||||
((ConnectionAccess) this.connection).protocolVersion(packet.protocolVersion());
|
||||
}
|
||||
}
|
||||
+78
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2025 Jason Penilla
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package xyz.jpenilla.minimotd.neoforge.mixin;
|
||||
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.DataResult;
|
||||
import com.mojang.serialization.codecs.PrimitiveCodec;
|
||||
import java.util.function.Function;
|
||||
import net.minecraft.network.protocol.status.ServerStatus;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import xyz.jpenilla.minimotd.neoforge.access.ServerStatusFaviconAccess;
|
||||
|
||||
@Mixin(ServerStatus.Favicon.class)
|
||||
abstract class ServerStatusFaviconMixin implements ServerStatusFaviconAccess {
|
||||
@Unique
|
||||
private static Function<ServerStatus.Favicon, String> VANILLA_ENCODE_TO_STRING;
|
||||
|
||||
@Redirect(
|
||||
method = "<clinit>",
|
||||
at = @At(
|
||||
target = "Lcom/mojang/serialization/codecs/PrimitiveCodec;comapFlatMap(Ljava/util/function/Function;Ljava/util/function/Function;)Lcom/mojang/serialization/Codec;",
|
||||
value = "INVOKE"
|
||||
),
|
||||
remap = false
|
||||
)
|
||||
private static Codec<ServerStatus.Favicon> makeCodec(
|
||||
final PrimitiveCodec<String> stringCodec,
|
||||
final Function<String, DataResult<ServerStatus.Favicon>> decode,
|
||||
final Function<ServerStatus.Favicon, String> encode
|
||||
) {
|
||||
VANILLA_ENCODE_TO_STRING = encode;
|
||||
return stringCodec.comapFlatMap(decode, favicon -> {
|
||||
final @Nullable String encodedIcon = ((ServerStatusFaviconAccess) (Object) favicon).cachedEncodedIcon();
|
||||
if (encodedIcon != null) {
|
||||
return encodedIcon;
|
||||
}
|
||||
return encode.apply(favicon);
|
||||
});
|
||||
}
|
||||
|
||||
@Unique
|
||||
private String encodedIcon;
|
||||
|
||||
@Override
|
||||
public @Nullable String cachedEncodedIcon() {
|
||||
return this.encodedIcon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cacheEncodedIcon() {
|
||||
this.encodedIcon = VANILLA_ENCODE_TO_STRING.apply((ServerStatus.Favicon) (Object) this);
|
||||
}
|
||||
}
|
||||
+94
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2025 Jason Penilla
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package xyz.jpenilla.minimotd.neoforge.mixin;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import net.minecraft.network.Connection;
|
||||
import net.minecraft.network.protocol.status.ServerStatus;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.network.ServerStatusPacketListenerImpl;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import xyz.jpenilla.minimotd.common.Constants;
|
||||
import xyz.jpenilla.minimotd.common.MiniMOTD;
|
||||
import xyz.jpenilla.minimotd.common.PingResponse;
|
||||
import xyz.jpenilla.minimotd.common.config.MOTDConfig;
|
||||
import xyz.jpenilla.minimotd.common.util.ComponentColorDownsampler;
|
||||
import xyz.jpenilla.minimotd.neoforge.MiniMOTDNeoForge;
|
||||
import xyz.jpenilla.minimotd.neoforge.access.ConnectionAccess;
|
||||
import xyz.jpenilla.minimotd.neoforge.util.MutableServerStatus;
|
||||
|
||||
@Mixin(ServerStatusPacketListenerImpl.class)
|
||||
abstract class ServerStatusPacketListenerImplMixin {
|
||||
@Shadow @Final private Connection connection;
|
||||
|
||||
@Redirect(
|
||||
method = "handleStatusRequest",
|
||||
at = @At(value = "FIELD", target = "Lnet/minecraft/server/network/ServerStatusPacketListenerImpl;status:Lnet/minecraft/network/protocol/status/ServerStatus;")
|
||||
)
|
||||
public ServerStatus injectHandleStatusRequest(final ServerStatusPacketListenerImpl instance) {
|
||||
final MiniMOTDNeoForge miniMOTDNeoForge = MiniMOTDNeoForge.get();
|
||||
final MinecraftServer minecraftServer = miniMOTDNeoForge.requireServer();
|
||||
final ServerStatus vanillaStatus = Objects.requireNonNull(minecraftServer.getStatus(), "vanillaStatus");
|
||||
|
||||
final MiniMOTD<ServerStatus.Favicon> miniMOTD = miniMOTDNeoForge.miniMOTD();
|
||||
final MOTDConfig config = miniMOTD.configManager().mainConfig();
|
||||
|
||||
final PingResponse<ServerStatus.Favicon> response = miniMOTD.createMOTD(
|
||||
config,
|
||||
minecraftServer.getPlayerCount(),
|
||||
vanillaStatus.players().map(ServerStatus.Players::max).orElseGet(minecraftServer::getMaxPlayers)
|
||||
);
|
||||
|
||||
final MutableServerStatus modifiedStatus = new MutableServerStatus(vanillaStatus);
|
||||
response.motd(motd -> {
|
||||
if (((ConnectionAccess) this.connection).protocolVersion() >= Constants.MINECRAFT_1_16_PROTOCOL_VERSION) {
|
||||
modifiedStatus.description(miniMOTDNeoForge.audiences().asNative(motd));
|
||||
} else {
|
||||
modifiedStatus.description(miniMOTDNeoForge.audiences().asNative(ComponentColorDownsampler.downsampler().downsample(motd)));
|
||||
}
|
||||
});
|
||||
response.icon(favicon -> modifiedStatus.favicon(Optional.of(favicon)));
|
||||
|
||||
if (response.hidePlayerCount()) {
|
||||
modifiedStatus.players(Optional.empty());
|
||||
} else {
|
||||
final ServerStatus.Players newPlayers = new ServerStatus.Players(
|
||||
response.playerCount().maxPlayers(),
|
||||
response.playerCount().onlinePlayers(),
|
||||
response.disablePlayerListHover()
|
||||
? Collections.emptyList()
|
||||
: vanillaStatus.players().map(ServerStatus.Players::sample).orElse(Collections.emptyList())
|
||||
);
|
||||
modifiedStatus.players(Optional.of(newPlayers));
|
||||
}
|
||||
|
||||
return modifiedStatus.toServerStatus();
|
||||
}
|
||||
}
|
||||
+98
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2025 Jason Penilla
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package xyz.jpenilla.minimotd.neoforge.util;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.protocol.status.ServerStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@SuppressWarnings({"OptionalUsedAsFieldOrParameterType", "unused"})
|
||||
@NullMarked
|
||||
public final class MutableServerStatus {
|
||||
private Component description;
|
||||
private Optional<ServerStatus.Players> players;
|
||||
private Optional<ServerStatus.Version> version;
|
||||
private Optional<ServerStatus.Favicon> favicon;
|
||||
private boolean enforcesSecureChat;
|
||||
private boolean isModded; // NeoForge addition
|
||||
|
||||
public MutableServerStatus(final ServerStatus status) {
|
||||
this.description = status.description();
|
||||
this.players = status.players();
|
||||
this.version = status.version();
|
||||
this.favicon = status.favicon();
|
||||
this.enforcesSecureChat = status.enforcesSecureChat();
|
||||
this.isModded = status.isModded(); // NeoForge addition
|
||||
}
|
||||
|
||||
public ServerStatus toServerStatus() {
|
||||
return new ServerStatus(this.description, this.players, this.version, this.favicon, this.enforcesSecureChat, this.isModded);
|
||||
}
|
||||
|
||||
public Component description() {
|
||||
return this.description;
|
||||
}
|
||||
|
||||
public void description(final Component description) {
|
||||
Objects.requireNonNull(description, "description");
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public Optional<ServerStatus.Players> players() {
|
||||
return this.players;
|
||||
}
|
||||
|
||||
public void players(final Optional<ServerStatus.Players> players) {
|
||||
Objects.requireNonNull(players, "players");
|
||||
this.players = players;
|
||||
}
|
||||
|
||||
public Optional<ServerStatus.Version> version() {
|
||||
return this.version;
|
||||
}
|
||||
|
||||
public void version(final Optional<ServerStatus.Version> version) {
|
||||
Objects.requireNonNull(version, "version");
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public Optional<ServerStatus.Favicon> favicon() {
|
||||
return this.favicon;
|
||||
}
|
||||
|
||||
public void favicon(final Optional<ServerStatus.Favicon> favicon) {
|
||||
Objects.requireNonNull(favicon, "favicon");
|
||||
this.favicon = favicon;
|
||||
}
|
||||
|
||||
public boolean enforcesSecureChat() {
|
||||
return this.enforcesSecureChat;
|
||||
}
|
||||
|
||||
public void enforcesSecureChat(final boolean enforcesSecureChat) {
|
||||
this.enforcesSecureChat = enforcesSecureChat;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
modLoader = "javafml"
|
||||
loaderVersion = "[1,)"
|
||||
license = "MIT"
|
||||
issueTrackerURL = "${github_url}/issues/"
|
||||
showAsResourcePack = false
|
||||
|
||||
[[mods]]
|
||||
modId = "minimotd"
|
||||
version = "${version}"
|
||||
displayName = "MiniMOTD"
|
||||
displayURL = "${github_url}"
|
||||
authors = "jmp"
|
||||
description = "${description}"
|
||||
displayTest = "IGNORE_ALL_VERSION"
|
||||
|
||||
[[dependencies.minimotd]]
|
||||
modId = "neoforge"
|
||||
type = "required"
|
||||
versionRange = "[21.0,)"
|
||||
ordering = "NONE"
|
||||
side = "BOTH"
|
||||
|
||||
[[dependencies.minimotd]]
|
||||
modId = "minecraft"
|
||||
type = "required"
|
||||
versionRange = "[26.3,)"
|
||||
ordering = "NONE"
|
||||
side = "BOTH"
|
||||
|
||||
[[dependencies.minimotd]]
|
||||
modId = "adventure_platform_neoforge"
|
||||
type = "required"
|
||||
versionRange = "*"
|
||||
ordering = "AFTER"
|
||||
side = "BOTH"
|
||||
|
||||
[[mixins]]
|
||||
config = "minimotd-neoforge.mixins.json"
|
||||
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"required": true,
|
||||
"minVersion": "0.8.4",
|
||||
"package": "xyz.jpenilla.minimotd.neoforge.mixin",
|
||||
"compatibilityLevel": "JAVA_21",
|
||||
"mixins": [
|
||||
"ConnectionMixin",
|
||||
"ServerHandshakePacketListenerImplMixin",
|
||||
"ServerStatusFaviconMixin",
|
||||
"ServerStatusPacketListenerImplMixin"
|
||||
],
|
||||
"client": [
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
import xyz.jpenilla.resourcefactory.paper.PaperPluginYaml.Load
|
||||
|
||||
plugins {
|
||||
id("minimotd.shadow-platform")
|
||||
alias(libs.plugins.run.paper)
|
||||
alias(libs.plugins.resource.factory.bukkit)
|
||||
alias(libs.plugins.resource.factory.paper)
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(projects.minimotdCommon)
|
||||
implementation(libs.bstatsBukkit)
|
||||
compileOnly(libs.paperApi)
|
||||
}
|
||||
|
||||
tasks {
|
||||
runServer {
|
||||
minecraftVersion(minecraftVersion)
|
||||
}
|
||||
shadowJar {
|
||||
configureForNativeAdventurePlatform()
|
||||
commonRelocation("org.bstats")
|
||||
dependencies {
|
||||
exclude(dependency("io.leangen.geantyref:geantyref"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
indra {
|
||||
javaVersions {
|
||||
target(21)
|
||||
}
|
||||
}
|
||||
|
||||
bukkitPluginYaml {
|
||||
name = "MiniMOTD"
|
||||
main = "xyz.jpenilla.minimotd.paper.MiniMOTDStub"
|
||||
foliaSupported = true
|
||||
authors = listOf("jmp")
|
||||
website = Constants.GITHUB_URL
|
||||
apiVersion = "1.13"
|
||||
}
|
||||
|
||||
paperPluginYaml {
|
||||
name = "MiniMOTD"
|
||||
main = "xyz.jpenilla.minimotd.paper.MiniMOTDPaper"
|
||||
foliaSupported = true
|
||||
authors = listOf("jmp")
|
||||
website = Constants.GITHUB_URL
|
||||
apiVersion = "1.21.8"
|
||||
dependencies.server.register("MiniPlaceholders") {
|
||||
required = false
|
||||
load = Load.BEFORE
|
||||
joinClasspath = true
|
||||
}
|
||||
}
|
||||
|
||||
runPaper.folia.registerTask()
|
||||
|
||||
publishMods.modrinth {
|
||||
modLoaders.addAll("paper", "folia")
|
||||
minecraftVersions = paperVersions
|
||||
optional("miniplaceholders")
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2025 Jason Penilla
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package xyz.jpenilla.minimotd.paper;
|
||||
|
||||
import io.papermc.paper.command.brigadier.CommandSourceStack;
|
||||
import io.papermc.paper.plugin.lifecycle.event.types.LifecycleEvents;
|
||||
import io.papermc.paper.threadedregions.RegionizedServerInitEvent;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import org.bstats.bukkit.Metrics;
|
||||
import org.bstats.charts.SimplePie;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.util.CachedServerIcon;
|
||||
import org.jspecify.annotations.NonNull;
|
||||
import org.slf4j.Logger;
|
||||
import xyz.jpenilla.minimotd.common.CommandHandler;
|
||||
import xyz.jpenilla.minimotd.common.MiniMOTD;
|
||||
import xyz.jpenilla.minimotd.common.MiniMOTDPlatform;
|
||||
import xyz.jpenilla.minimotd.common.util.BrigadierUtil;
|
||||
import xyz.jpenilla.minimotd.common.util.UpdateChecker;
|
||||
|
||||
public final class MiniMOTDPaper extends JavaPlugin implements MiniMOTDPlatform<CachedServerIcon>, Listener {
|
||||
|
||||
private MiniMOTD<CachedServerIcon> miniMOTD;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
this.miniMOTD = new MiniMOTD<>(this);
|
||||
|
||||
this.getServer().getPluginManager().registerEvents(this, this);
|
||||
this.getServer().getPluginManager().registerEvents(new PingListener(this.miniMOTD), this);
|
||||
|
||||
this.getLifecycleManager().registerEventHandler(LifecycleEvents.COMMANDS, event -> event.registrar().register(
|
||||
this.getPluginMeta(),
|
||||
BrigadierUtil.<CommandSourceStack>buildTree(
|
||||
new CommandHandler(this.miniMOTD),
|
||||
sourceStack -> Objects.requireNonNullElse(sourceStack.getExecutor(), sourceStack.getSender()),
|
||||
sourceStack -> sourceStack.getSender().hasPermission("minimotd.admin")
|
||||
).build(),
|
||||
"MiniMOTD Command",
|
||||
List.of()
|
||||
));
|
||||
|
||||
final Metrics metrics = new Metrics(this, 8132);
|
||||
metrics.addCustomChart(new SimplePie("variant", () -> "paper"));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void updateCheck(final RegionizedServerInitEvent event) {
|
||||
if (!this.miniMOTD.configManager().pluginSettings().updateChecker()) {
|
||||
return;
|
||||
}
|
||||
CompletableFuture.runAsync(() -> new UpdateChecker().checkVersion().forEach(this.getComponentLogger()::info)).whenComplete(($, thr) -> {
|
||||
if (thr != null) {
|
||||
this.getComponentLogger().warn("Exception checking for updates", thr);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull Path dataDirectory() {
|
||||
return this.getDataFolder().toPath();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull Logger logger() {
|
||||
return this.getComponentLogger();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull CachedServerIcon loadIcon(final @NonNull BufferedImage image) throws Exception {
|
||||
return this.getServer().loadServerIcon(image);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2025 Jason Penilla
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package xyz.jpenilla.minimotd.paper;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import xyz.jpenilla.minimotd.common.util.Nag;
|
||||
|
||||
public final class MiniMOTDStub extends JavaPlugin {
|
||||
@Override
|
||||
public void onEnable() {
|
||||
if (lavaChicken() && !Bukkit.getBukkitVersion().contains("1.21.7-")) {
|
||||
// 1.21.8+, non-Paper
|
||||
new Nag.JavaUtilLogging(this.getLogger()).lines(
|
||||
"MiniMOTD does not support Spigot on Minecraft 1.21.8 or newer.",
|
||||
"To continue using MiniMOTD on the latest Minecraft versions,",
|
||||
"switch to Paper (https://papermc.io/software/paper)."
|
||||
).error(true).logBanner();
|
||||
this.getServer().getPluginManager().disablePlugin(this);
|
||||
return;
|
||||
}
|
||||
|
||||
// Pre-Paper-plugins or non-Paper
|
||||
new Nag.JavaUtilLogging(this.getLogger()).lines(
|
||||
"You are using the incorrect MiniMOTD build for your server software.",
|
||||
"This build is for Paper 1.21.8+.",
|
||||
"Builds for Spigot/Paper 1.8.8 through 1.21.7 are available on Modrinth (https://modrinth.com/plugin/minimotd).",
|
||||
"When downloading be sure to check the supported versions/platforms",
|
||||
"field on the versions page, and/or make the correct selections in",
|
||||
"the download menu."
|
||||
).error(true).logBanner();
|
||||
this.getServer().getPluginManager().disablePlugin(this);
|
||||
|
||||
// Sadly I don't think there is any way to display a custom message for servers that support
|
||||
// Paper plugins but are < 1.21.8 (without lying in the plugin yaml)...
|
||||
// Hopefully users will realize they need to try a different build.
|
||||
}
|
||||
|
||||
// Crude 1.21.7+ check
|
||||
private static boolean lavaChicken() {
|
||||
try {
|
||||
final Material mat = Material.MUSIC_DISC_LAVA_CHICKEN;
|
||||
new ItemStack(mat);
|
||||
return true;
|
||||
} catch (final Throwable thr) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2025 Jason Penilla
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package xyz.jpenilla.minimotd.paper;
|
||||
|
||||
import com.destroystokyo.paper.event.server.PaperServerListPingEvent;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.util.CachedServerIcon;
|
||||
import org.jspecify.annotations.NonNull;
|
||||
import xyz.jpenilla.minimotd.common.Constants;
|
||||
import xyz.jpenilla.minimotd.common.MiniMOTD;
|
||||
import xyz.jpenilla.minimotd.common.PingResponse;
|
||||
import xyz.jpenilla.minimotd.common.config.MOTDConfig;
|
||||
import xyz.jpenilla.minimotd.common.util.ComponentColorDownsampler;
|
||||
|
||||
public final class PingListener implements Listener {
|
||||
private final MiniMOTD<CachedServerIcon> miniMOTD;
|
||||
|
||||
PingListener(final @NonNull MiniMOTD<CachedServerIcon> miniMOTD) {
|
||||
this.miniMOTD = miniMOTD;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void handlePing(final @NonNull PaperServerListPingEvent event) {
|
||||
final MOTDConfig cfg = this.miniMOTD.configManager().mainConfig();
|
||||
|
||||
final PingResponse<CachedServerIcon> response = this.miniMOTD.createMOTD(cfg, event.getNumPlayers(), event.getMaxPlayers());
|
||||
|
||||
response.playerCount().applyCount(event::setNumPlayers, event::setMaxPlayers);
|
||||
response.motd(motd -> {
|
||||
if (event.getClient().getProtocolVersion() < Constants.MINECRAFT_1_16_PROTOCOL_VERSION) {
|
||||
event.motd(ComponentColorDownsampler.downsampler().downsample(motd));
|
||||
} else {
|
||||
event.motd(motd);
|
||||
}
|
||||
});
|
||||
response.icon(event::setServerIcon);
|
||||
|
||||
if (response.disablePlayerListHover()) {
|
||||
event.getListedPlayers().clear();
|
||||
}
|
||||
if (response.hidePlayerCount()) {
|
||||
event.setHidePlayers(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,3 @@
|
||||
import java.util.Locale
|
||||
|
||||
plugins {
|
||||
id("minimotd.shadow-platform")
|
||||
}
|
||||
@@ -14,7 +12,7 @@ dependencies {
|
||||
tasks {
|
||||
processResources {
|
||||
val replacements = mapOf(
|
||||
"modid" to rootProject.name.toLowerCase(Locale.ENGLISH),
|
||||
"modid" to rootProject.name.lowercase(),
|
||||
"name" to rootProject.name,
|
||||
"version" to project.version.toString(),
|
||||
"description" to project.description.toString(),
|
||||
@@ -31,3 +29,8 @@ tasks {
|
||||
commonRelocation("org.bstats")
|
||||
}
|
||||
}
|
||||
|
||||
publishMods.modrinth {
|
||||
modLoaders.add("sponge")
|
||||
minecraftVersions.add("1.12.2")
|
||||
}
|
||||
+4
-4
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2022 Jason Penilla
|
||||
* Copyright (c) 2020-2025 Jason Penilla
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -25,13 +25,13 @@ package xyz.jpenilla.minimotd.sponge7;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import net.kyori.adventure.text.serializer.spongeapi.SpongeComponentSerializer;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.jspecify.annotations.NonNull;
|
||||
import org.spongepowered.api.event.EventListener;
|
||||
import org.spongepowered.api.event.server.ClientPingServerEvent;
|
||||
import org.spongepowered.api.network.status.Favicon;
|
||||
import xyz.jpenilla.minimotd.common.MiniMOTD;
|
||||
import xyz.jpenilla.minimotd.common.PingResponse;
|
||||
import xyz.jpenilla.minimotd.common.config.MiniMOTDConfig;
|
||||
import xyz.jpenilla.minimotd.common.config.MOTDConfig;
|
||||
|
||||
final class ClientPingServerEventListener implements EventListener<ClientPingServerEvent> {
|
||||
private final MiniMOTD<Favicon> miniMOTD;
|
||||
@@ -58,7 +58,7 @@ final class ClientPingServerEventListener implements EventListener<ClientPingSer
|
||||
}
|
||||
}
|
||||
|
||||
final MiniMOTDConfig config = this.miniMOTD.configManager().mainConfig();
|
||||
final MOTDConfig config = this.miniMOTD.configManager().mainConfig();
|
||||
|
||||
final PingResponse<Favicon> mini = this.miniMOTD.createMOTD(config, players.getOnline(), players.getMax());
|
||||
mini.playerCount().applyCount(players::setOnline, players::setMax);
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2022 Jason Penilla
|
||||
* Copyright (c) 2020-2025 Jason Penilla
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -32,7 +32,7 @@ import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import net.kyori.adventure.platform.spongeapi.SpongeAudiences;
|
||||
import org.bstats.sponge.Metrics;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.jspecify.annotations.NonNull;
|
||||
import org.slf4j.Logger;
|
||||
import org.spongepowered.api.Game;
|
||||
import org.spongepowered.api.Sponge;
|
||||
File renamed without changes.
@@ -1,10 +1,9 @@
|
||||
import org.spongepowered.gradle.plugin.config.PluginLoaders
|
||||
import org.spongepowered.plugin.metadata.model.PluginDependency
|
||||
import java.util.Locale
|
||||
|
||||
plugins {
|
||||
id("minimotd.shadow-platform")
|
||||
id("org.spongepowered.gradle.plugin")
|
||||
alias(libs.plugins.sponge.gradle.plugin)
|
||||
}
|
||||
|
||||
dependencies {
|
||||
@@ -14,7 +13,7 @@ dependencies {
|
||||
sponge {
|
||||
injectRepositories(false)
|
||||
apiVersion("8.1.0-SNAPSHOT")
|
||||
plugin(rootProject.name.toLowerCase(Locale.ENGLISH)) {
|
||||
plugin(rootProject.name.lowercase()) {
|
||||
loader {
|
||||
name(PluginLoaders.JAVA_PLAIN)
|
||||
version("1.0")
|
||||
@@ -35,15 +34,40 @@ sponge {
|
||||
loadOrder(PluginDependency.LoadOrder.AFTER)
|
||||
optional(false)
|
||||
}
|
||||
dependency("miniplaceholders") {
|
||||
loadOrder(PluginDependency.LoadOrder.AFTER)
|
||||
optional(true)
|
||||
version = "3.0.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks {
|
||||
shadowJar {
|
||||
configureForNativeAdventurePlatform()
|
||||
platformRelocation("sponge8", "xyz.jpenilla.minimotd.common")
|
||||
dependencies {
|
||||
exclude(dependency("io.leangen.geantyref:geantyref"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
publishMods.modrinth {
|
||||
modLoaders.add("sponge")
|
||||
minecraftVersions.addAll(
|
||||
"1.16.5",
|
||||
"1.18.2",
|
||||
"1.19.4",
|
||||
"1.20.6",
|
||||
"1.21.1",
|
||||
"1.21.3",
|
||||
"1.21.4",
|
||||
"1.21.5",
|
||||
"1.21.8",
|
||||
"1.21.10",
|
||||
"1.21.11",
|
||||
"26.1.2",
|
||||
"26.2",
|
||||
"26.3",
|
||||
)
|
||||
optional("miniplaceholders")
|
||||
}
|
||||
+4
-4
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2022 Jason Penilla
|
||||
* Copyright (c) 2020-2025 Jason Penilla
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -25,7 +25,7 @@ package xyz.jpenilla.minimotd.sponge8;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import java.lang.reflect.Method;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.jspecify.annotations.NonNull;
|
||||
import org.spongepowered.api.MinecraftVersion;
|
||||
import org.spongepowered.api.event.EventListener;
|
||||
import org.spongepowered.api.event.server.ClientPingServerEvent;
|
||||
@@ -33,7 +33,7 @@ import org.spongepowered.api.network.status.Favicon;
|
||||
import xyz.jpenilla.minimotd.common.Constants;
|
||||
import xyz.jpenilla.minimotd.common.MiniMOTD;
|
||||
import xyz.jpenilla.minimotd.common.PingResponse;
|
||||
import xyz.jpenilla.minimotd.common.config.MiniMOTDConfig;
|
||||
import xyz.jpenilla.minimotd.common.config.MOTDConfig;
|
||||
import xyz.jpenilla.minimotd.common.util.ComponentColorDownsampler;
|
||||
|
||||
final class ClientPingServerEventListener implements EventListener<ClientPingServerEvent> {
|
||||
@@ -72,7 +72,7 @@ final class ClientPingServerEventListener implements EventListener<ClientPingSer
|
||||
}
|
||||
}
|
||||
|
||||
final MiniMOTDConfig config = this.miniMOTD.configManager().mainConfig();
|
||||
final MOTDConfig config = this.miniMOTD.configManager().mainConfig();
|
||||
|
||||
final PingResponse<Favicon> mini = this.miniMOTD.createMOTD(config, players.online(), players.max());
|
||||
mini.playerCount().applyCount(players::setOnline, players::setMax);
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2022 Jason Penilla
|
||||
* Copyright (c) 2020-2025 Jason Penilla
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -29,7 +29,7 @@ import com.google.inject.Injector;
|
||||
import com.google.inject.TypeLiteral;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.nio.file.Path;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.jspecify.annotations.NonNull;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.spongepowered.api.Sponge;
|
||||
@@ -0,0 +1,43 @@
|
||||
plugins {
|
||||
id("minimotd.shadow-platform")
|
||||
alias(libs.plugins.run.velocity)
|
||||
alias(libs.plugins.resource.factory.velocity)
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(projects.minimotdCommon)
|
||||
implementation(libs.bstatsVelocity)
|
||||
compileOnly(libs.velocityApi)
|
||||
}
|
||||
|
||||
indra {
|
||||
javaVersions {
|
||||
target(21)
|
||||
}
|
||||
}
|
||||
|
||||
tasks {
|
||||
shadowJar {
|
||||
configureForNativeAdventurePlatform()
|
||||
commonRelocation("io.leangen.geantyref")
|
||||
commonRelocation("org.bstats")
|
||||
}
|
||||
runVelocity {
|
||||
velocityVersion(libs.versions.velocityApi.get())
|
||||
}
|
||||
}
|
||||
|
||||
velocityPluginJson {
|
||||
name = "MiniMOTD"
|
||||
id = "minimotd-velocity"
|
||||
url = Constants.GITHUB_URL
|
||||
authors = listOf("jmp")
|
||||
main = "xyz.jpenilla.minimotd.velocity.MiniMOTDVelocity"
|
||||
dependency("miniplaceholders", true)
|
||||
}
|
||||
|
||||
publishMods.modrinth {
|
||||
modLoaders.add("velocity")
|
||||
minecraftVersions.addAll(minecraftVersion)
|
||||
optional("miniplaceholders")
|
||||
}
|
||||
+16
-41
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2022 Jason Penilla
|
||||
* Copyright (c) 2020-2025 Jason Penilla
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -28,15 +28,10 @@ import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.TypeLiteral;
|
||||
import com.mojang.brigadier.Command;
|
||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import com.velocitypowered.api.command.BrigadierCommand;
|
||||
import com.velocitypowered.api.command.CommandManager;
|
||||
import com.velocitypowered.api.command.CommandSource;
|
||||
import com.velocitypowered.api.event.Subscribe;
|
||||
import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
|
||||
import com.velocitypowered.api.plugin.Plugin;
|
||||
import com.velocitypowered.api.plugin.annotation.DataDirectory;
|
||||
import com.velocitypowered.api.proxy.ProxyServer;
|
||||
import com.velocitypowered.api.util.Favicon;
|
||||
@@ -44,23 +39,15 @@ import java.awt.image.BufferedImage;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Set;
|
||||
import org.bstats.velocity.Metrics;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.jspecify.annotations.NonNull;
|
||||
import org.slf4j.Logger;
|
||||
import xyz.jpenilla.minimotd.common.CommandHandler;
|
||||
import xyz.jpenilla.minimotd.common.Constants;
|
||||
import xyz.jpenilla.minimotd.common.MiniMOTD;
|
||||
import xyz.jpenilla.minimotd.common.MiniMOTDPlatform;
|
||||
import xyz.jpenilla.minimotd.common.util.BrigadierUtil;
|
||||
import xyz.jpenilla.minimotd.common.util.UpdateChecker;
|
||||
|
||||
@Plugin(
|
||||
id = "${project.name}",
|
||||
name = Constants.PluginMetadata.NAME,
|
||||
version = Constants.PluginMetadata.VERSION,
|
||||
description = "${description}",
|
||||
url = "${url}",
|
||||
authors = {"jmp"}
|
||||
)
|
||||
public final class MiniMOTDPlugin implements MiniMOTDPlatform<Favicon> {
|
||||
public final class MiniMOTDVelocity implements MiniMOTDPlatform<Favicon> {
|
||||
private static final Set<Class<?>> LISTENER_CLASSES = ImmutableSet.of(
|
||||
PingListener.class
|
||||
);
|
||||
@@ -74,7 +61,7 @@ public final class MiniMOTDPlugin implements MiniMOTDPlatform<Favicon> {
|
||||
private final Injector injector;
|
||||
|
||||
@Inject
|
||||
public MiniMOTDPlugin(
|
||||
public MiniMOTDVelocity(
|
||||
final @NonNull ProxyServer server,
|
||||
final @NonNull Logger logger,
|
||||
final @NonNull CommandManager commandManager,
|
||||
@@ -93,7 +80,7 @@ public final class MiniMOTDPlugin implements MiniMOTDPlatform<Favicon> {
|
||||
@Override
|
||||
protected void configure() {
|
||||
this.bind(new TypeLiteral<MiniMOTD<Favicon>>() {
|
||||
}).toInstance(MiniMOTDPlugin.this.miniMOTD);
|
||||
}).toInstance(MiniMOTDVelocity.this.miniMOTD);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -114,28 +101,16 @@ public final class MiniMOTDPlugin implements MiniMOTDPlatform<Favicon> {
|
||||
}
|
||||
|
||||
private void registerCommand() {
|
||||
final class WrappingExecutor implements Command<CommandSource> {
|
||||
private final CommandHandler.Executor handler;
|
||||
|
||||
WrappingExecutor(final CommandHandler.@NonNull Executor handler) {
|
||||
this.handler = handler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int run(final @NonNull CommandContext<CommandSource> context) {
|
||||
this.handler.execute(context.getSource());
|
||||
return Command.SINGLE_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
final CommandHandler handler = new CommandHandler(this.miniMOTD);
|
||||
this.commandManager.register(this.commandManager.metaBuilder("minimotd").build(), new BrigadierCommand(
|
||||
LiteralArgumentBuilder.<CommandSource>literal("minimotd")
|
||||
.requires(source -> source.hasPermission("minimotd.admin"))
|
||||
.then(LiteralArgumentBuilder.<CommandSource>literal("help").executes(new WrappingExecutor(handler::help)))
|
||||
.then(LiteralArgumentBuilder.<CommandSource>literal("about").executes(new WrappingExecutor(handler::about)))
|
||||
.then(LiteralArgumentBuilder.<CommandSource>literal("reload").executes(new WrappingExecutor(handler::reload)))
|
||||
));
|
||||
this.commandManager.register(
|
||||
this.commandManager.metaBuilder("minimotd").plugin(this).build(),
|
||||
new BrigadierCommand(
|
||||
BrigadierUtil.buildTree(
|
||||
new CommandHandler(this.miniMOTD),
|
||||
source -> source,
|
||||
source -> source.hasPermission("minimotd.admin")
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
Loaded 100 of 107 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user