Compare commits

...
46 Commits
Author SHA1 Message Date
Jason Penilla 922079cc7d release: Version 2.1.1 2024-06-02 00:17:52 -07:00
renovate[bot] 798946390b chore(deps): Update gradle and github actions 2024-06-01 20:55:47 -07:00
renovate[bot] 743a149f3b chore(deps): Update dependency org.checkerframework:checker-qual to v3.43.0 2024-06-01 20:54:59 -07:00
renovate[bot] 316945b30f chore(deps): Update dependency net.fabricmc.fabric-api:fabric-api to v0.99.4+1.20.6 2024-06-01 20:54:50 -07:00
renovate[bot] c8bf42463c chore(deps): Update adventurePlatform to v4.3.3 2024-06-01 20:54:41 -07:00
Jason Penilla a9bf505028 Update dependencies 2024-05-10 17:41:09 -07:00
Jason Penilla 60bfb21444 Opt-out of remapping on Paper 1.20.5+ 2024-05-02 14:35:06 -07:00
Jason Penilla fb13022642 feat(fabric): Initial 1.20.6 update 2024-04-29 21:45:58 -07:00
Jason Penilla 1bbf3abd9a build updates 2024-04-29 21:32:37 -07:00
renovate[bot] 1967d9802f chore(deps): Update dependency net.fabricmc:fabric-loader to v0.15.10 2024-04-29 21:25:12 -07:00
renovate[bot] 6b3d7aeab6 chore(deps): Update dependency me.modmuss50:mod-publish-plugin to v0.5.1 2024-02-26 22:12:54 -07:00
renovate[bot] 267c0426fe chore(deps): Update dependency net.kyori:adventure-bom to v4.16.0 2024-02-26 22:12:43 -07:00
renovate[bot] c3d5afa680 chore(deps): Update dependency net.kyori:adventure-platform-fabric to v5.12.0 2024-02-26 22:12:13 -07:00
renovate[bot] 2009684fb5 chore(deps): Update dependency org.junit.jupiter:junit-jupiter-engine to v5.10.2 2024-02-05 18:23:42 -07:00
renovate[bot] 56202f3f26 chore(deps): Update dependency io.papermc:hangar-publish-plugin to v0.1.2 2024-02-02 16:45:09 -07:00
renovate[bot] f2be2062e5 chore(deps): Update dependency net.kyori:adventure-platform-fabric to v5.11.0 2024-01-21 10:19:46 -07:00
Jason Penilla 4cbe7d4bf9 Use adventure textOfChildren method 2024-01-13 21:03:33 -07:00
renovate[bot] fd20b5e583 chore(deps): Update dependency io.github.waterfallmc:waterfall-api to v1.16-R0.5-SNAPSHOT 2024-01-13 20:29:52 -07:00
Jason Penilla e495e76a2d 2.1.1-SNAPSHOT 2024-01-13 20:17:46 -07:00
Jason Penilla a37e7d8b7c release: Version 2.1.0 2024-01-13 20:15:30 -07:00
Jason Penillaandens-gijs b97ebcbbd6 Filter player lists with counts
closes #161

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

* pre-split host strings

* Extract real hostname from TCPShield hostnames

* fix style

* Update config comment

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

* fixup

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

* remove unused import

---------

Co-authored-by: ddPn08 <pyn.g.1125@gmail.com>
2024-01-12 21:08:40 -07:00
renovate[bot] 22064b8576 chore(deps): Update plugin org.gradle.toolchains.foojay-resolver-convention to v0.8.0 2024-01-12 12:59:31 -07:00
Jason Penilla aac6cab5f6 Update license 2024-01-06 16:47:31 -07:00
Jason Penilla 7197cf9100 Update loom, apply foojay resolver conventions, move build-logic dir 2024-01-06 16:20:37 -07:00
Jason Penilla b3c448136d Update dependencies for 1.20.4 2024-01-06 16:07:55 -07:00
renovate[bot] 25ad706ebf chore(deps): Update dependency net.kyori:adventure-bom to v4.15.0 2023-12-21 12:55:40 -08:00
renovate[bot] 3c04370488 chore(deps): Update adventurePlatform to v4.3.2 2023-12-21 12:52:44 -08:00
renovate[bot] 5a3c52481a chore(deps): Update gradle and github actions 2023-11-29 09:09:53 -08:00
renovate[bot] 2eb0ba1e98 chore(deps): Update dependency net.kyori:adventure-platform-fabric to v5.10.1 2023-11-17 11:56:29 -07:00
Jason Penilla b38e08daa0 build: switch from minotaur to mod-publish-plugin for modrinth publishing 2023-11-14 21:48:13 -07:00
renovate[bot] 3c61a2d24b chore(deps): Update dependency net.fabricmc.fabric-api:fabric-api to v0.90.7+1.20.2 2023-11-12 21:07:21 -07:00
renovate[bot] 611772f4bb chore(deps): Update dependency org.checkerframework:checker-qual to v3.40.0 2023-11-12 21:04:44 -07:00
renovate[bot] 118cef163a chore(deps): Update dependency net.fabricmc:fabric-loader to v0.14.24 2023-11-12 21:04:34 -07:00
renovate[bot] d17e4af825 chore(deps): Update dependency org.junit.jupiter:junit-jupiter-engine to v5.10.1 2023-11-12 21:04:26 -07:00
renovate[bot] 19a21d988f chore(deps): Update plugin blossom to v2.1.0 2023-11-12 21:04:17 -07:00
Jason Penilla 0cd04574f9 Remove plugin-yml-bungee 2023-11-12 20:58:04 -07:00
renovate[bot] 5acc5d285d chore(deps): Update dependency io.papermc:paperlib to v1.0.8 2023-11-12 20:49:22 -07:00
Jason Penilla 3d9e90d7bf Update gradle wrapper 2023-11-12 20:46:59 -07:00
Jason Penilla c39cad4017 Update loom to 1.4 2023-11-12 20:45:35 -07:00
Jason Penilla 9c9c67776b Remove guava dependency 2023-11-12 20:41:55 -07:00
Jason Penilla 2858de84ae Convert version catalog to toml and configure renovate 2023-11-12 20:39:43 -07:00
Jason Penilla 64b023fad7 2.0.15-SNAPSHOT 2023-09-30 12:20:22 -07:00
73 changed files with 487 additions and 426 deletions

