Compare commits

...
361 Commits
Author SHA1 Message Date
Jason Penilla 8c70ec3ea7 release: Version 2.2.2 2025-12-14 10:35:43 -07:00
Jason Penilla 7f43d73230 Bump minimum common Java requirement to 17
This is now the third-oldest LTS version, supporting anything older is not worth the build headache and outdated dependencies anymore.
2025-12-14 10:27:43 -07:00
Jason Penilla 1d4840e55f Bump minimum common Java requirement to 11 2025-12-14 10:23:05 -07:00
Jason Penilla 3bbb2dd18b Update for 1.21.11 2025-12-14 10:07:38 -07:00
Jason Penilla ff5d418387 Move disableAutoTargetJvm 2025-12-14 09:54:35 -07:00
renovate[bot] 17af4ab03a chore(deps): Update dependency io.github.miniplaceholders:miniplaceholders-api to v3.1.0 2025-12-14 09:50:08 -07:00
renovate[bot] a6d029d56b chore(deps): Update dependency io.papermc:hangar-publish-plugin to v0.1.4 2025-12-14 09:49:47 -07:00
Jason Penilla 1edfa4b53a Update junit 2025-12-14 09:48:56 -07:00
Jason Penilla 3f3cd43ab1 Update indra to v4 2025-12-14 09:46:15 -07:00
renovate[bot] 9728220a65 chore(deps): Update dependency net.fabricmc:fabric-loader to v0.18.2 2025-12-14 09:39:29 -07:00
renovate[bot] 0e23a15f3d chore(deps): Update gradle and github actions 2025-12-14 09:39:17 -07:00
renovate[bot] 43cbc6aaf4 chore(deps): Update gradle and github actions 2025-10-11 12:00:26 -07:00
Jason Penilla 811be6e946 2.2.2-SNAPSHOT 2025-10-09 10:50:50 -07:00
Jason Penilla 4a888a6032 release: Version 2.2.1 2025-10-09 10:45:57 -07:00
Jason Penilla 1854f552fe Update for Minecraft 1.21.10 2025-10-07 15:04:23 -07:00
Jason Penilla dd60234690 Fix mergeServiceFiles 2025-10-07 15:00:04 -07:00
renovate[bot] 2faeb581f1 chore(deps): Update gradle and github actions 2025-10-07 14:54:07 -07:00
renovate[bot] e5447dd94e chore(deps): Update dependency org.junit.jupiter:junit-jupiter-engine to v5.14.0 2025-10-07 14:53:50 -07:00
renovate[bot] 11c2dab22b chore(deps): Update dependency com.gradleup.shadow:shadow-gradle-plugin to v9.2.2 2025-10-07 14:53:42 -07:00
renovate[bot] c4b9c6e842 chore(deps): Update dependency net.fabricmc:fabric-loader to v0.17.2 2025-10-07 14:53:33 -07:00
renovate[bot] 7cfb191e2c chore(deps): Update dependency me.modmuss50:mod-publish-plugin to v1 2025-09-08 12:07:12 -07:00
renovate[bot] 110d409fa2 chore(deps): Update gradle and github actions 2025-09-07 20:06:13 -07:00
renovate[bot] facc10af69 chore(deps): Update slf4j monorepo to v1.7.36 2025-08-30 15:19:40 -07:00
renovate[bot] ec1ef8b2e7 chore(deps): Update dependency net.neoforged:neoforge to v21.8.39 2025-08-30 15:19:26 -07:00
renovate[bot] 57e2dbb731 chore(deps): Update dependency net.fabricmc.fabric-api:fabric-api to v0.133.0+1.21.8 2025-08-30 15:19:19 -07:00
renovate[bot] 931fa06d55 chore(deps): Update dependency com.gradleup.shadow:shadow-gradle-plugin to v9.1.0 2025-08-30 15:19:11 -07:00
Jason Penilla 47e642848e 2.2.1-SNAPSHOT 2025-08-30 15:10:43 -07:00
Jason Penilla 8b17cd0b8c release: Version 2.2.0 2025-08-30 14:59:00 -07:00
Jason Penilla 030d144e51 Don't register server init listener if MiniMOTD fails to init 2025-08-29 13:28:30 -07:00
Jason Penilla 14713f1585 Use API-provided Logger on Paper 2025-08-29 13:27:50 -07:00
Jason Penilla a5f4855a64 Update README 2025-08-29 12:40:24 -07:00
Jason Penilla 1e979808c3 Add MiniPlaceholders dependency to publishing metadata 2025-08-29 12:31:10 -07:00
Jason Penilla c113cc991e Bump minimum toolchain 2025-08-29 12:22:26 -07:00
Jason Penilla 6f44b52c03 Add support for MiniPlaceholders on native Adventure platforms 2025-08-29 12:15:15 -07:00
Jason Penilla 2cb658c3ba Switch to JSpecify nullness annotations 2025-08-29 11:36:11 -07:00
Jason Penilla 7e0dcf45a1 Update license headers 2025-08-29 11:35:25 -07:00
Jason Penilla 7230c27764 Implement native Paper platform (#318)
* Implement native Paper platform

* fix import order

* Add command description
2025-08-29 11:21:03 -07:00
Jason Penilla 7f0b547b17 mergeServiceFiles closes #317 2025-08-26 09:09:17 -07:00
renovate[bot] f0fea9c45a chore(deps): Update dependency com.gradleup.shadow:shadow-gradle-plugin to v9 2025-08-15 17:15:33 -07:00
renovate[bot] 950de09b40 chore(deps): Update dependency gradle to v9 2025-08-15 17:13:50 -07:00
renovate[bot] 7a35dcf3ab chore(deps): Update dependency net.fabricmc.fabric-api:fabric-api to v0.131.0+1.21.8 2025-08-15 17:12:10 -07:00
renovate[bot] 84b5557d30 chore(deps): Update dependency org.junit.jupiter:junit-jupiter-engine to v5.13.4 2025-08-15 17:10:23 -07:00
renovate[bot] 658178c477 chore(deps): Update plugin net.neoforged.moddev.repositories to v2.0.107 2025-08-15 17:10:09 -07:00
renovate[bot] ad529ec914 chore(deps): Update dependency net.neoforged:neoforge to v21.8.29 2025-08-08 10:20:37 -07:00
Jason Penilla 51b490be18 2.1.9-SNAPSHOT 2025-07-30 15:38:26 -07:00
Jason Penilla cd61adab95 release: Version 2.1.8 2025-07-30 15:32:38 -07:00
renovate[bot] fff3fc0711 chore(deps): Update adventurePlatformMod to v6.6.0 2025-07-30 15:02:12 -07:00
renovate[bot] 5bd936ebe8 chore(deps): Update dependency net.kyori:adventure-bom to v4.24.0 2025-07-30 14:59:02 -07:00
renovate[bot] 58566c4c73 chore(deps): Update indra to v3.2.0 2025-07-29 19:11:53 -07:00
Jason Penilla be16547182 Update adventure platforms 2025-07-29 19:07:59 -07:00
Jason Penilla 2fb0648c93 Link to Modrinth instead of GitHub from UpdateChecker 2025-07-28 12:34:42 -07:00
Jason Penilla 049e61df50 2.1.8-SNAPSHOT 2025-07-18 13:48:41 -07:00
Jason Penilla d4396a20bb release: Version 2.1.7 2025-07-18 13:44:29 -07:00
renovate[bot] 2ef09d0669 chore(deps): Update plugin net.neoforged.moddev.repositories to v2.0.103 2025-07-17 20:36:43 -07:00
Jason Penilla f7c7afd7e5 Update for 1.21.8 2025-07-17 20:36:23 -07:00
renovate[bot] d05dc770a5 chore(deps): Update dependency org.checkerframework:checker-qual to v3.49.5 2025-07-11 10:17:07 -07:00
renovate[bot] f8ade792bf chore(deps): Update dependency net.kyori:adventure-bom to v4.23.0 2025-07-11 10:17:00 -07:00
Jason Penilla 7dba88c9d2 Update for 1.21.7 (#301) 2025-07-11 09:55:14 -07:00
Jason Penilla b24955e113 build: Update repositories 2025-07-11 09:35:12 -07:00
renovate[bot] 89b8cbb26e chore(deps): Update dependency org.junit.jupiter:junit-jupiter-engine to v5.13.3 2025-07-11 09:22:25 -07:00
renovate[bot] 25902d132b chore(deps): Update gradle and github actions 2025-07-08 13:38:31 -07:00
renovate[bot] b1308e92ef chore(deps): Update dependency com.gradleup.shadow:shadow-gradle-plugin to v8.3.8 2025-07-01 11:30:30 -07:00
renovate[bot] 410272d025 chore(deps): Update dependency org.junit.jupiter:junit-jupiter-engine to v5.13.2 2025-06-29 19:03:52 -07:00
renovate[bot] e065283ae9 chore(deps): migrate config renovate.json 2025-06-29 19:03:45 -07:00
renovate[bot] c7a27a212f chore(deps): Update gradle and github actions 2025-06-29 18:58:01 -07:00
renovate[bot] ff99a0c231 chore(deps): Update dependency org.checkerframework:checker-qual to v3.49.4 2025-06-29 18:57:50 -07:00
renovate[bot] f8e8e81ace chore(deps): Update plugin org.gradle.toolchains.foojay-resolver-convention to v1 2025-06-29 18:57:39 -07:00
renovate[bot] 01a1091c5e chore(deps): Update dependency com.gradleup.shadow:shadow-gradle-plugin to v8.3.7 2025-06-29 18:57:24 -07:00
Jason Penilla 77a200203c Update adventure-platform 2025-05-10 17:13:36 -07:00
renovate[bot] cd88a2b73d chore(deps): Update dependency net.kyori:adventure-bom to v4.21.0 2025-04-30 11:21:43 -07:00
Jason Penilla 6a9bb08a1b 2.1.7-SNAPSHOT 2025-04-27 20:37:18 -07:00
Jason Penilla eab3617449 release: Version 2.1.6 2025-04-27 20:04:34 -07:00
Jason Penilla 73de0a0cff Update adventure-platform and loom 2025-04-27 19:29:03 -07:00
renovate[bot] ae1ea24c97 chore(deps): Update gradle and github actions 2025-04-27 15:30:02 -07:00
renovate[bot] 77e64e78bc chore(deps): Update dependency net.neoforged:neoforge to v21.5.62-beta 2025-04-27 15:29:56 -07:00
renovate[bot] a1bacb1747 chore(deps): Update dependency net.fabricmc.fabric-api:fabric-api to v0.121.0+1.21.5 2025-04-27 15:29:50 -07:00
Jason Penilla 8e6f9ea77d Minecraft 1.21.5 (#278) 2025-04-16 22:17:56 -07:00
renovate[bot] 03a95129f7 chore(deps): Update dependency net.fabricmc:fabric-loader to v0.16.14 2025-04-16 21:53:11 -07:00
renovate[bot] 6fc1f06fd9 chore(deps): Update dependency org.junit.jupiter:junit-jupiter-engine to v5.12.2 2025-04-16 21:48:38 -07:00
renovate[bot] cf918948c8 chore(deps): Update gradle and github actions 2025-04-16 21:48:32 -07:00
renovate[bot] 96254e790f chore(deps): Update dependency net.kyori:adventure-bom to v4.20.0 2025-04-05 18:01:22 -07:00
renovate[bot] ba6613e622 chore(deps): Update dependency net.fabricmc:fabric-loader to v0.16.12 2025-04-05 17:54:24 -07:00
renovate[bot] 1a1a4359c8 chore(deps): Update dependency org.checkerframework:checker-qual to v3.49.2 2025-04-05 17:54:15 -07:00
renovate[bot] 3e01f4a40c chore(deps): Update dependency io.papermc:hangar-publish-plugin to v0.1.3 2025-04-05 17:54:05 -07:00
renovate[bot] 31c24fc0f7 chore(deps): Update adventurePlatformMod to v6.3.0 2025-04-05 17:53:51 -07:00
renovate[bot] 87b74f6343 chore(deps): Update dependency net.neoforged:neoforge to v21.4.123 2025-03-28 09:42:07 -07:00
renovate[bot] 558e0a1b2c chore(deps): Update dependency net.fabricmc.fabric-api:fabric-api to v0.119.2+1.21.4 2025-03-28 09:42:00 -07:00
renovate[bot] 3fd8465433 chore(deps): Update dependency org.spongepowered:configurate-hocon to v4.2.0 2025-03-28 09:41:27 -07:00
renovate[bot] 689563a56e chore(deps): Update dependency org.junit.jupiter:junit-jupiter-engine to v5.12.1 2025-03-28 09:41:16 -07:00
renovate[bot] 180002e0e1 chore(deps): Update gradle and github actions 2025-02-24 16:08:07 -07:00
renovate[bot] b39cfdeb56 chore(deps): Update dependency org.checkerframework:checker-qual to v3.49.0 2025-02-24 16:07:49 -07:00
renovate[bot] 9a74c14f00 chore(deps): Update dependency net.fabricmc.fabric-api:fabric-api to v0.118.0+1.21.4 2025-02-24 16:07:40 -07:00
renovate[bot] ad8233a4d2 chore(deps): Update dependency org.junit.jupiter:junit-jupiter-engine to v5.12.0 2025-02-24 16:07:32 -07:00
renovate[bot] 0df4bc3c59 chore(deps): Update dependency net.kyori:adventure-bom to v4.19.0 2025-02-24 16:07:11 -07:00
renovate[bot] 9f216d90e6 chore(deps): Update dependency net.neoforged:neoforge to v21.4.95-beta 2025-02-24 15:58:17 -07:00
renovate[bot] 4c3f049e06 chore(deps): Update dependency net.fabricmc:fabric-loader to v0.16.10 2025-02-24 15:58:11 -07:00
renovate[bot] 095841448d chore(deps): Update dependency com.gradleup.shadow:shadow-gradle-plugin to v8.3.6 2025-02-24 15:58:04 -07:00
renovate[bot] 9378ea4d5d chore(deps): Update plugin sponge-gradle-plugin to v2.3.0 2025-01-01 21:39:08 -08:00
renovate[bot] 88a45eff62 chore(deps): Update dependency net.kyori:adventure-bom to v4.18.0 2025-01-01 21:38:58 -08:00
Jason Penilla a5a8d10940 Fix bukkit-bungeecord jar using deprecated Gradle features 2025-01-01 21:36:26 -08:00
Jason Penilla 79637815f6 Update Gradle wrapper to 8.12, loom to 1.9, switch to ModDevGradle for NeoForge 2025-01-01 21:20:46 -08:00
Jason Penilla 7f5a43f89f 2.1.6-SNAPSHOT 2025-01-01 20:59:37 -08:00
Jason Penilla c7a8656d3f release: Version 2.1.5 2025-01-01 20:51:28 -08:00
Jason Penilla a8a046d3ba build: Remove redundant configuration
Indra already does this
2025-01-01 20:47:26 -08:00
renovate[bot] cb8ffffe6f chore(deps): Update adventurePlatformMod to v6.2.0 2025-01-01 20:45:59 -08:00
Jason Penilla 3b15660097 Build with 1.21.4 2025-01-01 20:45:34 -08:00
renovate[bot] 80d16d2b13 chore(deps): Update dependency me.modmuss50:mod-publish-plugin to v0.8.4 2025-01-01 20:28:17 -08:00
renovate[bot] 16e8253fa0 chore(deps): Update dependency org.junit.jupiter:junit-jupiter-engine to v5.11.4 2025-01-01 20:28:09 -08:00
Jason Penilla a7042a8263 Update metadata to allow running on 1.21.4 2024-12-06 20:41:50 -07:00
renovate[bot] 9a77ed8b88 chore(deps): Update dependency net.neoforged:neoforge to v21.3.52-beta 2024-11-29 10:08:45 -07:00
renovate[bot] 9a2bba7fc3 chore(deps): Update dependency net.fabricmc:fabric-loader to v0.16.9 2024-11-28 17:52:22 -07:00
renovate[bot] a8c8848420 chore(deps): Update dependency org.checkerframework:checker-qual to v3.48.2 2024-11-28 17:52:06 -07:00
renovate[bot] 1ae536586e chore(deps): Update dependency net.fabricmc.fabric-api:fabric-api to v0.110.0+1.21.3 2024-11-28 17:51:45 -07:00
renovate[bot] b8a865a16f chore(deps): Update dependency me.modmuss50:mod-publish-plugin to v0.8.1 2024-11-28 17:51:37 -07:00
Jason Penilla 7de803fda2 build: use reproducible file order and time stamps 2024-11-26 18:29:08 -07:00
Jason Penilla 8d27f17184 Update metadata and velocity api 2024-11-06 18:50:44 -07:00
Jason Penilla 949ba5f21c 2.1.5-SNAPSHOT 2024-11-06 18:41:48 -07:00
Jason Penilla 10c0e521c3 release: Version 2.1.4 2024-11-06 18:34:48 -07:00
renovate[bot] 831894876c chore(deps): Update dependency com.gradleup.shadow:shadow-gradle-plugin to v8.3.5 2024-11-06 18:29:36 -07:00
renovate[bot] d0618af8ea chore(deps): Update dependency net.neoforged:neoforge to v21.3.11-beta 2024-11-06 18:26:14 -07:00
renovate[bot] d79ead8b13 chore(deps): Update dependency org.junit.jupiter:junit-jupiter-engine to v5.11.3 2024-11-06 18:20:09 -07:00
Jason Penilla 9c17676b74 Minecraft 1.21.3 (#243)
* Initial update for Minecraft 1.21.3

* Update adventure-platform-mod

* Update README
2024-11-06 18:17:15 -07:00
renovate[bot] 230ed8142a chore(deps): Update dependency net.fabricmc:fabric-loader to v0.16.7 2024-10-15 12:19:56 -07:00
renovate[bot] f155500f49 chore(deps): Update dependency org.junit.jupiter:junit-jupiter-engine to v5.11.2 2024-10-15 12:19:32 -07:00
renovate[bot] 5afd801850 chore(deps): Update dependency org.junit.jupiter:junit-jupiter-engine to v5.11.1 2024-09-25 16:27:25 -07:00
renovate[bot] 2681390aad chore(deps): Update dependency net.fabricmc.fabric-api:fabric-api to v0.105.0+1.21.1 2024-09-25 16:26:22 -07:00
renovate[bot] 3a56d24107 chore(deps): Update dependency net.neoforged:neoforge to v21.1.61 2024-09-25 16:26:13 -07:00
renovate[bot] 13260762d4 chore(deps): Update dependency me.modmuss50:mod-publish-plugin to v0.7.4 2024-09-25 16:26:05 -07:00
renovate[bot] 42a2c56770 chore(deps): Update bstats to v3.1.0 2024-09-25 16:25:58 -07:00
renovate[bot] 921055f2b0 chore(deps): Update dependency gradle to v8.10.2 2024-09-25 16:25:51 -07:00
renovate[bot] a6af02ae63 chore(deps): Update dependency gradle to v8.10.1 2024-09-10 12:27:22 -07:00
Jason Penilla 22ff761ee0 chore(paper): Update comments 2024-09-10 12:26:32 -07:00
Jason Penilla 9a274d1550 fix(paper): Work around Paper bug to fix #211 2024-09-10 10:33:06 -07:00
Jason Penilla af6610cdb2 2.1.4-SNAPSHOT 2024-09-09 19:18:08 -07:00
Jason Penilla d9a6d9eb74 release: Version 2.1.3 2024-09-09 19:09:50 -07:00
renovate[bot] 656f153bec chore(deps): Update gradle and github actions 2024-09-07 17:45:04 -07:00
renovate[bot] 266d3ff7dc chore(deps): Update dependency net.fabricmc:fabric-loader to v0.16.5 2024-09-07 17:38:36 -07:00
renovate[bot] 7d682d8121 chore(deps): Update dependency me.modmuss50:mod-publish-plugin to v0.7.3 2024-09-07 17:34:26 -07:00
renovate[bot] 11886270a8 chore(deps): Update dependency net.fabricmc.fabric-api:fabric-api to v0.103.0+1.21.1 2024-09-07 17:34:17 -07:00
renovate[bot] 60e2e9ceee chore(deps): Update dependency org.checkerframework:checker-qual to v3.47.0 2024-09-07 17:34:08 -07:00
renovate[bot] f9482769b8 chore(deps): Update dependency net.neoforged:neoforge to v21.1.42 2024-09-07 17:33:54 -07:00
Jason Penilla 98d12c4e39 Update renovate.json 2024-09-03 17:05:08 -07:00
Jason Penilla 4658d70e45 Update shadow 2024-09-03 17:03:26 -07:00
renovate[bot] f9355a6fb1 chore(deps): Update dependency org.junit.jupiter:junit-jupiter-engine to v5.11.0 2024-09-02 11:53:02 -07:00
renovate[bot] c8a94b738a chore(deps): Update dependency me.modmuss50:mod-publish-plugin to v0.7.2 2024-09-02 11:52:37 -07:00
Jason Penilla 596c07e11f Update readme 2024-08-25 15:12:31 -07:00
Jason Penilla f60d66673f Build using 1.21.1 and update readme 2024-08-25 15:10:05 -07:00
renovate[bot] 40bf7d13d6 chore(deps): Update bstats to v3.0.3 2024-08-25 14:49:30 -07:00
renovate[bot] 25ef13dc69 chore(deps): Update dependency org.checkerframework:checker-qual to v3.46.0 2024-08-25 14:45:15 -07:00
renovate[bot] 1d53ffedd1 chore(deps): Update dependency me.modmuss50:mod-publish-plugin to v0.7.0 2024-08-25 14:45:00 -07:00
renovate[bot] e3e99577d1 chore(deps): Update adventurePlatform to v4.3.4 2024-08-25 14:44:50 -07:00
Jason Penilla 59a8b3d82a Update adventure-platform 2024-08-25 14:37:00 -07:00
Jason Penilla a30d1bf7fb copy NeoForge ServerStatus fields 2024-08-25 14:37:00 -07:00
Jason Penilla 6be04f7700 Initial NeoForge implementation 2024-08-25 14:37:00 -07:00
Jason Penilla 91c33014ba build: bump loom to 1.7 2024-08-25 14:37:00 -07:00
renovate[bot] 19917d4eaa chore(deps): Update dependency io.github.goooler.shadow:shadow-gradle-plugin to v8.1.8 2024-07-02 10:52:35 -07:00
renovate[bot] 77283d0c84 chore(deps): Update dependency org.junit.jupiter:junit-jupiter-engine to v5.10.3 2024-07-02 10:52:25 -07:00
renovate[bot] 376682eac8 chore(deps): Update dependency org.checkerframework:checker-qual to v3.45.0 2024-07-02 10:52:13 -07:00
renovate[bot] f5c576e839 chore(deps): Update dependency me.modmuss50:mod-publish-plugin to v0.5.2 2024-07-02 10:52:00 -07:00
Jason Penilla 6bc70cf054 2.1.3-SNAPSHOT 2024-06-23 19:56:59 -07:00
Jason Penilla 12993bb866 release: Version 2.1.2 2024-06-23 19:53:48 -07:00
renovate[bot] 5a742f62e5 chore(deps): Update dependency org.checkerframework:checker-qual to v3.44.0 2024-06-23 19:47:52 -07:00
renovate[bot] 000dfda192 chore(deps): Update dependency net.kyori:adventure-platform-fabric to v5.14.0 2024-06-22 17:18:23 -07:00
Jason Penilla 8c66bcd408 Update dependencies for Minecraft 1.21 2024-06-19 22:36:15 -07:00
Jason Penilla 2d47e73d3b Fix mc versions metadata 2024-06-02 00:27:42 -07:00
Jason Penilla f500c9fb8f 2.1.2-SNAPSHOT 2024-06-02 00:21:17 -07:00
Jason Penilla 922079cc7d release: Version 2.1.1 2024-06-02 00:17:52 -07:00
renovate[bot] 798946390b chore(deps): Update gradle and github actions 2024-06-01 20:55:47 -07:00
renovate[bot] 743a149f3b chore(deps): Update dependency org.checkerframework:checker-qual to v3.43.0 2024-06-01 20:54:59 -07:00
renovate[bot] 316945b30f chore(deps): Update dependency net.fabricmc.fabric-api:fabric-api to v0.99.4+1.20.6 2024-06-01 20:54:50 -07:00
renovate[bot] c8bf42463c chore(deps): Update adventurePlatform to v4.3.3 2024-06-01 20:54:41 -07:00
Jason Penilla a9bf505028 Update dependencies 2024-05-10 17:41:09 -07:00
Jason Penilla 60bfb21444 Opt-out of remapping on Paper 1.20.5+ 2024-05-02 14:35:06 -07:00
Jason Penilla fb13022642 feat(fabric): Initial 1.20.6 update 2024-04-29 21:45:58 -07:00
Jason Penilla 1bbf3abd9a build updates 2024-04-29 21:32:37 -07:00
renovate[bot] 1967d9802f chore(deps): Update dependency net.fabricmc:fabric-loader to v0.15.10 2024-04-29 21:25:12 -07:00
renovate[bot] 6b3d7aeab6 chore(deps): Update dependency me.modmuss50:mod-publish-plugin to v0.5.1 2024-02-26 22:12:54 -07:00
renovate[bot] 267c0426fe chore(deps): Update dependency net.kyori:adventure-bom to v4.16.0 2024-02-26 22:12:43 -07:00
renovate[bot] c3d5afa680 chore(deps): Update dependency net.kyori:adventure-platform-fabric to v5.12.0 2024-02-26 22:12:13 -07:00
renovate[bot] 2009684fb5 chore(deps): Update dependency org.junit.jupiter:junit-jupiter-engine to v5.10.2 2024-02-05 18:23:42 -07:00
renovate[bot] 56202f3f26 chore(deps): Update dependency io.papermc:hangar-publish-plugin to v0.1.2 2024-02-02 16:45:09 -07:00
renovate[bot] f2be2062e5 chore(deps): Update dependency net.kyori:adventure-platform-fabric to v5.11.0 2024-01-21 10:19:46 -07:00
Jason Penilla 4cbe7d4bf9 Use adventure textOfChildren method 2024-01-13 21:03:33 -07:00
renovate[bot] fd20b5e583 chore(deps): Update dependency io.github.waterfallmc:waterfall-api to v1.16-R0.5-SNAPSHOT 2024-01-13 20:29:52 -07:00
Jason Penilla e495e76a2d 2.1.1-SNAPSHOT 2024-01-13 20:17:46 -07:00
Jason Penilla a37e7d8b7c release: Version 2.1.0 2024-01-13 20:15:30 -07:00
Jason Penillaandens-gijs b97ebcbbd6 Filter player lists with counts
closes #161

Co-authored-by: ens-gijs <ens.gijs@gmail.com>
2024-01-13 20:09:17 -07:00
Jason Penilla 2abf0c1eba Rename MiniMOTDConfig to avoid confusion 2024-01-13 20:05:04 -07:00
renovate[bot] 80df7d0500 chore(deps): Update dependency net.fabricmc.fabric-api:fabric-api to v0.93.1+1.20.4 2024-01-13 20:01:37 -07:00
Jason Penilla b7318a1ac8 Support basic star matching and TCPShield hostnames for virtual host configs (#167)
* Allow using single star for parts of domains in virtual host config

* pre-split host strings

* Extract real hostname from TCPShield hostnames

* fix style

* Update config comment

* Add test for virtual host matching
2024-01-13 14:14:15 -07:00
Jason PenillaandddPn08 b5e5848bd9 Add server filtering for player counts (Velocity) (#171)
* Add feature to show number of players per server

* fixup

* remove star syntax; it could be used for other purposes in the future

* remove unused import

---------

Co-authored-by: ddPn08 <pyn.g.1125@gmail.com>
2024-01-12 21:08:40 -07:00
renovate[bot] 22064b8576 chore(deps): Update plugin org.gradle.toolchains.foojay-resolver-convention to v0.8.0 2024-01-12 12:59:31 -07:00
Jason Penilla aac6cab5f6 Update license 2024-01-06 16:47:31 -07:00
Jason Penilla 7197cf9100 Update loom, apply foojay resolver conventions, move build-logic dir 2024-01-06 16:20:37 -07:00
Jason Penilla b3c448136d Update dependencies for 1.20.4 2024-01-06 16:07:55 -07:00
renovate[bot] 25ad706ebf chore(deps): Update dependency net.kyori:adventure-bom to v4.15.0 2023-12-21 12:55:40 -08:00
renovate[bot] 3c04370488 chore(deps): Update adventurePlatform to v4.3.2 2023-12-21 12:52:44 -08:00
renovate[bot] 5a3c52481a chore(deps): Update gradle and github actions 2023-11-29 09:09:53 -08:00
renovate[bot] 2eb0ba1e98 chore(deps): Update dependency net.kyori:adventure-platform-fabric to v5.10.1 2023-11-17 11:56:29 -07:00
Jason Penilla b38e08daa0 build: switch from minotaur to mod-publish-plugin for modrinth publishing 2023-11-14 21:48:13 -07:00
renovate[bot] 3c61a2d24b chore(deps): Update dependency net.fabricmc.fabric-api:fabric-api to v0.90.7+1.20.2 2023-11-12 21:07:21 -07:00
renovate[bot] 611772f4bb chore(deps): Update dependency org.checkerframework:checker-qual to v3.40.0 2023-11-12 21:04:44 -07:00
renovate[bot] 118cef163a chore(deps): Update dependency net.fabricmc:fabric-loader to v0.14.24 2023-11-12 21:04:34 -07:00
renovate[bot] d17e4af825 chore(deps): Update dependency org.junit.jupiter:junit-jupiter-engine to v5.10.1 2023-11-12 21:04:26 -07:00
renovate[bot] 19a21d988f chore(deps): Update plugin blossom to v2.1.0 2023-11-12 21:04:17 -07:00
Jason Penilla 0cd04574f9 Remove plugin-yml-bungee 2023-11-12 20:58:04 -07:00
renovate[bot] 5acc5d285d chore(deps): Update dependency io.papermc:paperlib to v1.0.8 2023-11-12 20:49:22 -07:00
Jason Penilla 3d9e90d7bf Update gradle wrapper 2023-11-12 20:46:59 -07:00
Jason Penilla c39cad4017 Update loom to 1.4 2023-11-12 20:45:35 -07:00
Jason Penilla 9c9c67776b Remove guava dependency 2023-11-12 20:41:55 -07:00
Jason Penilla 2858de84ae Convert version catalog to toml and configure renovate 2023-11-12 20:39:43 -07:00
Jason Penilla 64b023fad7 2.0.15-SNAPSHOT 2023-09-30 12:20:22 -07:00
Jason Penilla f59de86c5e release: Version 2.0.14 2023-09-30 12:15:26 -07:00
Jason Penilla 0f1c69f8b2 update run-paper and adventure-platform 2023-09-30 12:12:31 -07:00
Jason Penilla f8deb9b7fb build updates 2023-09-23 21:17:36 -07:00
Jason Penilla 8428e2b124 1.20.2 2023-09-23 21:10:19 -07:00
Jason Penilla 8f91a1b445 bump SpongeGradle 2023-09-09 16:47:30 -07:00
Jason Penilla 0ca1f8f19d build updates 2023-09-09 15:34:03 -07:00
Jason Penilla 2fd3d41cbd build: Remove quilt repo
Quiltflower is succeeded by Vineflower which is on Maven Central.
2023-07-13 11:01:31 -07:00
Jason Penilla ce201ba89e build updates 2023-06-27 22:02:55 -07:00
Jason Penilla e33135d3c6 2.0.14-SNAPSHOT 2023-06-27 22:01:51 -07:00
Jason Penilla 5f6e2789e2 release: Version 2.0.13 2023-06-27 21:40:49 -07:00
Jason Penilla add32b31e7 fabric: 1.20.1 2023-06-17 10:08:41 -07:00
Jason Penilla b2b2801907 2.0.13-SNAPSHOT 2023-05-07 14:52:36 -07:00
Jason Penilla c919c40a59 release: Version 2.0.12 2023-05-07 14:35:19 -07:00
Jason Penilla b3cc4bce5c Fix style and add remap=false to favicon codec mixin 2023-05-07 13:54:36 -07:00
Jason Penilla 6fdf75dd3d Update license headers 2023-05-07 13:50:04 -07:00
Jason Penilla a8c2b0f23e Improve Folia detection 2023-05-07 13:49:21 -07:00
Jason Penilla 0ee99d90f2 fabric: Bring back caching of encoded server icons 2023-05-07 13:47:58 -07:00
renovate[bot] 6623a5928e chore(deps): update dependency gradle to v8.1.1 2023-05-07 13:18:43 -07:00
Jason Penilla 6532c03706 Add error handler to future 2023-03-27 21:21:15 -07:00
Jason Penilla 0bf3bfba7f Add Folia support 2023-03-27 21:17:18 -07:00
Jason Penilla f7094e0a77 2.0.12-SNAPSHOT 2023-03-18 13:21:57 -07:00
Jason Penilla 563da7f255 release: Version 2.0.11 2023-03-18 13:03:56 -07:00
Jason Penilla 51e599838d build: Setup automatic Hangar and Modrinth publishing 2023-03-18 12:57:17 -07:00
Jason Penilla e4970016e4 fabric: Update fabric.mod.json 2023-03-18 10:26:25 -07:00
Jason Penilla 2a04d0b2c8 fabric: Adjust lifecycle listeners 2023-03-18 10:22:44 -07:00
Jason Penilla f8c6c2db6f fabric: Update for Minecraft 1.19.4 2023-03-18 10:11:33 -07:00
Jason Penilla 9e25b68d00 Build and dependency updates 2023-01-31 14:22:26 -07:00
Jason Penilla 96b7d12743 Update loom 2023-01-31 14:17:39 -07:00
Jason Penilla 328ad6cd39 Preload some stuff on bungee
Avoids misleading and annoying log spam
2023-01-31 14:07:27 -07:00
Jason Penilla c0ee968e5b 2.0.11-SNAPSHOT 2022-12-09 10:18:17 -07:00
Jason Penilla bc4d1e3cdd release: Version 2.0.10 2022-12-09 10:07:42 -07:00
Jason Penilla 2626ed4551 Update testing Paper 2022-12-09 10:06:57 -07:00
Jason Penilla a1f51db093 Update for Minecraft 1.19.3 2022-12-08 22:03:20 -07:00
Jason Penilla 59ab61825b Update actions 2022-12-08 22:02:47 -07:00
Jason Penilla 5d7f79ce8a Update gradle wrapper files 2022-11-25 10:31:32 -07:00
renovate[bot] a5145384f6 chore(deps): update dependency gradle to v7.6 2022-11-25 09:58:39 -07:00
Jason Penilla fba4066522 Rename uploaded artifact 2022-11-22 20:18:02 -07:00
Jason Penilla 3c9261a92d Update actions 2022-11-22 20:09:06 -07:00
Jason Penilla ab409537ac Update jupiter engine 2022-11-15 12:26:46 -07:00
Jason Penilla 98a5bba407 Update adventure-platform-fabric 2022-11-15 12:26:38 -07:00
Jason Penilla 87bec5315b build: Update run-paper, apply run-velocity and run-waterfall to respective platforms 2022-11-15 12:26:15 -07:00
Jason Penilla bf9d92150c build: Update loom 2022-09-01 18:50:49 -07:00
Jason Penilla 4cad4d461b Remove universal jar and add bukkit/bungee jar for spigot resources, also reorganize project directory structure 2022-08-28 13:41:48 -07:00
Jason Penilla fc7b78f7a8 2.0.10-SNAPSHOT 2022-08-26 15:17:38 -07:00
Jason Penilla 15cffc2d71 release: Version 2.0.9 2022-08-26 14:39:08 -07:00
Jason Penilla 28cb91a40c Bump fabric loader 2022-08-26 14:38:19 -07:00
Jason Penilla 4ab6567fd2 Make virtual hosts case-insensitive (fixes #115) 2022-08-26 14:35:34 -07:00
Jason Penilla bdac395c2d Bump dependencies 2022-08-26 14:16:37 -07:00
Jason Penilla ffb475f529 Update gradle wrapper 2022-08-26 14:14:58 -07:00
renovate[bot] d690104a9e chore(deps): update dependency gradle to v7.5.1 2022-08-05 18:52:06 -07:00
Jason Penilla efa0c69840 Handle Bukkit/Spigot throwing UnsupportedOperationException in setServerIcon for legacy pings
this change does not affect Paper users
2022-07-21 20:19:12 -07:00
renovate[bot] 369e387a39 chore(deps): update dependency gradle to v7.5 2022-07-14 16:15:21 -07:00
Jason Penilla 2f98e67a93 build: Don't apply indra publishing, we don't have anything to publish 2022-06-19 00:11:26 -07:00
Jason Penilla e2894e211c 2.0.9-SNAPSHOT 2022-06-19 00:09:44 -07:00
Jason Penilla 58ff03aa95 release: Version 2.0.8 2022-06-18 23:51:55 -07:00
Jason Penilla 4155249878 Dependency updates 2022-06-18 23:51:25 -07:00
Jason Penilla de0936c5d2 Update for Minecraft 1.19 2022-06-13 19:28:31 -07:00
Jason Penilla a8e5e910ee fabric: update loom to 0.12 2022-05-29 19:49:41 -07:00
Jason Penilla 0d48b46621 Update SpongeGradle 2022-05-07 13:08:42 -07:00
Jason Penilla 2a18bc156d 2.0.8-SNAPSHOT 2022-05-03 18:15:53 -07:00
Jason Penilla 0dd650dacb release: Version 2.0.7 2022-05-03 18:06:49 -07:00
Jason Penilla 624a97346d Dependency updates 2022-05-03 18:04:56 -07:00
Jason Penilla 3d4fdc1f53 Minor clean up 2022-05-03 18:04:37 -07:00
Jason Penilla 286f72f746 Dependency updates 2022-04-20 22:18:29 -07:00
Renovate Bot 0cc8d9a98d chore(deps): update dependency gradle to v7.4.2 2022-03-31 10:51:27 -07:00
Jason Penilla 80ae413c9d 2.0.7-SNAPSHOT 2022-03-12 12:03:08 -07:00
Jason Penilla 1a2ba16194 release: Version 2.0.6 2022-03-12 11:59:28 -07:00
Jason Penilla 8c0a9b6811 Move project metadata into gradle.properties 2022-03-12 11:59:06 -07:00
Jason Penilla 310e8e7e7a Update Adventure and remove no longer needed repo 2022-03-12 11:54:02 -07:00
Renovate Bot 45604e6bb3 chore(deps): update dependency gradle to v7.4.1 2022-03-09 10:38:19 -08:00
Jason Penilla ec8d81144b update license 2022-03-04 11:17:51 -07:00
Jason Penilla 48c1c09d79 bukkit: Use paperlib for version detection 2022-03-04 11:16:56 -07:00
Renovate Bot df89471fdd chore(deps): update actions/upload-artifact action to v3 2022-03-03 14:13:35 -07:00
Jason Penilla d2e0bba539 Update Adventure & Initial update for Minecraft 1.18.2 2022-03-02 22:35:46 -07:00
Renovate Bot e715f3bb57 chore(deps): update actions/checkout action to v3 2022-03-01 13:45:10 -07:00
Renovate Bot bd774480b3 chore(deps): update actions/setup-java action to v3 2022-02-27 23:10:53 -07:00
Jason Penilla d91ea43aa8 Build updates 2022-02-27 23:10:22 -07:00
Jason Penilla 3bf3796ce2 Build updates 2022-02-08 11:53:31 -07:00
Jason Penilla 34e819abf4 Update checker framework 2022-01-27 14:30:59 -07:00
Jason Penilla 799dd82b4f Update loom 2022-01-27 14:30:47 -07:00
Jason Penilla 67d4a12546 update actions 2022-01-11 00:25:40 -07:00
Jason Penilla 06543a2c45 dependency updates 2022-01-11 00:22:38 -07:00
Renovate Bot acf9056f5b chore(deps): update dependency gradle to v7.3.3 2021-12-22 15:17:13 -08:00
Jason Penilla ae3fefb54d 2.0.6-SNAPSHOT 2021-12-02 01:50:32 -08:00
Jason Penilla bcfe67fc6f release: Version 2.0.5 2021-12-02 01:39:21 -08:00
Jason Penilla 10775836cb Update gradle wrapper 2021-12-01 21:33:45 -08:00
Jason Penilla 3a07128bd0 Update adventure-platform 2021-12-01 21:10:22 -08:00
Jason Penilla 336d613274 velocity: Use new event api 2021-12-01 02:16:34 -08:00
Jason Penilla a742fd9b62 fabric: Use release adventure-platform 2021-12-01 01:38:51 -08:00
Jason Penilla 577a77951a fabric: Bump java target 2021-12-01 01:34:06 -08:00
Jason Penilla f8456bec5c fabric: Build against 1.18 release 2021-12-01 01:30:50 -08:00
Jason Penilla b086550eae bukkit: Test on 1.18 2021-12-01 01:30:19 -08:00
Jason Penilla f512ca6174 Update loom 2021-11-14 00:27:08 -08:00
Jason Penilla 82b3a35a9e Update gradle wrapper and dependencies 2021-11-09 15:46:08 -08:00
Jason Penilla 5f4e8efa45 Enable build cache 2021-10-13 23:51:52 -07:00
Jason Penilla 22a47511a2 Use minimotd instead of minimotd-sponge7 and minimotd-sponge8 for Sponge platform plugin ids. 2021-10-13 23:51:24 -07:00
Jason Penilla 972ac8fcc5 Update shadow, adventure, junit 2021-10-09 15:01:34 -07:00
Jason Penilla c7f2d5f33b Improve Sponge 8 legacy check 2021-09-26 12:45:23 -07:00
Jason Penilla 2bc4a4caac Update for MiniMessage changes 2021-09-26 12:10:48 -07:00
Jason Penilla 3577d67820 fabric: Require >=1.17 2021-09-26 11:26:45 -07:00
Jason Penilla 9392601232 Simplify Components#ofChildren 2021-09-26 11:04:56 -07:00
Jason Penilla e4071d390c Update dependencies 2021-09-17 21:55:27 -07:00
Jason Penilla c4ca735e8b build: Update Gradle wrapper to 7.2 2021-08-27 09:33:36 -07:00
Jason Penilla 42ccd182b0 build: Update plugin-yml and run-paper 2021-08-27 09:33:13 -07:00
Jason Penilla 99e7954612 Improve handling of malformed config files 2021-08-12 03:38:42 -07:00
Jason Penilla bcf2589eb0 2.0.5-SNAPSHOT 2021-08-10 15:46:53 -07:00
Jason Penilla fe41b21d9b release: Version 2.0.4 2021-08-10 15:40:03 -07:00
Jason Penilla cbbe201710 Minor clean up 2021-08-10 15:14:12 -07:00
Jason Penilla 30d58fc0f9 2.0.4-SNAPSHOT 2021-07-30 14:45:43 -07:00
Jason Penilla 067ec4ea65 Build and test against 1.17.1 2021-07-23 23:51:06 -07:00
Jason Penilla 22f805f4ab build: Update Gradle & Indra 2021-07-23 23:50:36 -07:00
Jason Penilla ed21f45573 fabric: Use quiet-fabric-loom 2021-07-23 23:50:36 -07:00
Jason Penilla 41b1fdffe3 sponge 8: Update for Sponge API changes 2021-07-23 23:50:36 -07:00
Jason Penilla 142f7a34f7 Remove final from virtualHostTestMode field
This was not meant to be final in the first place, however this also was causing the config to silently fail to deserialize.
2021-07-13 22:53:59 -07:00
Jason Penilla ed7fe3591b Update Velocity API dependency to 3.0.0 2021-07-06 02:34:09 -07:00
Jason Penilla fa67cd3538 release: Version 2.0.3 2021-06-24 16:09:19 -07:00
Jason Penilla 615fce3cd6 Update MiniMessage to 4.2.0-SNAPSHOT and Adventure to 4.8.1 2021-06-24 05:01:41 -07:00
Jason Penilla faccf19535 build: Update Run Paper to 1.0.3 2021-06-24 05:00:04 -07:00
Jason Penilla e50953c9fb Update Adventure to 4.8.0 2021-06-11 07:23:27 -07:00
Jason Penilla 5f2df1debd fabric: Update to 1.17 2021-06-08 13:30:56 -07:00
Jason Penilla 0c90ef0886 Fix typo in ConnectionMixin 2021-06-08 02:46:34 -07:00
Jason Penilla 9bfd73e862 Update Velocity API to 1.1.7 2021-06-08 02:46:21 -07:00
Jason Penilla ec74878a1b Appease checkstyle 2021-06-07 15:23:46 -07:00
Jason Penilla 502a775a41 velocity: Register listeners on ProxyInitializeEvent and make PingListener public 2021-06-07 15:22:21 -07:00
Jason Penilla 245596426e build: Update run-paper to 1.0.2 2021-06-06 17:09:54 -07:00
Jason Penilla 996fd0f7d2 bukkit: Specify command permission in plugin.yml 2021-06-04 21:26:56 -07:00
Jason Penilla 4713809a27 build: Tag all subproject versions with git hash when snapshot 2021-06-04 21:26:53 -07:00
Jason Penilla 259a1e784e Minor codestyle fixes 2021-06-04 21:18:16 -07:00
Jason Penilla 793d3d7736 Update README 2021-06-04 21:16:29 -07:00
Jason Penilla 49f86cc4ef build: Improve FileCopyTask up to date checking 2021-06-04 21:14:13 -07:00
Jason Penilla 6d70e82fbe build: Update blossom to 1.3.0 2021-06-04 21:13:11 -07:00
Jason Penilla ffe1f389e2 build: centralize dependency declarations and remove unnecessary explicit task dependencies 2021-06-02 17:28:35 -07:00
Jason Penilla 2c709d3dc7 Rename Bukkit module from 'spigot' to 'bukkit'
Update build scripts to use convention plugins

Clean up command handling

Refactor ping handlers to use a response object
2021-05-29 22:27:27 -07:00
Jason Penilla 5fe30bf8f9 Update checkstyle config 2021-05-29 21:26:59 -07:00
Jason Penilla 196e6d8f00 Fix indent on checkstyle.xml 2021-05-29 21:26:58 -07:00
jmp 1465423927 Fix #62 2021-05-18 23:39:45 -07:00
jmp 4b61e91220 build: Update Gradle to 7.0.2, Indra to 2.0.4, polyglot-version-catalogs to 5.0.0 2021-05-14 18:52:38 -07:00
jmp 09c590c873 build: Update Indra to 2.0.3 and Gradle to 7.0.1 2021-05-11 01:30:24 -07:00
jmp 57f3de39a2 Update Indra and switch from buildSrc to build-logic included build 2021-05-09 19:37:14 -07:00
jmp f472736b32 Update GH Actions workflow 2021-05-09 02:45:26 -07:00
jmp 27fbefdd9c Add virtual host testing mode
Will print virtual host debug info to console on each ping when enabled. Intended to aid in configuration of the virtual host configs feature.

Also bump a couple of dependencies
2021-05-09 02:39:25 -07:00
jmp 454439a10c sponge8: Update for plugin-spi changes 2021-05-06 22:17:04 -07:00
jmp eebe13ae06 Fix MiniMessage shading 2021-04-20 18:59:19 -07:00
jmp 8b36863244 Build script improvements
- Use version catalog for plugin versions (except shadow in buildSrc)
- Don't shade annotations that we don't need at runtime
- Organize relocations
2021-04-20 18:56:19 -07:00
jmp 0b89b1fbf3 Use VERSION_CATALOGS and TYPESAFE_PROJECT_ACCESSORS Gradle feature previews and polyglot-version-catalogs 2021-04-14 19:27:50 -07:00
jmp 34ece94cbb Update GitHub Actions setup-java to v2 2021-04-12 14:38:48 -07:00
Renovate Bot 880757cd09 chore(deps): update dependency org.spongepowered.gradle.plugin:org.spongepowered.gradle.plugin.gradle.plugin to v1.0.3 2021-04-10 21:28:24 -07:00
jmp dbcbb9e48e Update Gradle to 7.0 2021-04-09 17:41:28 -07:00
jmp 9f31ba4406 Bump version to 2.0.3-SNAPSHOT 2021-04-08 23:31:27 -07:00
111 changed files with 4356 additions and 1939 deletions

No files matched your search

+272 -230
View File
@@ -1,245 +1,287 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE module PUBLIC "-//Checkstyle//DTD Checkstyle Configuration 1.3//EN" "https://checkstyle.org/dtds/configuration_1_3.dtd">
<!-- This file is modified from KyoriPowered/adventure's checkstyle.xml -->
<module name="Checker">
<property name="charset" value="UTF-8"/>
<property name="fileExtensions" value="java, properties, xml"/>
<property name="severity" value="error"/>
<property name="charset" value="UTF-8"/>
<property name="fileExtensions" value="java, properties, xml"/>
<property name="severity" value="error"/>
<!-- https://checkstyle.org/config_filefilters.html#BeforeExecutionExclusionFileFilter -->
<module name="BeforeExecutionExclusionFileFilter">
<property name="fileNamePattern" value="module\-info\.java$"/>
<!-- https://checkstyle.org/config_filefilters.html#BeforeExecutionExclusionFileFilter -->
<module name="BeforeExecutionExclusionFileFilter">
<property name="fileNamePattern" value="module\-info\.java$"/>
</module>
<!-- https://checkstyle.org/config_whitespace.html#FileTabCharacter -->
<module name="FileTabCharacter">
<property name="eachLine" value="true"/>
</module>
<!-- https://checkstyle.org/config_misc.html#NewlineAtEndOfFile -->
<module name="NewlineAtEndOfFile"/>
<!-- https://checkstyle.org/config_filters.html#SuppressionFilter -->
<module name="SuppressionFilter">
<property name="file" value="${configDirectory}/suppressions.xml"/>
</module>
<!-- https://checkstyle.org/config_filters.html#SuppressWarningsFilter -->
<module name="SuppressWarningsFilter"/>
<!-- https://checkstyle.org/config_filters.html#SuppressWithPlainTextCommentFilter -->
<module name="SuppressWithPlainTextCommentFilter"/>
<module name="TreeWalker">
<!-- https://checkstyle.org/config_misc.html#ArrayTypeStyle -->
<module name="ArrayTypeStyle"/>
<!-- https://checkstyle.org/config_javadoc.html#AtclauseOrder -->
<module name="AtclauseOrder">
<property name="violateExecutionOnNonTightHtml" value="true"/>
<property name="tagOrder" value="@author, @deprecated, @exception, @param, @return, @serial, @serialData, @serialField, @throws, @see, @since, @sinceMinecraft, @version"/>
</module>
<!-- https://checkstyle.org/config_whitespace.html#FileTabCharacter -->
<module name="FileTabCharacter">
<property name="eachLine" value="true"/>
<!-- https://checkstyle.org/config_imports.html#AvoidStarImport -->
<module name="AvoidStarImport"/>
<!-- https://checkstyle.org/config_misc.html#AvoidEscapedUnicodeCharacters -->
<module name="AvoidEscapedUnicodeCharacters">
<property name="allowByTailComment" value="true"/>
<property name="allowEscapesForControlCharacters" value="true"/>
<property name="allowNonPrintableEscapes" value="true"/>
</module>
<!-- https://checkstyle.org/config_misc.html#NewlineAtEndOfFile -->
<module name="NewlineAtEndOfFile"/>
<!-- https://checkstyle.org/config_misc.html#CommentsIndentation -->
<module name="CommentsIndentation"/>
<!-- https://checkstyle.org/config_filters.html#SuppressionFilter -->
<module name="SuppressionFilter">
<property name="file" value="${configDirectory}/suppressions.xml"/>
<!-- https://checkstyle.org/config_imports.html#CustomImportOrder -->
<module name="CustomImportOrder">
<property name="customImportOrderRules" value="THIRD_PARTY_PACKAGE###STATIC"/>
<property name="standardPackageRegExp" value="^$"/>
<property name="sortImportsInGroupAlphabetically" value="true"/>
</module>
<!-- https://checkstyle.org/config_filters.html#SuppressWarningsFilter -->
<module name="SuppressWarningsFilter"/>
<!-- https://checkstyle.org/config_whitespace.html#EmptyForInitializerPad -->
<module name="EmptyForInitializerPad"/>
<!-- https://checkstyle.org/config_filters.html#SuppressWithPlainTextCommentFilter -->
<module name="SuppressWithPlainTextCommentFilter"/>
<module name="TreeWalker">
<!-- https://checkstyle.org/config_misc.html#ArrayTypeStyle -->
<module name="ArrayTypeStyle"/>
<!-- https://checkstyle.org/config_javadoc.html#AtclauseOrder -->
<module name="AtclauseOrder">
<property name="violateExecutionOnNonTightHtml" value="true"/>
<property name="tagOrder" value="@author, @deprecated, @exception, @param, @return, @serial, @serialData, @serialField, @throws, @see, @since, @sinceMinecraft, @version"/>
</module>
<!-- https://checkstyle.org/config_imports.html#AvoidStarImport -->
<module name="AvoidStarImport"/>
<!-- https://checkstyle.org/config_misc.html#AvoidEscapedUnicodeCharacters -->
<module name="AvoidEscapedUnicodeCharacters">
<property name="allowByTailComment" value="true"/>
<property name="allowEscapesForControlCharacters" value="true"/>
<property name="allowNonPrintableEscapes" value="true"/>
</module>
<!-- https://checkstyle.org/config_misc.html#CommentsIndentation -->
<module name="CommentsIndentation"/>
<!-- https://checkstyle.org/config_whitespace.html#EmptyForInitializerPad -->
<module name="EmptyForInitializerPad"/>
<!-- https://checkstyle.org/config_whitespace.html#EmptyForIteratorPad -->
<module name="EmptyForIteratorPad"/>
<!-- https://checkstyle.org/config_whitespace.html#EmptyLineSeparator -->
<module name="EmptyLineSeparator">
<property name="allowMultipleEmptyLines" value="false"/>
<property name="allowMultipleEmptyLinesInsideClassMembers" value="false"/>
<property name="allowNoEmptyLineBetweenFields" value="true"/>
<property name="tokens" value="CLASS_DEF, CTOR_DEF, ENUM_DEF, IMPORT, INSTANCE_INIT, INTERFACE_DEF, METHOD_DEF, STATIC_IMPORT, STATIC_INIT, VARIABLE_DEF"/> <!-- remove PACKAGE_DEF, temporarily remove COMPACT_CTOR_DEF, RECORD_DEF -->
</module>
<!-- https://checkstyle.org/config_coding.html#FallThrough -->
<module name="FallThrough">
<property name="checkLastCaseGroup" value="true"/>
</module>
<!-- https://checkstyle.org/config_design.html#FinalClass -->
<module name="FinalClass"/>
<!-- https://checkstyle.org/config_coding.html#FinalLocalVariable -->
<module name="FinalLocalVariable">
<property name="tokens" value="PARAMETER_DEF, VARIABLE_DEF"/> <!-- add PARAMETER_DEF -->
<property name="validateEnhancedForLoopVariable" value="true"/>
</module>
<!-- https://checkstyle.org/config_whitespace.html#GenericWhitespace -->
<module name="GenericWhitespace"/>
<!-- https://checkstyle.org/config_design.html#HideUtilityClassConstructor -->
<module name="HideUtilityClassConstructor"/>
<!-- https://checkstyle.org/config_imports.html#IllegalImport -->
<module name="IllegalImport">
<property name="illegalPkgs" value="sun.misc, jdk"/>
</module>
<!-- https://checkstyle.org/config_coding.html#IllegalTokenText -->
<module name="IllegalTokenText">
<property name="format" value="($|[^\\])\\u00(09|0(a|A)|0(c|C)|0(d|D)|22|27|5(C|c))|\\(0(10|11|12|14|15|42|47)|134)"/>
<property name="message" value="Consider using special escape sequence instead of octal value or Unicode escaped value."/>
<property name="tokens" value="CHAR_LITERAL, STRING_LITERAL"/>
</module>
<!-- https://checkstyle.org/config_misc.html#Indentation -->
<module name="Indentation">
<property name="arrayInitIndent" value="2"/>
<property name="basicOffset" value="2"/>
<property name="braceAdjustment" value="0"/>
<property name="caseIndent" value="2"/>
<property name="lineWrappingIndentation" value="0"/>
<property name="throwsIndent" value="2"/>
</module>
<!-- https://checkstyle.org/config_javadoc.html#InvalidJavadocPosition -->
<module name="InvalidJavadocPosition"/>
<!-- https://checkstyle.org/config_javadoc.html#JavadocContentLocation -->
<module name="JavadocContentLocation"/>
<!-- https://checkstyle.org/config_javadoc.html#JavadocMissingWhitespaceAfterAsterisk -->
<module name="JavadocMissingWhitespaceAfterAsterisk"/>
<!-- https://checkstyle.org/config_javadoc.html#JavadocParagraph -->
<module name="JavadocParagraph"/>
<!-- https://checkstyle.org/config_javadoc.html#JavadocMissingWhitespaceAfterAsterisk -->
<module name="JavadocTagContinuationIndentation"/>
<!-- https://checkstyle.org/config_blocks.html#LeftCurly -->
<module name="LeftCurly"/>
<!-- https://checkstyle.org/config_naming.html#MethodName -->
<module name="MethodName">
<property name="format" value="^(?:(?:.{1,3})|(?:[gs]et[^A-Z].*)|(?:(?:[^gsA-Z]..|.[^e].|..[^t]).+))$"/>
</module>
<!-- https://checkstyle.org/config_whitespace.html#MethodParamPad -->
<module name="MethodParamPad"/>
<!-- https://checkstyle.org/config_coding.html#MultipleVariableDeclarations -->
<module name="MultipleVariableDeclarations"/>
<!-- https://checkstyle.org/config_coding.html#NoFinalizer -->
<module name="NoFinalizer"/>
<!-- https://checkstyle.org/config_whitespace.html#NoLineWrap -->
<module name="NoLineWrap"/>
<!-- https://checkstyle.org/config_javadoc.html#NonEmptyAtclauseDescription -->
<module name="NonEmptyAtclauseDescription"/>
<!-- https://checkstyle.org/config_whitespace.html#NoWhitespaceAfter -->
<module name="NoWhitespaceAfter">
<property name="allowLineBreaks" value="false"/>
</module>
<!-- https://checkstyle.org/config_whitespace.html#NoWhitespaceBefore -->
<module name="NoWhitespaceBefore">
<property name="allowLineBreaks" value="true"/>
<property name="tokens" value="COMMA, DOT, LABELED_STAT, METHOD_REF, POST_DEC, POST_INC, SEMI"/> <!-- remove ELLIPSIS -->
</module>
<!-- https://checkstyle.org/config_coding.html#OneStatementPerLine -->
<module name="OneStatementPerLine"/>
<!-- https://checkstyle.org/config_misc.html#OuterTypeFilename -->
<module name="OuterTypeFilename"/>
<!-- https://checkstyle.org/config_imports.html#RedundantImport -->
<module name="RedundantImport"/>
<!-- https://checkstyle.org/config_modifier.html#RedundantModifier -->
<module name="RedundantModifier">
<property name="tokens" value="ANNOTATION_FIELD_DEF, CLASS_DEF, CTOR_DEF, ENUM_DEF, INTERFACE_DEF, VARIABLE_DEF"/> <!-- remove METHOD_DEF and RESOURCE -->
</module>
<!-- https://checkstyle.org/config_javadoc.html#RequireEmptyLineBeforeBlockTagGroup -->
<module name="RequireEmptyLineBeforeBlockTagGroup"/>
<!-- https://checkstyle.org/config_coding.html#RequireThis -->
<module name="RequireThis">
<property name="validateOnlyOverlapping" value="false"/>
</module>
<!-- https://checkstyle.org/config_blocks.html#RightCurly -->
<module name="RightCurly">
<property name="id" value="RightCurlyAlone"/>
<property name="option" value="alone"/>
<property name="tokens" value="ANNOTATION_DEF, CLASS_DEF, CTOR_DEF, ENUM_DEF, INSTANCE_INIT, LITERAL_FOR, LITERAL_WHILE, METHOD_DEF, STATIC_INIT"/>
</module>
<module name="RightCurly">
<property name="id" value="RightCurlySame"/>
<property name="option" value="same"/>
<property name="tokens" value="LITERAL_CATCH, LITERAL_DO, LITERAL_ELSE, LITERAL_FINALLY, LITERAL_IF, LITERAL_TRY"/> <!-- add LITERAL_DO -->
</module>
<!-- https://checkstyle.org/config_whitespace.html#SeparatorWrap -->
<module name="SeparatorWrap">
<property name="id" value="SeparatorWrapEol"/>
<property name="option" value="eol"/>
<property name="tokens" value="COMMA, SEMI, ELLIPSIS, RBRACK, ARRAY_DECLARATOR, METHOD_REF"/>
</module>
<module name="SeparatorWrap">
<property name="id" value="SeparatorWrapNl"/>
<property name="option" value="nl"/>
<property name="tokens" value="DOT, AT"/>
</module>
<!-- https://checkstyle.org/config_coding.html#SimplifyBooleanExpression -->
<module name="SimplifyBooleanExpression"/>
<!-- https://checkstyle.org/config_coding.html#SimplifyBooleanReturn -->
<module name="SimplifyBooleanReturn"/>
<!-- https://checkstyle.org/config_whitespace.html#SingleSpaceSeparator -->
<module name="SingleSpaceSeparator">
<property name="validateComments" value="true"/>
</module>
<!-- https://checkstyle.org/config_javadoc.html#SummaryJavadoc -->
<module name="SummaryJavadoc"/>
<!-- https://checkstyle.org/config_annotation.html#SuppressWarningsHolder -->
<module name="SuppressWarningsHolder"/>
<!-- https://checkstyle.org/config_whitespace.html#TypecastParenPad -->
<module name="TypecastParenPad"/>
<!-- https://checkstyle.org/config_coding.html#UnnecessaryParentheses -->
<module name="UnnecessaryParentheses"/>
<!-- https://checkstyle.org/config_imports.html#UnusedImports -->
<module name="UnusedImports"/>
<!-- https://checkstyle.org/config_whitespace.html#WhitespaceAfter -->
<module name="WhitespaceAfter">
<property name="tokens" value="COMMA, SEMI, TYPECAST, LITERAL_IF, LITERAL_ELSE, LITERAL_WHILE, LITERAL_DO, LITERAL_FOR, DO_WHILE"/>
</module>
<!--
#####################
#### third-party ####
#####################
-->
<!-- https://checkstyle.org/config_whitespace.html#EmptyForIteratorPad -->
<module name="EmptyForIteratorPad"/>
<!-- https://checkstyle.org/config_whitespace.html#EmptyLineSeparator -->
<module name="EmptyLineSeparator">
<property name="allowMultipleEmptyLines" value="false"/>
<property name="allowMultipleEmptyLinesInsideClassMembers" value="false"/>
<property name="allowNoEmptyLineBetweenFields" value="true"/>
<property name="tokens" value="CLASS_DEF, CTOR_DEF, ENUM_DEF, IMPORT, INSTANCE_INIT, INTERFACE_DEF, METHOD_DEF, STATIC_IMPORT, STATIC_INIT, VARIABLE_DEF"/> <!-- remove PACKAGE_DEF, temporarily remove COMPACT_CTOR_DEF, RECORD_DEF -->
</module>
<!-- https://checkstyle.org/config_coding.html#FallThrough -->
<module name="FallThrough">
<property name="checkLastCaseGroup" value="true"/>
</module>
<!-- https://checkstyle.org/config_design.html#FinalClass -->
<module name="FinalClass"/>
<!-- https://checkstyle.org/config_coding.html#FinalLocalVariable -->
<module name="FinalLocalVariable">
<property name="tokens" value="PARAMETER_DEF, VARIABLE_DEF"/> <!-- add PARAMETER_DEF -->
<property name="validateEnhancedForLoopVariable" value="true"/>
</module>
<!-- https://checkstyle.org/config_whitespace.html#GenericWhitespace -->
<module name="GenericWhitespace"/>
<!-- https://checkstyle.org/config_design.html#HideUtilityClassConstructor -->
<module name="HideUtilityClassConstructor"/>
<!-- https://checkstyle.org/config_imports.html#IllegalImport -->
<module name="IllegalImport">
<property name="illegalPkgs" value="sun, jdk, com.sun"/>
</module>
<!-- https://checkstyle.org/config_coding.html#IllegalTokenText -->
<module name="IllegalTokenText">
<property name="format" value="($|[^\\])\\u00(09|0(a|A)|0(c|C)|0(d|D)|22|27|5(C|c))|\\(0(10|11|12|14|15|42|47)|134)"/>
<property name="message" value="Consider using special escape sequence instead of octal value or Unicode escaped value."/>
<property name="tokens" value="CHAR_LITERAL, STRING_LITERAL"/>
</module>
<!-- https://checkstyle.org/config_misc.html#Indentation -->
<module name="Indentation">
<property name="arrayInitIndent" value="2"/>
<property name="basicOffset" value="2"/>
<property name="braceAdjustment" value="0"/>
<property name="caseIndent" value="2"/>
<property name="lineWrappingIndentation" value="0"/>
<property name="throwsIndent" value="2"/>
</module>
<!-- https://checkstyle.org/config_javadoc.html#InvalidJavadocPosition -->
<module name="InvalidJavadocPosition"/>
<!-- https://checkstyle.org/config_javadoc.html#JavadocContentLocation -->
<module name="JavadocContentLocation"/>
<!-- https://checkstyle.org/config_javadoc.html#JavadocMissingWhitespaceAfterAsterisk -->
<module name="JavadocMissingWhitespaceAfterAsterisk"/>
<!-- https://checkstyle.org/config_javadoc.html#JavadocParagraph -->
<module name="JavadocParagraph"/>
<!-- https://checkstyle.org/config_javadoc.html#JavadocMissingWhitespaceAfterAsterisk -->
<module name="JavadocTagContinuationIndentation"/>
<!-- https://checkstyle.org/config_blocks.html#LeftCurly -->
<module name="LeftCurly"/>
<!-- https://checkstyle.org/config_naming.html#MethodName -->
<module name="MethodName">
<property name="format" value="^(?:(?:.{1,3})|(?:[gs]et[^A-Z].*)|(?:(?:[^gsA-Z]..|.[^e].|..[^t]).+))$"/>
</module>
<!-- https://checkstyle.org/config_whitespace.html#MethodParamPad -->
<module name="MethodParamPad"/>
<!-- https://checkstyle.org/config_javadoc.html#MissingJavadocMethod -->
<!-- <module name="MissingJavadocMethod"/> -->
<!-- https://checkstyle.org/config_javadoc.html#MissingJavadocPackage -->
<!-- <module name="MissingJavadocPackage"/> -->
<!-- https://checkstyle.org/config_javadoc.html#MissingJavadocType -->
<!-- <module name="MissingJavadocType"/> -->
<!-- https://checkstyle.org/config_coding.html#MultipleVariableDeclarations -->
<module name="MultipleVariableDeclarations"/>
<!-- https://checkstyle.org/config_coding.html#NoFinalizer -->
<module name="NoFinalizer"/>
<!-- https://checkstyle.org/config_whitespace.html#NoLineWrap -->
<module name="NoLineWrap"/>
<!-- https://checkstyle.org/config_javadoc.html#NonEmptyAtclauseDescription -->
<module name="NonEmptyAtclauseDescription"/>
<!-- https://checkstyle.org/config_whitespace.html#NoWhitespaceAfter -->
<module name="NoWhitespaceAfter">
<property name="allowLineBreaks" value="false"/>
</module>
<!-- https://checkstyle.org/config_whitespace.html#NoWhitespaceBefore -->
<module name="NoWhitespaceBefore">
<property name="allowLineBreaks" value="true"/>
<property name="tokens" value="COMMA, DOT, LABELED_STAT, METHOD_REF, POST_DEC, POST_INC, SEMI"/> <!-- remove ELLIPSIS -->
</module>
<!-- https://checkstyle.org/config_coding.html#OneStatementPerLine -->
<module name="OneStatementPerLine"/>
<!-- https://checkstyle.org/config_misc.html#OuterTypeFilename -->
<module name="OuterTypeFilename"/>
<!-- https://checkstyle.org/config_imports.html#RedundantImport -->
<module name="RedundantImport"/>
<!-- https://checkstyle.org/config_modifier.html#RedundantModifier -->
<module name="RedundantModifier">
<property name="tokens" value="ANNOTATION_FIELD_DEF, CLASS_DEF, CTOR_DEF, ENUM_DEF, INTERFACE_DEF, VARIABLE_DEF"/> <!-- remove METHOD_DEF and RESOURCE -->
</module>
<!-- https://checkstyle.org/config_javadoc.html#RequireEmptyLineBeforeBlockTagGroup -->
<module name="RequireEmptyLineBeforeBlockTagGroup"/>
<!-- https://checkstyle.org/config_coding.html#RequireThis -->
<module name="RequireThis">
<property name="validateOnlyOverlapping" value="false"/>
</module>
<!-- https://checkstyle.org/config_blocks.html#RightCurly -->
<module name="RightCurly">
<property name="id" value="RightCurlyAlone"/>
<property name="option" value="alone"/>
<property name="tokens" value="ANNOTATION_DEF, CLASS_DEF, CTOR_DEF, ENUM_DEF, INSTANCE_INIT, LITERAL_FOR, LITERAL_WHILE, METHOD_DEF, STATIC_INIT"/>
</module>
<module name="RightCurly">
<property name="id" value="RightCurlySame"/>
<property name="option" value="same"/>
<property name="tokens" value="LITERAL_CATCH, LITERAL_DO, LITERAL_ELSE, LITERAL_FINALLY, LITERAL_IF, LITERAL_TRY"/> <!-- add LITERAL_DO -->
</module>
<!-- https://checkstyle.org/config_whitespace.html#SeparatorWrap -->
<module name="SeparatorWrap">
<property name="id" value="SeparatorWrapEol"/>
<property name="option" value="eol"/>
<property name="tokens" value="COMMA, SEMI, ELLIPSIS, RBRACK, ARRAY_DECLARATOR, METHOD_REF"/>
</module>
<module name="SeparatorWrap">
<property name="id" value="SeparatorWrapNl"/>
<property name="option" value="nl"/>
<property name="tokens" value="DOT, AT"/>
</module>
<!-- https://checkstyle.org/config_coding.html#SimplifyBooleanExpression -->
<module name="SimplifyBooleanExpression"/>
<!-- https://checkstyle.org/config_coding.html#SimplifyBooleanReturn -->
<module name="SimplifyBooleanReturn"/>
<!-- https://checkstyle.org/config_whitespace.html#SingleSpaceSeparator -->
<module name="SingleSpaceSeparator">
<property name="validateComments" value="true"/>
</module>
<!-- https://checkstyle.org/config_javadoc.html#SummaryJavadoc -->
<module name="SummaryJavadoc"/>
<!-- https://checkstyle.org/config_annotation.html#SuppressWarningsHolder -->
<module name="SuppressWarningsHolder"/>
<!-- https://checkstyle.org/config_whitespace.html#TypecastParenPad -->
<module name="TypecastParenPad"/>
<!-- https://checkstyle.org/config_coding.html#UnnecessaryParentheses -->
<module name="UnnecessaryParentheses"/>
<!-- https://checkstyle.org/config_imports.html#UnusedImports -->
<module name="UnusedImports"/>
<!-- https://checkstyle.org/config_whitespace.html#WhitespaceAfter -->
<module name="WhitespaceAfter">
<property name="tokens" value="COMMA, SEMI, TYPECAST, LITERAL_IF, LITERAL_ELSE, LITERAL_WHILE, LITERAL_DO, LITERAL_FOR, DO_WHILE"/>
</module>
<!-- https://checkstyle.org/config_whitespace.html#WhitespaceAround -->
<module name="WhitespaceAround">
<property name="ignoreEnhancedForColon" value="false"/>
<property name="allowEmptyTypes" value="true"/>
<property name="allowEmptyLambdas" value="true"/>
<property name="tokens" value="ASSIGN, COLON, BAND, BAND_ASSIGN, BOR, BOR_ASSIGN, BSR, BSR_ASSIGN, BXOR, BXOR_ASSIGN, COLON, DIV, DIV_ASSIGN, EQUAL, GE, GT, LAND, LCURLY, LE, LOR, LT, MINUS, MINUS_ASSIGN, MOD, MOD_ASSIGN, NOT_EQUAL, PLUS, PLUS_ASSIGN, QUESTION, RCURLY, SL, SLIST, SL_ASSIGN, SR, SR_ASSIGN, STAR, STAR_ASSIGN, LITERAL_ASSERT, TYPE_EXTENSION_AND"/>
</module>
<!--
#####################
#### third-party ####
#####################
-->
<!-- https://checkstyle.org/config_javadoc.html#WriteTag -->
<!-- https://gitlab.com/stellardrift/stylecheck/-/blob/dev/src/main/java/ca/stellardrift/stylecheck/FilteringWriteTag.java -->
<!--
<module name="FilteringWriteTag">
<property name="tag" value="@since\s"/>
<property name="tagFormat" value="\d\.\d+\.\d+"/>
<property name="tagSeverity" value="ignore"/>
<property name="minimumScope" value="public"/>
<property name="tokens" value="INTERFACE_DEF, CLASS_DEF, ENUM_DEF, ANNOTATION_DEF, RECORD_DEF, METHOD_DEF, CTOR_DEF, ANNOTATION_FIELD_DEF, RECORD_DEF, COMPACT_CTOR_DEF"/>
</module>
-->
<!-- https://gitlab.com/stellardrift/stylecheck/-/blob/dev/src/main/java/ca/stellardrift/stylecheck/StatementNoWhitespaceAfter.java -->
<!--
<module name="StatementNoWhitespaceAfter">
<property name="tokens" value="LITERAL_CATCH, LITERAL_FOR, LITERAL_IF, LITERAL_TRY, LITERAL_WHILE"/>
</module>
-->
</module>
</module>
+1
View File
@@ -6,3 +6,4 @@ indent_size = 2
indent_style = space
insert_final_newline = true
max_line_length = off
ij_java_imports_layout=*,|,$*
+20
View File
@@ -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: 21
-26
View File
@@ -1,26 +0,0 @@
name: MiniMOTD
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Build with Gradle
run: ./gradlew clean build
- run: mkdir staging && cp build/libs/*.jar staging
- uses: actions/upload-artifact@v2
with:
name: Package
path: staging
+3 -1
View File
@@ -116,4 +116,6 @@ run/
.gradle
# Ignore Gradle build output directory
build
build/
.kotlin/
+14 -6
View File
@@ -1,5 +1,6 @@
![MiniMOTD logo](https://i.imgur.com/CXWwjOJ.png)
![MiniMOTD logo](resources/minimotd-logo.png)
[![build](https://img.shields.io/github/checks-status/jpenilla/MiniMOTD/master?label=build)](https://github.com/jpenilla/MiniMOTD/actions) [![latest release](https://img.shields.io/github/v/release/jpenilla/MiniMOTD)](https://github.com/jpenilla/MiniMOTD/releases)
### MiniMOTD is a basic server list MOTD plugin/mod for Minecraft servers and proxies
@@ -9,21 +10,28 @@
- 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
![demo motd image](https://i.ibb.co/1LRCV8b/minimotd-demo.png)
![demo motd image](resources/minimotd-demo.png)
+2 -100
View File
@@ -1,102 +1,4 @@
import com.adarshr.gradle.testlogger.TestLoggerPlugin
import com.adarshr.gradle.testlogger.theme.ThemeType
import com.github.jengelman.gradle.plugins.shadow.ShadowPlugin
import net.kyori.indra.IndraCheckstylePlugin
import net.kyori.indra.IndraLicenseHeaderPlugin
import net.kyori.indra.IndraPlugin
import net.kyori.indra.sonatypeSnapshots
import java.io.ByteArrayOutputStream
plugins {
`java-library`
id("net.kyori.indra") version "1.3.1"
id("com.github.johnrengelman.shadow") version "6.1.0"
id("com.adarshr.test-logger") version "3.0.0"
id("net.kyori.blossom") version "1.2.0" apply false
id("minimotd.build-logic")
alias(libs.plugins.run.paper) apply false
}
allprojects {
group = "xyz.jpenilla"
version = "2.0.2+${lastCommitHash()}-SNAPSHOT"
description = "Use MiniMessage text formatting in the server list MOTD."
}
ext["url"] = "https://github.com/jpenilla/MiniMOTD"
subprojects {
apply<JavaLibraryPlugin>()
apply<ShadowPlugin>()
apply<IndraPlugin>()
apply<IndraCheckstylePlugin>()
apply<IndraLicenseHeaderPlugin>()
apply<TestLoggerPlugin>()
repositories {
//mavenLocal()
mavenCentral()
sonatypeSnapshots()
jcenter()
maven("https://papermc.io/repo/repository/maven-public/")
maven("https://nexus.velocitypowered.com/repository/maven-public/")
maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots/")
maven("https://oss.sonatype.org/content/groups/public/")
maven("https://repo.spongepowered.org/repository/maven-public/")
maven("https://repo.jpenilla.xyz/snapshots/")
maven("https://jitpack.io")
maven("https://repo.codemc.org/repository/maven-public")
}
dependencies {
testImplementation("org.junit.jupiter", "junit-jupiter-engine", "5.7.0")
}
indra {
javaVersions {
testWith(8, 11, 15)
target.set(8)
}
github("jpenilla", "MiniMOTD") {
issues = true
}
mitLicense()
}
testlogger {
theme = ThemeType.MOCHA_PARALLEL
showPassed = false
}
tasks {
shadowJar {
minimize()
exclude("META-INF/versions/**")
if (!project.name.contains("fabric")) {
archiveClassifier.set("")
doLast {
val output = outputs.files.singleFile
output.copyTo(rootProject.buildDir.resolve("libs").resolve(output.name), overwrite = true)
}
}
}
withType<JavaCompile> {
options.compilerArgs.add("-Xlint:-processing")
}
withType<Jar> {
onlyIf { archiveClassifier.get() != "javadoc" }
}
withType<Javadoc> {
onlyIf { false }
}
}
}
tasks.withType<Jar> {
onlyIf { false }
}
fun lastCommitHash(): String = ByteArrayOutputStream().apply {
exec {
commandLine = listOf("git", "rev-parse", "--short", "HEAD")
standardOutput = this@apply
}
}.toString(Charsets.UTF_8.name()).trim()
-32
View File
@@ -1,32 +0,0 @@
plugins {
id("net.minecrell.plugin-yml.bungee") version "0.3.0"
}
dependencies {
implementation(project(":minimotd-common"))
implementation("org.slf4j", "slf4j-jdk14","1.7.30")
implementation("net.kyori", "adventure-platform-bungeecord", "4.0.0-SNAPSHOT")
implementation("org.bstats", "bstats-bungeecord", "2.2.1")
compileOnly("io.github.waterfallmc", "waterfall-api", "1.16-R0.4-SNAPSHOT")
}
tasks {
shadowJar {
relocate("org.slf4j", "xyz.jpenilla.minimotd.lib.slf4j")
relocate("io.leangen.geantyref", "xyz.jpenilla.minimotd.lib.io.leangen.geantyref")
relocate("org.spongepowered.configurate", "xyz.jpenilla.minimotd.lib.spongepowered.configurate")
relocate("com.typesafe.config", "xyz.jpenilla.minimotd.lib.typesafe.config")
relocate("net.kyori", "xyz.jpenilla.minimotd.lib.kyori")
relocate("org.checkerframework", "xyz.jpenilla.minimotd.lib.checkerframework")
relocate("org.bstats", "xyz.jpenilla.minimotd.lib.bstats")
}
build {
dependsOn(shadowJar)
}
}
bungee {
name = rootProject.name
main = "xyz.jpenilla.minimotd.bungee.MiniMOTDPlugin"
author = "jmp"
}
+24 -19
View File
@@ -1,34 +1,39 @@
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" }
}
}
dependencies {
api("org.slf4j", "slf4j-api", "1.7.30")
api("org.spongepowered", "configurate-hocon", "4.1.0-SNAPSHOT")
platform(api("net.kyori", "adventure-bom", "4.7.0"))
api("net.kyori", "adventure-text-serializer-gson") {
api(libs.configurateHocon)
api(platform(libs.adventureBom))
api(libs.adventureApi)
api(libs.adventureTextSerializerPlain)
api(libs.adventureTextSerializerGson) {
exclude("com.google.code.gson", "gson")
}
api("net.kyori", "adventure-text-minimessage", "4.1.0-SNAPSHOT")
compileOnlyApi("com.google.code.gson", "gson", "2.8.0")
testImplementation("com.google.code.gson", "gson", "2.8.0")
compileOnlyApi("com.google.guava", "guava", "21.0")
api(libs.minimessage)
compileOnlyApi(libs.slf4jApi)
compileOnlyApi(libs.jspecify)
compileOnlyApi(libs.gson)
testImplementation(libs.gson)
compileOnly(libs.brigadier)
compileOnly(libs.miniplaceholders)
}
blossom {
fun replaceTokens(file: String, vararg tokens: Pair<String, String>) = tokens.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)
}
}
replaceTokens(
"src/main/java/xyz/jpenilla/minimotd/common/Constants.java",
"PLUGIN_NAME" to rootProject.name,
"PLUGIN_VERSION" to project.version.toString(),
"PLUGIN_WEBSITE" to rootProject.ext["url"].toString()
)
}
@@ -1,7 +1,7 @@
/*
* This file is part of MiniMOTD, licensed under the MIT License.
*
* Copyright (c) 2021 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,12 +34,15 @@ 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 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;
}
public static final int MINECRAFT_1_16_PROTOCOL_VERSION = 735;
public static final Component COMMAND_PREFIX = MiniMessage.get().parse("<white>[</white><gradient:#0047AB:#ADD8E6>" + PluginMetadata.NAME + "<white>]</white>");
public static final Component COMMAND_PREFIX = MiniMessage.miniMessage().deserialize("<white>[</white><gradient:#0047AB:#ADD8E6>" + PluginMetadata.NAME + "</gradient><white>]</white>");
}
@@ -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;
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.jspecify.annotations.NullMarked;
import static net.kyori.adventure.text.Component.space;
import static net.kyori.adventure.text.Component.text;
import static net.kyori.adventure.text.LinearComponents.linear;
import static net.kyori.adventure.text.event.ClickEvent.openUrl;
import static net.kyori.adventure.text.event.ClickEvent.runCommand;
import static net.kyori.adventure.text.format.NamedTextColor.GRAY;
import static net.kyori.adventure.text.format.NamedTextColor.GREEN;
import static net.kyori.adventure.text.format.NamedTextColor.RED;
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;
@NullMarked
public final class CommandHandler {
private final MiniMOTD<?> miniMOTD;
public CommandHandler(final MiniMOTD<?> miniMOTD) {
this.miniMOTD = miniMOTD;
}
public void about(final Audience audience) {
final Component header = miniMessage("<gradient:white:#007FFF:white> ").decorate(STRIKETHROUGH);
Stream.of(
header,
text()
.hoverEvent(miniMessage("<rainbow>click me!"))
.clickEvent(openUrl(Constants.PluginMetadata.WEBSITE))
.content(Constants.PluginMetadata.NAME)
.color(WHITE)
.append(space())
.append(miniMessage("<gradient:#0047AB:#007FFF>" + Constants.PluginMetadata.VERSION))
.build(),
text()
.content("By ")
.color(GRAY)
.append(text("jmp", WHITE))
.build(),
header
).forEach(audience::sendMessage);
}
public void reload(final Audience audience) {
try {
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(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)
));
return;
}
audience.sendMessage(Component.textOfChildren(
Constants.COMMAND_PREFIX,
space(),
text("Done reloading configuration.", GREEN)
));
}
public void help(final Audience audience) {
Stream.of(
linear(Constants.COMMAND_PREFIX, space(), text(Constants.PluginMetadata.NAME + " command help", WHITE)),
commandInfo("minimotd about", "Show information about MiniMOTD"),
commandInfo("minimotd reload", "Reload MiniMOTD configuration files"),
commandInfo("minimotd help", "Show this help menu")
).forEach(audience::sendMessage);
}
private static Component commandInfo(final String command, final String description) {
return text()
.content(" - ")
.color(GRAY)
.append(text('/', WHITE))
.append(text(command, color(0x007FFF)))
.append(text(':'))
.append(space())
.append(text(description, WHITE))
.hoverEvent(text()
.content("Click to execute '")
.color(GRAY)
.append(text("/" + command, WHITE))
.append(text("'"))
.build())
.clickEvent(runCommand("/" + command))
.build();
}
private static Component miniMessage(final String message) {
return MiniMessage.miniMessage().deserialize(message);
}
@FunctionalInterface
public interface Executor {
void execute(Audience audience);
}
}
@@ -1,124 +0,0 @@
/*
* This file is part of MiniMOTD, licensed under the MIT License.
*
* Copyright (c) 2021 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 net.kyori.adventure.audience.Audience;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
import net.kyori.adventure.text.minimessage.MiniMessage;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.stream.Stream;
import static net.kyori.adventure.text.Component.space;
import static net.kyori.adventure.text.Component.text;
import static net.kyori.adventure.text.LinearComponents.linear;
import static net.kyori.adventure.text.event.ClickEvent.openUrl;
import static net.kyori.adventure.text.event.ClickEvent.runCommand;
import static net.kyori.adventure.text.format.NamedTextColor.GRAY;
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;
public final class CommandHandlerFactory {
private final MiniMOTD<?> miniMOTD;
public CommandHandlerFactory(final @NonNull MiniMOTD<?> miniMOTD) {
this.miniMOTD = miniMOTD;
}
public @NonNull CommandHandler about() {
return audience -> {
final Component header = miniMessage("<gradient:white:#007FFF:white> ").decorate(STRIKETHROUGH);
Stream.of(
header,
text()
.hoverEvent(miniMessage("<rainbow>click me!"))
.clickEvent(openUrl(Constants.PluginMetadata.WEBSITE))
.content(Constants.PluginMetadata.NAME)
.color(WHITE)
.append(space())
.append(miniMessage("<gradient:#0047AB:#007FFF>" + Constants.PluginMetadata.VERSION))
.build(),
text()
.content("By ")
.color(GRAY)
.append(text("jmp", WHITE))
.build(),
header
).forEach(audience::sendMessage);
};
}
public @NonNull CommandHandler reload() {
return audience -> {
this.miniMOTD.reload();
audience.sendMessage(linear(Constants.COMMAND_PREFIX, space(), text("Done reloading configuration.", NamedTextColor.GREEN)));
};
}
public @NonNull CommandHandler help() {
return audience -> Stream.of(
linear(Constants.COMMAND_PREFIX, space(), text(Constants.PluginMetadata.NAME + " command help", WHITE)),
commandInfo("/minimotd about", "Show information about MiniMOTD"),
commandInfo("/minimotd reload", "Reload MiniMOTD configuration files"),
commandInfo("/minimotd help", "Show this help menu")
).forEach(audience::sendMessage);
}
private static @NonNull Component commandInfo(final @NonNull String command, final @NonNull String description) {
return text()
.content(" - ")
.color(GRAY)
.append(
text(command, color(0x007FFF))
.replaceText(config -> {
config.matchLiteral("/");
config.replacement(builder -> builder.color(WHITE));
})
)
.append(text(':', GRAY))
.append(space())
.append(text(description, WHITE))
.hoverEvent(
text()
.content("Click to execute '")
.color(GRAY)
.append(text(command, WHITE))
.append(text("'"))
.build()
)
.clickEvent(runCommand(command))
.build();
}
private static @NonNull Component miniMessage(final @NonNull String message) {
return MiniMessage.get().parse(message);
}
@FunctionalInterface
public interface CommandHandler {
void execute(@NonNull Audience audience);
}
}
@@ -1,7 +1,7 @@
/*
* This file is part of MiniMOTD, licensed under the MIT License.
*
* Copyright (c) 2021 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,23 +23,22 @@
*/
package xyz.jpenilla.minimotd.common;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.File;
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.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;
@@ -55,27 +54,27 @@ public final class IconManager<I> {
if (!Files.exists(this.iconsDirectory)) {
Files.createDirectories(this.iconsDirectory);
}
Files.list(this.iconsDirectory)
.map(Path::toFile)
.filter(File::isFile)
.filter(file -> file.getName().endsWith(".png"))
.forEach(this::loadIcon);
try (final Stream<Path> stream = Files.list(this.iconsDirectory)) {
stream.filter(Files::isRegularFile)
.filter(file -> file.getFileName().toString().endsWith(".png"))
.forEach(this::loadIcon);
}
} catch (final IOException ex) {
throw new RuntimeException("Exception loading server icons", ex);
}
}
private void loadIcon(final @NonNull File iconFile) {
try {
final BufferedImage bufferedImage = ImageIO.read(iconFile);
private void loadIcon(final @NonNull Path iconFile) {
try (final InputStream inputStream = Files.newInputStream(iconFile)) {
final BufferedImage bufferedImage = ImageIO.read(inputStream);
if (bufferedImage.getHeight() == 64 && bufferedImage.getWidth() == 64) {
final I newIcon = this.miniMOTD.platform().loadIcon(bufferedImage);
this.icons.put(iconFile.getName().split("\\.")[0], newIcon);
this.icons.put(iconFile.getFileName().toString().split("\\.")[0], newIcon);
} else {
this.miniMOTD.logger().warn("Could not load " + iconFile.getName() + ": image must be 64x64px");
this.miniMOTD.logger().warn("Could not load {}: image must be 64x64px", iconFile.getFileName());
}
} catch (final Exception ex) {
this.miniMOTD.logger().warn("Could not load " + iconFile.getName() + ": invalid image file", ex);
this.miniMOTD.logger().warn("Could not load {}: invalid image file", iconFile.getFileName(), ex);
}
}
@@ -95,5 +94,4 @@ public final class IconManager<I> {
return this.icons.get(iconString);
}
}
@@ -1,7 +1,7 @@
/*
* This file is part of MiniMOTD, licensed under the MIT License.
*
* Copyright (c) 2021 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,78 +23,106 @@
*/
package xyz.jpenilla.minimotd.common;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TextComponent;
import net.kyori.adventure.text.minimessage.MiniMessage;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.slf4j.Logger;
import xyz.jpenilla.minimotd.common.config.ConfigManager;
import xyz.jpenilla.minimotd.common.config.MiniMOTDConfig;
import java.nio.file.Path;
import java.util.concurrent.ThreadLocalRandom;
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.jspecify.annotations.NullMarked;
import org.slf4j.Logger;
import xyz.jpenilla.minimotd.common.config.ConfigManager;
import xyz.jpenilla.minimotd.common.config.MOTDConfig;
import xyz.jpenilla.minimotd.common.util.MiniPlaceholdersUtil;
import static net.kyori.adventure.text.Component.newline;
@NullMarked
public final class MiniMOTD<I> {
private final ConfigManager configManager;
private final IconManager<I> iconManager;
private final MiniMOTDPlatform<I> platform;
public MiniMOTD(final @NonNull MiniMOTDPlatform<I> platform) {
public MiniMOTD(final MiniMOTDPlatform<I> platform) {
this.platform = platform;
this.iconManager = new IconManager<>(this);
this.configManager = new ConfigManager(this);
this.configManager.loadConfigs();
try {
this.iconManager = new IconManager<>(this);
this.configManager = new ConfigManager(this);
this.configManager.loadConfigs();
} catch (final Exception ex) {
throw new IllegalStateException("Failed to load MiniMOTD. Ensure your config files are without errors.", ex);
}
}
public @NonNull MiniMOTDPlatform<I> platform() {
public MiniMOTDPlatform<I> platform() {
return this.platform;
}
public final @NonNull Path dataDirectory() {
public Path dataDirectory() {
return this.platform.dataDirectory();
}
public final @NonNull IconManager<I> iconManager() {
public IconManager<I> iconManager() {
return this.iconManager;
}
public final @NonNull Logger logger() {
public Logger logger() {
return this.platform.logger();
}
public final @NonNull ConfigManager configManager() {
public ConfigManager configManager() {
return this.configManager;
}
public final @NonNull MOTDIconPair<I> createMOTD(final @NonNull MiniMOTDConfig config, final int onlinePlayers, final int maxPlayers) {
I icon = null;
Component motd = null;
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());
String iconString = null;
if (config.motdEnabled()) {
if (config.motds().size() == 0) {
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);
motd = TextComponent.ofChildren(
MiniMessage.get().parse(replacePlayerCount(motdConfig.line1(), onlinePlayers, maxPlayers)),
Component.newline(),
MiniMessage.get().parse(replacePlayerCount(motdConfig.line2(), onlinePlayers, maxPlayers))
final MOTDConfig.MOTD motdConfig = config.motds().get(index);
final Component motd = Component.textOfChildren(
parse(motdConfig.line1(), count),
newline(),
parse(motdConfig.line2(), count)
);
response.motd(motd);
iconString = motdConfig.icon();
}
if (config.iconEnabled()) {
icon = this.iconManager().icon(iconString);
response.icon(this.iconManager().icon(iconString));
}
return new MOTDIconPair<>(icon, motd);
return response.build();
}
private static @NonNull String replacePlayerCount(final @NonNull String input, final int onlinePlayers, final int maxPlayers) {
return input.replace("{onlinePlayers}", String.valueOf(onlinePlayers))
.replace("{maxPlayers}", String.valueOf(maxPlayers));
private static Component parse(final String input, final PingResponse.PlayerCount count) {
final String online = Integer.toString(count.onlinePlayers());
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),
MiniPlaceholdersUtil.tagResolver()
)
);
}
public void reload() {
private static String replacePlayerCount(final String input, final String online, final String max) {
return input.replace("{onlinePlayers}", online).replace("{maxPlayers}", max);
}
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) 2021 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,11 +23,10 @@
*/
package xyz.jpenilla.minimotd.common;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.slf4j.Logger;
import java.awt.image.BufferedImage;
import java.nio.file.Path;
import org.jspecify.annotations.NonNull;
import org.slf4j.Logger;
public interface MiniMOTDPlatform<I> {
@NonNull Path dataDirectory();
@@ -0,0 +1,221 @@
/*
* 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.function.Consumer;
import java.util.function.IntConsumer;
import net.kyori.adventure.text.Component;
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;
import static java.util.Objects.requireNonNull;
@NullMarked
public final class PingResponse<I> {
private final @Nullable I icon;
private final @Nullable Component motd;
private final PlayerCount playerCount;
private final boolean hidePlayerCount;
private final boolean disablePlayerListHover;
private PingResponse(
final @Nullable I icon,
final @Nullable Component motd,
final PlayerCount playerCount,
final boolean hidePlayerCount,
final boolean disablePlayerListHover
) {
this.icon = icon;
this.motd = motd;
this.playerCount = playerCount;
this.hidePlayerCount = hidePlayerCount;
this.disablePlayerListHover = disablePlayerListHover;
}
public @Nullable I icon() {
return this.icon;
}
/**
* If {@link #icon()} is non-null, the provided {@link Consumer} will be called using
* its return value. If {@link #icon()} is {@code null}, do nothing.
*
* @param iconConsumer icon consumer
*/
public void icon(final Consumer<I> iconConsumer) {
if (this.icon != null) {
iconConsumer.accept(this.icon);
}
}
public @Nullable Component motd() {
return this.motd;
}
/**
* If {@link #motd()} is non-null, the provided {@link Consumer} will be called using
* its return value. If {@link #motd()} is {@code null}, do nothing.
*
* @param motdConsumer motd consumer
*/
public void motd(final Consumer<Component> motdConsumer) {
if (this.motd != null) {
motdConsumer.accept(this.motd);
}
}
public PlayerCount playerCount() {
return this.playerCount;
}
public boolean hidePlayerCount() {
return this.hidePlayerCount;
}
public boolean disablePlayerListHover() {
return this.disablePlayerListHover;
}
public Builder<I> toBuilder() {
return new BuilderImpl<>(
this.motd,
this.icon,
this.playerCount,
this.hidePlayerCount,
this.disablePlayerListHover
);
}
public static <I> Builder<I> builder() {
return new BuilderImpl<>();
}
public static final class PlayerCount {
private final int onlinePlayers;
private final int maxPlayers;
private PlayerCount(final int onlinePlayers, final int maxPlayers) {
this.onlinePlayers = onlinePlayers;
this.maxPlayers = maxPlayers;
}
public int onlinePlayers() {
return this.onlinePlayers;
}
public int maxPlayers() {
return this.maxPlayers;
}
public void applyCount(final IntConsumer onlinePlayersSetter, final IntConsumer maxPlayersSetter) {
onlinePlayersSetter.accept(this.onlinePlayers);
maxPlayersSetter.accept(this.maxPlayers);
}
public static PlayerCount playerCount(final int onlinePlayers, final int maxPlayers) {
return new PlayerCount(onlinePlayers, maxPlayers);
}
}
public interface Builder<I> {
Builder<I> motd(@Nullable Component motd);
Builder<I> icon(@Nullable I icon);
Builder<I> playerCount(PlayerCount playerCount);
Builder<I> hidePlayerCount(boolean hidePlayerCount);
Builder<I> disablePlayerListHover(boolean disablePlayerListHover);
PingResponse<I> build();
}
private static final class BuilderImpl<I> implements Builder<I> {
private @Nullable Component motd;
private @Nullable I icon;
private @Nullable PlayerCount playerCount;
private boolean hidePlayerCount = false;
private boolean disablePlayerListHover = false;
private BuilderImpl() {
}
private BuilderImpl(
final @Nullable Component motd,
final @Nullable I icon,
final @Nullable PlayerCount playerCount,
final boolean hidePlayerCount,
final boolean disablePlayerListHover
) {
this.motd = motd;
this.icon = icon;
this.playerCount = playerCount;
this.hidePlayerCount = hidePlayerCount;
this.disablePlayerListHover = disablePlayerListHover;
}
@Override
public Builder<I> motd(final @Nullable Component motd) {
this.motd = motd;
return this;
}
@Override
public Builder<I> icon(final @Nullable I icon) {
this.icon = icon;
return this;
}
@Override
public Builder<I> playerCount(final PlayerCount playerCount) {
this.playerCount = playerCount;
return this;
}
@Override
public Builder<I> hidePlayerCount(final boolean hidePlayerCount) {
this.hidePlayerCount = hidePlayerCount;
return this;
}
@Override
public Builder<I> disablePlayerListHover(final boolean disablePlayerListHover) {
this.disablePlayerListHover = disablePlayerListHover;
return this;
}
@Override
public PingResponse<I> build() {
requireNonNull(this.playerCount, "playerCount");
return new PingResponse<>(
this.icon,
this.motd,
this.playerCount,
this.hidePlayerCount,
this.disablePlayerListHover
);
}
}
}
@@ -1,7 +1,7 @@
/*
* This file is part of MiniMOTD, licensed under the MIT License.
*
* Copyright (c) 2021 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,13 @@
*/
package xyz.jpenilla.minimotd.common.config;
import org.checkerframework.checker.nullness.qual.NonNull;
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.jspecify.annotations.NullMarked;
import org.spongepowered.configurate.CommentedConfigurationNode;
import org.spongepowered.configurate.ConfigurateException;
import org.spongepowered.configurate.ConfigurationOptions;
@@ -32,30 +38,31 @@ import org.spongepowered.configurate.objectmapping.ObjectMapper;
import org.spongepowered.configurate.serialize.SerializationException;
import org.spongepowered.configurate.serialize.TypeSerializerCollection;
import java.nio.file.Path;
import java.util.function.UnaryOperator;
@NullMarked
public final class ConfigLoader<C> {
private static final TypeSerializerCollection SERIALIZERS;
static {
SERIALIZERS = TypeSerializerCollection.defaults()
.childBuilder()
SERIALIZERS = TypeSerializerCollection.builder()
.register(PlayerCountModifier.serializer())
.build();
}
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 ConfigurationOptions options
final Class<C> configClass,
final Path configPath,
final UnaryOperator<ConfigurationOptions> optionsModifier
) {
this.postProcess = this.findPostProcessors(configClass);
this.loader = HoconConfigurationLoader.builder()
.path(configPath)
.defaultOptions(options.serializers(SERIALIZERS))
.defaultOptions(options ->
optionsModifier.apply(options)
.serializers(builder -> builder.registerAll(SERIALIZERS)))
.build();
try {
this.mapper = ObjectMapper.factory().get(configClass);
@@ -67,27 +74,41 @@ public final class ConfigLoader<C> {
}
}
public ConfigLoader(
final @NonNull Class<C> configClass,
final @NonNull Path configPath,
final @NonNull UnaryOperator<ConfigurationOptions> options
) {
this(configClass, configPath, options.apply(ConfigurationOptions.defaults()));
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, ConfigurationOptions.defaults());
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) 2021 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,36 +23,41 @@
*/
package xyz.jpenilla.minimotd.common.config;
import com.google.common.collect.ImmutableList;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.spongepowered.configurate.ConfigurateException;
import xyz.jpenilla.minimotd.common.MiniMOTD;
import xyz.jpenilla.minimotd.common.util.Pair;
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.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;
import static xyz.jpenilla.minimotd.common.util.Pair.pair;
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")
);
@@ -83,15 +88,18 @@ public final class ConfigManager {
Files.createDirectories(extraConfigsDir);
this.createDefaultExtraConfigs(extraConfigsDir);
}
for (final Path path : Files.list(extraConfigsDir).collect(Collectors.toList())) {
if (path.toString().endsWith(".conf")) {
try (final Stream<Path> stream = Files.list(extraConfigsDir)) {
for (final Path path : stream.collect(Collectors.toList())) {
if (!path.toString().endsWith(".conf")) {
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);
}
@@ -102,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.of(extraConfigsDir.resolve("skyblock.conf"), new MiniMOTDConfig.MOTD("<green><italic>Skyblock</green>", "<bold><rainbow>MiniMOTD Skyblock Server")),
Pair.of(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");
}
@@ -129,15 +137,31 @@ public final class ConfigManager {
return this.pluginSettings;
}
public @NonNull MiniMOTDConfig resolveConfig(final @NonNull String name) {
public @NonNull MOTDConfig resolveConfig(final @Nullable InetSocketAddress address) {
if (address == null) {
return this.mainConfig();
}
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: '{}'", address.getHostString(), address.getPort(), configString == null ? "default" : configString);
}
if (configString == null) {
return this.mainConfig();
}
return this.resolveConfig(configString);
}
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;
}
this.miniMOTD.logger().warn(String.format("Invalid extra-config name: '%s', falling back to main.conf", name));
this.miniMOTD.logger().warn("Invalid extra-config name: '{}', falling back to main.conf", name);
return this.mainConfig();
}
@@ -1,7 +1,7 @@
/*
* This file is part of MiniMOTD, licensed under the MIT License.
*
* Copyright (c) 2021 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,31 +23,33 @@
*/
package xyz.jpenilla.minimotd.common.config;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.spongepowered.configurate.objectmapping.ConfigSerializable;
import org.spongepowered.configurate.objectmapping.meta.Comment;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.jspecify.annotations.NonNull;
import org.spongepowered.configurate.objectmapping.ConfigSerializable;
import org.spongepowered.configurate.objectmapping.meta.Comment;
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<>();
@@ -121,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 {
@@ -155,6 +162,10 @@ public final class MiniMOTDConfig {
}
public List<String> targetServers() {
return this.playerCountSettings.servers;
}
public boolean iconEnabled() {
return this.iconEnabled;
}
@@ -196,30 +207,12 @@ public final class MiniMOTDConfig {
return maxPlayers;
}
public @NonNull PlayerCount modifyPlayerCount(final int onlinePlayers, final int maxPlayers) {
public PingResponse.@NonNull PlayerCount modifyPlayerCount(final int onlinePlayers, final int maxPlayers) {
final int online = this.calculateOnlinePlayers(onlinePlayers);
final int max = this.calculateMaxPlayers(online, maxPlayers);
if (!this.playerCountSettings.allowExceedingMaximum) {
return new PlayerCount(Math.min(online, max), max);
}
return new PlayerCount(online, max);
}
public static final class PlayerCount {
private final int onlinePlayers;
private final int maxPlayers;
private PlayerCount(final int onlinePlayers, final int maxPlayers) {
this.onlinePlayers = onlinePlayers;
this.maxPlayers = maxPlayers;
}
public int onlinePlayers() {
return this.onlinePlayers;
}
public int maxPlayers() {
return this.maxPlayers;
return playerCount(Math.min(online, max), max);
}
return playerCount(online, max);
}
}
@@ -1,7 +1,7 @@
/*
* This file is part of MiniMOTD, licensed under the MIT License.
*
* Copyright (c) 2021 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,15 +23,14 @@
*/
package xyz.jpenilla.minimotd.common.config;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.spongepowered.configurate.serialize.ScalarSerializer;
import org.spongepowered.configurate.serialize.SerializationException;
import xyz.jpenilla.minimotd.common.util.Int2IntFunction;
import java.lang.reflect.Type;
import java.util.concurrent.ThreadLocalRandom;
import java.util.function.Predicate;
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;
public final class PlayerCountModifier implements Int2IntFunction {
private final String input;
@@ -47,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) 2021 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,14 +23,15 @@
*/
package xyz.jpenilla.minimotd.common.config;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.LinkedHashMap;
import java.util.Locale;
import java.util.Map;
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;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
@ConfigSerializable
public final class PluginSettings {
@@ -50,20 +51,97 @@ 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.")
private boolean virtualHostTestMode = false;
public boolean virtualHostTestMode() {
return this.virtualHostTestMode;
}
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);
});
}
}
public @NonNull ProxySettings proxySettings() {
return this.proxySettings;
}
public boolean updateChecker() {
return this.updateChecker;
}
public @NonNull Optional<String> configStringForHost(final @NonNull String host) {
return Optional.ofNullable(this.proxySettings.virtualHostConfigs.get(host));
@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)));
}
}
@@ -1,7 +1,7 @@
/*
* This file is part of MiniMOTD, licensed under the MIT License.
*
* Copyright (c) 2021 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,11 +21,11 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package xyz.jpenilla.minimotd.common;
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) 2021 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) 2021 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,9 @@
*/
package xyz.jpenilla.minimotd.common.util;
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;
public final class Pair<L, R> {
private final L left;
@@ -63,7 +62,7 @@ public final class Pair<L, R> {
return Objects.hash(this.left, this.right);
}
public static <L, R> @NonNull Pair<L, R> of(final @NonNull L left, final @NonNull R right) {
public static <L, R> @NonNull Pair<L, R> pair(final @NonNull L left, final @NonNull R right) {
return new Pair<>(left, right);
}
}
@@ -1,7 +1,7 @@
/*
* This file is part of MiniMOTD, licensed under the MIT License.
*
* Copyright (c) 2021 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,32 +21,34 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package xyz.jpenilla.minimotd.common;
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 org.checkerframework.checker.nullness.qual.NonNull;
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.jspecify.annotations.NonNull;
import xyz.jpenilla.minimotd.common.Constants;
public final class UpdateChecker {
private final JsonParser parser = new JsonParser();
public @NonNull List<String> checkVersion() {
final JsonArray result;
try {
result = this.parser.parse(new InputStreamReader(new URL("https://api.github.com/repos/jpenilla/MiniMOTD/releases").openStream(), Charsets.UTF_8)).getAsJsonArray();
} catch (final IOException exception) {
return Collections.singletonList("Cannot look for updates: " + exception.getMessage());
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, StandardCharsets.UTF_8)) {
result = this.parser.parse(reader).getAsJsonArray();
} catch (final IOException ex) {
return Collections.singletonList("Cannot look for updates: " + ex.getMessage());
}
final Map<String, String> versionMap = new LinkedHashMap<>();
result.forEach(element -> versionMap.put(element.getAsJsonObject().get("tag_name").getAsString(), element.getAsJsonObject().get("html_url").getAsString()));
@@ -56,17 +58,17 @@ public final class UpdateChecker {
return Collections.emptyList(); // Up to date, do nothing
}
if (currentVersion.contains("SNAPSHOT")) {
return ImmutableList.of(
"This server is running a development build of MiniMOTD! (" + currentVersion + ")",
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));
}
}
@@ -1,7 +1,7 @@
/*
* This file is part of MiniMOTD, licensed under the MIT License.
*
* Copyright (c) 2021 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,34 +21,34 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package xyz.jpenilla.minimotd.common;
package xyz.jpenilla.minimotd.common.util;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TextComponent;
import net.kyori.adventure.text.format.TextColor;
import org.junit.jupiter.api.Test;
import static net.kyori.adventure.text.Component.text;
import static net.kyori.adventure.text.format.NamedTextColor.nearestTo;
import static net.kyori.adventure.text.format.TextColor.color;
import static org.junit.jupiter.api.Assertions.assertEquals;
class ComponentColorDownsamplerTest {
private static final TextColor GREEN = TextColor.color(0x04E762);
private static final TextColor ORANGE_YELLOW = TextColor.color(0xF5B700);
private static final TextColor PINK = TextColor.color(0xDC0073);
private static final TextColor BLUE = TextColor.color(0x008BF8);
private static final TextColor LIME_GREEN = TextColor.color(0x89FC00);
private static final TextColor GREEN = color(0x04E762);
private static final TextColor ORANGE_YELLOW = color(0xF5B700);
private static final TextColor PINK = color(0xDC0073);
private static final TextColor BLUE = color(0x008BF8);
private static final TextColor LIME_GREEN = color(0x89FC00);
@Test
void testColorDownsampling() {
final Component fullColor = TextComponent.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 = TextComponent.ofChildren(
final Component expectedDownsample = Component.textOfChildren(
text("Green ", nearestTo(GREEN)),
text("Orange Yellow ", nearestTo(ORANGE_YELLOW)),
text("Pink ", nearestTo(PINK)),
@@ -57,9 +57,6 @@ class ComponentColorDownsamplerTest {
);
final Component actualDownsample = ComponentColorDownsampler.downsampler().downsample(fullColor);
assertEquals(
expectedDownsample,
actualDownsample
);
assertEquals(expectedDownsample, actualDownsample);
}
}
-55
View File
@@ -1,55 +0,0 @@
plugins {
id("fabric-loom") version "0.6-SNAPSHOT"
}
val shade: Configuration by configurations.creating
val minecraftVersion = "1.16.5"
dependencies {
minecraft("com.mojang", "minecraft", minecraftVersion)
mappings(minecraft.officialMojangMappings())
modImplementation("net.fabricmc", "fabric-loader", "0.11.1")
modImplementation("net.fabricmc.fabric-api", "fabric-api", "0.31.0+1.16")
shade(implementation(project(":minimotd-common")) {
exclude("net.kyori")
exclude("org.slf4j")
})
modImplementation(include("net.kyori", "adventure-platform-fabric", "4.0.0-SNAPSHOT"))
implementation(include("net.kyori", "adventure-text-minimessage", "4.1.0-SNAPSHOT"))
implementation(include("org.slf4j", "slf4j-api", "1.7.30"))
implementation(include("org.apache.logging.log4j", "log4j-slf4j-impl", "2.8.1"))
}
tasks {
shadowJar {
configurations = listOf(shade)
relocate("io.leangen.geantyref", "xyz.jpenilla.minimotd.lib.io.leangen.geantyref")
relocate("org.spongepowered.configurate", "xyz.jpenilla.minimotd.lib.spongepowered.configurate")
relocate("com.typesafe.config", "xyz.jpenilla.minimotd.lib.typesafe.config")
relocate("org.checkerframework", "xyz.jpenilla.minimotd.lib.checkerframework")
relocate("xyz.jpenilla.minimotd.common", "xyz.jpenilla.minimotd.lib.fabric.minimotd.common")
}
remapJar {
dependsOn(shadowJar)
input.set(shadowJar.get().outputs.files.singleFile)
archiveFileName.set("${project.name}-mc$minecraftVersion-${project.version}.jar")
destinationDirectory.set(rootProject.buildDir.resolve("libs"))
}
processResources {
filesMatching("fabric.mod.json") {
mapOf(
"{project.name}" to project.name,
"{rootProject.name}" to rootProject.name,
"{project.version}" to project.version.toString(),
"{project.description}" to project.description.toString(),
"{project.github_url}" to rootProject.ext["url"].toString()
).forEach { (k, v) ->
filter { it.replace(k, v) }
}
}
}
}
@@ -1,100 +0,0 @@
/*
* This file is part of MiniMOTD, licensed under the MIT License.
*
* Copyright (c) 2021 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.authlib.GameProfile;
import net.kyori.adventure.text.Component;
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.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
import xyz.jpenilla.minimotd.common.ComponentColorDownsampler;
import xyz.jpenilla.minimotd.common.Constants;
import xyz.jpenilla.minimotd.common.MOTDIconPair;
import xyz.jpenilla.minimotd.common.MiniMOTD;
import xyz.jpenilla.minimotd.common.config.MiniMOTDConfig;
import xyz.jpenilla.minimotd.common.config.MiniMOTDConfig.PlayerCount;
import xyz.jpenilla.minimotd.fabric.MiniMOTDFabric;
import xyz.jpenilla.minimotd.fabric.access.ConnectionAccess;
@Unique
@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());
final MiniMOTDFabric miniMOTDFabric = MiniMOTDFabric.get();
final MiniMOTD<String> miniMOTD = miniMOTDFabric.miniMOTD();
final MiniMOTDConfig config = miniMOTD.configManager().mainConfig();
final PlayerCount count = config.modifyPlayerCount(minecraftServer.getPlayerCount(), vanillaStatus.getPlayers().getMaxPlayers());
final int onlinePlayers = count.onlinePlayers();
final int maxPlayers = count.maxPlayers();
final MOTDIconPair<String> pair = miniMOTD.createMOTD(config, onlinePlayers, maxPlayers);
final Component motdComponent = pair.motd();
if (motdComponent != null) {
if (((ConnectionAccess) this.connection).protocolVersion() >= Constants.MINECRAFT_1_16_PROTOCOL_VERSION) {
modifiedStatus.setDescription(miniMOTDFabric.audiences().toNative(motdComponent));
} else {
modifiedStatus.setDescription(miniMOTDFabric.audiences().toNative(
ComponentColorDownsampler.downsampler().downsample(motdComponent)
));
}
}
final String favicon = pair.icon();
if (favicon != null) {
modifiedStatus.setFavicon(favicon);
}
if (!config.hidePlayerCount()) {
final GameProfile[] oldSample = vanillaStatus.getPlayers().getSample();
final ServerStatus.Players newPlayers = new ServerStatus.Players(maxPlayers, onlinePlayers);
if (config.disablePlayerListHover()) {
newPlayers.setSample(new GameProfile[]{});
} else {
newPlayers.setSample(oldSample);
}
modifiedStatus.setPlayers(newPlayers);
}
return modifiedStatus;
}
}
-30
View File
@@ -1,30 +0,0 @@
{
"schemaVersion": 1,
"id": "{project.name}",
"version": "{project.version}",
"name": "{rootProject.name}",
"description": "{project.description}",
"authors": [
"jmp"
],
"contact": {
"homepage": "{project.github_url}",
"sources": "{project.github_url}",
"issues": "{project.github_url}/issues"
},
"license": "MIT",
"environment": "server",
"entrypoints": {
"main": [
"xyz.jpenilla.minimotd.fabric.MiniMOTDFabric"
]
},
"mixins": [
"minimotd-fabric.mixins.json"
],
"depends": {
"fabricloader": ">=0.11.1",
"fabric": ">=0.31.0",
"minecraft": "1.16.x"
}
}
+7 -2
View File
@@ -1,2 +1,7 @@
org.gradle.jvmargs=-Xmx1G
#org.gradle.parallel=true
group=xyz.jpenilla
version=2.2.2
description=Use MiniMessage text formatting in the server list MOTD.
org.gradle.caching=true
org.gradle.jvmargs=-Xmx2G
org.gradle.parallel=true
+18
View File
@@ -0,0 +1,18 @@
plugins {
`kotlin-dsl`
}
repositories {
gradlePluginPortal()
}
dependencies {
implementation(libs.indraCommon)
implementation(libs.indraLicenser)
implementation(libs.shadow)
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))
}
+9
View File
@@ -0,0 +1,9 @@
rootProject.name = "build-logic"
dependencyResolutionManagement {
versionCatalogs {
create("libs") {
from(files("../libs.versions.toml"))
}
}
}
@@ -0,0 +1,6 @@
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 = "minimotd"
}
@@ -0,0 +1,19 @@
import org.gradle.api.DefaultTask
import org.gradle.api.file.RegularFileProperty
import org.gradle.api.tasks.InputFile
import org.gradle.api.tasks.OutputFile
import org.gradle.api.tasks.TaskAction
abstract class FileCopyTask : DefaultTask() {
@get:InputFile
abstract val fileToCopy: RegularFileProperty
@get:OutputFile
abstract val destination: RegularFileProperty
@TaskAction
fun copyFile() {
destination.get().asFile.parentFile.mkdirs()
fileToCopy.get().asFile.copyTo(destination.get().asFile, overwrite = true)
}
}
@@ -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,53 @@
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",
)
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(21)
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")
}
@@ -0,0 +1,18 @@
plugins {
id("minimotd.platform-conventions")
id("com.gradleup.shadow")
}
tasks {
jar {
archiveClassifier.set("unshaded")
}
shadowJar {
archiveClassifier.set(null as String?)
commonConfiguration()
}
}
extensions.configure<MiniMOTDPlatformExtension> {
jarTask.set(tasks.shadowJar)
}
@@ -0,0 +1,27 @@
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.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 {
exclude(dependency("org.checkerframework:checker-qual"))
exclude(dependency("org.jetbrains:annotations")) // transitive dep from adventure
}
}
fun ShadowJar.configureForNativeAdventurePlatform() {
dependencies {
exclude { dependency -> dependency.moduleGroup == "net.kyori" }
}
}
+91
View File
@@ -0,0 +1,91 @@
[versions]
run-task = "3.0.2"
resource-factory = "1.3.1"
mod-publish-plugin = "1.0.0"
hangarPublishPlugin = "0.1.4"
indra = "4.0.0"
shadow = "9.2.2"
adventure = "4.25.0"
adventurePlatform = "4.4.1"
adventurePlatformMod = "6.8.0"
configurate = "4.2.0"
slf4j = "1.7.36"
gson = "2.8.0"
bstats = "3.1.0"
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.139.5+1.21.11"
fabricLoader = "0.18.2"
minecraft = "1.21.11"
spongeApi7 = "7.2.0"
velocityApi = "3.4.0-SNAPSHOT"
neoforge = "21.11.6-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.1.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.0.1"
# 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]
Binary file not shown.
+3 -1
View File
@@ -1,5 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Vendored
+179 -116
View File
@@ -1,7 +1,7 @@
#!/usr/bin/env sh
#!/bin/sh
#
# Copyright 2015 the original author or 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,81 +15,114 @@
# 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 UN*X
##
#
# Gradle start up script for POSIX generated by Gradle.
#
# Important for running:
#
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
# noncompliant, but you have some other compliant shell such as ksh or
# bash, then to run this script, type that shell name before the whole
# command line, like:
#
# ksh Gradle
#
# Busybox and similar reduced shells will NOT work, because this script
# requires all of these POSIX shell features:
# * functions;
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
# * compound commands having a testable exit status, especially «case»;
# * various built-in commands including «command», «set», and «ulimit».
#
# Important for patching:
#
# (2) This script targets any POSIX shell, so it avoids extensions provided
# by Bash, Ksh, etc; in particular arrays are avoided.
#
# The "traditional" practice of packing multiple parameters into a
# space-separated string is a well documented source of bugs and security
# problems, so this is (mostly) avoided, by progressively accumulating
# options in "$@", and eventually passing that to Java.
#
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
# see the in-line comments for details.
#
# There are tweaks for specific operating systems such as AIX, CygWin,
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/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/.
#
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
app_path=$0
# Need this for daisy-chained symlinks.
while
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
[ -h "$app_path" ]
do
ls=$( ls -ld "$app_path" )
link=${ls#*' -> '}
case $link in #(
/*) app_path=$link ;; #(
*) app_path=$APP_HOME$link ;;
esac
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$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"'
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# 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"
MAX_FD=maximum
warn () {
echo "$*"
}
} >&2
die () {
echo
echo "$*"
echo
exit 1
}
} >&2
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
case "$( uname )" in #(
CYGWIN* ) cygwin=true ;; #(
Darwin* ) darwin=true ;; #(
MSYS* | MINGW* ) msys=true ;; #(
NONSTOP* ) nonstop=true ;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
JAVACMD=$JAVA_HOME/jre/sh/java
else
JAVACMD="$JAVA_HOME/bin/java"
JAVACMD=$JAVA_HOME/bin/java
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
@@ -98,88 +131,118 @@ Please set the JAVA_HOME variable in your environment to match the
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.
JAVACMD=java
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" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin or MSYS, switch paths to Windows format before running java
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=`expr $i + 1`
done
case $i in
0) set -- ;;
1) set -- "$args0" ;;
2) set -- "$args0" "$args1" ;;
3) set -- "$args0" "$args1" "$args2" ;;
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
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
fi
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=`save "$@"`
# Collect all arguments for the java command, stacking in reverse order:
# * args from the command line
# * the main class name
# * -classpath
# * -D...appname settings
# * --module-path (only if needed)
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
# For Cygwin or MSYS, switch paths to Windows format before running java
if "$cygwin" || "$msys" ; then
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
JAVACMD=$( cygpath --unix "$JAVACMD" )
# Now convert the arguments - kludge to limit ourselves to /bin/sh
for arg do
if
case $arg in #(
-*) false ;; # don't mess with options #(
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
[ -e "$t" ] ;; #(
*) false ;;
esac
then
arg=$( cygpath --path --ignore --mixed "$arg" )
fi
# Roll the args list around exactly as many times as the number of
# args, so each arg winds up back in the position where it started, but
# possibly modified.
#
# NB: a `for` loop captures its iteration list before it begins, so
# changing the positional parameters here affects neither the number of
# iterations, nor the values presented in `arg`.
shift # remove old arg
set -- "$@" "$arg" # push replacement arg
done
fi
# 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" \
-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.
#
# In Bash we could simply go:
#
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
# set -- "${ARGS[@]}" "$@"
#
# but POSIX shell has neither arrays nor command substitution, so instead we
# post-process each arg (as a line of input to sed) to backslash-escape any
# character that might be a shell metacharacter, then use eval to reverse
# that process (while maintaining the separation between arguments), and wrap
# the whole thing up as a single "set" statement.
#
# This will of course break if any of these variables contains a newline or
# an unmatched quote.
#
eval "set -- $(
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
xargs -n1 |
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
tr '\n' ' '
)" '"$@"'
exec "$JAVACMD" "$@"
Vendored
+22 -18
View File
@@ -13,8 +13,10 @@
@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
@@ -25,7 +27,8 @@
if "%OS%"=="Windows_NT" setlocal
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,13 +43,13 @@ 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
@@ -56,32 +59,33 @@ 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
: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 %*
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
if %ERRORLEVEL% equ 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
set EXIT_CODE=%ERRORLEVEL%
if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%
:mainEnd
if "%OS%"=="Windows_NT" endlocal
+1 -1
View File
@@ -1,6 +1,6 @@
MIT License
Copyright (c) 2021 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
View File
@@ -1,6 +1,6 @@
This file is part of MiniMOTD, licensed under the MIT License.
Copyright (c) 2021 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
+52
View File
@@ -0,0 +1,52 @@
plugins {
id("minimotd.shadow-platform")
alias(libs.plugins.run.paper)
alias(libs.plugins.resource.factory.bukkit)
}
dependencies {
implementation(projects.minimotdCommon)
implementation(libs.slf4jJdk14)
implementation(libs.adventurePlatformBukkit)
implementation(libs.bstatsBukkit)
implementation(libs.paperlib)
compileOnly(libs.paperApiLegacy)
}
tasks {
runServer {
minecraftVersion("1.21.7")
}
shadowJar {
commonRelocation("org.slf4j")
commonRelocation("io.leangen.geantyref")
commonRelocation("net.kyori")
commonRelocation("org.bstats")
commonRelocation("io.papermc.lib")
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
}
@@ -1,7 +1,7 @@
/*
* This file is part of MiniMOTD, licensed under the MIT License.
*
* Copyright (c) 2021 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,37 +21,37 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package xyz.jpenilla.minimotd.spigot;
package xyz.jpenilla.minimotd.bukkit;
import com.google.common.collect.ImmutableList;
import java.util.Collections;
import java.util.List;
import net.kyori.adventure.audience.Audience;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.event.ClickEvent;
import net.kyori.adventure.text.format.NamedTextColor;
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 xyz.jpenilla.minimotd.common.CommandHandlerFactory;
import org.jspecify.annotations.NonNull;
import xyz.jpenilla.minimotd.common.CommandHandler;
import java.util.Collections;
import java.util.List;
import static net.kyori.adventure.text.Component.text;
import static net.kyori.adventure.text.event.ClickEvent.runCommand;
import static net.kyori.adventure.text.format.NamedTextColor.RED;
public class SpigotCommand implements CommandExecutor, TabCompleter {
private final MiniMOTDPlugin plugin;
private final CommandHandlerFactory handlerFactory;
final class BukkitCommand implements CommandExecutor, TabCompleter {
private final MiniMOTDBukkit plugin;
private final CommandHandler handler;
public SpigotCommand(final @NonNull MiniMOTDPlugin plugin) {
BukkitCommand(final @NonNull MiniMOTDBukkit plugin) {
this.plugin = plugin;
this.handlerFactory = new CommandHandlerFactory(plugin.miniMOTD());
this.handler = new CommandHandler(plugin.miniMOTD());
}
@Override
public boolean onCommand(final @NonNull CommandSender sender, final @NonNull Command command, final @NonNull String label, final @NonNull String[] args) {
final Audience audience = this.plugin.audiences().sender(sender);
if (!sender.hasPermission("minimotd.admin")) {
audience.sendMessage(Component.text("No permission.", NamedTextColor.RED));
audience.sendMessage(text("No permission.", RED));
return true;
}
@@ -62,13 +62,13 @@ public class SpigotCommand implements CommandExecutor, TabCompleter {
switch (args[0]) {
case "about":
this.handlerFactory.about().execute(audience);
this.handler.about(audience);
return true;
case "help":
this.handlerFactory.help().execute(audience);
this.handler.help(audience);
return true;
case "reload":
this.handlerFactory.reload().execute(audience);
this.handler.reload(audience);
return true;
}
@@ -77,11 +77,9 @@ public class SpigotCommand implements CommandExecutor, TabCompleter {
}
private void onInvalidUse(final @NonNull Audience audience) {
audience.sendMessage(
Component.text("Invalid command usage. Use '/minimotd help' for a list of command provided by MiniMOTD.", NamedTextColor.RED)
.hoverEvent(Component.text("Click to execute '/minimotd help'"))
.clickEvent(ClickEvent.runCommand("/minimotd help"))
);
audience.sendMessage(text("Invalid command usage. Use '/minimotd help' for a list of command provided by MiniMOTD.", RED)
.hoverEvent(text("Click to execute '/minimotd help'"))
.clickEvent(runCommand("/minimotd help")));
}
private static final List<String> COMMANDS = ImmutableList.of("about", "reload", "help");
@@ -1,7 +1,7 @@
/*
* This file is part of MiniMOTD, licensed under the MIT License.
*
* Copyright (c) 2021 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,65 +21,86 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package xyz.jpenilla.minimotd.spigot;
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.bukkit.Bukkit;
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.UpdateChecker;
import xyz.jpenilla.minimotd.common.util.Nag;
import xyz.jpenilla.minimotd.common.util.UpdateChecker;
import java.awt.image.BufferedImage;
import java.nio.file.Path;
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;
private MiniMOTD<CachedServerIcon> miniMOTD;
private BukkitAudiences audiences;
private String serverPackageName;
private String serverApiVersion;
private int majorMinecraftVersion;
@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);
this.serverPackageName = this.getServer().getClass().getPackage().getName();
this.serverApiVersion = this.serverPackageName.substring(this.serverPackageName.lastIndexOf('.') + 1);
this.majorMinecraftVersion = Integer.parseInt(this.serverApiVersion.split("_")[1]);
if (PAPER_PING_EVENT_EXISTS) {
Bukkit.getPluginManager().registerEvents(new PaperPingListener(this, this.miniMOTD), this);
this.getServer().getPluginManager().registerEvents(new PaperPingListener(this.miniMOTD), this);
} else {
Bukkit.getPluginManager().registerEvents(new PingListener(this, this.miniMOTD), this);
if (this.majorMinecraftVersion >= 12) { // PaperServerListPingEvent was added in 1.12
this.getServer().getPluginManager().registerEvents(new PingListener(this.miniMOTD), this);
if (PaperLib.getMinecraftVersion() >= 12) { // PaperServerListPingEvent was added in 1.12
this.suggestPaper();
}
}
final PluginCommand command = this.getCommand("minimotd");
if (command != null) {
final SpigotCommand spigotCommand = new SpigotCommand(this);
command.setExecutor(spigotCommand);
command.setTabCompleter(spigotCommand);
final BukkitCommand bukkitCommand = new BukkitCommand(this);
command.setExecutor(bukkitCommand);
command.setTabCompleter(bukkitCommand);
}
final Metrics metrics = new Metrics(this, 8132);
metrics.addCustomChart(new SimplePie("variant", () -> "bukkit"));
if (this.miniMOTD.configManager().pluginSettings().updateChecker()) {
Bukkit.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));
}
}
}
@@ -99,11 +120,7 @@ public final class MiniMOTDPlugin extends JavaPlugin implements MiniMOTDPlatform
@Override
public @NonNull CachedServerIcon loadIcon(final @NonNull BufferedImage image) throws Exception {
return Bukkit.loadServerIcon(image);
}
public int majorMinecraftVersion() {
return this.majorMinecraftVersion;
return this.getServer().loadServerIcon(image);
}
public @NonNull BukkitAudiences audiences() {
@@ -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.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.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;
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;
PaperPingListener(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 || PaperLib.getMinecraftVersion() < 16) {
event.setMotd(LegacyComponentSerializer.legacySection().serialize(motd));
} else {
event.setMotd(this.unusualHexSerializer.serialize(motd));
}
});
response.icon(event::setServerIcon);
if (response.disablePlayerListHover()) {
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);
}
}
}
@@ -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.bukkit;
import io.papermc.lib.PaperLib;
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.server.ServerListPingEvent;
import org.bukkit.util.CachedServerIcon;
import org.jspecify.annotations.NonNull;
import xyz.jpenilla.minimotd.common.MiniMOTD;
import xyz.jpenilla.minimotd.common.PingResponse;
import xyz.jpenilla.minimotd.common.config.MOTDConfig;
public final class PingListener implements Listener {
private final MiniMOTD<CachedServerIcon> miniMOTD;
private final LegacyComponentSerializer unusualHexSerializer = LegacyComponentSerializer.builder().hexColors().useUnusualXRepeatedCharacterHexFormat().build();
PingListener(final @NonNull MiniMOTD<CachedServerIcon> miniMOTD) {
this.miniMOTD = miniMOTD;
}
@EventHandler
public void handlePing(final @NonNull ServerListPingEvent event) {
final MOTDConfig cfg = this.miniMOTD.configManager().mainConfig();
final PingResponse<CachedServerIcon> response = this.miniMOTD.createMOTD(cfg, event.getNumPlayers(), event.getMaxPlayers());
event.setMaxPlayers(response.playerCount().maxPlayers());
response.motd(motd -> {
if (PaperLib.getMinecraftVersion() > 15) {
event.setMotd(this.unusualHexSerializer.serialize(motd));
} else {
event.setMotd(LegacyComponentSerializer.legacySection().serialize(motd));
}
});
response.icon(icon -> {
try {
event.setServerIcon(icon);
} catch (final UnsupportedOperationException ignore) {
}
});
}
}
+37
View File
@@ -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)
}
@@ -1,7 +1,7 @@
/*
* This file is part of MiniMOTD, licensed under the MIT License.
*
* Copyright (c) 2021 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,29 +24,30 @@
package xyz.jpenilla.minimotd.bungee;
import net.kyori.adventure.audience.Audience;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.event.ClickEvent;
import net.kyori.adventure.text.format.NamedTextColor;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.plugin.Command;
import org.checkerframework.checker.nullness.qual.NonNull;
import xyz.jpenilla.minimotd.common.CommandHandlerFactory;
import org.jspecify.annotations.NonNull;
import xyz.jpenilla.minimotd.common.CommandHandler;
public class BungeeCommand extends Command {
private final MiniMOTDPlugin plugin;
private final CommandHandlerFactory handlerFactory;
import static net.kyori.adventure.text.Component.text;
import static net.kyori.adventure.text.event.ClickEvent.runCommand;
import static net.kyori.adventure.text.format.NamedTextColor.RED;
public BungeeCommand(final @NonNull MiniMOTDPlugin plugin) {
final class BungeeCommand extends Command {
private final MiniMOTDBungee plugin;
private final CommandHandler handler;
BungeeCommand(final @NonNull MiniMOTDBungee plugin) {
super("minimotd");
this.plugin = plugin;
this.handlerFactory = new CommandHandlerFactory(plugin.miniMOTD());
this.handler = new CommandHandler(plugin.miniMOTD());
}
@Override
public void execute(final @NonNull CommandSender sender, final @NonNull String @NonNull [] args) {
final Audience audience = this.plugin.audiences().sender(sender);
if (!sender.hasPermission("minimotd.admin")) {
audience.sendMessage(Component.text("No permission.", NamedTextColor.RED));
audience.sendMessage(text("No permission.", RED));
return;
}
@@ -57,13 +58,13 @@ public class BungeeCommand extends Command {
switch (args[0]) {
case "about":
this.handlerFactory.about().execute(audience);
this.handler.about(audience);
return;
case "help":
this.handlerFactory.help().execute(audience);
this.handler.help(audience);
return;
case "reload":
this.handlerFactory.reload().execute(audience);
this.handler.reload(audience);
return;
}
@@ -71,10 +72,8 @@ public class BungeeCommand extends Command {
}
private void onInvalidUse(final @NonNull Audience audience) {
audience.sendMessage(
Component.text("Invalid command usage. Use '/minimotd help' for a list of command provided by MiniMOTD.", NamedTextColor.RED)
.hoverEvent(Component.text("Click to execute '/minimotd help'"))
.clickEvent(ClickEvent.runCommand("/minimotd help"))
);
audience.sendMessage(text("Invalid command usage. Use '/minimotd help' for a list of command provided by MiniMOTD.", RED)
.hoverEvent(text("Click to execute '/minimotd help'"))
.clickEvent(runCommand("/minimotd help")));
}
}
@@ -1,7 +1,7 @@
/*
* This file is part of MiniMOTD, licensed under the MIT License.
*
* Copyright (c) 2021 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,25 +24,26 @@
package xyz.jpenilla.minimotd.bungee;
import com.google.gson.Gson;
import java.awt.image.BufferedImage;
import java.lang.reflect.Field;
import java.nio.file.Path;
import net.kyori.adventure.platform.bungeecord.BungeeAudiences;
import net.kyori.adventure.text.serializer.bungeecord.BungeeComponentSerializer;
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.UpdateChecker;
import xyz.jpenilla.minimotd.common.PingResponse;
import xyz.jpenilla.minimotd.common.config.MOTDConfig;
import xyz.jpenilla.minimotd.common.util.UpdateChecker;
import java.awt.image.BufferedImage;
import java.lang.reflect.Field;
import java.nio.file.Path;
public 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;
@@ -66,6 +67,9 @@ public class MiniMOTDPlugin extends Plugin implements MiniMOTDPlatform<Favicon>
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
@@ -110,4 +114,10 @@ public class MiniMOTDPlugin extends Plugin implements MiniMOTDPlatform<Favicon>
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));
}
}
@@ -1,7 +1,7 @@
/*
* This file is part of MiniMOTD, licensed under the MIT License.
*
* Copyright (c) 2021 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,6 @@
*/
package xyz.jpenilla.minimotd.bungee;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.serializer.bungeecord.BungeeComponentSerializer;
import net.md_5.bungee.api.Favicon;
import net.md_5.bungee.api.ServerPing;
@@ -32,19 +31,16 @@ 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.MOTDIconPair;
import xyz.jpenilla.minimotd.common.MiniMOTD;
import xyz.jpenilla.minimotd.common.config.MiniMOTDConfig;
import xyz.jpenilla.minimotd.common.config.MiniMOTDConfig.PlayerCount;
import xyz.jpenilla.minimotd.common.PingResponse;
import xyz.jpenilla.minimotd.common.config.MOTDConfig;
import java.util.Optional;
public class PingListener implements Listener {
public final class PingListener implements Listener {
private final MiniMOTD<Favicon> miniMOTD;
public PingListener(final @NonNull MiniMOTD<Favicon> miniMOTD) {
PingListener(final @NonNull MiniMOTD<Favicon> miniMOTD) {
this.miniMOTD = miniMOTD;
}
@@ -55,48 +51,33 @@ public class PingListener implements Listener {
return;
}
final String configString = this.miniMOTD.configManager().pluginSettings().configStringForHost(
Optional.ofNullable(e.getConnection().getVirtualHost())
.map(inetSocketAddress -> String.format("%s:%s", inetSocketAddress.getHostName(), inetSocketAddress.getPort()))
.orElse("default")
).orElse("default");
final MiniMOTDConfig cfg = this.miniMOTD.configManager().resolveConfig(configString);
final ServerPing.Players players = response.getPlayers();
final PlayerCount count = cfg.modifyPlayerCount(players.getOnline(), players.getMax());
final int onlinePlayers = count.onlinePlayers();
final int maxPlayers = count.maxPlayers();
final MOTDConfig cfg = this.miniMOTD.configManager().resolveConfig(e.getConnection().getVirtualHost());
final PingResponse<Favicon> mini = this.miniMOTD.createMOTD(cfg, players.getOnline(), players.getMax());
if (cfg.hidePlayerCount()) {
if (mini.hidePlayerCount()) {
response.setPlayers(null);
} else {
players.setOnline(onlinePlayers);
players.setMax(maxPlayers);
if (cfg.disablePlayerListHover()) {
mini.playerCount().applyCount(players::setOnline, players::setMax);
if (mini.disablePlayerListHover()) {
players.setSample(new ServerPing.PlayerInfo[]{});
}
}
final MOTDIconPair<Favicon> pair = this.miniMOTD.createMOTD(cfg, onlinePlayers, maxPlayers);
final Component motdComponent = pair.motd();
if (motdComponent != null) {
mini.motd(motd -> {
final BaseComponent[] bungee;
if (e.getConnection().getVersion() < Constants.MINECRAFT_1_16_PROTOCOL_VERSION) {
bungee = BungeeComponentSerializer.legacy().serialize(motdComponent);
bungee = BungeeComponentSerializer.legacy().serialize(motd);
} else {
bungee = BungeeComponentSerializer.get().serialize(motdComponent);
bungee = BungeeComponentSerializer.get().serialize(motd);
}
if (BungeeComponentSerializer.isNative()) {
response.setDescriptionComponent(bungee[0]);
} else {
response.setDescriptionComponent(new TextComponent(bungee));
}
}
final Favicon favicon = pair.icon();
if (favicon != null) {
response.setFavicon(favicon);
}
});
mini.icon(response::setFavicon);
e.setResponse(response);
}
@@ -0,0 +1,5 @@
name: MiniMOTD
main: xyz.jpenilla.minimotd.bungee.MiniMOTDBungee
version: $version
author: jmp
description: $description
+62
View File
@@ -0,0 +1,62 @@
plugins {
id("quiet-fabric-loom")
id("minimotd.platform-conventions")
id("com.gradleup.shadow")
}
val shade: Configuration by configurations.creating
dependencies {
minecraft(libs.minecraft)
mappings(loom.officialMojangMappings())
modImplementation(libs.fabricLoader)
modImplementation(libs.fabricApi)
shade(implementation(projects.minimotdCommon) {
exclude("net.kyori")
exclude("com.google.errorprone")
})
modImplementation(libs.adventurePlatformFabric)
include(libs.adventurePlatformFabric)
}
miniMOTDPlatform {
jarTask.set(tasks.remapJar)
}
indra {
javaVersions {
target(21)
}
}
tasks {
shadowJar {
configurations = listOf(shade)
commonConfiguration()
commonRelocation("io.leangen.geantyref")
}
remapJar {
archiveFileName.set("${project.name}-mc$minecraftVersion-${project.version}.jar")
}
processResources {
val replacements = mapOf(
"modid" to project.name,
"name" to rootProject.name,
"version" to project.version.toString(),
"description" to project.description.toString(),
"github_url" to Constants.GITHUB_URL
)
inputs.properties(replacements)
filesMatching("fabric.mod.json") {
expand(replacements)
}
}
}
publishMods.modrinth {
modLoaders.add("fabric")
minecraftVersions.addAll(minecraftVersion)
optional("miniplaceholders")
}
@@ -1,7 +1,7 @@
/*
* This file is part of MiniMOTD, licensed under the MIT License.
*
* Copyright (c) 2021 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,41 +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.io.ByteArrayOutputStream;
import java.nio.file.Path;
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.CommandHandlerFactory;
import xyz.jpenilla.minimotd.common.CommandHandler;
import xyz.jpenilla.minimotd.common.MiniMOTD;
import xyz.jpenilla.minimotd.common.MiniMOTDPlatform;
import xyz.jpenilla.minimotd.common.UpdateChecker;
import xyz.jpenilla.minimotd.common.util.BrigadierUtil;
import xyz.jpenilla.minimotd.common.util.UpdateChecker;
import xyz.jpenilla.minimotd.fabric.access.ServerStatusFaviconAccess;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
import java.util.Base64;
import java.util.concurrent.CompletableFuture;
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) {
@@ -68,48 +66,54 @@ 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");
}
private void registerCommand() {
final class WrappingExecutor implements Command<CommandSourceStack> {
private final CommandHandlerFactory.CommandHandler handler;
private final CommandHandler.Executor handler;
WrappingExecutor(final CommandHandlerFactory.@NonNull CommandHandler handler) {
WrappingExecutor(final CommandHandler.@NonNull Executor handler) {
this.handler = handler;
}
@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 CommandHandlerFactory handlerFactory = new CommandHandlerFactory(this.miniMOTD);
CommandRegistrationCallback.EVENT.register((dispatcher, $) -> dispatcher.register(
literal("minimotd")
.requires(source -> source.hasPermission(4))
.then(literal("reload").executes(new WrappingExecutor(handlerFactory.reload())))
.then(literal("about").executes(new WrappingExecutor(handlerFactory.about())))
.then(literal("help").executes(new WrappingExecutor(handlerFactory.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;
}
@@ -117,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;
@@ -128,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,7 +1,7 @@
/*
* This file is part of MiniMOTD, licensed under the MIT License.
*
* Copyright (c) 2021 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 @@
/*
* This file is part of MiniMOTD, licensed under the MIT License.
*
* Copyright (c) 2021 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;
package xyz.jpenilla.minimotd.fabric.access;
import net.kyori.adventure.text.Component;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.jspecify.annotations.Nullable;
public final class MOTDIconPair<I> {
private final I icon;
private final Component motd;
public MOTDIconPair(final @Nullable I icon, final @Nullable Component motd) {
this.icon = icon;
this.motd = motd;
}
public @Nullable I icon() {
return this.icon;
}
public @Nullable Component motd() {
return this.motd;
}
public interface ServerStatusFaviconAccess {
@Nullable String cachedEncodedIcon();
void cacheEncodedIcon();
}
@@ -1,7 +1,7 @@
/*
* This file is part of MiniMOTD, licensed under the MIT License.
*
* Copyright (c) 2021 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
@@ -30,18 +30,17 @@ import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import xyz.jpenilla.minimotd.fabric.access.ConnectionAccess;
@SuppressWarnings("checkstyle:FinalLocalVariable")
@Unique
@Mixin(Connection.class)
@Implements({@Interface(iface = ConnectionAccess.class, prefix = "tabtps$")})
@Implements({@Interface(iface = ConnectionAccess.class, prefix = "miniMOTD$")})
abstract class ConnectionMixin {
private int protocolVersion = -1;
private int miniMOTD$protocolVersion = -1;
public void tabtps$protocolVersion(int protocolVersion) {
this.protocolVersion = protocolVersion;
public void miniMOTD$protocolVersion(final int protocolVersion) {
this.miniMOTD$protocolVersion = protocolVersion;
}
public int tabtps$protocolVersion() {
return this.protocolVersion;
public int miniMOTD$protocolVersion() {
return this.miniMOTD$protocolVersion;
}
}
@@ -1,7 +1,7 @@
/*
* This file is part of MiniMOTD, licensed under the MIT License.
*
* Copyright (c) 2021 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,19 +29,17 @@ 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.Unique;
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.fabric.access.ConnectionAccess;
@Unique
@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.getProtocolVersion());
((ConnectionAccess) this.connection).protocolVersion(packet.protocolVersion());
}
}
@@ -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);
}
}
@@ -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.fabric.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.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 = "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 MinecraftServer minecraftServer = miniMOTDFabric.requireServer();
final ServerStatus vanillaStatus = Objects.requireNonNull(minecraftServer.getStatus(), "vanillaStatus");
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.description(miniMOTDFabric.audiences().asNative(motd));
} else {
modifiedStatus.description(miniMOTDFabric.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();
}
}
@@ -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;
}
}
@@ -0,0 +1,31 @@
{
"schemaVersion": 1,
"id": "${modid}",
"version": "${version}",
"name": "${name}",
"description": "${description}",
"authors": [
"jmp"
],
"contact": {
"homepage": "${github_url}",
"sources": "${github_url}",
"issues": "${github_url}/issues"
},
"license": "MIT",
"environment": "server",
"entrypoints": {
"main": [
"xyz.jpenilla.minimotd.fabric.MiniMOTDFabric"
]
},
"mixins": [
"minimotd-fabric.mixins.json"
],
"depends": {
"fabricloader": ">=0.18.2",
"fabric-api": "*",
"minecraft": ">=1.21.11",
"adventure-platform-fabric": "*"
}
}
@@ -1,11 +1,12 @@
{
"required": true,
"minVersion": "0.8",
"minVersion": "0.8.4",
"package": "xyz.jpenilla.minimotd.fabric.mixin",
"compatibilityLevel": "JAVA_8",
"compatibilityLevel": "JAVA_21",
"mixins": [
"ConnectionMixin",
"ServerHandshakePacketListenerImplMixin",
"ServerStatusFaviconMixin",
"ServerStatusPacketListenerImplMixin"
],
"client": [
+65
View File
@@ -0,0 +1,65 @@
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(21)
}
}
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 {
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;
}
}
@@ -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();
}
@@ -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();
}
@@ -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;
}
}
@@ -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());
}
}
@@ -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);
}
}
@@ -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();
}
}
@@ -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 = "[1.21.11,)"
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
}
}
+64
View File
@@ -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);
}
}
}
+36
View File
@@ -0,0 +1,36 @@
plugins {
id("minimotd.shadow-platform")
}
dependencies {
implementation(projects.minimotdCommon)
implementation(libs.adventurePlatformSpongeApi)
compileOnly(libs.spongeApi7)
implementation(libs.bstatsSponge)
}
tasks {
processResources {
val replacements = mapOf(
"modid" to rootProject.name.lowercase(),
"name" to rootProject.name,
"version" to project.version.toString(),
"description" to project.description.toString(),
"url" to Constants.GITHUB_URL
)
inputs.properties(replacements)
filesMatching("mcmod.info") {
expand(replacements)
}
}
shadowJar {
commonRelocation("io.leangen.geantyref")
commonRelocation("net.kyori")
commonRelocation("org.bstats")
}
}
publishMods.modrinth {
modLoaders.add("sponge")
minecraftVersions.add("1.12.2")
}
@@ -1,7 +1,7 @@
/*
* This file is part of MiniMOTD, licensed under the MIT License.
*
* Copyright (c) 2021 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,21 +23,21 @@
*/
package xyz.jpenilla.minimotd.sponge7;
import net.kyori.adventure.text.Component;
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.MOTDIconPair;
import xyz.jpenilla.minimotd.common.MiniMOTD;
import xyz.jpenilla.minimotd.common.config.MiniMOTDConfig;
import xyz.jpenilla.minimotd.common.config.MiniMOTDConfig.PlayerCount;
import xyz.jpenilla.minimotd.common.PingResponse;
import xyz.jpenilla.minimotd.common.config.MOTDConfig;
final class ClientPingServerEventListener implements EventListener<ClientPingServerEvent> {
private final MiniMOTD<Favicon> miniMOTD;
ClientPingServerEventListener(final @NonNull MiniMOTD<Favicon> miniMOTD) {
@Inject
private ClientPingServerEventListener(final @NonNull MiniMOTD<Favicon> miniMOTD) {
this.miniMOTD = miniMOTD;
}
@@ -58,30 +58,17 @@ final class ClientPingServerEventListener implements EventListener<ClientPingSer
}
}
final MiniMOTDConfig config = this.miniMOTD.configManager().mainConfig();
final MOTDConfig config = this.miniMOTD.configManager().mainConfig();
final PlayerCount count = config.modifyPlayerCount(players.getOnline(), players.getMax());
final int onlinePlayers = count.onlinePlayers();
final int maxPlayers = count.maxPlayers();
players.setOnline(onlinePlayers);
players.setMax(maxPlayers);
final PingResponse<Favicon> mini = this.miniMOTD.createMOTD(config, players.getOnline(), players.getMax());
mini.playerCount().applyCount(players::setOnline, players::setMax);
mini.motd(motd -> response.setDescription(SpongeComponentSerializer.get().serialize(motd)));
mini.icon(response::setFavicon);
final MOTDIconPair<Favicon> pair = this.miniMOTD.createMOTD(config, onlinePlayers, maxPlayers);
final Component motd = pair.motd();
if (motd != null) {
response.setDescription(SpongeComponentSerializer.get().serialize(motd));
}
final Favicon favicon = pair.icon();
if (favicon != null) {
response.setFavicon(favicon);
}
if (config.disablePlayerListHover()) {
if (mini.disablePlayerListHover()) {
players.getProfiles().clear();
}
if (config.hidePlayerCount()) {
if (mini.hidePlayerCount()) {
response.setHidePlayers(true);
}
}
@@ -1,7 +1,7 @@
/*
* This file is part of MiniMOTD, licensed under the MIT License.
*
* Copyright (c) 2021 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,11 +23,18 @@
*/
package xyz.jpenilla.minimotd.sponge7;
import com.google.inject.AbstractModule;
import com.google.inject.Inject;
import com.google.inject.Injector;
import com.google.inject.TypeLiteral;
import java.awt.image.BufferedImage;
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;
import org.spongepowered.api.command.CommandResult;
import org.spongepowered.api.command.CommandSource;
@@ -42,14 +49,10 @@ import org.spongepowered.api.event.server.ClientPingServerEvent;
import org.spongepowered.api.network.status.Favicon;
import org.spongepowered.api.plugin.Plugin;
import org.spongepowered.api.scheduler.Task;
import xyz.jpenilla.minimotd.common.CommandHandlerFactory;
import xyz.jpenilla.minimotd.common.CommandHandler;
import xyz.jpenilla.minimotd.common.MiniMOTD;
import xyz.jpenilla.minimotd.common.MiniMOTDPlatform;
import xyz.jpenilla.minimotd.common.UpdateChecker;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.nio.file.Path;
import xyz.jpenilla.minimotd.common.util.UpdateChecker;
@Plugin(id = "minimotd-sponge7")
public final class MiniMOTDPlugin implements MiniMOTDPlatform<Favicon> {
@@ -57,24 +60,36 @@ public final class MiniMOTDPlugin implements MiniMOTDPlatform<Favicon> {
private final Path dataDirectory;
private final MiniMOTD<Favicon> miniMOTD;
private final SpongeAudiences audiences;
private final Game game;
private final Injector injector;
@Inject
public MiniMOTDPlugin(
final @NonNull Logger logger,
@ConfigDir(sharedRoot = false) final @NonNull Path dataDirectory,
final @NonNull SpongeAudiences audiences,
final Metrics.@NonNull Factory metricsFactory
final Metrics.@NonNull Factory metricsFactory,
final @NonNull Injector injector,
final @NonNull Game game
) {
this.logger = logger;
this.dataDirectory = dataDirectory;
this.audiences = audiences;
this.game = game;
this.miniMOTD = new MiniMOTD<>(this);
this.injector = injector.createChildInjector(new AbstractModule() {
@Override
protected void configure() {
this.bind(new TypeLiteral<MiniMOTD<Favicon>>() {
}).toInstance(MiniMOTDPlugin.this.miniMOTD);
}
});
metricsFactory.make(10768);
}
@Listener
public void gameStarted(final @NonNull GameStartedServerEvent event) {
Sponge.getEventManager().registerListener(this, ClientPingServerEvent.class, new ClientPingServerEventListener(this.miniMOTD));
Sponge.getEventManager().registerListener(this, ClientPingServerEvent.class, this.injector.getInstance(ClientPingServerEventListener.class));
this.registerCommands();
if (this.miniMOTD.configManager().pluginSettings().updateChecker()) {
Task.builder()
@@ -86,33 +101,37 @@ public final class MiniMOTDPlugin implements MiniMOTDPlatform<Favicon> {
@Listener
public void reloaded(final @NonNull GameReloadEvent event) {
this.miniMOTD.reload();
try {
this.miniMOTD.reload();
} catch (final Exception ex) {
this.miniMOTD.logger().warn("Failed to reload MiniMOTD.", ex);
}
}
private void registerCommands() {
final class WrappingExecutor implements CommandExecutor {
private final CommandHandlerFactory.CommandHandler handler;
private final CommandHandler.Executor handler;
WrappingExecutor(final CommandHandlerFactory.@NonNull CommandHandler handler) {
WrappingExecutor(final CommandHandler.@NonNull Executor handler) {
this.handler = handler;
}
@Override
public CommandResult execute(final @NonNull CommandSource src, final @NonNull CommandContext args) {
public @NonNull CommandResult execute(final @NonNull CommandSource src, final @NonNull CommandContext args) {
this.handler.execute(MiniMOTDPlugin.this.audiences.receiver(src));
return CommandResult.success();
}
}
final CommandHandlerFactory factory = new CommandHandlerFactory(this.miniMOTD);
final CommandHandler handler = new CommandHandler(this.miniMOTD);
final CommandSpec help = CommandSpec.builder()
.executor(new WrappingExecutor(factory.help()))
.executor(new WrappingExecutor(handler::help))
.build();
final CommandSpec about = CommandSpec.builder()
.executor(new WrappingExecutor(factory.about()))
.executor(new WrappingExecutor(handler::about))
.build();
final CommandSpec reload = CommandSpec.builder()
.executor(new WrappingExecutor(factory.reload()))
.executor(new WrappingExecutor(handler::reload))
.build();
Sponge.getCommandManager().register(
this,
@@ -138,6 +157,6 @@ public final class MiniMOTDPlugin implements MiniMOTDPlatform<Favicon> {
@Override
public @NonNull Favicon loadIcon(final @NonNull BufferedImage image) throws IOException {
return Sponge.getRegistry().loadFavicon(image);
return this.game.getRegistry().loadFavicon(image);
}
}
@@ -1,10 +1,10 @@
[
{
"modid": "{project.name}",
"name": "{rootProject.name}",
"version": "{project.version}",
"description": "{project.description}",
"url": "{url}",
"modid": "${modid}",
"name": "${name}",
"version": "${version}",
"description": "${description}",
"url": "${url}",
"authorList": [
"jmp"
],
+70
View File
@@ -0,0 +1,70 @@
import org.spongepowered.gradle.plugin.config.PluginLoaders
import org.spongepowered.plugin.metadata.model.PluginDependency
plugins {
id("minimotd.shadow-platform")
alias(libs.plugins.sponge.gradle.plugin)
}
dependencies {
implementation(projects.minimotdCommon)
}
sponge {
injectRepositories(false)
apiVersion("8.1.0-SNAPSHOT")
plugin(rootProject.name.lowercase()) {
loader {
name(PluginLoaders.JAVA_PLAIN)
version("1.0")
}
license("MIT")
displayName(rootProject.name)
entrypoint("xyz.jpenilla.minimotd.sponge8.MiniMOTDPlugin")
description(project.description)
links {
homepage(Constants.GITHUB_URL)
source(Constants.GITHUB_URL)
issues("${Constants.GITHUB_URL}/issues")
}
contributor("jmp") {
description("Lead Developer")
}
dependency("spongeapi") {
loadOrder(PluginDependency.LoadOrder.AFTER)
optional(false)
}
dependency("miniplaceholders") {
loadOrder(PluginDependency.LoadOrder.AFTER)
optional(true)
version = "3.0.0"
}
}
}
tasks {
shadowJar {
configureForNativeAdventurePlatform()
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",
)
optional("miniplaceholders")
}
@@ -1,7 +1,7 @@
/*
* This file is part of MiniMOTD, licensed under the MIT License.
*
* Copyright (c) 2021 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,27 +23,35 @@
*/
package xyz.jpenilla.minimotd.sponge8;
import net.kyori.adventure.text.Component;
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
import org.checkerframework.checker.nullness.qual.NonNull;
import com.google.inject.Inject;
import java.lang.reflect.Method;
import org.jspecify.annotations.NonNull;
import org.spongepowered.api.MinecraftVersion;
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.ComponentColorDownsampler;
import xyz.jpenilla.minimotd.common.Constants;
import xyz.jpenilla.minimotd.common.MOTDIconPair;
import xyz.jpenilla.minimotd.common.MiniMOTD;
import xyz.jpenilla.minimotd.common.config.MiniMOTDConfig;
import xyz.jpenilla.minimotd.common.config.MiniMOTDConfig.PlayerCount;
import java.lang.reflect.Method;
import xyz.jpenilla.minimotd.common.PingResponse;
import xyz.jpenilla.minimotd.common.config.MOTDConfig;
import xyz.jpenilla.minimotd.common.util.ComponentColorDownsampler;
final class ClientPingServerEventListener implements EventListener<ClientPingServerEvent> {
private final MiniMOTD<Favicon> miniMOTD;
private @MonotonicNonNull Method SpongeMinecraftVersion_getProtocol;
private static final Method GET_PROTOCOL;
ClientPingServerEventListener(final @NonNull MiniMOTD<Favicon> miniMOTD) {
static {
try {
final Class<?> protocolMinecraftVersion = Class.forName("org.spongepowered.common.ProtocolMinecraftVersion");
GET_PROTOCOL = protocolMinecraftVersion.getMethod("getProtocol");
} catch (final ReflectiveOperationException ex) {
throw new RuntimeException(ex);
}
}
private final MiniMOTD<Favicon> miniMOTD;
@Inject
private ClientPingServerEventListener(final @NonNull MiniMOTD<Favicon> miniMOTD) {
this.miniMOTD = miniMOTD;
}
@@ -64,46 +72,31 @@ final class ClientPingServerEventListener implements EventListener<ClientPingSer
}
}
final MiniMOTDConfig config = this.miniMOTD.configManager().mainConfig();
final MOTDConfig config = this.miniMOTD.configManager().mainConfig();
final PlayerCount count = config.modifyPlayerCount(players.online(), players.max());
final int onlinePlayers = count.onlinePlayers();
final int maxPlayers = count.maxPlayers();
players.setOnline(onlinePlayers);
players.setMax(maxPlayers);
final MOTDIconPair<Favicon> pair = this.miniMOTD.createMOTD(config, onlinePlayers, maxPlayers);
final Component motdComponent = pair.motd();
if (motdComponent != null) {
final MinecraftVersion version = event.client().version();
if (this.legacy(version)) {
response.setDescription(ComponentColorDownsampler.downsampler().downsample(motdComponent));
final PingResponse<Favicon> mini = this.miniMOTD.createMOTD(config, players.online(), players.max());
mini.playerCount().applyCount(players::setOnline, players::setMax);
mini.motd(motd -> {
if (this.legacy(event.client().version())) {
response.setDescription(ComponentColorDownsampler.downsampler().downsample(motd));
} else {
response.setDescription(motdComponent);
response.setDescription(motd);
}
}
});
mini.icon(response::setFavicon);
final Favicon favicon = pair.icon();
if (favicon != null) {
response.setFavicon(favicon);
}
if (config.disablePlayerListHover()) {
if (mini.disablePlayerListHover()) {
players.profiles().clear();
}
if (config.hidePlayerCount()) {
if (mini.hidePlayerCount()) {
response.setHidePlayers(true);
}
}
private boolean legacy(final @NonNull MinecraftVersion version) {
try {
if (!version.isLegacy() && this.SpongeMinecraftVersion_getProtocol == null) {
this.SpongeMinecraftVersion_getProtocol = version.getClass().getMethod("getProtocol");
}
return version.isLegacy()
|| (int) this.SpongeMinecraftVersion_getProtocol.invoke(version) < Constants.MINECRAFT_1_16_PROTOCOL_VERSION;
|| (int) GET_PROTOCOL.invoke(version) < Constants.MINECRAFT_1_16_PROTOCOL_VERSION;
} catch (final ReflectiveOperationException e) {
throw new IllegalStateException("Failed to get protocol version", e);
}
@@ -1,7 +1,7 @@
/*
* This file is part of MiniMOTD, licensed under the MIT License.
*
* Copyright (c) 2021 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,8 +23,13 @@
*/
package xyz.jpenilla.minimotd.sponge8;
import com.google.inject.AbstractModule;
import com.google.inject.Inject;
import org.checkerframework.checker.nullness.qual.NonNull;
import com.google.inject.Injector;
import com.google.inject.TypeLiteral;
import java.awt.image.BufferedImage;
import java.nio.file.Path;
import org.jspecify.annotations.NonNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.spongepowered.api.Sponge;
@@ -33,7 +38,9 @@ import org.spongepowered.api.command.CommandExecutor;
import org.spongepowered.api.command.CommandResult;
import org.spongepowered.api.command.parameter.CommandContext;
import org.spongepowered.api.config.ConfigDir;
import org.spongepowered.api.event.EventListenerRegistration;
import org.spongepowered.api.event.Listener;
import org.spongepowered.api.event.Order;
import org.spongepowered.api.event.lifecycle.LoadedGameEvent;
import org.spongepowered.api.event.lifecycle.RefreshGameEvent;
import org.spongepowered.api.event.lifecycle.RegisterCommandEvent;
@@ -41,15 +48,12 @@ import org.spongepowered.api.event.server.ClientPingServerEvent;
import org.spongepowered.api.network.status.Favicon;
import org.spongepowered.api.scheduler.Task;
import org.spongepowered.plugin.PluginContainer;
import org.spongepowered.plugin.jvm.Plugin;
import org.spongepowered.plugin.builtin.jvm.Plugin;
import org.spongepowered.plugin.metadata.PluginMetadata;
import xyz.jpenilla.minimotd.common.CommandHandlerFactory;
import xyz.jpenilla.minimotd.common.CommandHandler;
import xyz.jpenilla.minimotd.common.MiniMOTD;
import xyz.jpenilla.minimotd.common.MiniMOTDPlatform;
import xyz.jpenilla.minimotd.common.UpdateChecker;
import java.awt.image.BufferedImage;
import java.nio.file.Path;
import xyz.jpenilla.minimotd.common.util.UpdateChecker;
@Plugin("minimotd-sponge8")
public final class MiniMOTDPlugin implements MiniMOTDPlatform<Favicon> {
@@ -58,21 +62,32 @@ public final class MiniMOTDPlugin implements MiniMOTDPlatform<Favicon> {
private final Logger logger;
private final PluginContainer pluginContainer;
private final MiniMOTD<Favicon> miniMOTD;
private final Injector injector;
@Inject
public MiniMOTDPlugin(
@ConfigDir(sharedRoot = false) final @NonNull Path dataDirectory,
final @NonNull PluginContainer pluginContainer
final @NonNull PluginContainer pluginContainer,
final @NonNull Injector injector
) {
this.dataDirectory = dataDirectory;
this.pluginContainer = pluginContainer;
this.pluginMetadata = pluginContainer.getMetadata();
this.logger = LoggerFactory.getLogger(this.pluginMetadata.getId());
this.pluginMetadata = pluginContainer.metadata();
this.logger = LoggerFactory.getLogger(this.pluginMetadata.id());
this.miniMOTD = new MiniMOTD<>(this);
this.injector = injector.createChildInjector(new AbstractModule() {
@Override
protected void configure() {
this.bind(new TypeLiteral<MiniMOTD<Favicon>>() {
}).toInstance(MiniMOTDPlugin.this.miniMOTD);
}
});
Sponge.eventManager().registerListener(
pluginContainer,
ClientPingServerEvent.class,
new ClientPingServerEventListener(this.miniMOTD)
EventListenerRegistration.builder(ClientPingServerEvent.class)
.plugin(pluginContainer)
.listener(this.injector.getInstance(ClientPingServerEventListener.class))
.order(Order.DEFAULT)
.build()
);
}
@@ -89,9 +104,9 @@ public final class MiniMOTDPlugin implements MiniMOTDPlatform<Favicon> {
@Listener
public void registerCommands(final @NonNull RegisterCommandEvent<Command.Parameterized> event) {
final class WrappingExecutor implements CommandExecutor {
private final CommandHandlerFactory.CommandHandler handler;
private final CommandHandler.Executor handler;
WrappingExecutor(final CommandHandlerFactory.@NonNull CommandHandler handler) {
WrappingExecutor(final CommandHandler.@NonNull Executor handler) {
this.handler = handler;
}
@@ -102,15 +117,15 @@ public final class MiniMOTDPlugin implements MiniMOTDPlatform<Favicon> {
}
}
final CommandHandlerFactory handlerFactory = new CommandHandlerFactory(this.miniMOTD);
final CommandHandler handler = new CommandHandler(this.miniMOTD);
final Command.Parameterized about = Command.builder()
.executor(new WrappingExecutor(handlerFactory.about()))
.executor(new WrappingExecutor(handler::about))
.build();
final Command.Parameterized help = Command.builder()
.executor(new WrappingExecutor(handlerFactory.help()))
.executor(new WrappingExecutor(handler::help))
.build();
final Command.Parameterized reload = Command.builder()
.executor(new WrappingExecutor(handlerFactory.reload()))
.executor(new WrappingExecutor(handler::reload))
.build();
event.register(
this.pluginContainer,
@@ -126,7 +141,11 @@ public final class MiniMOTDPlugin implements MiniMOTDPlatform<Favicon> {
@Listener
public void onRefresh(final @NonNull RefreshGameEvent event) {
this.miniMOTD.reload();
try {
this.miniMOTD.reload();
} catch (final Exception ex) {
this.miniMOTD.logger().warn("Failed to reload MiniMOTD.", ex);
}
}
@Override
+43
View File
@@ -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")
}
@@ -0,0 +1,135 @@
/*
* 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.velocity;
import com.google.common.collect.ImmutableSet;
import com.google.inject.AbstractModule;
import com.google.inject.Inject;
import com.google.inject.Injector;
import com.google.inject.TypeLiteral;
import com.velocitypowered.api.command.BrigadierCommand;
import com.velocitypowered.api.command.CommandManager;
import com.velocitypowered.api.event.Subscribe;
import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
import com.velocitypowered.api.plugin.annotation.DataDirectory;
import com.velocitypowered.api.proxy.ProxyServer;
import com.velocitypowered.api.util.Favicon;
import java.awt.image.BufferedImage;
import java.nio.file.Path;
import java.util.Set;
import org.bstats.velocity.Metrics;
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 MiniMOTDVelocity implements MiniMOTDPlatform<Favicon> {
private static final Set<Class<?>> LISTENER_CLASSES = ImmutableSet.of(
PingListener.class
);
private final MiniMOTD<Favicon> miniMOTD;
private final ProxyServer server;
private final Logger logger;
private final CommandManager commandManager;
private final Path dataDirectory;
private final Metrics.Factory metricsFactory;
private final Injector injector;
@Inject
public MiniMOTDVelocity(
final @NonNull ProxyServer server,
final @NonNull Logger logger,
final @NonNull CommandManager commandManager,
@DataDirectory final @NonNull Path dataDirectory,
final Metrics.@NonNull Factory metricsFactory,
final @NonNull Injector injector
) {
this.server = server;
this.logger = logger;
this.commandManager = commandManager;
this.dataDirectory = dataDirectory;
this.metricsFactory = metricsFactory;
this.miniMOTD = new MiniMOTD<>(this);
this.miniMOTD.configManager().loadExtraConfigs();
this.injector = injector.createChildInjector(new AbstractModule() {
@Override
protected void configure() {
this.bind(new TypeLiteral<MiniMOTD<Favicon>>() {
}).toInstance(MiniMOTDVelocity.this.miniMOTD);
}
});
}
@Subscribe
public void onProxyInitialization(final @NonNull ProxyInitializeEvent event) {
for (final Class<?> clazz : LISTENER_CLASSES) {
this.server.getEventManager().register(this, this.injector.getInstance(clazz));
}
this.registerCommand();
this.metricsFactory.make(this, 10257);
if (this.miniMOTD.configManager().pluginSettings().updateChecker()) {
this.server.getScheduler().buildTask(
this,
() -> new UpdateChecker().checkVersion().forEach(this.logger::info)
).schedule();
}
}
private void registerCommand() {
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
public @NonNull Path dataDirectory() {
return this.dataDirectory;
}
@Override
public @NonNull Logger logger() {
return this.logger;
}
@Override
public @NonNull Favicon loadIcon(final @NonNull BufferedImage image) {
return Favicon.create(image);
}
@Override
public void onReload() {
this.miniMOTD.configManager().loadExtraConfigs();
}
}
@@ -0,0 +1,97 @@
/*
* 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.velocity;
import com.google.inject.Inject;
import com.velocitypowered.api.event.EventTask;
import com.velocitypowered.api.event.Subscribe;
import com.velocitypowered.api.event.proxy.ProxyPingEvent;
import com.velocitypowered.api.proxy.ProxyServer;
import com.velocitypowered.api.proxy.server.RegisteredServer;
import com.velocitypowered.api.proxy.server.ServerPing;
import com.velocitypowered.api.util.Favicon;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;
import xyz.jpenilla.minimotd.common.MiniMOTD;
import xyz.jpenilla.minimotd.common.PingResponse;
import xyz.jpenilla.minimotd.common.config.MOTDConfig;
@NullMarked
public final class PingListener {
private final MiniMOTD<Favicon> miniMOTD;
private final ProxyServer proxy;
@Inject
private PingListener(final MiniMOTD<Favicon> miniMOTD, final ProxyServer proxy) {
this.miniMOTD = miniMOTD;
this.proxy = proxy;
}
@Subscribe
public EventTask onProxyPingEvent(final ProxyPingEvent event) {
return EventTask.async(() -> this.handle(event));
}
private void handle(final ProxyPingEvent event) {
final MOTDConfig config = this.miniMOTD.configManager().resolveConfig(event.getConnection().getVirtualHost().orElse(null));
final ServerPing.Builder pong = event.getPing().asBuilder();
final List<String> targetServers = config.targetServers();
int playersCount = 0;
if (targetServers.isEmpty()) {
playersCount = pong.getOnlinePlayers();
} else {
final Set<ServerPing.SamplePlayer> players = new HashSet<>();
for (final String serverName : targetServers) {
final @Nullable RegisteredServer server = this.proxy.getServer(serverName).orElse(null);
if (server != null) {
playersCount += server.getPlayersConnected().size();
players.addAll(server.getPlayersConnected().stream()
.map(p -> new ServerPing.SamplePlayer(p.getGameProfile().getName(), p.getUniqueId()))
.collect(Collectors.toList()));
}
}
pong.clearSamplePlayers();
pong.samplePlayers(players.toArray(new ServerPing.SamplePlayer[0]));
}
final PingResponse<Favicon> response = this.miniMOTD.createMOTD(config, playersCount, pong.getMaximumPlayers());
response.icon(pong::favicon);
response.motd(pong::description);
response.playerCount().applyCount(pong::onlinePlayers, pong::maximumPlayers);
if (response.disablePlayerListHover()) {
pong.clearSamplePlayers();
}
if (response.hidePlayerCount()) {
pong.nullPlayers();
}
event.setPing(pong.build());
}
}
+50 -2
View File
@@ -1,5 +1,53 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"config:base"
]
"config:recommended"
],
"ignoreDeps": [
"quiet-fabric-loom",
"com.mojang:minecraft",
"com.google.code.gson:gson"
],
"labels": [
"dependencies"
],
"packageRules": [
{
"description": "Correct Fabric API version handling",
"matchPackageNames": [
"net.fabricmc.fabric-api:fabric-api",
"net.fabricmc.fabric-api:fabric-api-deprecated"
],
"versioning": "regex:^(?<major>\\d+)(\\.(?<minor>\\d+))?(\\.(?<patch>\\d+))?(?:\\+(?<compatibility>.*))?$"
},
{
"description": "Correct NeoForge version handling",
"matchPackageNames": [
"net.neoforged:neoforge"
],
"versioning": "regex:^(?<compatibility>(\\d+\\.){2})(?<minor>\\d+)(-beta)?$"
},
{
"matchManagers": [
"github-actions",
"gradle-wrapper"
],
"groupName": "gradle and github actions"
},
{
"matchDepTypes": [
"plugin"
],
"groupName": "gradle and github actions"
},
{
"matchFileNames": [
"build-logic/*",
"buildSrc/*"
],
"groupName": "gradle and github actions"
}
],
"semanticCommitType": "build",
"commitMessagePrefix": "chore(deps): "
}
Loaded 100 of 111 files, more files were not shown because too many files have changed in this diff. Show more