mirror of
https://github.com/jpenilla/MiniMOTD.git
synced 2026-11-06 09:32:33 -05:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
15cffc2d71 | ||
|
|
28cb91a40c | ||
|
|
4ab6567fd2 | ||
|
|
bdac395c2d | ||
|
|
ffb475f529 | ||
|
|
d690104a9e | ||
|
|
efa0c69840 | ||
|
|
369e387a39 | ||
|
|
2f98e67a93 | ||
|
|
e2894e211c | ||
|
|
58ff03aa95 | ||
|
|
4155249878 | ||
|
|
de0936c5d2 | ||
|
|
a8e5e910ee | ||
|
|
0d48b46621 | ||
|
|
2a18bc156d |
No files matched your search
@@ -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")
|
||||
|
||||
@@ -15,7 +15,7 @@ dependencies {
|
||||
|
||||
tasks {
|
||||
runServer {
|
||||
minecraftVersion("1.18.2")
|
||||
minecraftVersion("1.19.2")
|
||||
}
|
||||
shadowJar {
|
||||
commonRelocation("org.slf4j")
|
||||
|
||||
@@ -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) {
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -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 {
|
||||
|
||||
@@ -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-2022 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,7 +1,7 @@
|
||||
plugins {
|
||||
id("quiet-fabric-loom")
|
||||
id("minimotd.platform-conventions")
|
||||
id("com.github.johnrengelman.shadow")
|
||||
id("quiet-fabric-loom")
|
||||
}
|
||||
|
||||
val shade: Configuration by configurations.creating
|
||||
@@ -32,10 +32,6 @@ indra {
|
||||
}
|
||||
}
|
||||
|
||||
loom {
|
||||
serverOnlyMinecraftJar()
|
||||
}
|
||||
|
||||
tasks {
|
||||
shadowJar {
|
||||
configurations = listOf(shade)
|
||||
|
||||
@@ -36,7 +36,7 @@ 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;
|
||||
@@ -99,7 +99,7 @@ public final class MiniMOTDFabric implements ModInitializer, MiniMOTDPlatform<St
|
||||
}
|
||||
|
||||
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)))
|
||||
|
||||
@@ -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.19.x"
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
group=xyz.jpenilla
|
||||
version=2.0.7
|
||||
version=2.0.9
|
||||
description=Use MiniMessage text formatting in the server list MOTD.
|
||||
|
||||
org.gradle.caching=true
|
||||
|
||||
+10
-10
@@ -5,8 +5,8 @@ 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
|
||||
org.spongepowered.gradle.plugin: 2.0.2
|
||||
net.minecrell.plugin-yml.bungee: &plugin-yml 0.5.2
|
||||
net.minecrell.plugin-yml.bukkit: *plugin-yml
|
||||
xyz.jpenilla.run-paper: 1.0.6
|
||||
|
||||
@@ -14,21 +14,21 @@ versions:
|
||||
indra: 2.1.1
|
||||
shadow: 7.1.2
|
||||
testLoggerPlugin: 3.2.0
|
||||
adventure: 4.10.1
|
||||
adventurePlatform: 4.1.0
|
||||
adventurePlatformFabric: 5.2.1
|
||||
adventure: 4.11.0
|
||||
adventurePlatform: 4.1.2
|
||||
adventurePlatformFabric: 5.4.0-SNAPSHOT
|
||||
configurate: 4.1.2
|
||||
checkerQual: 3.22.0
|
||||
checkerQual: 3.24.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.51.0+1.18.2
|
||||
fabricLoader: 0.14.4
|
||||
fabricMinecraft: 1.18.2
|
||||
fabricApi: 0.60.0+1.19.2
|
||||
fabricLoader: 0.14.9
|
||||
fabricMinecraft: 1.19.2
|
||||
spongeApi7: 7.2.0
|
||||
velocityApi: 3.1.2-SNAPSHOT
|
||||
jupiterEngine: 5.8.2
|
||||
|
||||
Vendored
BIN
Binary file not shown.
+1
-1
@@ -1,5 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
@@ -205,6 +205,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
+8
-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,7 @@
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
if "%DIRNAME%"=="" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@@ -40,7 +40,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 +75,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
|
||||
|
||||
+5
-2
@@ -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() }
|
||||
@@ -24,7 +27,7 @@ pluginManagement {
|
||||
|
||||
plugins {
|
||||
id("ca.stellardrift.polyglot-version-catalogs") version "5.0.1"
|
||||
id("quiet-fabric-loom") version "0.11-SNAPSHOT"
|
||||
id("quiet-fabric-loom") version "0.12-SNAPSHOT"
|
||||
}
|
||||
|
||||
rootProject.name = "MiniMOTD"
|
||||
|
||||
Reference in new issue
Block a user