Compare commits
29
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b034e2ec64
|
||
|
|
a6652f6b83
|
||
|
|
8c66bcd408 | ||
|
|
2d47e73d3b | ||
|
|
f500c9fb8f | ||
|
|
922079cc7d | ||
|
|
798946390b | ||
|
|
743a149f3b | ||
|
|
316945b30f | ||
|
|
c8bf42463c | ||
|
|
a9bf505028 | ||
|
|
60bfb21444 | ||
|
|
fb13022642 | ||
|
|
1bbf3abd9a | ||
|
|
1967d9802f | ||
|
|
6b3d7aeab6 | ||
|
|
267c0426fe | ||
|
|
c3d5afa680 | ||
|
|
2009684fb5 | ||
|
|
56202f3f26 | ||
|
|
f2be2062e5 | ||
|
|
4cbe7d4bf9 | ||
|
|
fd20b5e583 | ||
|
|
e495e76a2d | ||
|
|
a37e7d8b7c | ||
|
|
b97ebcbbd6 | ||
|
|
2abf0c1eba | ||
|
|
80df7d0500 | ||
|
|
b7318a1ac8 |
No files matched your search
@@ -4,3 +4,4 @@
|
||||
# These are explicitly windows files and should use crlf
|
||||
*.bat text eol=crlf
|
||||
|
||||
.gitea/CODEOWNERS linguist-detectable=false
|
||||
@@ -0,0 +1,3 @@
|
||||
# Pull requests request review from the eligible staff team(s).
|
||||
# One approval from either an Admin or Developer satisfies branch protection.
|
||||
* @trueog/Admins @trueog/Developers
|
||||
@@ -17,3 +17,4 @@ jobs:
|
||||
modrinth-publish: true
|
||||
hangar-publish: true
|
||||
loom: true
|
||||
jdk-version: 21
|
||||
@@ -29,7 +29,6 @@ import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.framework.qual.DefaultQualifier;
|
||||
import xyz.jpenilla.minimotd.common.util.Components;
|
||||
|
||||
import static net.kyori.adventure.text.Component.space;
|
||||
import static net.kyori.adventure.text.Component.text;
|
||||
@@ -77,7 +76,7 @@ public final class CommandHandler {
|
||||
this.miniMOTD.reload();
|
||||
} catch (final Exception ex) {
|
||||
this.miniMOTD.logger().warn("Failed to reload MiniMOTD. Ensure there are no errors in your config files.", ex);
|
||||
audience.sendMessage(Components.ofChildren(
|
||||
audience.sendMessage(Component.textOfChildren(
|
||||
Constants.COMMAND_PREFIX,
|
||||
space(),
|
||||
text("Failed to reload MiniMOTD. Ensure there are no errors in your config files. See console for more details.", RED)
|
||||
@@ -85,7 +84,7 @@ public final class CommandHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
audience.sendMessage(Components.ofChildren(
|
||||
audience.sendMessage(Component.textOfChildren(
|
||||
Constants.COMMAND_PREFIX,
|
||||
space(),
|
||||
text("Done reloading configuration.", GREEN)
|
||||
|
||||
@@ -34,8 +34,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import org.checkerframework.framework.qual.DefaultQualifier;
|
||||
import org.slf4j.Logger;
|
||||
import xyz.jpenilla.minimotd.common.config.ConfigManager;
|
||||
import xyz.jpenilla.minimotd.common.config.MiniMOTDConfig;
|
||||
import xyz.jpenilla.minimotd.common.util.Components;
|
||||
import xyz.jpenilla.minimotd.common.config.MOTDConfig;
|
||||
|
||||
import static net.kyori.adventure.text.Component.newline;
|
||||
|
||||
@@ -77,7 +76,7 @@ public final class MiniMOTD<I> {
|
||||
return this.configManager;
|
||||
}
|
||||
|
||||
public PingResponse<I> createMOTD(final MiniMOTDConfig config, final int onlinePlayers, final int maxPlayers) {
|
||||
public PingResponse<I> createMOTD(final MOTDConfig config, final int onlinePlayers, final int maxPlayers) {
|
||||
final PingResponse.PlayerCount count = config.modifyPlayerCount(onlinePlayers, maxPlayers);
|
||||
final PingResponse.Builder<I> response = PingResponse.<I>builder()
|
||||
.playerCount(count)
|
||||
@@ -90,8 +89,8 @@ public final class MiniMOTD<I> {
|
||||
throw new IllegalStateException("MOTD is enabled, but there are no MOTDs in the config file?");
|
||||
}
|
||||
final int index = config.motds().size() == 1 ? 0 : ThreadLocalRandom.current().nextInt(config.motds().size());
|
||||
final MiniMOTDConfig.MOTD motdConfig = config.motds().get(index);
|
||||
final Component motd = Components.ofChildren(
|
||||
final MOTDConfig.MOTD motdConfig = config.motds().get(index);
|
||||
final Component motd = Component.textOfChildren(
|
||||
parse(motdConfig.line1(), count),
|
||||
newline(),
|
||||
parse(motdConfig.line2(), count)
|
||||
|
||||
@@ -46,18 +46,18 @@ public final class ConfigManager {
|
||||
|
||||
private final MiniMOTD<?> miniMOTD;
|
||||
|
||||
private final ConfigLoader<MiniMOTDConfig> mainConfigLoader;
|
||||
private MiniMOTDConfig mainConfig;
|
||||
private final ConfigLoader<MOTDConfig> mainConfigLoader;
|
||||
private MOTDConfig mainConfig;
|
||||
|
||||
private final ConfigLoader<PluginSettings> pluginSettingsLoader;
|
||||
private PluginSettings pluginSettings;
|
||||
|
||||
private final Map<String, MiniMOTDConfig> extraConfigs = new HashMap<>();
|
||||
private final Map<String, MOTDConfig> extraConfigs = new HashMap<>();
|
||||
|
||||
public ConfigManager(final @NonNull MiniMOTD<?> miniMOTD) {
|
||||
this.miniMOTD = miniMOTD;
|
||||
this.mainConfigLoader = new ConfigLoader<>(
|
||||
MiniMOTDConfig.class,
|
||||
MOTDConfig.class,
|
||||
this.miniMOTD.dataDirectory().resolve("main.conf"),
|
||||
options -> options.header("MiniMOTD Main Configuration")
|
||||
);
|
||||
@@ -94,12 +94,12 @@ public final class ConfigManager {
|
||||
continue;
|
||||
}
|
||||
final String name = path.getFileName().toString().replace(".conf", "");
|
||||
final ConfigLoader<MiniMOTDConfig> loader = new ConfigLoader<>(
|
||||
MiniMOTDConfig.class,
|
||||
final ConfigLoader<MOTDConfig> loader = new ConfigLoader<>(
|
||||
MOTDConfig.class,
|
||||
path,
|
||||
options -> options.header(String.format("Extra MiniMOTD config '%s'", name))
|
||||
);
|
||||
final MiniMOTDConfig config = loader.load();
|
||||
final MOTDConfig config = loader.load();
|
||||
loader.save(config);
|
||||
this.extraConfigs.put(name, config);
|
||||
}
|
||||
@@ -110,20 +110,20 @@ public final class ConfigManager {
|
||||
}
|
||||
|
||||
private void createDefaultExtraConfigs(final @NonNull Path extraConfigsDir) throws ConfigurateException {
|
||||
final List<Pair<Path, MiniMOTDConfig.MOTD>> defaults = Collections.unmodifiableList(Arrays.asList(
|
||||
pair(extraConfigsDir.resolve("skyblock.conf"), new MiniMOTDConfig.MOTD("<green><italic>Skyblock</green>", "<bold><rainbow>MiniMOTD Skyblock Server")),
|
||||
pair(extraConfigsDir.resolve("survival.conf"), new MiniMOTDConfig.MOTD("<gradient:blue:red>Survival Mode Hardcore", "<green><bold>MiniMOTD Survival Server"))
|
||||
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, MiniMOTDConfig.MOTD> pair : defaults) {
|
||||
final ConfigLoader<MiniMOTDConfig> loader = new ConfigLoader<>(
|
||||
MiniMOTDConfig.class,
|
||||
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");
|
||||
}
|
||||
@@ -137,7 +137,7 @@ public final class ConfigManager {
|
||||
return this.pluginSettings;
|
||||
}
|
||||
|
||||
public @NonNull MiniMOTDConfig resolveConfig(final @Nullable InetSocketAddress address) {
|
||||
public @NonNull MOTDConfig resolveConfig(final @Nullable InetSocketAddress address) {
|
||||
if (address == null) {
|
||||
return this.mainConfig();
|
||||
}
|
||||
@@ -153,11 +153,11 @@ public final class ConfigManager {
|
||||
return this.resolveConfig(configString);
|
||||
}
|
||||
|
||||
public @NonNull MiniMOTDConfig resolveConfig(final @NonNull String name) {
|
||||
public @NonNull MOTDConfig resolveConfig(final @NonNull String name) {
|
||||
if ("default".equals(name)) {
|
||||
return this.mainConfig();
|
||||
}
|
||||
final MiniMOTDConfig cfg = this.extraConfigs.get(name);
|
||||
final MOTDConfig cfg = this.extraConfigs.get(name);
|
||||
if (cfg != null) {
|
||||
return cfg;
|
||||
}
|
||||
|
||||
+5
-5
@@ -34,16 +34,16 @@ 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));
|
||||
}
|
||||
|
||||
@@ -123,9 +123,9 @@ 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.\n"
|
||||
@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 determined by the proxy will be used.")
|
||||
+ "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
|
||||
@@ -1,47 +0,0 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2024 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 net.kyori.adventure.text.ComponentLike;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.framework.qual.DefaultQualifier;
|
||||
|
||||
import static net.kyori.adventure.text.Component.empty;
|
||||
import static net.kyori.adventure.text.Component.text;
|
||||
|
||||
@DefaultQualifier(NonNull.class)
|
||||
public final class Components {
|
||||
private Components() {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
public static TextComponent ofChildren(final ComponentLike... children) {
|
||||
if (children.length == 0) {
|
||||
return empty();
|
||||
}
|
||||
|
||||
return text().append(children).build();
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -41,14 +41,14 @@ class ComponentColorDownsamplerTest {
|
||||
|
||||
@Test
|
||||
void testColorDownsampling() {
|
||||
final Component fullColor = Components.ofChildren(
|
||||
final Component fullColor = Component.textOfChildren(
|
||||
text("Green ", GREEN),
|
||||
text("Orange Yellow ", ORANGE_YELLOW),
|
||||
text("Pink ", PINK),
|
||||
text("Blue ", BLUE),
|
||||
text("Lime Green", LIME_GREEN)
|
||||
);
|
||||
final Component expectedDownsample = Components.ofChildren(
|
||||
final Component expectedDownsample = Component.textOfChildren(
|
||||
text("Green ", nearestTo(GREEN)),
|
||||
text("Orange Yellow ", nearestTo(ORANGE_YELLOW)),
|
||||
text("Pink ", nearestTo(PINK)),
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
group=xyz.jpenilla
|
||||
version=2.0.15-SNAPSHOT
|
||||
version=2.1.2-SNAPSHOT
|
||||
description=Use MiniMessage text formatting in the server list MOTD.
|
||||
|
||||
org.gradle.caching=true
|
||||
|
||||
@@ -30,5 +30,6 @@ val bukkitVersions = listOf(
|
||||
"1.17.1",
|
||||
"1.18.2",
|
||||
"1.19.4",
|
||||
"1.20.4"
|
||||
"1.20.6",
|
||||
"1.21",
|
||||
)
|
||||
@@ -1,6 +1,6 @@
|
||||
plugins {
|
||||
id("minimotd.platform-conventions")
|
||||
id("com.github.johnrengelman.shadow")
|
||||
id("io.github.goooler.shadow")
|
||||
}
|
||||
|
||||
tasks {
|
||||
|
||||
+15
-15
@@ -6,28 +6,28 @@ run-velocity = { id = "xyz.jpenilla.run-velocity", version.ref = "run-task" }
|
||||
run-waterfall = { id = "xyz.jpenilla.run-waterfall", version.ref = "run-task" }
|
||||
|
||||
[versions]
|
||||
run-task = "2.2.2"
|
||||
mod-publish-plugin = "0.4.5"
|
||||
hangarPublishPlugin = "0.1.1"
|
||||
run-task = "2.3.0"
|
||||
mod-publish-plugin = "0.5.1"
|
||||
hangarPublishPlugin = "0.1.2"
|
||||
indra = "3.1.3"
|
||||
shadow = "8.1.1"
|
||||
adventure = "4.15.0"
|
||||
adventurePlatform = "4.3.2"
|
||||
adventurePlatformFabric = "5.11.0-SNAPSHOT"
|
||||
shadow = "8.1.7"
|
||||
adventure = "4.17.0"
|
||||
adventurePlatform = "4.3.3"
|
||||
adventurePlatformFabric = "5.14.0-SNAPSHOT"
|
||||
configurate = "4.1.2"
|
||||
checkerQual = "3.42.0"
|
||||
checkerQual = "3.43.0"
|
||||
slf4j = "1.7.32"
|
||||
gson = "2.8.0"
|
||||
bstats = "3.0.2"
|
||||
paperApi = "1.16.5-R0.1-SNAPSHOT"
|
||||
paperlib = "1.0.8"
|
||||
waterfallApi = "1.16-R0.4-SNAPSHOT"
|
||||
fabricApi = "0.92.1+1.20.4"
|
||||
fabricLoader = "0.15.3"
|
||||
minecraft = "1.20.4"
|
||||
waterfallApi = "1.16-R0.5-SNAPSHOT"
|
||||
fabricApi = "0.100.3+1.21"
|
||||
fabricLoader = "0.15.11"
|
||||
minecraft = "1.21"
|
||||
spongeApi7 = "7.2.0"
|
||||
velocityApi = "3.2.0-SNAPSHOT"
|
||||
jupiterEngine = "5.10.1"
|
||||
velocityApi = "3.3.0-SNAPSHOT"
|
||||
jupiterEngine = "5.10.2"
|
||||
|
||||
[libraries]
|
||||
adventureBom = { group = "net.kyori", name = "adventure-bom", version.ref = "adventure" }
|
||||
@@ -72,7 +72,7 @@ jupiterEngine = { group = "org.junit.jupiter", name = "junit-jupiter-engine", ve
|
||||
# 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.github.johnrengelman", name = "shadow", version.ref = "shadow" }
|
||||
shadow = { group = "io.github.goooler.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" }
|
||||
|
||||
|
||||
Vendored
BIN
Binary file not shown.
+1
-1
@@ -1,6 +1,6 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
|
||||
@@ -55,7 +55,7 @@
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# 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/.
|
||||
|
||||
Vendored
+10
-10
@@ -43,11 +43,11 @@ set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
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
|
||||
|
||||
@@ -57,11 +57,11 @@ 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
|
||||
|
||||
|
||||
@@ -23,6 +23,9 @@ tasks {
|
||||
commonRelocation("net.kyori")
|
||||
commonRelocation("org.bstats")
|
||||
commonRelocation("io.papermc.lib")
|
||||
manifest {
|
||||
attributes("paperweight-mappings-namespace" to "mojang")
|
||||
}
|
||||
}
|
||||
processResources {
|
||||
val props = mapOf(
|
||||
|
||||
@@ -33,7 +33,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import xyz.jpenilla.minimotd.common.Constants;
|
||||
import xyz.jpenilla.minimotd.common.MiniMOTD;
|
||||
import xyz.jpenilla.minimotd.common.PingResponse;
|
||||
import xyz.jpenilla.minimotd.common.config.MiniMOTDConfig;
|
||||
import xyz.jpenilla.minimotd.common.config.MOTDConfig;
|
||||
|
||||
public final class PaperPingListener implements Listener {
|
||||
private final LegacyComponentSerializer unusualHexSerializer = LegacyComponentSerializer.builder().hexColors().useUnusualXRepeatedCharacterHexFormat().build();
|
||||
@@ -45,7 +45,7 @@ public final class PaperPingListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void handlePing(final @NonNull PaperServerListPingEvent event) {
|
||||
final MiniMOTDConfig cfg = this.miniMOTD.configManager().mainConfig();
|
||||
final MOTDConfig cfg = this.miniMOTD.configManager().mainConfig();
|
||||
|
||||
final PingResponse<CachedServerIcon> response = this.miniMOTD.createMOTD(cfg, event.getNumPlayers(), event.getMaxPlayers());
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ import org.bukkit.util.CachedServerIcon;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import xyz.jpenilla.minimotd.common.MiniMOTD;
|
||||
import xyz.jpenilla.minimotd.common.PingResponse;
|
||||
import xyz.jpenilla.minimotd.common.config.MiniMOTDConfig;
|
||||
import xyz.jpenilla.minimotd.common.config.MOTDConfig;
|
||||
|
||||
public final class PingListener implements Listener {
|
||||
private final MiniMOTD<CachedServerIcon> miniMOTD;
|
||||
@@ -44,7 +44,7 @@ public final class PingListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void handlePing(final @NonNull ServerListPingEvent event) {
|
||||
final MiniMOTDConfig cfg = this.miniMOTD.configManager().mainConfig();
|
||||
final MOTDConfig cfg = this.miniMOTD.configManager().mainConfig();
|
||||
|
||||
final PingResponse<CachedServerIcon> response = this.miniMOTD.createMOTD(cfg, event.getNumPlayers(), event.getMaxPlayers());
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ 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.config.MOTDConfig;
|
||||
import xyz.jpenilla.minimotd.common.util.UpdateChecker;
|
||||
|
||||
public final class MiniMOTDPlugin extends Plugin implements MiniMOTDPlatform<Favicon> {
|
||||
@@ -116,7 +116,7 @@ public final class MiniMOTDPlugin extends Plugin implements MiniMOTDPlatform<Fav
|
||||
}
|
||||
|
||||
private void preload() {
|
||||
final MiniMOTDConfig cfg = this.miniMOTD.configManager().mainConfig();
|
||||
final MOTDConfig cfg = this.miniMOTD.configManager().mainConfig();
|
||||
final PingResponse<Favicon> mini = this.miniMOTD.createMOTD(cfg, 0, 0);
|
||||
mini.motd(motd -> BungeeComponentSerializer.get().serialize(motd));
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import xyz.jpenilla.minimotd.common.Constants;
|
||||
import xyz.jpenilla.minimotd.common.MiniMOTD;
|
||||
import xyz.jpenilla.minimotd.common.PingResponse;
|
||||
import xyz.jpenilla.minimotd.common.config.MiniMOTDConfig;
|
||||
import xyz.jpenilla.minimotd.common.config.MOTDConfig;
|
||||
|
||||
public final class PingListener implements Listener {
|
||||
private final MiniMOTD<Favicon> miniMOTD;
|
||||
@@ -52,7 +52,7 @@ public final class PingListener implements Listener {
|
||||
}
|
||||
|
||||
final ServerPing.Players players = response.getPlayers();
|
||||
final MiniMOTDConfig cfg = this.miniMOTD.configManager().resolveConfig(e.getConnection().getVirtualHost());
|
||||
final MOTDConfig cfg = this.miniMOTD.configManager().resolveConfig(e.getConnection().getVirtualHost());
|
||||
final PingResponse<Favicon> mini = this.miniMOTD.createMOTD(cfg, players.getOnline(), players.getMax());
|
||||
|
||||
if (mini.hidePlayerCount()) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
plugins {
|
||||
id("quiet-fabric-loom")
|
||||
id("minimotd.platform-conventions")
|
||||
id("com.github.johnrengelman.shadow")
|
||||
id("io.github.goooler.shadow")
|
||||
}
|
||||
|
||||
val shade: Configuration by configurations.creating
|
||||
@@ -26,7 +26,7 @@ miniMOTDPlatform {
|
||||
|
||||
indra {
|
||||
javaVersions {
|
||||
target(17)
|
||||
target(21)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -38,7 +38,7 @@ import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import xyz.jpenilla.minimotd.common.Constants;
|
||||
import xyz.jpenilla.minimotd.common.MiniMOTD;
|
||||
import xyz.jpenilla.minimotd.common.PingResponse;
|
||||
import xyz.jpenilla.minimotd.common.config.MiniMOTDConfig;
|
||||
import xyz.jpenilla.minimotd.common.config.MOTDConfig;
|
||||
import xyz.jpenilla.minimotd.common.util.ComponentColorDownsampler;
|
||||
import xyz.jpenilla.minimotd.fabric.MiniMOTDFabric;
|
||||
import xyz.jpenilla.minimotd.fabric.access.ConnectionAccess;
|
||||
@@ -58,7 +58,7 @@ abstract class ServerStatusPacketListenerImplMixin {
|
||||
final ServerStatus vanillaStatus = Objects.requireNonNull(minecraftServer.getStatus(), "vanillaStatus");
|
||||
|
||||
final MiniMOTD<ServerStatus.Favicon> miniMOTD = miniMOTDFabric.miniMOTD();
|
||||
final MiniMOTDConfig config = miniMOTD.configManager().mainConfig();
|
||||
final MOTDConfig config = miniMOTD.configManager().mainConfig();
|
||||
|
||||
final PingResponse<ServerStatus.Favicon> response = miniMOTD.createMOTD(
|
||||
config,
|
||||
|
||||
@@ -23,8 +23,8 @@
|
||||
"minimotd-fabric.mixins.json"
|
||||
],
|
||||
"depends": {
|
||||
"fabricloader": ">=0.15.3",
|
||||
"fabricloader": ">=0.15.11",
|
||||
"fabric": "*",
|
||||
"minecraft": "~1.20.4"
|
||||
"minecraft": "~1.21"
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -31,7 +31,7 @@ import org.spongepowered.api.event.server.ClientPingServerEvent;
|
||||
import org.spongepowered.api.network.status.Favicon;
|
||||
import xyz.jpenilla.minimotd.common.MiniMOTD;
|
||||
import xyz.jpenilla.minimotd.common.PingResponse;
|
||||
import xyz.jpenilla.minimotd.common.config.MiniMOTDConfig;
|
||||
import xyz.jpenilla.minimotd.common.config.MOTDConfig;
|
||||
|
||||
final class ClientPingServerEventListener implements EventListener<ClientPingServerEvent> {
|
||||
private final MiniMOTD<Favicon> miniMOTD;
|
||||
@@ -58,7 +58,7 @@ final class ClientPingServerEventListener implements EventListener<ClientPingSer
|
||||
}
|
||||
}
|
||||
|
||||
final MiniMOTDConfig config = this.miniMOTD.configManager().mainConfig();
|
||||
final MOTDConfig config = this.miniMOTD.configManager().mainConfig();
|
||||
|
||||
final PingResponse<Favicon> mini = this.miniMOTD.createMOTD(config, players.getOnline(), players.getMax());
|
||||
mini.playerCount().applyCount(players::setOnline, players::setMax);
|
||||
|
||||
@@ -53,6 +53,7 @@ publishMods.modrinth {
|
||||
"1.17.1",
|
||||
"1.18.2",
|
||||
"1.19.4",
|
||||
"1.20.4"
|
||||
"1.20.6",
|
||||
"1.21",
|
||||
)
|
||||
}
|
||||
+2
-2
@@ -33,7 +33,7 @@ import org.spongepowered.api.network.status.Favicon;
|
||||
import xyz.jpenilla.minimotd.common.Constants;
|
||||
import xyz.jpenilla.minimotd.common.MiniMOTD;
|
||||
import xyz.jpenilla.minimotd.common.PingResponse;
|
||||
import xyz.jpenilla.minimotd.common.config.MiniMOTDConfig;
|
||||
import xyz.jpenilla.minimotd.common.config.MOTDConfig;
|
||||
import xyz.jpenilla.minimotd.common.util.ComponentColorDownsampler;
|
||||
|
||||
final class ClientPingServerEventListener implements EventListener<ClientPingServerEvent> {
|
||||
@@ -72,7 +72,7 @@ final class ClientPingServerEventListener implements EventListener<ClientPingSer
|
||||
}
|
||||
}
|
||||
|
||||
final MiniMOTDConfig config = this.miniMOTD.configManager().mainConfig();
|
||||
final MOTDConfig config = this.miniMOTD.configManager().mainConfig();
|
||||
|
||||
final PingResponse<Favicon> mini = this.miniMOTD.createMOTD(config, players.online(), players.max());
|
||||
mini.playerCount().applyCount(players::setOnline, players::setMax);
|
||||
|
||||
@@ -31,13 +31,16 @@ 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.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import org.checkerframework.framework.qual.DefaultQualifier;
|
||||
import xyz.jpenilla.minimotd.common.MiniMOTD;
|
||||
import xyz.jpenilla.minimotd.common.PingResponse;
|
||||
import xyz.jpenilla.minimotd.common.config.MiniMOTDConfig;
|
||||
import xyz.jpenilla.minimotd.common.config.MOTDConfig;
|
||||
|
||||
@DefaultQualifier(NonNull.class)
|
||||
public final class PingListener {
|
||||
@@ -56,7 +59,7 @@ public final class PingListener {
|
||||
}
|
||||
|
||||
private void handle(final ProxyPingEvent event) {
|
||||
final MiniMOTDConfig config = this.miniMOTD.configManager().resolveConfig(event.getConnection().getVirtualHost().orElse(null));
|
||||
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();
|
||||
@@ -64,12 +67,18 @@ public final class PingListener {
|
||||
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());
|
||||
|
||||
+7
-2
@@ -2,7 +2,12 @@ enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")
|
||||
|
||||
dependencyResolutionManagement {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
mavenCentral {
|
||||
mavenContent { releasesOnly() }
|
||||
}
|
||||
maven("https://oss.sonatype.org/content/repositories/snapshots/") {
|
||||
mavenContent { snapshotsOnly() }
|
||||
}
|
||||
maven("https://s01.oss.sonatype.org/content/repositories/snapshots/") {
|
||||
mavenContent { snapshotsOnly() }
|
||||
}
|
||||
@@ -25,7 +30,7 @@ pluginManagement {
|
||||
}
|
||||
|
||||
plugins {
|
||||
id("quiet-fabric-loom") version "1.5-SNAPSHOT"
|
||||
id("quiet-fabric-loom") version "1.6-SNAPSHOT"
|
||||
id("org.gradle.toolchains.foojay-resolver-convention") version "0.8.0"
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user