Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5f6e2789e2 | ||
|
|
add32b31e7 | ||
|
|
b2b2801907 | ||
|
|
c919c40a59 | ||
|
|
b3cc4bce5c | ||
|
|
6fdf75dd3d | ||
|
|
a8c2b0f23e | ||
|
|
0ee99d90f2 | ||
|
|
6623a5928e | ||
|
|
6532c03706 | ||
|
|
0bf3bfba7f | ||
|
|
f7094e0a77 | ||
|
|
563da7f255 | ||
|
|
51e599838d | ||
|
|
e4970016e4 | ||
|
|
2a04d0b2c8 | ||
|
|
f8c6c2db6f | ||
|
|
9e25b68d00 | ||
|
|
96b7d12743 | ||
|
|
328ad6cd39 | ||
|
|
c0ee968e5b | ||
|
|
bc4d1e3cdd | ||
|
|
2626ed4551 | ||
|
|
a1f51db093 | ||
|
|
59ab61825b | ||
|
|
5d7f79ce8a | ||
|
|
a5145384f6 | ||
|
|
fba4066522 | ||
|
|
3c9261a92d | ||
|
|
ab409537ac | ||
|
|
98a5bba407 | ||
|
|
87bec5315b | ||
|
|
bf9d92150c | ||
|
|
4cad4d461b | ||
|
|
fc7b78f7a8 | ||
|
|
15cffc2d71 | ||
|
|
28cb91a40c | ||
|
|
4ab6567fd2 | ||
|
|
bdac395c2d | ||
|
|
ffb475f529 | ||
|
|
d690104a9e | ||
|
|
efa0c69840 | ||
|
|
369e387a39 | ||
|
|
2f98e67a93 | ||
|
|
e2894e211c | ||
|
|
58ff03aa95 | ||
|
|
4155249878 | ||
|
|
de0936c5d2 | ||
|
|
a8e5e910ee | ||
|
|
0d48b46621 | ||
|
|
2a18bc156d | ||
|
|
0dd650dacb | ||
|
|
624a97346d | ||
|
|
3d4fdc1f53 | ||
|
|
286f72f746 | ||
|
|
0cc8d9a98d | ||
|
|
80ae413c9d |
No files matched your search
@@ -0,0 +1,19 @@
|
||||
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
|
||||
@@ -1,22 +0,0 @@
|
||||
name: Build MiniMOTD
|
||||
on: [ push, pull_request ]
|
||||
jobs:
|
||||
build:
|
||||
# Only run on PRs if the source branch is on someone else's repo
|
||||
if: ${{ github.event_name != 'pull_request' || github.repository != github.event.pull_request.head.repo.full_name }}
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: gradle/wrapper-validation-action@v1
|
||||
- name: Set up JDK
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: '17'
|
||||
- name: Build with Gradle
|
||||
run: ./gradlew build
|
||||
- run: mkdir staging && cp build/libs/*.jar staging
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: Package
|
||||
path: staging
|
||||
@@ -8,8 +8,11 @@ repositories {
|
||||
|
||||
dependencies {
|
||||
implementation(libs.indraCommon)
|
||||
implementation(libs.indraLicenser)
|
||||
implementation(libs.shadow)
|
||||
implementation(libs.testLogger)
|
||||
implementation(libs.minotaur)
|
||||
implementation(libs.hangarPublishPlugin)
|
||||
|
||||
// https://github.com/gradle/gradle/issues/15383#issuecomment-779893192
|
||||
implementation(files(libs.javaClass.superclass.protectionDomain.codeSource.location))
|
||||
|
||||
@@ -2,7 +2,7 @@ import ca.stellardrift.build.configurate.ConfigFormats
|
||||
import ca.stellardrift.build.configurate.catalog.PolyglotVersionCatalogExtension
|
||||
|
||||
plugins {
|
||||
id("ca.stellardrift.polyglot-version-catalogs") version "5.0.1"
|
||||
id("ca.stellardrift.polyglot-version-catalogs") version "6.0.1"
|
||||
}
|
||||
|
||||
extensions.configure<PolyglotVersionCatalogExtension> {
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.provider.Property
|
||||
import org.gradle.api.tasks.bundling.AbstractArchiveTask
|
||||
import org.gradle.kotlin.dsl.property
|
||||
|
||||
abstract class MiniMOTDPlatformExtension(project: Project) {
|
||||
val jarTask: Property<AbstractArchiveTask> = project.objects.property()
|
||||
interface MiniMOTDPlatformExtension {
|
||||
val jarTask: Property<AbstractArchiveTask>
|
||||
val hangar: Property<Boolean>
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
import net.kyori.indra.git.IndraGitExtension
|
||||
import org.gradle.accessors.dm.LibrariesForLibs
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.provider.Provider
|
||||
import org.gradle.kotlin.dsl.the
|
||||
|
||||
fun Project.lastCommitHash(): String =
|
||||
@@ -8,3 +9,25 @@ fun Project.lastCommitHash(): String =
|
||||
|
||||
val Project.libs: LibrariesForLibs
|
||||
get() = the()
|
||||
|
||||
val Project.releaseNotes: Provider<String>
|
||||
get() = providers.environmentVariable("RELEASE_NOTES")
|
||||
|
||||
val Project.minecraftVersion
|
||||
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"
|
||||
)
|
||||
@@ -3,7 +3,7 @@ import com.adarshr.gradle.testlogger.theme.ThemeType
|
||||
plugins {
|
||||
id("java-library")
|
||||
id("net.kyori.indra")
|
||||
id("net.kyori.indra.publishing")
|
||||
id("net.kyori.indra.git")
|
||||
id("net.kyori.indra.checkstyle")
|
||||
id("net.kyori.indra.license-header")
|
||||
id("com.adarshr.test-logger")
|
||||
|
||||
@@ -1,3 +1,35 @@
|
||||
import io.papermc.hangarpublishplugin.model.Platforms
|
||||
|
||||
plugins {
|
||||
base
|
||||
id("io.papermc.hangar-publish-plugin")
|
||||
}
|
||||
|
||||
fun jar(platform: String) = project(":minimotd-$platform")
|
||||
.the<MiniMOTDPlatformExtension>().jarTask.flatMap { it.archiveFile }
|
||||
|
||||
hangarPublish.publications.register("plugin") {
|
||||
version.set(project.version as String)
|
||||
namespace("jmp", "MiniMOTD")
|
||||
channel.set("Release")
|
||||
changelog.set(releaseNotes)
|
||||
apiKey.set(providers.environmentVariable("HANGAR_UPLOAD_KEY"))
|
||||
platforms {
|
||||
register(Platforms.PAPER) {
|
||||
jar.set(jar("bukkit"))
|
||||
val vers = bukkitVersions.toMutableList()
|
||||
vers -= "1.8.8"
|
||||
vers -= "1.8.9"
|
||||
vers += "1.8"
|
||||
platformVersions.addAll(vers)
|
||||
}
|
||||
register(Platforms.VELOCITY) {
|
||||
jar.set(jar("velocity"))
|
||||
platformVersions.addAll("3.2")
|
||||
}
|
||||
register(Platforms.WATERFALL) {
|
||||
jar.set(jar("bungeecord"))
|
||||
platformVersions.addAll("1.19")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,11 @@
|
||||
import com.modrinth.minotaur.ModrinthExtension
|
||||
|
||||
plugins {
|
||||
id("minimotd.base-conventions")
|
||||
id("net.kyori.indra.git")
|
||||
}
|
||||
|
||||
val platformExtension = extensions.create<MiniMOTDPlatformExtension>("miniMOTDPlatform", project)
|
||||
val platformExtension = extensions.create<MiniMOTDPlatformExtension>("miniMOTDPlatform")
|
||||
|
||||
tasks {
|
||||
val copyJar = register<FileCopyTask>("copyJar") {
|
||||
@@ -16,3 +18,15 @@ tasks {
|
||||
dependsOn(copyJar)
|
||||
}
|
||||
}
|
||||
|
||||
if (name != "minimotd-bukkit-bungeecord") {
|
||||
plugins.apply("com.modrinth.minotaur")
|
||||
|
||||
the<ModrinthExtension>().apply {
|
||||
projectId.set("16vhQOQN")
|
||||
versionType.set("release")
|
||||
file.set(platformExtension.jarTask.flatMap { it.archiveFile })
|
||||
changelog.set(releaseNotes)
|
||||
token.set(providers.environmentVariable("MODRINTH_TOKEN"))
|
||||
}
|
||||
}
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
import com.github.jengelman.gradle.plugins.shadow.internal.DependencyFilter
|
||||
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
||||
|
||||
fun ShadowJar.commonRelocation(pkg: String) {
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2022 Jason Penilla
|
||||
* Copyright (c) 2020-2023 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) 2020-2022 Jason Penilla
|
||||
* Copyright (c) 2020-2023 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) 2020-2022 Jason Penilla
|
||||
* Copyright (c) 2020-2023 Jason Penilla
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -28,9 +28,9 @@ 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;
|
||||
@@ -38,7 +38,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public final class IconManager<I> {
|
||||
private final Map<String, I> icons = new HashMap<>();
|
||||
private final Map<String, I> icons = new ConcurrentHashMap<>();
|
||||
private final MiniMOTD<I> miniMOTD;
|
||||
private final Path iconsDirectory;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2022 Jason Penilla
|
||||
* Copyright (c) 2020-2023 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
|
||||
@@ -120,7 +120,7 @@ public final class MiniMOTD<I> {
|
||||
return input.replace("{onlinePlayers}", online).replace("{maxPlayers}", max);
|
||||
}
|
||||
|
||||
public void reload() {
|
||||
public synchronized void reload() {
|
||||
this.iconManager.loadIcons();
|
||||
this.configManager.loadConfigs();
|
||||
this.platform.onReload();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2022 Jason Penilla
|
||||
* Copyright (c) 2020-2023 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) 2020-2022 Jason Penilla
|
||||
* Copyright (c) 2020-2023 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) 2020-2022 Jason Penilla
|
||||
* Copyright (c) 2020-2023 Jason Penilla
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -23,9 +23,14 @@
|
||||
*/
|
||||
package xyz.jpenilla.minimotd.common.config;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.UnaryOperator;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.framework.qual.DefaultQualifier;
|
||||
import org.spongepowered.configurate.CommentedConfigurationNode;
|
||||
import org.spongepowered.configurate.ConfigurateException;
|
||||
import org.spongepowered.configurate.ConfigurationOptions;
|
||||
@@ -34,6 +39,7 @@ import org.spongepowered.configurate.objectmapping.ObjectMapper;
|
||||
import org.spongepowered.configurate.serialize.SerializationException;
|
||||
import org.spongepowered.configurate.serialize.TypeSerializerCollection;
|
||||
|
||||
@DefaultQualifier(NonNull.class)
|
||||
public final class ConfigLoader<C> {
|
||||
private static final TypeSerializerCollection SERIALIZERS;
|
||||
|
||||
@@ -45,12 +51,14 @@ public final class ConfigLoader<C> {
|
||||
|
||||
private final HoconConfigurationLoader loader;
|
||||
private final ObjectMapper<C> mapper;
|
||||
private final List<Consumer<C>> postProcess;
|
||||
|
||||
public ConfigLoader(
|
||||
final @NonNull Class<C> configClass,
|
||||
final @NonNull Path configPath,
|
||||
final @NonNull UnaryOperator<ConfigurationOptions> optionsModifier
|
||||
final Class<C> configClass,
|
||||
final Path configPath,
|
||||
final UnaryOperator<ConfigurationOptions> optionsModifier
|
||||
) {
|
||||
this.postProcess = this.findPostProcessors(configClass);
|
||||
this.loader = HoconConfigurationLoader.builder()
|
||||
.path(configPath)
|
||||
.defaultOptions(options ->
|
||||
@@ -67,6 +75,24 @@ public final class ConfigLoader<C> {
|
||||
}
|
||||
}
|
||||
|
||||
private List<Consumer<C>> findPostProcessors(final Class<C> configClass) {
|
||||
final List<Consumer<C>> ret = new ArrayList<>();
|
||||
for (final Method method : configClass.getDeclaredMethods()) {
|
||||
if (method.getAnnotation(PostProcessor.class) == null) {
|
||||
continue;
|
||||
}
|
||||
ret.add(config -> {
|
||||
try {
|
||||
method.setAccessible(true);
|
||||
method.invoke(config);
|
||||
} catch (final ReflectiveOperationException ex) {
|
||||
throw new RuntimeException("Failed to invoke post processor method", ex);
|
||||
}
|
||||
});
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public ConfigLoader(
|
||||
final @NonNull Class<C> configClass,
|
||||
final @NonNull Path configPath
|
||||
@@ -76,7 +102,11 @@ public final class ConfigLoader<C> {
|
||||
|
||||
public @NonNull 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 {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2022 Jason Penilla
|
||||
* Copyright (c) 2020-2023 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) 2020-2022 Jason Penilla
|
||||
* Copyright (c) 2020-2023 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
|
||||
@@ -49,7 +49,7 @@ public final class MiniMOTDConfig {
|
||||
|
||||
@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<>();
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2022 Jason Penilla
|
||||
* Copyright (c) 2020-2023 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
|
||||
@@ -46,7 +46,7 @@ public final class PlayerCountModifier implements Int2IntFunction {
|
||||
return this.function.apply(actualPlayers);
|
||||
}
|
||||
|
||||
public final @NonNull String input() {
|
||||
public @NonNull String input() {
|
||||
return this.input;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2022 Jason Penilla
|
||||
* Copyright (c) 2020-2023 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,6 +24,7 @@
|
||||
package xyz.jpenilla.minimotd.common.config;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
@@ -64,7 +65,7 @@ public final class PluginSettings {
|
||||
}
|
||||
|
||||
public @Nullable String findConfigStringForHost(final @NonNull String host) {
|
||||
return this.virtualHostConfigs.get(host);
|
||||
return this.virtualHostConfigs.get(host.toLowerCase(Locale.ENGLISH));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,4 +77,10 @@ public final class PluginSettings {
|
||||
return this.updateChecker;
|
||||
}
|
||||
|
||||
@PostProcessor
|
||||
private void lowercaseVirtualHosts() {
|
||||
final Map<String, String> virtualHosts = new HashMap<>(this.proxySettings.virtualHostConfigs);
|
||||
this.proxySettings.virtualHostConfigs.clear();
|
||||
virtualHosts.forEach((host, config) -> this.proxySettings.virtualHostConfigs.put(host.toLowerCase(Locale.ENGLISH), config));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2023 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 {
|
||||
}
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2022 Jason Penilla
|
||||
* Copyright (c) 2020-2023 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) 2020-2022 Jason Penilla
|
||||
* Copyright (c) 2020-2023 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) 2020-2022 Jason Penilla
|
||||
* Copyright (c) 2020-2023 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) 2020-2022 Jason Penilla
|
||||
* Copyright (c) 2020-2023 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) 2020-2022 Jason Penilla
|
||||
* Copyright (c) 2020-2023 Jason Penilla
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2022 Jason Penilla
|
||||
* Copyright (c) 2020-2023 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
|
||||
|
||||
@@ -9,13 +9,9 @@ tasks.jar {
|
||||
val platforms = setOf(
|
||||
projects.minimotdBukkit,
|
||||
projects.minimotdBungeecord,
|
||||
projects.minimotdVelocity,
|
||||
projects.minimotdFabric,
|
||||
projects.minimotdSponge7,
|
||||
projects.minimotdSponge8
|
||||
).map { it.dependencyProject }
|
||||
|
||||
val universal = tasks.register<Jar>("universal") {
|
||||
val dist = tasks.register<Jar>("bukkitAndBungeeJar") {
|
||||
artifacts.add("archives", this)
|
||||
archiveClassifier.set(null as String?)
|
||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||
@@ -27,5 +23,5 @@ val universal = tasks.register<Jar>("universal") {
|
||||
}
|
||||
|
||||
miniMOTDPlatform {
|
||||
jarTask.set(universal)
|
||||
jarTask.set(dist)
|
||||
}
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
group=xyz.jpenilla
|
||||
version=2.0.6
|
||||
version=2.0.13
|
||||
description=Use MiniMessage text formatting in the server list MOTD.
|
||||
|
||||
org.gradle.caching=true
|
||||
|
||||
+33
-18
@@ -5,33 +5,36 @@ metadata:
|
||||
|
||||
plugins:
|
||||
net.kyori.blossom: 1.3.0
|
||||
org.spongepowered.gradle.plugin: 2.0.1
|
||||
net.minecrell.plugin-yml.bungee: &plugin-yml 0.5.1
|
||||
net.minecrell.plugin-yml.bukkit: *plugin-yml
|
||||
xyz.jpenilla.run-paper: 1.0.6
|
||||
org.spongepowered.gradle.plugin: 2.1.1
|
||||
net.minecrell.plugin-yml.bungee: 0.5.3
|
||||
xyz.jpenilla.run-paper: &run-task 2.1.0
|
||||
xyz.jpenilla.run-velocity: *run-task
|
||||
xyz.jpenilla.run-waterfall: *run-task
|
||||
|
||||
versions:
|
||||
indra: 2.1.1
|
||||
shadow: 7.1.2
|
||||
minotaur: 2.7.5
|
||||
hangarPublishPlugin: 0.0.5
|
||||
indra: 3.0.1
|
||||
shadow: 8.1.1
|
||||
testLoggerPlugin: 3.2.0
|
||||
adventure: 4.10.1
|
||||
adventurePlatform: 4.1.0
|
||||
adventurePlatformFabric: 5.2.0
|
||||
adventure: 4.14.0
|
||||
adventurePlatform: 4.3.0
|
||||
adventurePlatformFabric: 5.10.0-SNAPSHOT
|
||||
configurate: 4.1.2
|
||||
checkerQual: 3.21.3
|
||||
checkerQual: 3.35.0
|
||||
slf4j: 1.7.32
|
||||
gson: 2.8.0
|
||||
guava: 21.0
|
||||
bstats: 2.2.1
|
||||
bstats: 3.0.0
|
||||
paperApi: 1.16.5-R0.1-SNAPSHOT
|
||||
paperlib: 1.0.8-SNAPSHOT
|
||||
waterfallApi: 1.16-R0.4-SNAPSHOT
|
||||
fabricApi: 0.47.8+1.18.2
|
||||
fabricLoader: 0.13.3
|
||||
fabricMinecraft: 1.18.2
|
||||
fabricApi: 0.83.0+1.20.1
|
||||
fabricLoader: 0.14.19
|
||||
minecraft: 1.20.1
|
||||
spongeApi7: 7.2.0
|
||||
velocityApi: 3.1.2-SNAPSHOT
|
||||
jupiterEngine: 5.8.2
|
||||
jupiterEngine: 5.9.2
|
||||
|
||||
dependencies:
|
||||
adventureBom:
|
||||
@@ -134,10 +137,10 @@ dependencies:
|
||||
group: net.fabricmc
|
||||
name: fabric-loader
|
||||
version: { ref: fabricLoader }
|
||||
fabricMinecraft:
|
||||
minecraft:
|
||||
group: com.mojang
|
||||
name: minecraft
|
||||
version: { ref: fabricMinecraft }
|
||||
version: { ref: minecraft }
|
||||
|
||||
spongeApi7:
|
||||
group: org.spongepowered
|
||||
@@ -159,13 +162,25 @@ dependencies:
|
||||
group: net.kyori
|
||||
name: indra-common
|
||||
version: { ref: indra }
|
||||
indraLicenser:
|
||||
group: net.kyori
|
||||
name: indra-licenser-cadix
|
||||
version: { ref: indra }
|
||||
shadow:
|
||||
group: gradle.plugin.com.github.johnrengelman
|
||||
group: com.github.johnrengelman
|
||||
name: shadow
|
||||
version: { ref: shadow }
|
||||
testLogger:
|
||||
group: com.adarshr
|
||||
name: gradle-test-logger-plugin
|
||||
version: { ref: testLoggerPlugin }
|
||||
minotaur:
|
||||
group: com.modrinth.minotaur
|
||||
name: Minotaur
|
||||
version: { ref: minotaur }
|
||||
hangarPublishPlugin:
|
||||
group: io.papermc
|
||||
name: hangar-publish-plugin
|
||||
version: { ref: hangarPublishPlugin }
|
||||
|
||||
bundles:
|
||||
Vendored
BIN
Binary file not shown.
+2
-1
@@ -1,5 +1,6 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.1-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
|
||||
networkTimeout=10000
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
@@ -55,7 +55,7 @@
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
@@ -80,13 +80,10 @@ do
|
||||
esac
|
||||
done
|
||||
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||
|
||||
APP_NAME="Gradle"
|
||||
# This is normally unused
|
||||
# shellcheck disable=SC2034
|
||||
APP_BASE_NAME=${0##*/}
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
@@ -143,12 +140,16 @@ fi
|
||||
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=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=SC3045
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
@@ -193,6 +194,10 @@ if "$cygwin" || "$msys" ; then
|
||||
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 $GRADLE_OPTS can contain fragments of
|
||||
# shell script including quotes and variable substitutions, so put them in
|
||||
@@ -205,6 +210,12 @@ set -- \
|
||||
org.gradle.wrapper.GradleWrapperMain \
|
||||
"$@"
|
||||
|
||||
# Stop when "xargs" is not available.
|
||||
if ! command -v xargs >/dev/null 2>&1
|
||||
then
|
||||
die "xargs is not available"
|
||||
fi
|
||||
|
||||
# Use "xargs" to parse quoted args.
|
||||
#
|
||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||
|
||||
Vendored
+9
-6
@@ -14,7 +14,7 @@
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%" == "" @echo off
|
||||
@if "%DEBUG%"=="" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@@ -25,7 +25,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,7 +41,7 @@ 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.
|
||||
@@ -75,13 +76,15 @@ set CLASSPATH=%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
@@ -1,6 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2020-2022 Jason Penilla
|
||||
Copyright (c) 2020-2023 Jason Penilla
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
This file is part of MiniMOTD, licensed under the MIT License.
|
||||
|
||||
Copyright (c) 2020-2022 Jason Penilla
|
||||
Copyright (c) 2020-2023 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,6 +1,5 @@
|
||||
plugins {
|
||||
id("minimotd.shadow-platform")
|
||||
id("net.minecrell.plugin-yml.bukkit")
|
||||
id("xyz.jpenilla.run-paper")
|
||||
}
|
||||
|
||||
@@ -15,29 +14,31 @@ dependencies {
|
||||
|
||||
tasks {
|
||||
runServer {
|
||||
minecraftVersion("1.18.2")
|
||||
minecraftVersion(minecraftVersion)
|
||||
}
|
||||
shadowJar {
|
||||
platformRelocation("bukkit", "xyz.jpenilla.minimotd.common")
|
||||
commonRelocation("org.slf4j")
|
||||
commonRelocation("io.leangen.geantyref")
|
||||
commonRelocation("net.kyori")
|
||||
commonRelocation("org.bstats")
|
||||
commonRelocation("io.papermc.lib")
|
||||
}
|
||||
}
|
||||
|
||||
bukkit {
|
||||
name = rootProject.name
|
||||
main = "xyz.jpenilla.minimotd.bukkit.MiniMOTDPlugin"
|
||||
apiVersion = "1.13"
|
||||
website = Constants.GITHUB_URL
|
||||
authors = listOf("jmp")
|
||||
softDepend = listOf("ViaVersion")
|
||||
commands {
|
||||
register("minimotd") {
|
||||
description = "MiniMOTD Command"
|
||||
usage = "/minimotd help"
|
||||
permission = "minimotd.admin"
|
||||
processResources {
|
||||
val props = mapOf(
|
||||
"version" to project.version,
|
||||
"website" to Constants.GITHUB_URL,
|
||||
"description" to project.description
|
||||
)
|
||||
inputs.properties(props)
|
||||
filesMatching("plugin.yml") {
|
||||
expand(props)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
runPaper.folia.registerTask()
|
||||
|
||||
modrinth {
|
||||
gameVersions.addAll(bukkitVersions)
|
||||
}
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2022 Jason Penilla
|
||||
* Copyright (c) 2020-2023 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
|
||||
+13
-3
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2022 Jason Penilla
|
||||
* Copyright (c) 2020-2023 Jason Penilla
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -26,6 +26,7 @@ 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.command.PluginCommand;
|
||||
@@ -71,8 +72,17 @@ public final class MiniMOTDPlugin extends JavaPlugin implements MiniMOTDPlatform
|
||||
final Metrics metrics = new Metrics(this, 8132);
|
||||
|
||||
if (this.miniMOTD.configManager().pluginSettings().updateChecker()) {
|
||||
this.getServer().getScheduler().runTaskAsynchronously(this, () ->
|
||||
new UpdateChecker().checkVersion().forEach(this.logger::info));
|
||||
try {
|
||||
Class.forName("io.papermc.paper.threadedregions.RegionizedServer");
|
||||
CompletableFuture.runAsync(() -> new UpdateChecker().checkVersion().forEach(this.logger::info)).whenComplete(($, thr) -> {
|
||||
if (thr != null) {
|
||||
this.logger.warn("Exception checking for updates", thr);
|
||||
}
|
||||
});
|
||||
} catch (final ReflectiveOperationException ex) {
|
||||
this.getServer().getScheduler().runTaskAsynchronously(this, () ->
|
||||
new UpdateChecker().checkVersion().forEach(this.logger::info));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2022 Jason Penilla
|
||||
* Copyright (c) 2020-2023 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
|
||||
+7
-2
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2022 Jason Penilla
|
||||
* Copyright (c) 2020-2023 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
|
||||
@@ -56,6 +56,11 @@ public final class PingListener implements Listener {
|
||||
event.setMotd(LegacyComponentSerializer.legacySection().serialize(motd));
|
||||
}
|
||||
});
|
||||
response.icon(event::setServerIcon);
|
||||
response.icon(icon -> {
|
||||
try {
|
||||
event.setServerIcon(icon);
|
||||
} catch (final UnsupportedOperationException ignore) {
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
name: MiniMOTD
|
||||
version: $version
|
||||
main: xyz.jpenilla.minimotd.bukkit.MiniMOTDPlugin
|
||||
folia-supported: true
|
||||
description: $description
|
||||
authors:
|
||||
- jmp
|
||||
website: $website
|
||||
commands:
|
||||
minimotd:
|
||||
description: MiniMOTD Command
|
||||
permission: minimotd.admin
|
||||
usage: /minimotd help
|
||||
api-version: 1.13
|
||||
softdepend:
|
||||
- ViaVersion
|
||||
@@ -1,6 +1,7 @@
|
||||
plugins {
|
||||
id("minimotd.shadow-platform")
|
||||
id("net.minecrell.plugin-yml.bungee")
|
||||
id("xyz.jpenilla.run-waterfall")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
@@ -12,10 +13,14 @@ dependencies {
|
||||
|
||||
tasks {
|
||||
shadowJar {
|
||||
platformRelocation("bungee", "xyz.jpenilla.minimotd.common")
|
||||
commonRelocation("io.leangen.geantyref")
|
||||
commonRelocation("net.kyori")
|
||||
commonRelocation("org.bstats")
|
||||
}
|
||||
runWaterfall {
|
||||
waterfallVersion("1.19")
|
||||
}
|
||||
}
|
||||
|
||||
bungee {
|
||||
@@ -23,3 +28,8 @@ bungee {
|
||||
main = "xyz.jpenilla.minimotd.bungee.MiniMOTDPlugin"
|
||||
author = "jmp"
|
||||
}
|
||||
|
||||
modrinth {
|
||||
loaders.add("waterfall") // not sure why this isn't detected automatically from run-waterfall...
|
||||
gameVersions.addAll(minecraftVersion)
|
||||
}
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2022 Jason Penilla
|
||||
* Copyright (c) 2020-2023 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
|
||||
+12
-1
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2022 Jason Penilla
|
||||
* Copyright (c) 2020-2023 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
|
||||
@@ -39,6 +39,8 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import xyz.jpenilla.minimotd.common.MiniMOTD;
|
||||
import xyz.jpenilla.minimotd.common.MiniMOTDPlatform;
|
||||
import xyz.jpenilla.minimotd.common.PingResponse;
|
||||
import xyz.jpenilla.minimotd.common.config.MiniMOTDConfig;
|
||||
import xyz.jpenilla.minimotd.common.util.UpdateChecker;
|
||||
|
||||
public final class MiniMOTDPlugin extends Plugin implements MiniMOTDPlatform<Favicon> {
|
||||
@@ -65,6 +67,9 @@ public final class MiniMOTDPlugin extends Plugin implements MiniMOTDPlatform<Fav
|
||||
this.getProxy().getScheduler().runAsync(this, () ->
|
||||
new UpdateChecker().checkVersion().forEach(this.logger::info));
|
||||
}
|
||||
|
||||
// preload some stuff, so the first ping is as fast as the rest
|
||||
this.preload();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -109,4 +114,10 @@ public final class MiniMOTDPlugin extends Plugin implements MiniMOTDPlatform<Fav
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private void preload() {
|
||||
final MiniMOTDConfig cfg = this.miniMOTD.configManager().mainConfig();
|
||||
final PingResponse<Favicon> mini = this.miniMOTD.createMOTD(cfg, 0, 0);
|
||||
mini.motd(motd -> BungeeComponentSerializer.get().serialize(motd));
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2022 Jason Penilla
|
||||
* Copyright (c) 2020-2023 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,15 +1,13 @@
|
||||
plugins {
|
||||
id("quiet-fabric-loom")
|
||||
id("minimotd.platform-conventions")
|
||||
id("com.github.johnrengelman.shadow")
|
||||
id("quiet-fabric-loom")
|
||||
}
|
||||
|
||||
val shade: Configuration by configurations.creating
|
||||
|
||||
val minecraftVersion = libs.versions.fabricMinecraft.get()
|
||||
|
||||
dependencies {
|
||||
minecraft(libs.fabricMinecraft)
|
||||
minecraft(libs.minecraft)
|
||||
mappings(loom.officialMojangMappings())
|
||||
modImplementation(libs.fabricLoader)
|
||||
modImplementation(libs.fabricApi)
|
||||
@@ -32,16 +30,11 @@ indra {
|
||||
}
|
||||
}
|
||||
|
||||
loom {
|
||||
serverOnlyMinecraftJar()
|
||||
}
|
||||
|
||||
tasks {
|
||||
shadowJar {
|
||||
configurations = listOf(shade)
|
||||
commonConfiguration()
|
||||
commonRelocation("io.leangen.geantyref")
|
||||
platformRelocation("fabric", "xyz.jpenilla.minimotd.common")
|
||||
}
|
||||
remapJar {
|
||||
archiveFileName.set("${project.name}-mc$minecraftVersion-${project.version}.jar")
|
||||
+33
-25
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2022 Jason Penilla
|
||||
* Copyright (c) 2020-2023 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,22 +25,19 @@ package xyz.jpenilla.minimotd.fabric;
|
||||
|
||||
import com.mojang.brigadier.Command;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.ByteBufOutputStream;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Base64;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import javax.imageio.ImageIO;
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
import net.fabricmc.fabric.api.command.v1.CommandRegistrationCallback;
|
||||
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
|
||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.kyori.adventure.platform.fabric.FabricServerAudiences;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.network.protocol.status.ServerStatus;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -48,16 +45,18 @@ import xyz.jpenilla.minimotd.common.CommandHandler;
|
||||
import xyz.jpenilla.minimotd.common.MiniMOTD;
|
||||
import xyz.jpenilla.minimotd.common.MiniMOTDPlatform;
|
||||
import xyz.jpenilla.minimotd.common.util.UpdateChecker;
|
||||
import xyz.jpenilla.minimotd.fabric.access.ServerStatusFaviconAccess;
|
||||
|
||||
import static net.minecraft.commands.Commands.literal;
|
||||
|
||||
public final class MiniMOTDFabric implements ModInitializer, MiniMOTDPlatform<String> {
|
||||
public final class MiniMOTDFabric implements ModInitializer, MiniMOTDPlatform<ServerStatus.Favicon> {
|
||||
private static MiniMOTDFabric instance = null;
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(MiniMOTD.class);
|
||||
private final Path dataDirectory = FabricLoader.getInstance().getConfigDir().resolve("MiniMOTD");
|
||||
private final MiniMOTD<String> miniMOTD = new MiniMOTD<>(this);
|
||||
private final MiniMOTD<ServerStatus.Favicon> miniMOTD = new MiniMOTD<>(this);
|
||||
|
||||
private MinecraftServer server;
|
||||
private FabricServerAudiences audiences;
|
||||
|
||||
public MiniMOTDFabric() {
|
||||
@@ -67,19 +66,26 @@ public final class MiniMOTDFabric implements ModInitializer, MiniMOTDPlatform<St
|
||||
instance = this;
|
||||
}
|
||||
|
||||
public @NonNull MiniMOTD<String> miniMOTD() {
|
||||
public @NonNull MiniMOTD<ServerStatus.Favicon> miniMOTD() {
|
||||
return this.miniMOTD;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInitialize() {
|
||||
this.registerCommand();
|
||||
ServerLifecycleEvents.SERVER_STARTED.register(minecraftServer -> {
|
||||
ServerLifecycleEvents.SERVER_STARTING.register(minecraftServer -> {
|
||||
this.server = minecraftServer;
|
||||
this.audiences = FabricServerAudiences.of(minecraftServer);
|
||||
});
|
||||
ServerLifecycleEvents.SERVER_STARTED.register(minecraftServer -> {
|
||||
if (this.miniMOTD.configManager().pluginSettings().updateChecker()) {
|
||||
CompletableFuture.runAsync(() -> new UpdateChecker().checkVersion().forEach(this.logger()::info));
|
||||
}
|
||||
});
|
||||
ServerLifecycleEvents.SERVER_STOPPED.register($ -> {
|
||||
this.server = null;
|
||||
this.audiences = null;
|
||||
});
|
||||
this.miniMOTD.logger().info("Done initializing MiniMOTD");
|
||||
}
|
||||
|
||||
@@ -93,13 +99,13 @@ public final class MiniMOTDFabric implements ModInitializer, MiniMOTDPlatform<St
|
||||
|
||||
@Override
|
||||
public int run(final @NonNull CommandContext<CommandSourceStack> context) {
|
||||
this.handler.execute(MiniMOTDFabric.this.audiences.audience(context.getSource()));
|
||||
this.handler.execute(context.getSource());
|
||||
return Command.SINGLE_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
final CommandHandler handler = new CommandHandler(this.miniMOTD);
|
||||
CommandRegistrationCallback.EVENT.register((dispatcher, $) -> dispatcher.register(
|
||||
CommandRegistrationCallback.EVENT.register((dispatcher, commandBuildContext, commandSelection) -> dispatcher.register(
|
||||
literal("minimotd")
|
||||
.requires(source -> source.hasPermission(4))
|
||||
.then(literal("reload").executes(new WrappingExecutor(handler::reload)))
|
||||
@@ -116,6 +122,13 @@ public final class MiniMOTDFabric implements ModInitializer, MiniMOTDPlatform<St
|
||||
return instance;
|
||||
}
|
||||
|
||||
public @NonNull MinecraftServer requireServer() {
|
||||
if (this.server == null) {
|
||||
throw new IllegalStateException("Server requested before started");
|
||||
}
|
||||
return this.server;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull Path dataDirectory() {
|
||||
return this.dataDirectory;
|
||||
@@ -127,16 +140,11 @@ public final class MiniMOTDFabric implements ModInitializer, MiniMOTDPlatform<St
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull String loadIcon(final @NonNull BufferedImage bufferedImage) throws Exception {
|
||||
final ByteBuf byteBuf = Unpooled.buffer();
|
||||
final String icon;
|
||||
try {
|
||||
ImageIO.write(bufferedImage, "PNG", new ByteBufOutputStream(byteBuf));
|
||||
final ByteBuffer base64 = Base64.getEncoder().encode(byteBuf.nioBuffer());
|
||||
icon = "data:image/png;base64," + StandardCharsets.UTF_8.decode(base64);
|
||||
} finally {
|
||||
byteBuf.release();
|
||||
}
|
||||
return icon;
|
||||
public ServerStatus.@NonNull Favicon loadIcon(final @NonNull BufferedImage bufferedImage) throws Exception {
|
||||
final ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
ImageIO.write(bufferedImage, "PNG", out);
|
||||
final ServerStatus.Favicon favicon = new ServerStatus.Favicon(out.toByteArray());
|
||||
((ServerStatusFaviconAccess) (Object) favicon).cacheEncodedIcon();
|
||||
return favicon;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2022 Jason Penilla
|
||||
* Copyright (c) 2020-2023 Jason Penilla
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2023 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.access;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public interface ServerStatusFaviconAccess {
|
||||
@Nullable String cachedEncodedIcon();
|
||||
|
||||
void cacheEncodedIcon();
|
||||
}
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2022 Jason Penilla
|
||||
* Copyright (c) 2020-2023 Jason Penilla
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2022 Jason Penilla
|
||||
* Copyright (c) 2020-2023 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
|
||||
+78
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2023 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.checkerframework.checker.nullness.qual.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);
|
||||
}
|
||||
}
|
||||
+35
-26
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2022 Jason Penilla
|
||||
* Copyright (c) 2020-2023 Jason Penilla
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -23,7 +23,9 @@
|
||||
*/
|
||||
package xyz.jpenilla.minimotd.fabric.mixin;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import java.util.Collections;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import net.minecraft.network.Connection;
|
||||
import net.minecraft.network.protocol.status.ServerStatus;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
@@ -40,46 +42,53 @@ import xyz.jpenilla.minimotd.common.config.MiniMOTDConfig;
|
||||
import xyz.jpenilla.minimotd.common.util.ComponentColorDownsampler;
|
||||
import xyz.jpenilla.minimotd.fabric.MiniMOTDFabric;
|
||||
import xyz.jpenilla.minimotd.fabric.access.ConnectionAccess;
|
||||
import xyz.jpenilla.minimotd.fabric.util.MutableServerStatus;
|
||||
|
||||
@Mixin(ServerStatusPacketListenerImpl.class)
|
||||
abstract class ServerStatusPacketListenerImplMixin {
|
||||
@Shadow @Final private Connection connection;
|
||||
|
||||
@Redirect(method = "handleStatusRequest", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/MinecraftServer;getStatus()Lnet/minecraft/network/protocol/status/ServerStatus;"))
|
||||
public ServerStatus injectHandleStatusRequest(final MinecraftServer minecraftServer) {
|
||||
final ServerStatus vanillaStatus = minecraftServer.getStatus();
|
||||
|
||||
final ServerStatus modifiedStatus = new ServerStatus();
|
||||
modifiedStatus.setDescription(vanillaStatus.getDescription());
|
||||
modifiedStatus.setFavicon(vanillaStatus.getFavicon());
|
||||
modifiedStatus.setVersion(vanillaStatus.getVersion());
|
||||
|
||||
@Redirect(
|
||||
method = "handleStatusRequest",
|
||||
at = @At(value = "FIELD", target = "Lnet/minecraft/server/network/ServerStatusPacketListenerImpl;status:Lnet/minecraft/network/protocol/status/ServerStatus;")
|
||||
)
|
||||
public ServerStatus injectHandleStatusRequest(final ServerStatusPacketListenerImpl instance) {
|
||||
final MiniMOTDFabric miniMOTDFabric = MiniMOTDFabric.get();
|
||||
final MiniMOTD<String> miniMOTD = miniMOTDFabric.miniMOTD();
|
||||
final MinecraftServer minecraftServer = miniMOTDFabric.requireServer();
|
||||
final ServerStatus vanillaStatus = Objects.requireNonNull(minecraftServer.getStatus(), "vanillaStatus");
|
||||
|
||||
final MiniMOTD<ServerStatus.Favicon> miniMOTD = miniMOTDFabric.miniMOTD();
|
||||
final MiniMOTDConfig config = miniMOTD.configManager().mainConfig();
|
||||
|
||||
final PingResponse<String> response = miniMOTD.createMOTD(config, minecraftServer.getPlayerCount(), vanillaStatus.getPlayers().getMaxPlayers());
|
||||
final PingResponse<ServerStatus.Favicon> response = miniMOTD.createMOTD(
|
||||
config,
|
||||
minecraftServer.getPlayerCount(),
|
||||
vanillaStatus.players().map(ServerStatus.Players::max).orElseGet(minecraftServer::getMaxPlayers)
|
||||
);
|
||||
|
||||
final MutableServerStatus modifiedStatus = new MutableServerStatus(vanillaStatus);
|
||||
response.motd(motd -> {
|
||||
if (((ConnectionAccess) this.connection).protocolVersion() >= Constants.MINECRAFT_1_16_PROTOCOL_VERSION) {
|
||||
modifiedStatus.setDescription(miniMOTDFabric.audiences().toNative(motd));
|
||||
modifiedStatus.description(miniMOTDFabric.audiences().toNative(motd));
|
||||
} else {
|
||||
modifiedStatus.setDescription(miniMOTDFabric.audiences().toNative(ComponentColorDownsampler.downsampler().downsample(motd)));
|
||||
modifiedStatus.description(miniMOTDFabric.audiences().toNative(ComponentColorDownsampler.downsampler().downsample(motd)));
|
||||
}
|
||||
});
|
||||
response.icon(modifiedStatus::setFavicon);
|
||||
response.icon(favicon -> modifiedStatus.favicon(Optional.of(favicon)));
|
||||
|
||||
if (!response.hidePlayerCount()) {
|
||||
final GameProfile[] oldSample = vanillaStatus.getPlayers().getSample();
|
||||
final ServerStatus.Players newPlayers = new ServerStatus.Players(response.playerCount().maxPlayers(), response.playerCount().onlinePlayers());
|
||||
if (response.disablePlayerListHover()) {
|
||||
newPlayers.setSample(new GameProfile[]{});
|
||||
} else {
|
||||
newPlayers.setSample(oldSample);
|
||||
}
|
||||
modifiedStatus.setPlayers(newPlayers);
|
||||
if (response.hidePlayerCount()) {
|
||||
modifiedStatus.players(Optional.empty());
|
||||
} else {
|
||||
final ServerStatus.Players newPlayers = new ServerStatus.Players(
|
||||
response.playerCount().maxPlayers(),
|
||||
response.playerCount().onlinePlayers(),
|
||||
response.disablePlayerListHover()
|
||||
? Collections.emptyList()
|
||||
: vanillaStatus.players().map(ServerStatus.Players::sample).orElse(Collections.emptyList())
|
||||
);
|
||||
modifiedStatus.players(Optional.of(newPlayers));
|
||||
}
|
||||
|
||||
return modifiedStatus;
|
||||
return modifiedStatus.toServerStatus();
|
||||
}
|
||||
}
|
||||
+97
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2023 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.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.framework.qual.DefaultQualifier;
|
||||
|
||||
@SuppressWarnings({"OptionalUsedAsFieldOrParameterType", "unused"})
|
||||
@DefaultQualifier(NonNull.class)
|
||||
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;
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -23,8 +23,8 @@
|
||||
"minimotd-fabric.mixins.json"
|
||||
],
|
||||
"depends": {
|
||||
"fabricloader": ">=0.12.8",
|
||||
"fabric": ">=0.31.0",
|
||||
"minecraft": ">=1.18"
|
||||
"fabricloader": ">=0.14.6",
|
||||
"fabric": "*",
|
||||
"minecraft": ">=1.20.1"
|
||||
}
|
||||
}
|
||||
+1
@@ -6,6 +6,7 @@
|
||||
"mixins": [
|
||||
"ConnectionMixin",
|
||||
"ServerHandshakePacketListenerImplMixin",
|
||||
"ServerStatusFaviconMixin",
|
||||
"ServerStatusPacketListenerImplMixin"
|
||||
],
|
||||
"client": [
|
||||
@@ -31,3 +31,8 @@ tasks {
|
||||
commonRelocation("org.bstats")
|
||||
}
|
||||
}
|
||||
|
||||
modrinth {
|
||||
loaders.add("sponge")
|
||||
gameVersions.add("1.12.2")
|
||||
}
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2022 Jason Penilla
|
||||
* Copyright (c) 2020-2023 Jason Penilla
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2022 Jason Penilla
|
||||
* Copyright (c) 2020-2023 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
|
||||
File renamed without changes.
@@ -41,9 +41,17 @@ sponge {
|
||||
tasks {
|
||||
shadowJar {
|
||||
configureForNativeAdventurePlatform()
|
||||
platformRelocation("sponge8", "xyz.jpenilla.minimotd.common")
|
||||
dependencies {
|
||||
exclude(dependency("io.leangen.geantyref:geantyref"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
modrinth {
|
||||
gameVersions.addAll(
|
||||
"1.16.5",
|
||||
"1.17.1",
|
||||
"1.18.2",
|
||||
"1.19.4"
|
||||
)
|
||||
}
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2022 Jason Penilla
|
||||
* Copyright (c) 2020-2023 Jason Penilla
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2022 Jason Penilla
|
||||
* Copyright (c) 2020-2023 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,6 +1,7 @@
|
||||
plugins {
|
||||
id("minimotd.shadow-platform")
|
||||
id("net.kyori.blossom")
|
||||
id("xyz.jpenilla.run-velocity")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
@@ -14,9 +15,11 @@ tasks {
|
||||
shadowJar {
|
||||
configureForNativeAdventurePlatform()
|
||||
commonRelocation("io.leangen.geantyref")
|
||||
platformRelocation("velocity", "xyz.jpenilla.minimotd.common")
|
||||
commonRelocation("org.bstats")
|
||||
}
|
||||
runVelocity {
|
||||
velocityVersion(libs.versions.velocityApi.get())
|
||||
}
|
||||
}
|
||||
|
||||
blossom {
|
||||
@@ -29,3 +32,7 @@ blossom {
|
||||
replaceToken("\${$k}", v, file)
|
||||
}
|
||||
}
|
||||
|
||||
modrinth {
|
||||
gameVersions.addAll(minecraftVersion)
|
||||
}
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2022 Jason Penilla
|
||||
* Copyright (c) 2020-2023 Jason Penilla
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2022 Jason Penilla
|
||||
* Copyright (c) 2020-2023 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
|
||||
+19
-9
@@ -3,7 +3,10 @@ enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")
|
||||
dependencyResolutionManagement {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven("https://papermc.io/repo/repository/maven-public/")
|
||||
maven("https://s01.oss.sonatype.org/content/repositories/snapshots/") {
|
||||
mavenContent { snapshotsOnly() }
|
||||
}
|
||||
maven("https://repo.papermc.io/repository/maven-public/")
|
||||
maven("https://repo.spongepowered.org/repository/maven-public/")
|
||||
maven("https://repo.jpenilla.xyz/snapshots/") {
|
||||
mavenContent { snapshotsOnly() }
|
||||
@@ -23,22 +26,29 @@ pluginManagement {
|
||||
}
|
||||
|
||||
plugins {
|
||||
id("ca.stellardrift.polyglot-version-catalogs") version "5.0.1"
|
||||
id("quiet-fabric-loom") version "0.11-SNAPSHOT"
|
||||
id("ca.stellardrift.polyglot-version-catalogs") version "6.0.1"
|
||||
id("quiet-fabric-loom") version "1.2-SNAPSHOT"
|
||||
}
|
||||
|
||||
rootProject.name = "MiniMOTD"
|
||||
|
||||
fun setup(name: String, dir: String) {
|
||||
include(name)
|
||||
project(":$name").projectDir = file(dir)
|
||||
}
|
||||
|
||||
fun platform(name: String) = setup("minimotd-$name", "platform/$name")
|
||||
fun dist(name: String) = setup("minimotd-$name", "dist/$name")
|
||||
|
||||
setup("minimotd-common", "common")
|
||||
|
||||
sequenceOf(
|
||||
"common",
|
||||
"bukkit",
|
||||
"sponge8",
|
||||
"sponge7",
|
||||
"bungeecord",
|
||||
"velocity",
|
||||
"fabric",
|
||||
"universal"
|
||||
).forEach {
|
||||
include("minimotd-$it")
|
||||
project(":minimotd-$it").projectDir = file(it)
|
||||
}
|
||||
).forEach(::platform)
|
||||
|
||||
dist("bukkit-bungeecord")
|
||||
Reference in new issue
Block a user