No files matched your search

+1
View File
@@ -17,3 +17,4 @@ jobs:
modrinth-publish: true
hangar-publish: true
loom: true
jdk-version: 21
-10
View File
@@ -1,10 +0,0 @@
import ca.stellardrift.build.configurate.ConfigFormats
import ca.stellardrift.build.configurate.catalog.PolyglotVersionCatalogExtension
plugins {
id("ca.stellardrift.polyglot-version-catalogs") version "6.1.0"
}
extensions.configure<PolyglotVersionCatalogExtension> {
from(ConfigFormats.YAML, file("../gradle/libs.versions.yml"))
}
+1 -2
View File
@@ -1,5 +1,5 @@
plugins {
id("net.kyori.blossom")
alias(libs.plugins.blossom)
id("minimotd.base-conventions")
}
@@ -22,7 +22,6 @@ dependencies {
compileOnlyApi(libs.checkerQual)
compileOnlyApi(libs.gson)
testImplementation(libs.gson)
compileOnlyApi(libs.guava)
}
sourceSets.main {
@@ -1,7 +1,7 @@
/*
* This file is part of MiniMOTD, licensed under the MIT License.
*
* Copyright (c) 2020-2023 Jason Penilla
* 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
@@ -1,7 +1,7 @@
/*
* This file is part of MiniMOTD, licensed under the MIT License.
*
* Copyright (c) 2020-2023 Jason Penilla
* 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
@@ -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)
@@ -1,7 +1,7 @@
/*
* This file is part of MiniMOTD, licensed under the MIT License.
*
* Copyright (c) 2020-2023 Jason Penilla
* 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
@@ -1,7 +1,7 @@
/*
* This file is part of MiniMOTD, licensed under the MIT License.
*
* Copyright (c) 2020-2023 Jason Penilla
* 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
@@ -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)
@@ -1,7 +1,7 @@
/*
* This file is part of MiniMOTD, licensed under the MIT License.
*
* Copyright (c) 2020-2023 Jason Penilla
* 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
@@ -1,7 +1,7 @@
/*
* This file is part of MiniMOTD, licensed under the MIT License.
*
* Copyright (c) 2020-2023 Jason Penilla
* 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
@@ -1,7 +1,7 @@
/*
* This file is part of MiniMOTD, licensed under the MIT License.
*
* Copyright (c) 2020-2023 Jason Penilla
* 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
@@ -1,7 +1,7 @@
/*
* This file is part of MiniMOTD, licensed under the MIT License.
*
* Copyright (c) 2020-2023 Jason Penilla
* 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
@@ -23,11 +23,12 @@
*/
package xyz.jpenilla.minimotd.common.config;
import com.google.common.collect.ImmutableList;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -45,18 +46,18 @@ public final class ConfigManager {
private final MiniMOTD<?> miniMOTD;
private final ConfigLoader<MiniMOTDConfig> mainConfigLoader;
private MiniMOTDConfig mainConfig;
private final ConfigLoader<MOTDConfig> mainConfigLoader;
private MOTDConfig mainConfig;
private final ConfigLoader<PluginSettings> pluginSettingsLoader;
private PluginSettings pluginSettings;
private final Map<String, MiniMOTDConfig> extraConfigs = new HashMap<>();
private final Map<String, MOTDConfig> extraConfigs = new HashMap<>();
public ConfigManager(final @NonNull MiniMOTD<?> miniMOTD) {
this.miniMOTD = miniMOTD;
this.mainConfigLoader = new ConfigLoader<>(
MiniMOTDConfig.class,
MOTDConfig.class,
this.miniMOTD.dataDirectory().resolve("main.conf"),
options -> options.header("MiniMOTD Main Configuration")
);
@@ -93,12 +94,12 @@ public final class ConfigManager {
continue;
}
final String name = path.getFileName().toString().replace(".conf", "");
final ConfigLoader<MiniMOTDConfig> loader = new ConfigLoader<>(
MiniMOTDConfig.class,
final ConfigLoader<MOTDConfig> loader = new ConfigLoader<>(
MOTDConfig.class,
path,
options -> options.header(String.format("Extra MiniMOTD config '%s'", name))
);
final MiniMOTDConfig config = loader.load();
final MOTDConfig config = loader.load();
loader.save(config);
this.extraConfigs.put(name, config);
}
@@ -109,20 +110,20 @@ public final class ConfigManager {
}
private void createDefaultExtraConfigs(final @NonNull Path extraConfigsDir) throws ConfigurateException {
final List<Pair<Path, MiniMOTDConfig.MOTD>> defaults = ImmutableList.of(
pair(extraConfigsDir.resolve("skyblock.conf"), new MiniMOTDConfig.MOTD("<green><italic>Skyblock</green>", "<bold><rainbow>MiniMOTD Skyblock Server")),
pair(extraConfigsDir.resolve("survival.conf"), new MiniMOTDConfig.MOTD("<gradient:blue:red>Survival Mode Hardcore", "<green><bold>MiniMOTD Survival Server"))
);
for (final Pair<Path, MiniMOTDConfig.MOTD> pair : defaults) {
final ConfigLoader<MiniMOTDConfig> loader = new ConfigLoader<>(
MiniMOTDConfig.class,
final List<Pair<Path, MOTDConfig.MOTD>> defaults = Collections.unmodifiableList(Arrays.asList(
pair(extraConfigsDir.resolve("skyblock.conf"), new MOTDConfig.MOTD("<green><italic>Skyblock</green>", "<bold><rainbow>MiniMOTD Skyblock Server")),
pair(extraConfigsDir.resolve("survival.conf"), new MOTDConfig.MOTD("<gradient:blue:red>Survival Mode Hardcore", "<green><bold>MiniMOTD Survival Server"))
));
for (final Pair<Path, MOTDConfig.MOTD> pair : defaults) {
final ConfigLoader<MOTDConfig> loader = new ConfigLoader<>(
MOTDConfig.class,
pair.left()
);
loader.save(new MiniMOTDConfig(pair.right()));
loader.save(new MOTDConfig(pair.right()));
}
}
public @NonNull MiniMOTDConfig mainConfig() {
public @NonNull MOTDConfig mainConfig() {
if (this.mainConfig == null) {
throw new IllegalStateException("Config has not yet been loaded");
}
@@ -136,15 +137,14 @@ public final class ConfigManager {
return this.pluginSettings;
}
public @NonNull MiniMOTDConfig resolveConfig(final @Nullable InetSocketAddress address) {
public @NonNull MOTDConfig resolveConfig(final @Nullable InetSocketAddress address) {
if (address == null) {
return this.mainConfig();
}
final String hostString = address.getHostString() + ":" + address.getPort();
final String configString = this.pluginSettings().proxySettings().findConfigStringForHost(hostString);
final String configString = this.pluginSettings().proxySettings().findConfigStringForHost(address.getHostString(), address.getPort());
if (this.pluginSettings().proxySettings().virtualHostTestMode()) {
this.miniMOTD.platform().logger().info("[virtual-host-debug] Virtual Host: '{}', Selected Config: '{}'", hostString, configString == null ? "default" : configString);
this.miniMOTD.platform().logger().info("[virtual-host-debug] Virtual Host: '{}:{}', Selected Config: '{}'", address.getHostString(), address.getPort(), configString == null ? "default" : configString);
}
if (configString == null) {
@@ -153,11 +153,11 @@ public final class ConfigManager {
return this.resolveConfig(configString);
}
public @NonNull MiniMOTDConfig resolveConfig(final @NonNull String name) {
public @NonNull MOTDConfig resolveConfig(final @NonNull String name) {
if ("default".equals(name)) {
return this.mainConfig();
}
final MiniMOTDConfig cfg = this.extraConfigs.get(name);
final MOTDConfig cfg = this.extraConfigs.get(name);
if (cfg != null) {
return cfg;
}
@@ -1,7 +1,7 @@
/*
* This file is part of MiniMOTD, licensed under the MIT License.
*
* Copyright (c) 2020-2023 Jason Penilla
* 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
@@ -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,6 +123,11 @@ public final class MiniMOTDConfig {
+ "If false, the online player count will be capped at the maximum player count")
private boolean allowExceedingMaximum = false;
@Comment("The list of server names that affect player counts/listing.\n"
+ "Only applicable when running the plugin on a proxy (Velocity or Waterfall/Bungeecord).\n"
+ "When set to an empty list, the default count & list as determined by the proxy will be used.")
private final List<String> servers = new ArrayList<>();
@ConfigSerializable
public static final class JustXMore {
@@ -157,6 +162,10 @@ public final class MiniMOTDConfig {
}
public List<String> targetServers() {
return this.playerCountSettings.servers;
}
public boolean iconEnabled() {
return this.iconEnabled;
}
@@ -1,7 +1,7 @@
/*
* This file is part of MiniMOTD, licensed under the MIT License.
*
* Copyright (c) 2020-2023 Jason Penilla
* 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
@@ -1,7 +1,7 @@
/*
* This file is part of MiniMOTD, licensed under the MIT License.
*
* Copyright (c) 2020-2023 Jason Penilla
* 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
@@ -23,9 +23,10 @@
*/
package xyz.jpenilla.minimotd.common.config;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Locale;
import java.util.Map;
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.spongepowered.configurate.objectmapping.ConfigSerializable;
@@ -50,11 +51,19 @@ public final class PluginSettings {
this.virtualHostConfigs.put("skyblock.example.com:25565", "skyblock");
}
public ProxySettings(final Map<String, String> virtualHostConfigs) {
this.virtualHostConfigs.putAll(virtualHostConfigs);
}
@Comment("Here you can assign configs in the 'extra-configs' folder to specific virtual hosts\n"
+ "Either use the name of the config in 'extra-configs', or use \"default\" to use the configuration in main.conf\n"
+ "\n"
+ "Format is \"hostname:port\"=\"configName|default\"")
private final Map<String, String> virtualHostConfigs = new HashMap<>();
+ "Format is \"hostname:port\"=\"configName|default\"\n"
+ "Parts of domains can be substituted for wildcards, i.e. \"*.mydomain.com:25565\". Wildcard-containing configs are\n"
+ "checked in the order they are declared if there are no exact matches.")
private final Map<String, String> virtualHostConfigs = new LinkedHashMap<>();
private transient @MonotonicNonNull Map<String[], String> splitVirtualHostConfigs;
@Comment("Set whether to enable virtual host testing mode.\n"
+ "When enabled, MiniMOTD will print virtual host debug info to the console on each server ping.")
@@ -64,8 +73,61 @@ public final class PluginSettings {
return this.virtualHostTestMode;
}
public @Nullable String findConfigStringForHost(final @NonNull String host) {
return this.virtualHostConfigs.get(host.toLowerCase(Locale.ENGLISH));
public @Nullable String findConfigStringForHost(@NonNull String host, final int port) {
host = processTcpShieldHostname(host).toLowerCase(Locale.ENGLISH) + ':' + port;
final @Nullable String exactMatch = this.virtualHostConfigs.get(host);
if (exactMatch != null) {
return exactMatch;
}
if (this.splitVirtualHostConfigs.isEmpty()) {
return null;
}
final String[] splitHost = host.split("\\.");
configs:
for (final Map.Entry<String[], String> e : this.splitVirtualHostConfigs.entrySet()) {
final String[] splitKey = e.getKey();
if (splitKey.length != splitHost.length) {
continue;
}
for (int i = 0; i < splitHost.length; i++) {
final String keyPart = splitKey[i];
if (!keyPart.equals(splitHost[i]) && !keyPart.equals("*")) {
continue configs;
}
}
return e.getValue();
}
return null;
}
private static String processTcpShieldHostname(final String hostname) {
if (hostname.contains("///")) {
final String[] split = hostname.split("///");
if (split.length == 4) {
// <actual hostname>///<user-ip>:<user-port>///<unix timestamp>///<signature>
return split[0];
}
}
return hostname;
}
public void processVirtualHosts() {
final Map<String, String> virtualHosts = new LinkedHashMap<>(this.virtualHostConfigs);
this.virtualHostConfigs.clear();
virtualHosts.forEach((host, config) -> this.virtualHostConfigs.put(host.toLowerCase(Locale.ENGLISH), config));
this.splitVirtualHostConfigs = new LinkedHashMap<>();
this.virtualHostConfigs.forEach((host, config) -> {
if (!host.contains("*")) {
return;
}
this.splitVirtualHostConfigs.put(host.split("\\."), config);
});
}
}
@@ -78,9 +140,7 @@ public final class PluginSettings {
}
@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));
private void processVirtualHosts() {
this.proxySettings.processVirtualHosts();
}
}
@@ -1,7 +1,7 @@
/*
* This file is part of MiniMOTD, licensed under the MIT License.
*
* Copyright (c) 2020-2023 Jason Penilla
* 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
@@ -1,7 +1,7 @@
/*
* This file is part of MiniMOTD, licensed under the MIT License.
*
* Copyright (c) 2020-2023 Jason Penilla
* 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
@@ -1,47 +0,0 @@
/*
* 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.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();
}
}
@@ -1,7 +1,7 @@
/*
* This file is part of MiniMOTD, licensed under the MIT License.
*
* Copyright (c) 2020-2023 Jason Penilla
* 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
@@ -1,7 +1,7 @@
/*
* This file is part of MiniMOTD, licensed under the MIT License.
*
* Copyright (c) 2020-2023 Jason Penilla
* 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
@@ -1,7 +1,7 @@
/*
* This file is part of MiniMOTD, licensed under the MIT License.
*
* Copyright (c) 2020-2023 Jason Penilla
* 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
@@ -23,14 +23,14 @@
*/
package xyz.jpenilla.minimotd.common.util;
import com.google.common.base.Charsets;
import com.google.common.collect.ImmutableList;
import com.google.gson.JsonArray;
import com.google.gson.JsonParser;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.LinkedList;
@@ -45,7 +45,7 @@ public final class UpdateChecker {
public @NonNull List<String> checkVersion() {
final JsonArray result;
final String url = String.format("https://api.github.com/repos/%s/%s/releases", Constants.PluginMetadata.GITHUB_USER, Constants.PluginMetadata.GITHUB_REPO);
try (final InputStream is = new URL(url).openStream(); InputStreamReader reader = new InputStreamReader(is, Charsets.UTF_8)) {
try (final InputStream is = new URL(url).openStream(); InputStreamReader reader = new InputStreamReader(is, StandardCharsets.UTF_8)) {
result = this.parser.parse(reader).getAsJsonArray();
} catch (final IOException ex) {
return Collections.singletonList("Cannot look for updates: " + ex.getMessage());
@@ -58,13 +58,13 @@ public final class UpdateChecker {
return Collections.emptyList(); // Up to date, do nothing
}
if (currentVersion.contains("SNAPSHOT")) {
return ImmutableList.of(
return Arrays.asList(
"This server is running a development build of " + Constants.PluginMetadata.NAME + "! (" + currentVersion + ")",
"The latest official release is " + versionList.get(0)
);
}
final int versionsBehind = versionList.indexOf(currentVersion);
return ImmutableList.of(
return Arrays.asList(
"There is an update available for " + Constants.PluginMetadata.NAME + "!",
"This server is running version " + currentVersion + ", which is " + (versionsBehind == -1 ? "UNKNOWN" : versionsBehind) + " versions outdated.",
"Download the latest version, " + versionList.get(0) + " from GitHub at the link below:",
@@ -0,0 +1,56 @@
/*
* 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;
import java.util.LinkedHashMap;
import java.util.Map;
import org.junit.jupiter.api.Test;
import xyz.jpenilla.minimotd.common.config.PluginSettings;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
class VirtualHostMatchingTest {
@Test
void testMatching() {
final Map<String, String> map = new LinkedHashMap<>();
map.put("abc.xyz:25565", "1");
map.put("subdomain.abc.xyz:25565", "2");
map.put("*.abc.xyz:25565", "3");
map.put("abc.*.*.domain.com:25565", "4");
map.put("*.*.*.domain.com:25565", "5");
final PluginSettings.ProxySettings proxySettings = new PluginSettings.ProxySettings(map);
proxySettings.processVirtualHosts();
assertEquals("1", proxySettings.findConfigStringForHost("abc.xyz", 25565));
assertEquals("2", proxySettings.findConfigStringForHost("subdomain.abc.xyz", 25565));
assertEquals("3", proxySettings.findConfigStringForHost("other_subdomain.abc.xyz", 25565));
assertEquals("4", proxySettings.findConfigStringForHost("abc.2.3.domain.com", 25565));
assertEquals("5", proxySettings.findConfigStringForHost("1.2.3.domain.com", 25565));
// TCPShield-mangled hostname
assertEquals("5", proxySettings.findConfigStringForHost("1.2.3.domain.com///127.0.0.1:25565///1681016669///MGQCMAW5X13a9cF5ysnWdrBLovH4wfVu60l7eBUwWsCI8vw0cuZ9aj+UM7+y1wC//qGHngIwRsCke7eCpO99HTHOVdvZKjx9G0E51ALqRFGWH7kxMhVKYNF2IfMaT1FfbS0/D0du", 25565));
assertNull(proxySettings.findConfigStringForHost("subdomain.subdomain.abc.xyz", 25565));
assertNull(proxySettings.findConfigStringForHost("google.com", 25565));
}
}
@@ -1,7 +1,7 @@
/*
* This file is part of MiniMOTD, licensed under the MIT License.
*
* Copyright (c) 2020-2023 Jason Penilla
* 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
@@ -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
View File
@@ -1,5 +1,5 @@
group=xyz.jpenilla
version=2.0.14
version=2.1.1
description=Use MiniMessage text formatting in the server list MOTD.
org.gradle.caching=true
@@ -10,7 +10,7 @@ dependencies {
implementation(libs.indraCommon)
implementation(libs.indraLicenser)
implementation(libs.shadow)
implementation(libs.minotaur)
implementation(libs.mod.publish.plugin)
implementation(libs.hangarPublishPlugin)
// https://github.com/gradle/gradle/issues/15383#issuecomment-779893192
+9
View File
@@ -0,0 +1,9 @@
rootProject.name = "build-logic"
dependencyResolutionManagement {
versionCatalogs {
create("libs") {
from(files("../libs.versions.toml"))
}
}
}
@@ -2,18 +2,18 @@ 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
import org.gradle.kotlin.dsl.getByType
fun Project.lastCommitHash(): String =
the<IndraGitExtension>().commit()?.name?.substring(0, 7) ?: "unknown"
extensions.getByType<IndraGitExtension>().commit()?.name?.substring(0, 7) ?: "unknown"
val Project.libs: LibrariesForLibs
get() = the()
get() = extensions.getByType()
val Project.releaseNotes: Provider<String>
get() = providers.environmentVariable("RELEASE_NOTES")
val Project.minecraftVersion
val Project.minecraftVersion: String
get() = libs.versions.minecraft.get()
val bukkitVersions = listOf(
@@ -30,5 +30,5 @@ val bukkitVersions = listOf(
"1.17.1",
"1.18.2",
"1.19.4",
"1.20.2"
"1.20.4"
)
@@ -27,7 +27,7 @@ tasks {
withType<JavaCompile> {
options.compilerArgs.add("-Xlint:-processing")
}
sequenceOf(javadocJar, javadoc).forEach {
listOf(javadocJar, javadoc).forEach {
it.configure {
onlyIf { false }
}
@@ -1,12 +1,10 @@
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 }
.extensions.getByType<MiniMOTDPlatformExtension>().jarTask.flatMap { it.archiveFile }
hangarPublish.publications.register("plugin") {
version.set(project.version as String)
@@ -15,7 +13,7 @@ hangarPublish.publications.register("plugin") {
changelog.set(releaseNotes)
apiKey.set(providers.environmentVariable("HANGAR_UPLOAD_KEY"))
platforms {
register(Platforms.PAPER) {
paper {
jar.set(jar("bukkit"))
val vers = bukkitVersions.toMutableList()
vers -= "1.8.8"
@@ -23,11 +21,11 @@ hangarPublish.publications.register("plugin") {
vers += "1.8"
platformVersions.addAll(vers)
}
register(Platforms.VELOCITY) {
velocity {
jar.set(jar("velocity"))
platformVersions.addAll("3.2")
}
register(Platforms.WATERFALL) {
waterfall {
jar.set(jar("bungeecord"))
platformVersions.addAll("1.20")
}
@@ -1,4 +1,4 @@
import com.modrinth.minotaur.ModrinthExtension
import me.modmuss50.mpp.ModPublishExtension
plugins {
id("minimotd.base-conventions")
@@ -20,13 +20,15 @@ tasks {
}
if (name != "minimotd-bukkit-bungeecord") {
plugins.apply("com.modrinth.minotaur")
plugins.apply("me.modmuss50.mod-publish-plugin")
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"))
extensions.configure(ModPublishExtension::class) {
modrinth {
projectId.set("16vhQOQN")
type = STABLE
file.set(platformExtension.jarTask.flatMap { it.archiveFile })
changelog.set(releaseNotes)
accessToken.set(providers.environmentVariable("MODRINTH_TOKEN"))
}
}
}
@@ -1,6 +1,6 @@
plugins {
id("minimotd.platform-conventions")
id("com.github.johnrengelman.shadow")
id("io.github.goooler.shadow")
}
tasks {
+79
View File
@@ -0,0 +1,79 @@
[plugins]
blossom = { id = "net.kyori.blossom", version = "2.1.0" }
sponge-gradle-plugin = { id = "org.spongepowered.gradle.plugin", version = "2.2.0" }
run-paper = { id = "xyz.jpenilla.run-paper", version.ref = "run-task" }
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.3.0"
mod-publish-plugin = "0.5.1"
hangarPublishPlugin = "0.1.2"
indra = "3.1.3"
shadow = "8.1.7"
adventure = "4.17.0"
adventurePlatform = "4.3.3"
adventurePlatformFabric = "5.13.0"
configurate = "4.1.2"
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.5-SNAPSHOT"
fabricApi = "0.99.4+1.20.6"
fabricLoader = "0.15.11"
minecraft = "1.20.6"
spongeApi7 = "7.2.0"
velocityApi = "3.2.0-SNAPSHOT"
jupiterEngine = "5.10.2"
[libraries]
adventureBom = { group = "net.kyori", name = "adventure-bom", version.ref = "adventure" }
adventureApi = { group = "net.kyori", name = "adventure-api" }
adventureTextSerializerPlain = { group = "net.kyori", name = "adventure-text-serializer-plain" }
adventureTextSerializerGson = { group = "net.kyori", name = "adventure-text-serializer-gson" }
adventurePlatformBungeecord = { group = "net.kyori", name = "adventure-platform-bungeecord", version.ref = "adventurePlatform" }
adventurePlatformBukkit = { group = "net.kyori", name = "adventure-platform-bukkit", version.ref = "adventurePlatform" }
adventurePlatformFabric = { group = "net.kyori", name = "adventure-platform-fabric", version.ref = "adventurePlatformFabric" }
adventurePlatformSpongeApi = { group = "net.kyori", name = "adventure-platform-spongeapi", version.ref = "adventurePlatform" }
minimessage = { group = "net.kyori", name = "adventure-text-minimessage" }
configurateHocon = { group = "org.spongepowered", name = "configurate-hocon", version.ref = "configurate" }
checkerQual = { group = "org.checkerframework", name = "checker-qual", version.ref = "checkerQual" }
slf4jApi = { group = "org.slf4j", name = "slf4j-api", version.ref = "slf4j" }
slf4jJdk14 = { group = "org.slf4j", name = "slf4j-jdk14", version.ref = "slf4j" }
gson = { group = "com.google.code.gson", name = "gson", version.ref = "gson" }
bstatsBukkit = { group = "org.bstats", name = "bstats-bukkit", version.ref = "bstats" }
bstatsBungeecord = { group = "org.bstats", name = "bstats-bungeecord", version.ref = "bstats" }
bstatsVelocity = { group = "org.bstats", name = "bstats-velocity", version.ref = "bstats" }
bstatsSponge = { group = "org.bstats", name = "bstats-sponge", version.ref = "bstats" }
paperApi = { group = "com.destroystokyo.paper", name = "paper-api", version.ref = "paperApi" }
paperlib = { group = "io.papermc", name = "paperlib", version.ref = "paperlib" }
waterfallApi = { group = "io.github.waterfallmc", name = "waterfall-api", version.ref = "waterfallApi" }
fabricApi = { group = "net.fabricmc.fabric-api", name = "fabric-api", version.ref = "fabricApi" }
fabricLoader = { group = "net.fabricmc", name = "fabric-loader", version.ref = "fabricLoader" }
minecraft = { group = "com.mojang", name = "minecraft", version.ref = "minecraft" }
spongeApi7 = { group = "org.spongepowered", name = "spongeapi", version.ref = "spongeApi7" }
velocityApi = { group = "com.velocitypowered", name = "velocity-api", version.ref = "velocityApi" }
jupiterEngine = { group = "org.junit.jupiter", name = "junit-jupiter-engine", version.ref = "jupiterEngine" }
# build-logic
indraCommon = { group = "net.kyori", name = "indra-common", version.ref = "indra" }
indraLicenser = { group = "net.kyori", name = "indra-licenser-spotless", version.ref = "indra" }
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" }
[bundles]
-181
View File
@@ -1,181 +0,0 @@
metadata:
format: { version: 1.0 }
polyglot-extensions:
- plugins
plugins:
net.kyori.blossom: 2.0.1
org.spongepowered.gradle.plugin: 2.2.0
net.minecrell.plugin-yml.bungee: 0.5.3
xyz.jpenilla.run-paper: &run-task 2.2.0
xyz.jpenilla.run-velocity: *run-task
xyz.jpenilla.run-waterfall: *run-task
versions:
minotaur: 2.7.5
hangarPublishPlugin: 0.1.0
indra: 3.1.3
shadow: 8.1.1
adventure: 4.14.0
adventurePlatform: 4.3.1
adventurePlatformFabric: 5.10.0
configurate: 4.1.2
checkerQual: 3.38.0
slf4j: 1.7.32
gson: 2.8.0
guava: 21.0
bstats: 3.0.2
paperApi: 1.16.5-R0.1-SNAPSHOT
paperlib: 1.0.8-SNAPSHOT
waterfallApi: 1.16-R0.4-SNAPSHOT
fabricApi: 0.89.2+1.20.2
fabricLoader: 0.14.22
minecraft: 1.20.2
spongeApi7: 7.2.0
velocityApi: 3.1.2-SNAPSHOT
jupiterEngine: 5.10.0
dependencies:
adventureBom:
group: net.kyori
name: adventure-bom
version: { ref: adventure }
adventureApi:
group: net.kyori
name: adventure-api
adventureTextSerializerPlain:
group: net.kyori
name: adventure-text-serializer-plain
adventureTextSerializerGson:
group: net.kyori
name: adventure-text-serializer-gson
adventurePlatformBungeecord:
group: net.kyori
name: adventure-platform-bungeecord
version: { ref: adventurePlatform }
adventurePlatformBukkit:
group: net.kyori
name: adventure-platform-bukkit
version: { ref: adventurePlatform }
adventurePlatformFabric:
group: net.kyori
name: adventure-platform-fabric
version: { ref: adventurePlatformFabric }
adventurePlatformSpongeApi:
group: net.kyori
name: adventure-platform-spongeapi
version: { ref: adventurePlatform }
minimessage:
group: net.kyori
name: adventure-text-minimessage
configurateHocon:
group: org.spongepowered
name: configurate-hocon
version: { ref: configurate }
checkerQual:
group: org.checkerframework
name: checker-qual
version: { ref: checkerQual }
slf4jApi:
group: org.slf4j
name: slf4j-api
version: { ref: slf4j }
slf4jJdk14:
group: org.slf4j
name: slf4j-jdk14
version: { ref: slf4j }
gson:
group: com.google.code.gson
name: gson
version: { ref: gson }
guava:
group: com.google.guava
name: guava
version: { ref: guava }
bstatsBukkit:
group: org.bstats
name: bstats-bukkit
version: { ref: bstats }
bstatsBungeecord:
group: org.bstats
name: bstats-bungeecord
version: { ref: bstats }
bstatsVelocity:
group: org.bstats
name: bstats-velocity
version: { ref: bstats }
bstatsSponge:
group: org.bstats
name: bstats-sponge
version: { ref: bstats }
paperApi:
group: com.destroystokyo.paper
name: paper-api
version: { ref: paperApi }
paperlib:
group: io.papermc
name: paperlib
version: { ref: paperlib }
waterfallApi:
group: io.github.waterfallmc
name: waterfall-api
version: { ref: waterfallApi }
fabricApi:
group: net.fabricmc.fabric-api
name: fabric-api
version: { ref: fabricApi }
fabricLoader:
group: net.fabricmc
name: fabric-loader
version: { ref: fabricLoader }
minecraft:
group: com.mojang
name: minecraft
version: { ref: minecraft }
spongeApi7:
group: org.spongepowered
name: spongeapi
version: { ref: spongeApi7 }
velocityApi:
group: com.velocitypowered
name: velocity-api
version: { ref: velocityApi }
jupiterEngine:
group: org.junit.jupiter
name: junit-jupiter-engine
version: { ref: jupiterEngine }
# build-logic
indraCommon:
group: net.kyori
name: indra-common
version: { ref: indra }
indraLicenser:
group: net.kyori
name: indra-licenser-spotless
version: { ref: indra }
shadow:
group: com.github.johnrengelman
name: shadow
version: { ref: shadow }
minotaur:
group: com.modrinth.minotaur
name: Minotaur
version: { ref: minotaur }
hangarPublishPlugin:
group: io.papermc
name: hangar-publish-plugin
version: { ref: hangarPublishPlugin }
bundles:
Binary file not shown.
+2 -1
View File
@@ -1,6 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Vendored
+14 -10
View File
@@ -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/.
@@ -83,7 +83,8 @@ done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
@@ -130,10 +131,13 @@ location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi
# Increase the maximum file descriptors if we can.
@@ -141,7 +145,7 @@ 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
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
@@ -149,7 +153,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
@@ -198,11 +202,11 @@ 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
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
Vendored
+10 -10
View File
@@ -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
+1 -1
View File
@@ -1,6 +1,6 @@
MIT License
Copyright (c) 2020-2023 Jason Penilla
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
+1 -1
View File
@@ -1,6 +1,6 @@
This file is part of MiniMOTD, licensed under the MIT License.
Copyright (c) 2020-2023 Jason Penilla
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
+7 -4
View File
@@ -1,6 +1,6 @@
plugins {
id("minimotd.shadow-platform")
id("xyz.jpenilla.run-paper")
alias(libs.plugins.run.paper)
}
dependencies {
@@ -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(
@@ -39,7 +42,7 @@ tasks {
runPaper.folia.registerTask()
modrinth {
loaders.set(listOf("paper", "folia"))
gameVersions.addAll(bukkitVersions)
publishMods.modrinth {
modLoaders.addAll("paper", "folia")
minecraftVersions.addAll(bukkitVersions)
}
@@ -1,7 +1,7 @@
/*
* This file is part of MiniMOTD, licensed under the MIT License.
*
* Copyright (c) 2020-2023 Jason Penilla
* 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
@@ -1,7 +1,7 @@
/*
* This file is part of MiniMOTD, licensed under the MIT License.
*
* Copyright (c) 2020-2023 Jason Penilla
* 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
@@ -1,7 +1,7 @@
/*
* This file is part of MiniMOTD, licensed under the MIT License.
*
* Copyright (c) 2020-2023 Jason Penilla
* 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
@@ -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());
@@ -1,7 +1,7 @@
/*
* This file is part of MiniMOTD, licensed under the MIT License.
*
* Copyright (c) 2020-2023 Jason Penilla
* 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
@@ -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());
+14 -11
View File
@@ -1,7 +1,6 @@
plugins {
id("minimotd.shadow-platform")
id("net.minecrell.plugin-yml.bungee")
id("xyz.jpenilla.run-waterfall")
alias(libs.plugins.run.waterfall)
}
dependencies {
@@ -21,15 +20,19 @@ tasks {
runWaterfall {
waterfallVersion("1.20")
}
processResources {
val props = mapOf(
"version" to project.version,
"description" to project.description
)
inputs.properties(props)
filesMatching("bungee.yml") {
expand(props)
}
}
}
bungee {
name = rootProject.name
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)
publishMods.modrinth {
modLoaders.add("waterfall")
minecraftVersions.addAll(minecraftVersion)
}
@@ -1,7 +1,7 @@
/*
* This file is part of MiniMOTD, licensed under the MIT License.
*
* Copyright (c) 2020-2023 Jason Penilla
* 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
@@ -1,7 +1,7 @@
/*
* This file is part of MiniMOTD, licensed under the MIT License.
*
* Copyright (c) 2020-2023 Jason Penilla
* 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
@@ -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));
}
@@ -1,7 +1,7 @@
/*
* This file is part of MiniMOTD, licensed under the MIT License.
*
* Copyright (c) 2020-2023 Jason Penilla
* 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
@@ -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()) {
@@ -0,0 +1,5 @@
name: MiniMOTD
main: xyz.jpenilla.minimotd.bungee.MiniMOTDPlugin
version: $version
author: jmp
description: $description
+7 -2
View File
@@ -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)
}
}
@@ -53,3 +53,8 @@ tasks {
}
}
}
publishMods.modrinth {
modLoaders.add("fabric")
minecraftVersions.addAll(minecraftVersion)
}
@@ -1,7 +1,7 @@
/*
* This file is part of MiniMOTD, licensed under the MIT License.
*
* Copyright (c) 2020-2023 Jason Penilla
* 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
@@ -1,7 +1,7 @@
/*
* This file is part of MiniMOTD, licensed under the MIT License.
*
* Copyright (c) 2020-2023 Jason Penilla
* 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
@@ -1,7 +1,7 @@
/*
* This file is part of MiniMOTD, licensed under the MIT License.
*
* Copyright (c) 2020-2023 Jason Penilla
* 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
@@ -1,7 +1,7 @@
/*
* This file is part of MiniMOTD, licensed under the MIT License.
*
* Copyright (c) 2020-2023 Jason Penilla
* 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
@@ -1,7 +1,7 @@
/*
* This file is part of MiniMOTD, licensed under the MIT License.
*
* Copyright (c) 2020-2023 Jason Penilla
* 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
@@ -1,7 +1,7 @@
/*
* This file is part of MiniMOTD, licensed under the MIT License.
*
* Copyright (c) 2020-2023 Jason Penilla
* 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
@@ -1,7 +1,7 @@
/*
* This file is part of MiniMOTD, licensed under the MIT License.
*
* Copyright (c) 2020-2023 Jason Penilla
* 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
@@ -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,
@@ -1,7 +1,7 @@
/*
* This file is part of MiniMOTD, licensed under the MIT License.
*
* Copyright (c) 2020-2023 Jason Penilla
* 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
@@ -23,8 +23,8 @@
"minimotd-fabric.mixins.json"
],
"depends": {
"fabricloader": ">=0.14.6",
"fabricloader": ">=0.15.10",
"fabric": "*",
"minecraft": "~1.20.2"
"minecraft": "~1.20.5"
}
}
+3 -3
View File
@@ -30,7 +30,7 @@ tasks {
}
}
modrinth {
loaders.add("sponge")
gameVersions.add("1.12.2")
publishMods.modrinth {
modLoaders.add("sponge")
minecraftVersions.add("1.12.2")
}
@@ -1,7 +1,7 @@
/*
* This file is part of MiniMOTD, licensed under the MIT License.
*
* Copyright (c) 2020-2023 Jason Penilla
* 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
@@ -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);
@@ -1,7 +1,7 @@
/*
* This file is part of MiniMOTD, licensed under the MIT License.
*
* Copyright (c) 2020-2023 Jason Penilla
* 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
+5 -4
View File
@@ -3,7 +3,7 @@ import org.spongepowered.plugin.metadata.model.PluginDependency
plugins {
id("minimotd.shadow-platform")
id("org.spongepowered.gradle.plugin")
alias(libs.plugins.sponge.gradle.plugin)
}
dependencies {
@@ -46,12 +46,13 @@ tasks {
}
}
modrinth {
gameVersions.addAll(
publishMods.modrinth {
modLoaders.add("sponge")
minecraftVersions.addAll(
"1.16.5",
"1.17.1",
"1.18.2",
"1.19.4",
"1.20.2"
"1.20.4"
)
}
@@ -1,7 +1,7 @@
/*
* This file is part of MiniMOTD, licensed under the MIT License.
*
* Copyright (c) 2020-2023 Jason Penilla
* 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
@@ -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);
@@ -1,7 +1,7 @@
/*
* This file is part of MiniMOTD, licensed under the MIT License.
*
* Copyright (c) 2020-2023 Jason Penilla
* 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
+6 -3
View File
@@ -1,6 +1,6 @@
plugins {
id("minimotd.shadow-platform")
id("xyz.jpenilla.run-velocity")
alias(libs.plugins.run.velocity)
}
dependencies {
@@ -9,6 +9,8 @@ dependencies {
compileOnly(libs.velocityApi)
}
java.disableAutoTargetJvm()
tasks {
shadowJar {
configureForNativeAdventurePlatform()
@@ -31,6 +33,7 @@ tasks {
}
}
modrinth {
gameVersions.addAll(minecraftVersion)
publishMods.modrinth {
modLoaders.add("velocity")
minecraftVersions.addAll(minecraftVersion)
}
@@ -1,7 +1,7 @@
/*
* This file is part of MiniMOTD, licensed under the MIT License.
*
* Copyright (c) 2020-2023 Jason Penilla
* 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
@@ -1,7 +1,7 @@
/*
* This file is part of MiniMOTD, licensed under the MIT License.
*
* Copyright (c) 2020-2023 Jason Penilla
* 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
@@ -27,21 +27,30 @@ import com.google.inject.Inject;
import com.velocitypowered.api.event.EventTask;
import com.velocitypowered.api.event.Subscribe;
import com.velocitypowered.api.event.proxy.ProxyPingEvent;
import com.velocitypowered.api.proxy.ProxyServer;
import com.velocitypowered.api.proxy.server.RegisteredServer;
import com.velocitypowered.api.proxy.server.ServerPing;
import com.velocitypowered.api.util.Favicon;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import org.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 {
private final MiniMOTD<Favicon> miniMOTD;
private final ProxyServer proxy;
@Inject
private PingListener(final MiniMOTD<Favicon> miniMOTD) {
private PingListener(final MiniMOTD<Favicon> miniMOTD, final ProxyServer proxy) {
this.miniMOTD = miniMOTD;
this.proxy = proxy;
}
@Subscribe
@@ -50,10 +59,29 @@ 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 PingResponse<Favicon> response = this.miniMOTD.createMOTD(config, pong.getOnlinePlayers(), pong.getMaximumPlayers());
final List<String> targetServers = config.targetServers();
int playersCount = 0;
if (targetServers.isEmpty()) {
playersCount = pong.getOnlinePlayers();
} else {
final Set<ServerPing.SamplePlayer> players = new HashSet<>();
for (final String serverName : targetServers) {
final @Nullable RegisteredServer server = this.proxy.getServer(serverName).orElse(null);
if (server != null) {
playersCount += server.getPlayersConnected().size();
players.addAll(server.getPlayersConnected().stream()
.map(p -> new ServerPing.SamplePlayer(p.getGameProfile().getName(), p.getUniqueId()))
.collect(Collectors.toList()));
}
}
pong.clearSamplePlayers();
pong.samplePlayers(players.toArray(new ServerPing.SamplePlayer[0]));
}
final PingResponse<Favicon> response = this.miniMOTD.createMOTD(config, playersCount, pong.getMaximumPlayers());
response.icon(pong::favicon);
response.motd(pong::description);
response.playerCount().applyCount(pong::onlinePlayers, pong::maximumPlayers);
+31 -1
View File
@@ -1,5 +1,35 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"config:base"
]
],
"ignoreDeps": [
"quiet-fabric-loom",
"com.mojang:minecraft",
"com.google.code.gson:gson"
],
"labels": [
"dependencies"
],
"packageRules": [
{
"description": "Correct Fabric API version handling",
"matchPackageNames": ["net.fabricmc.fabric-api:fabric-api", "net.fabricmc.fabric-api:fabric-api-deprecated"],
"versioning": "regex:^(?<major>\\d+)(\\.(?<minor>\\d+))?(\\.(?<patch>\\d+))?(?:\\+(?<compatibility>.*))?$"
},
{
"matchManagers": ["github-actions", "gradle-wrapper"],
"groupName": "gradle and github actions"
},
{
"matchDepTypes": ["plugin"],
"groupName": "gradle and github actions"
},
{
"matchPaths": ["build-logic/*", "buildSrc/*"],
"groupName": "gradle and github actions"
}
],
"semanticCommitType": "build",
"commitMessagePrefix": "chore(deps): "
}
+9 -4
View File
@@ -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() }
}
@@ -21,12 +26,12 @@ pluginManagement {
maven("https://maven.fabricmc.net/")
maven("https://repo.jpenilla.xyz/snapshots/")
}
includeBuild("build-logic")
includeBuild("gradle/build-logic")
}
plugins {
id("ca.stellardrift.polyglot-version-catalogs") version "6.1.0"
id("quiet-fabric-loom") version "1.3-SNAPSHOT"
id("quiet-fabric-loom") version "1.6-SNAPSHOT"
id("org.gradle.toolchains.foojay-resolver-convention") version "0.8.0"
}
rootProject.name = "MiniMOTD"