Compare commits
49
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
efc1d825a7 | ||
|
|
b192a4c5e1 | ||
|
|
e1b6aff732 | ||
|
|
7f255f3921 | ||
|
|
b363f279a8 | ||
|
|
2a2a6dea59 | ||
|
|
b5e5848bd9 | ||
|
|
22064b8576 | ||
|
|
aac6cab5f6 | ||
|
|
7197cf9100 | ||
|
|
b3c448136d | ||
|
|
25ad706ebf | ||
|
|
3c04370488 | ||
|
|
5a3c52481a | ||
|
|
2eb0ba1e98 | ||
|
|
b38e08daa0 | ||
|
|
3c61a2d24b | ||
|
|
611772f4bb | ||
|
|
118cef163a | ||
|
|
d17e4af825 | ||
|
|
19a21d988f | ||
|
|
0cd04574f9 | ||
|
|
5acc5d285d | ||
|
|
3d9e90d7bf | ||
|
|
c39cad4017 | ||
|
|
9c9c67776b | ||
|
|
2858de84ae | ||
|
|
64b023fad7 | ||
|
|
f59de86c5e | ||
|
|
0f1c69f8b2 | ||
|
|
f8deb9b7fb | ||
|
|
8428e2b124 | ||
|
|
8f91a1b445 | ||
|
|
0ca1f8f19d | ||
|
|
2fd3d41cbd | ||
|
|
ce201ba89e | ||
|
|
e33135d3c6 | ||
|
|
5f6e2789e2 | ||
|
|
add32b31e7 | ||
|
|
b2b2801907 | ||
|
|
c919c40a59 | ||
|
|
b3cc4bce5c | ||
|
|
6fdf75dd3d | ||
|
|
a8c2b0f23e | ||
|
|
0ee99d90f2 | ||
|
|
6623a5928e | ||
|
|
6532c03706 | ||
|
|
0bf3bfba7f | ||
|
|
f7094e0a77 |
No files matched your search
@@ -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.0.1"
|
||||
}
|
||||
|
||||
extensions.configure<PolyglotVersionCatalogExtension> {
|
||||
from(ConfigFormats.YAML, file("../gradle/libs.versions.yml"))
|
||||
}
|
||||
+11
-13
@@ -1,11 +1,11 @@
|
||||
plugins {
|
||||
id("net.kyori.blossom")
|
||||
alias(libs.plugins.blossom)
|
||||
id("minimotd.base-conventions")
|
||||
}
|
||||
|
||||
tasks.jar {
|
||||
from(rootProject.file("license.txt")) {
|
||||
rename { "license_${rootProject.name.toLowerCase()}.txt" }
|
||||
rename { "license_${rootProject.name.lowercase()}.txt" }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,18 +22,16 @@ dependencies {
|
||||
compileOnlyApi(libs.checkerQual)
|
||||
compileOnlyApi(libs.gson)
|
||||
testImplementation(libs.gson)
|
||||
compileOnlyApi(libs.guava)
|
||||
}
|
||||
|
||||
blossom {
|
||||
val file = "src/main/java/xyz/jpenilla/minimotd/common/Constants.java"
|
||||
mapOf(
|
||||
"PLUGIN_NAME" to rootProject.name,
|
||||
"PLUGIN_VERSION" to project.version.toString(),
|
||||
"PLUGIN_WEBSITE" to Constants.GITHUB_URL,
|
||||
"GITHUB_USER" to Constants.GITHUB_USER,
|
||||
"GITHUB_REPO" to Constants.GITHUB_REPO
|
||||
).forEach { (k, v) ->
|
||||
replaceToken("\${$k}", v, file)
|
||||
sourceSets.main {
|
||||
blossom {
|
||||
javaSources {
|
||||
property("PLUGIN_NAME", rootProject.name)
|
||||
property("PLUGIN_VERSION", project.version.toString())
|
||||
property("PLUGIN_WEBSITE", Constants.GITHUB_URL)
|
||||
property("GITHUB_USER", Constants.GITHUB_USER)
|
||||
property("GITHUB_REPO", Constants.GITHUB_REPO)
|
||||
}
|
||||
}
|
||||
}
|
||||
+6
-6
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2022 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,11 +34,11 @@ public final class Constants {
|
||||
private PluginMetadata() {
|
||||
}
|
||||
|
||||
public static final String NAME = "${PLUGIN_NAME}";
|
||||
public static final String VERSION = "${PLUGIN_VERSION}";
|
||||
public static final String WEBSITE = "${PLUGIN_WEBSITE}";
|
||||
public static final String GITHUB_USER = "${GITHUB_USER}";
|
||||
public static final String GITHUB_REPO = "${GITHUB_REPO}";
|
||||
public static final String NAME = "{{ PLUGIN_NAME }}";
|
||||
public static final String VERSION = "{{ PLUGIN_VERSION }}";
|
||||
public static final String WEBSITE = "{{ PLUGIN_WEBSITE }}";
|
||||
public static final String GITHUB_USER = "{{ GITHUB_USER }}";
|
||||
public static final String GITHUB_REPO = "{{ GITHUB_REPO }}";
|
||||
public static final String GITHUB_REPO_URL = "https://github.com/" + GITHUB_USER + "/" + GITHUB_REPO;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2022 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-2022 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-2022 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
|
||||
@@ -120,7 +120,7 @@ public final class MiniMOTD<I> {
|
||||
return input.replace("{onlinePlayers}", online).replace("{maxPlayers}", max);
|
||||
}
|
||||
|
||||
public void reload() {
|
||||
public synchronized void reload() {
|
||||
this.iconManager.loadIcons();
|
||||
this.configManager.loadConfigs();
|
||||
this.platform.onReload();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2022 Jason Penilla
|
||||
* Copyright (c) 2020-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-2022 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-2022 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-2022 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;
|
||||
@@ -109,10 +110,10 @@ public final class ConfigManager {
|
||||
}
|
||||
|
||||
private void createDefaultExtraConfigs(final @NonNull Path extraConfigsDir) throws ConfigurateException {
|
||||
final List<Pair<Path, MiniMOTDConfig.MOTD>> defaults = ImmutableList.of(
|
||||
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"))
|
||||
);
|
||||
));
|
||||
for (final Pair<Path, MiniMOTDConfig.MOTD> pair : defaults) {
|
||||
final ConfigLoader<MiniMOTDConfig> loader = new ConfigLoader<>(
|
||||
MiniMOTDConfig.class,
|
||||
@@ -140,11 +141,10 @@ public final class ConfigManager {
|
||||
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) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2022 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
|
||||
@@ -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.\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.")
|
||||
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-2022 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-2022 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-2022 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
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2022 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-2022 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-2022 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-2022 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-2022 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
-1
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2022 Jason Penilla
|
||||
* Copyright (c) 2020-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
@@ -1,5 +1,5 @@
|
||||
group=xyz.jpenilla
|
||||
version=2.0.11
|
||||
version=2.0.15-SNAPSHOT
|
||||
description=Use MiniMessage text formatting in the server list MOTD.
|
||||
|
||||
org.gradle.caching=true
|
||||
|
||||
@@ -10,8 +10,7 @@ dependencies {
|
||||
implementation(libs.indraCommon)
|
||||
implementation(libs.indraLicenser)
|
||||
implementation(libs.shadow)
|
||||
implementation(libs.testLogger)
|
||||
implementation(libs.minotaur)
|
||||
implementation(libs.mod.publish.plugin)
|
||||
implementation(libs.hangarPublishPlugin)
|
||||
|
||||
// https://github.com/gradle/gradle/issues/15383#issuecomment-779893192
|
||||
@@ -0,0 +1,9 @@
|
||||
rootProject.name = "build-logic"
|
||||
|
||||
dependencyResolutionManagement {
|
||||
versionCatalogs {
|
||||
create("libs") {
|
||||
from(files("../libs.versions.toml"))
|
||||
}
|
||||
}
|
||||
}
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
+6
-5
@@ -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(
|
||||
@@ -29,5 +29,6 @@ val bukkitVersions = listOf(
|
||||
"1.16.5",
|
||||
"1.17.1",
|
||||
"1.18.2",
|
||||
"1.19.4"
|
||||
"1.19.4",
|
||||
"1.20.4"
|
||||
)
|
||||
+12
-16
@@ -1,12 +1,9 @@
|
||||
import com.adarshr.gradle.testlogger.theme.ThemeType
|
||||
|
||||
plugins {
|
||||
id("java-library")
|
||||
id("net.kyori.indra")
|
||||
id("net.kyori.indra.git")
|
||||
id("net.kyori.indra.checkstyle")
|
||||
id("net.kyori.indra.license-header")
|
||||
id("com.adarshr.test-logger")
|
||||
id("net.kyori.indra.licenser.spotless")
|
||||
}
|
||||
|
||||
version = (version as String)
|
||||
@@ -21,24 +18,23 @@ indra {
|
||||
mitLicense()
|
||||
}
|
||||
|
||||
testlogger {
|
||||
theme = ThemeType.MOCHA_PARALLEL
|
||||
showPassed = false
|
||||
}
|
||||
|
||||
dependencies {
|
||||
testImplementation(libs.jupiterEngine)
|
||||
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
|
||||
}
|
||||
|
||||
tasks {
|
||||
tasks {
|
||||
withType<JavaCompile> {
|
||||
options.compilerArgs.add("-Xlint:-processing")
|
||||
withType<JavaCompile> {
|
||||
options.compilerArgs.add("-Xlint:-processing")
|
||||
}
|
||||
listOf(javadocJar, javadoc).forEach {
|
||||
it.configure {
|
||||
onlyIf { false }
|
||||
}
|
||||
sequenceOf(javadocJar, javadoc).forEach {
|
||||
it.configure {
|
||||
onlyIf { false }
|
||||
}
|
||||
}
|
||||
test {
|
||||
testLogging {
|
||||
events("passed")
|
||||
}
|
||||
}
|
||||
}
|
||||
+6
-8
@@ -1,21 +1,19 @@
|
||||
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)
|
||||
namespace("jmp", "MiniMOTD")
|
||||
id.set("MiniMOTD")
|
||||
channel.set("Release")
|
||||
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,13 +21,13 @@ 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.19")
|
||||
platformVersions.addAll("1.20")
|
||||
}
|
||||
}
|
||||
}
|
||||
+14
-7
@@ -1,7 +1,8 @@
|
||||
import me.modmuss50.mpp.ModPublishExtension
|
||||
|
||||
plugins {
|
||||
id("minimotd.base-conventions")
|
||||
id("net.kyori.indra.git")
|
||||
id("com.modrinth.minotaur")
|
||||
}
|
||||
|
||||
val platformExtension = extensions.create<MiniMOTDPlatformExtension>("miniMOTDPlatform")
|
||||
@@ -18,10 +19,16 @@ tasks {
|
||||
}
|
||||
}
|
||||
|
||||
modrinth {
|
||||
projectId.set("16vhQOQN")
|
||||
versionType.set("release")
|
||||
file.set(platformExtension.jarTask.flatMap { it.archiveFile })
|
||||
changelog.set(releaseNotes)
|
||||
token.set(providers.environmentVariable("MODRINTH_TOKEN"))
|
||||
if (name != "minimotd-bukkit-bungeecord") {
|
||||
plugins.apply("me.modmuss50.mod-publish-plugin")
|
||||
|
||||
extensions.configure(ModPublishExtension::class) {
|
||||
modrinth {
|
||||
projectId.set("16vhQOQN")
|
||||
type = STABLE
|
||||
file.set(platformExtension.jarTask.flatMap { it.archiveFile })
|
||||
changelog.set(releaseNotes)
|
||||
accessToken.set(providers.environmentVariable("MODRINTH_TOKEN"))
|
||||
}
|
||||
}
|
||||
}
|
||||
File renamed without changes.
File renamed without changes.
@@ -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.2.2"
|
||||
mod-publish-plugin = "0.4.5"
|
||||
hangarPublishPlugin = "0.1.1"
|
||||
indra = "3.1.3"
|
||||
shadow = "8.1.1"
|
||||
adventure = "4.15.0"
|
||||
adventurePlatform = "4.3.2"
|
||||
adventurePlatformFabric = "5.11.0-SNAPSHOT"
|
||||
configurate = "4.1.2"
|
||||
checkerQual = "3.42.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"
|
||||
spongeApi7 = "7.2.0"
|
||||
velocityApi = "3.2.0-SNAPSHOT"
|
||||
jupiterEngine = "5.10.1"
|
||||
|
||||
[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 = "com.github.johnrengelman", name = "shadow", 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]
|
||||
@@ -1,187 +0,0 @@
|
||||
metadata:
|
||||
format: { version: 1.0 }
|
||||
polyglot-extensions:
|
||||
- plugins
|
||||
|
||||
plugins:
|
||||
net.kyori.blossom: 1.3.0
|
||||
org.spongepowered.gradle.plugin: 2.1.1
|
||||
net.minecrell.plugin-yml.bungee: &plugin-yml 0.5.3
|
||||
net.minecrell.plugin-yml.bukkit: *plugin-yml
|
||||
xyz.jpenilla.run-paper: &run-task 2.0.1
|
||||
xyz.jpenilla.run-velocity: *run-task
|
||||
xyz.jpenilla.run-waterfall: *run-task
|
||||
|
||||
versions:
|
||||
minotaur: 2.7.5
|
||||
hangarPublishPlugin: 0.0.4
|
||||
indra: 3.0.1
|
||||
shadow: 8.1.0
|
||||
testLoggerPlugin: 3.2.0
|
||||
adventure: 4.13.0
|
||||
adventurePlatform: 4.3.0
|
||||
adventurePlatformFabric: 5.8.0
|
||||
configurate: 4.1.2
|
||||
checkerQual: 3.32.0
|
||||
slf4j: 1.7.32
|
||||
gson: 2.8.0
|
||||
guava: 21.0
|
||||
bstats: 3.0.0
|
||||
paperApi: 1.16.5-R0.1-SNAPSHOT
|
||||
paperlib: 1.0.8-SNAPSHOT
|
||||
waterfallApi: 1.16-R0.4-SNAPSHOT
|
||||
fabricApi: 0.76.0+1.19.4
|
||||
fabricLoader: 0.14.17
|
||||
minecraft: 1.19.4
|
||||
spongeApi7: 7.2.0
|
||||
velocityApi: 3.1.2-SNAPSHOT
|
||||
jupiterEngine: 5.9.2
|
||||
|
||||
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-cadix
|
||||
version: { ref: indra }
|
||||
shadow:
|
||||
group: com.github.johnrengelman
|
||||
name: shadow
|
||||
version: { ref: shadow }
|
||||
testLogger:
|
||||
group: com.adarshr
|
||||
name: gradle-test-logger-plugin
|
||||
version: { ref: testLoggerPlugin }
|
||||
minotaur:
|
||||
group: com.modrinth.minotaur
|
||||
name: Minotaur
|
||||
version: { ref: minotaur }
|
||||
hangarPublishPlugin:
|
||||
group: io.papermc
|
||||
name: hangar-publish-plugin
|
||||
version: { ref: hangarPublishPlugin }
|
||||
|
||||
bundles:
|
||||
Vendored
BIN
Binary file not shown.
+2
-1
@@ -1,6 +1,7 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
@@ -83,10 +83,8 @@ done
|
||||
# This is normally unused
|
||||
# shellcheck disable=SC2034
|
||||
APP_BASE_NAME=${0##*/}
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||
|
||||
# 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"'
|
||||
# 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
|
||||
@@ -133,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.
|
||||
@@ -144,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
|
||||
@@ -152,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
|
||||
@@ -197,11 +198,15 @@ if "$cygwin" || "$msys" ; then
|
||||
done
|
||||
fi
|
||||
|
||||
# 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.
|
||||
|
||||
# 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, 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" \
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2020-2022 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
@@ -1,6 +1,6 @@
|
||||
This file is part of MiniMOTD, licensed under the MIT License.
|
||||
|
||||
Copyright (c) 2020-2022 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,6 @@
|
||||
plugins {
|
||||
id("minimotd.shadow-platform")
|
||||
id("net.minecrell.plugin-yml.bukkit")
|
||||
id("xyz.jpenilla.run-paper")
|
||||
alias(libs.plugins.run.paper)
|
||||
}
|
||||
|
||||
dependencies {
|
||||
@@ -25,24 +24,22 @@ tasks {
|
||||
commonRelocation("org.bstats")
|
||||
commonRelocation("io.papermc.lib")
|
||||
}
|
||||
}
|
||||
|
||||
bukkit {
|
||||
name = rootProject.name
|
||||
main = "xyz.jpenilla.minimotd.bukkit.MiniMOTDPlugin"
|
||||
apiVersion = "1.13"
|
||||
website = Constants.GITHUB_URL
|
||||
authors = listOf("jmp")
|
||||
softDepend = listOf("ViaVersion")
|
||||
commands {
|
||||
register("minimotd") {
|
||||
description = "MiniMOTD Command"
|
||||
usage = "/minimotd help"
|
||||
permission = "minimotd.admin"
|
||||
processResources {
|
||||
val props = mapOf(
|
||||
"version" to project.version,
|
||||
"website" to Constants.GITHUB_URL,
|
||||
"description" to project.description
|
||||
)
|
||||
inputs.properties(props)
|
||||
filesMatching("plugin.yml") {
|
||||
expand(props)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
modrinth {
|
||||
gameVersions.addAll(bukkitVersions)
|
||||
runPaper.folia.registerTask()
|
||||
|
||||
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-2022 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-2022 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
|
||||
@@ -26,6 +26,7 @@ package xyz.jpenilla.minimotd.bukkit;
|
||||
import io.papermc.lib.PaperLib;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.nio.file.Path;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
|
||||
import org.bstats.bukkit.Metrics;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
@@ -71,8 +72,17 @@ public final class MiniMOTDPlugin extends JavaPlugin implements MiniMOTDPlatform
|
||||
final Metrics metrics = new Metrics(this, 8132);
|
||||
|
||||
if (this.miniMOTD.configManager().pluginSettings().updateChecker()) {
|
||||
this.getServer().getScheduler().runTaskAsynchronously(this, () ->
|
||||
new UpdateChecker().checkVersion().forEach(this.logger::info));
|
||||
try {
|
||||
Class.forName("io.papermc.paper.threadedregions.RegionizedServer");
|
||||
CompletableFuture.runAsync(() -> new UpdateChecker().checkVersion().forEach(this.logger::info)).whenComplete(($, thr) -> {
|
||||
if (thr != null) {
|
||||
this.logger.warn("Exception checking for updates", thr);
|
||||
}
|
||||
});
|
||||
} catch (final ReflectiveOperationException ex) {
|
||||
this.getServer().getScheduler().runTaskAsynchronously(this, () ->
|
||||
new UpdateChecker().checkVersion().forEach(this.logger::info));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2022 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-2022 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
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
name: MiniMOTD
|
||||
version: $version
|
||||
main: xyz.jpenilla.minimotd.bukkit.MiniMOTDPlugin
|
||||
folia-supported: true
|
||||
description: $description
|
||||
authors:
|
||||
- jmp
|
||||
website: $website
|
||||
commands:
|
||||
minimotd:
|
||||
description: MiniMOTD Command
|
||||
permission: minimotd.admin
|
||||
usage: /minimotd help
|
||||
api-version: 1.13
|
||||
softdepend:
|
||||
- ViaVersion
|
||||
@@ -1,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 {
|
||||
@@ -19,16 +18,21 @@ tasks {
|
||||
commonRelocation("org.bstats")
|
||||
}
|
||||
runWaterfall {
|
||||
waterfallVersion("1.19")
|
||||
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 {
|
||||
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-2022 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-2022 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-2022 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
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
name: MiniMOTD
|
||||
main: xyz.jpenilla.minimotd.bungee.MiniMOTDPlugin
|
||||
version: $version
|
||||
author: jmp
|
||||
description: $description
|
||||
@@ -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-2022 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
|
||||
@@ -45,6 +45,7 @@ import xyz.jpenilla.minimotd.common.CommandHandler;
|
||||
import xyz.jpenilla.minimotd.common.MiniMOTD;
|
||||
import xyz.jpenilla.minimotd.common.MiniMOTDPlatform;
|
||||
import xyz.jpenilla.minimotd.common.util.UpdateChecker;
|
||||
import xyz.jpenilla.minimotd.fabric.access.ServerStatusFaviconAccess;
|
||||
|
||||
import static net.minecraft.commands.Commands.literal;
|
||||
|
||||
@@ -98,7 +99,7 @@ public final class MiniMOTDFabric implements ModInitializer, MiniMOTDPlatform<Se
|
||||
|
||||
@Override
|
||||
public int run(final @NonNull CommandContext<CommandSourceStack> context) {
|
||||
this.handler.execute(MiniMOTDFabric.this.audiences.audience(context.getSource()));
|
||||
this.handler.execute(context.getSource());
|
||||
return Command.SINGLE_SUCCESS;
|
||||
}
|
||||
}
|
||||
@@ -142,6 +143,8 @@ public final class MiniMOTDFabric implements ModInitializer, MiniMOTDPlatform<Se
|
||||
public ServerStatus.@NonNull Favicon loadIcon(final @NonNull BufferedImage bufferedImage) throws Exception {
|
||||
final ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
ImageIO.write(bufferedImage, "PNG", out);
|
||||
return new ServerStatus.Favicon(out.toByteArray());
|
||||
final ServerStatus.Favicon favicon = new ServerStatus.Favicon(out.toByteArray());
|
||||
((ServerStatusFaviconAccess) (Object) favicon).cacheEncodedIcon();
|
||||
return favicon;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2022 Jason Penilla
|
||||
* Copyright (c) 2020-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
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* 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.fabric.access;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public interface ServerStatusFaviconAccess {
|
||||
@Nullable String cachedEncodedIcon();
|
||||
|
||||
void cacheEncodedIcon();
|
||||
}
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2022 Jason Penilla
|
||||
* Copyright (c) 2020-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
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2022 Jason Penilla
|
||||
* Copyright (c) 2020-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,6 +40,6 @@ abstract class ServerHandshakePacketListenerImplMixin {
|
||||
|
||||
@Inject(method = "handleIntention", at = @At("HEAD"))
|
||||
public void injectHandleIntention(final ClientIntentionPacket packet, final CallbackInfo ci) {
|
||||
((ConnectionAccess) this.connection).protocolVersion(packet.getProtocolVersion());
|
||||
((ConnectionAccess) this.connection).protocolVersion(packet.protocolVersion());
|
||||
}
|
||||
}
|
||||
+78
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* 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.fabric.mixin;
|
||||
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.DataResult;
|
||||
import com.mojang.serialization.codecs.PrimitiveCodec;
|
||||
import java.util.function.Function;
|
||||
import net.minecraft.network.protocol.status.ServerStatus;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import xyz.jpenilla.minimotd.fabric.access.ServerStatusFaviconAccess;
|
||||
|
||||
@Mixin(ServerStatus.Favicon.class)
|
||||
abstract class ServerStatusFaviconMixin implements ServerStatusFaviconAccess {
|
||||
@Unique
|
||||
private static Function<ServerStatus.Favicon, String> VANILLA_ENCODE_TO_STRING;
|
||||
|
||||
@Redirect(
|
||||
method = "<clinit>",
|
||||
at = @At(
|
||||
target = "Lcom/mojang/serialization/codecs/PrimitiveCodec;comapFlatMap(Ljava/util/function/Function;Ljava/util/function/Function;)Lcom/mojang/serialization/Codec;",
|
||||
value = "INVOKE"
|
||||
),
|
||||
remap = false
|
||||
)
|
||||
private static Codec<ServerStatus.Favicon> makeCodec(
|
||||
final PrimitiveCodec<String> stringCodec,
|
||||
final Function<String, DataResult<ServerStatus.Favicon>> decode,
|
||||
final Function<ServerStatus.Favicon, String> encode
|
||||
) {
|
||||
VANILLA_ENCODE_TO_STRING = encode;
|
||||
return stringCodec.comapFlatMap(decode, favicon -> {
|
||||
final @Nullable String encodedIcon = ((ServerStatusFaviconAccess) (Object) favicon).cachedEncodedIcon();
|
||||
if (encodedIcon != null) {
|
||||
return encodedIcon;
|
||||
}
|
||||
return encode.apply(favicon);
|
||||
});
|
||||
}
|
||||
|
||||
@Unique
|
||||
private String encodedIcon;
|
||||
|
||||
@Override
|
||||
public @Nullable String cachedEncodedIcon() {
|
||||
return this.encodedIcon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cacheEncodedIcon() {
|
||||
this.encodedIcon = VANILLA_ENCODE_TO_STRING.apply((ServerStatus.Favicon) (Object) this);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2022 Jason Penilla
|
||||
* Copyright (c) 2020-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
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2022 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.3",
|
||||
"fabric": "*",
|
||||
"minecraft": "~1.19.4"
|
||||
"minecraft": "~1.20.4"
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@
|
||||
"mixins": [
|
||||
"ConnectionMixin",
|
||||
"ServerHandshakePacketListenerImplMixin",
|
||||
"ServerStatusFaviconMixin",
|
||||
"ServerStatusPacketListenerImplMixin"
|
||||
],
|
||||
"client": [
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import java.util.Locale
|
||||
|
||||
plugins {
|
||||
id("minimotd.shadow-platform")
|
||||
}
|
||||
@@ -14,7 +12,7 @@ dependencies {
|
||||
tasks {
|
||||
processResources {
|
||||
val replacements = mapOf(
|
||||
"modid" to rootProject.name.toLowerCase(Locale.ENGLISH),
|
||||
"modid" to rootProject.name.lowercase(),
|
||||
"name" to rootProject.name,
|
||||
"version" to project.version.toString(),
|
||||
"description" to project.description.toString(),
|
||||
@@ -32,7 +30,7 @@ tasks {
|
||||
}
|
||||
}
|
||||
|
||||
modrinth {
|
||||
loaders.add("sponge")
|
||||
gameVersions.add("1.12.2")
|
||||
publishMods.modrinth {
|
||||
modLoaders.add("sponge")
|
||||
minecraftVersions.add("1.12.2")
|
||||
}
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2022 Jason Penilla
|
||||
* Copyright (c) 2020-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-2022 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,10 +1,9 @@
|
||||
import org.spongepowered.gradle.plugin.config.PluginLoaders
|
||||
import org.spongepowered.plugin.metadata.model.PluginDependency
|
||||
import java.util.Locale
|
||||
|
||||
plugins {
|
||||
id("minimotd.shadow-platform")
|
||||
id("org.spongepowered.gradle.plugin")
|
||||
alias(libs.plugins.sponge.gradle.plugin)
|
||||
}
|
||||
|
||||
dependencies {
|
||||
@@ -14,7 +13,7 @@ dependencies {
|
||||
sponge {
|
||||
injectRepositories(false)
|
||||
apiVersion("8.1.0-SNAPSHOT")
|
||||
plugin(rootProject.name.toLowerCase(Locale.ENGLISH)) {
|
||||
plugin(rootProject.name.lowercase()) {
|
||||
loader {
|
||||
name(PluginLoaders.JAVA_PLAIN)
|
||||
version("1.0")
|
||||
@@ -47,11 +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.19.4",
|
||||
"1.20.4"
|
||||
)
|
||||
}
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2022 Jason Penilla
|
||||
* Copyright (c) 2020-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-2022 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,16 +1,16 @@
|
||||
plugins {
|
||||
id("minimotd.shadow-platform")
|
||||
id("net.kyori.blossom")
|
||||
id("xyz.jpenilla.run-velocity")
|
||||
alias(libs.plugins.run.velocity)
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(projects.minimotdCommon)
|
||||
implementation(libs.bstatsVelocity)
|
||||
compileOnly(libs.velocityApi)
|
||||
annotationProcessor(libs.velocityApi)
|
||||
}
|
||||
|
||||
java.disableAutoTargetJvm()
|
||||
|
||||
tasks {
|
||||
shadowJar {
|
||||
configureForNativeAdventurePlatform()
|
||||
@@ -20,19 +20,20 @@ tasks {
|
||||
runVelocity {
|
||||
velocityVersion(libs.versions.velocityApi.get())
|
||||
}
|
||||
}
|
||||
|
||||
blossom {
|
||||
val file = "src/main/java/xyz/jpenilla/minimotd/velocity/MiniMOTDPlugin.java"
|
||||
mapOf(
|
||||
"project.name" to project.name,
|
||||
"description" to description as String,
|
||||
"url" to Constants.GITHUB_URL
|
||||
).forEach { (k, v) ->
|
||||
replaceToken("\${$k}", v, file)
|
||||
processResources {
|
||||
val props = mapOf(
|
||||
"description" to project.description as String,
|
||||
"url" to Constants.GITHUB_URL,
|
||||
"version" to project.version,
|
||||
)
|
||||
inputs.properties(props)
|
||||
filesMatching("velocity-plugin.json") {
|
||||
expand(props)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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-2022 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
|
||||
@@ -36,7 +36,6 @@ import com.velocitypowered.api.command.CommandManager;
|
||||
import com.velocitypowered.api.command.CommandSource;
|
||||
import com.velocitypowered.api.event.Subscribe;
|
||||
import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
|
||||
import com.velocitypowered.api.plugin.Plugin;
|
||||
import com.velocitypowered.api.plugin.annotation.DataDirectory;
|
||||
import com.velocitypowered.api.proxy.ProxyServer;
|
||||
import com.velocitypowered.api.util.Favicon;
|
||||
@@ -47,19 +46,10 @@ import org.bstats.velocity.Metrics;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.slf4j.Logger;
|
||||
import xyz.jpenilla.minimotd.common.CommandHandler;
|
||||
import xyz.jpenilla.minimotd.common.Constants;
|
||||
import xyz.jpenilla.minimotd.common.MiniMOTD;
|
||||
import xyz.jpenilla.minimotd.common.MiniMOTDPlatform;
|
||||
import xyz.jpenilla.minimotd.common.util.UpdateChecker;
|
||||
|
||||
@Plugin(
|
||||
id = "${project.name}",
|
||||
name = Constants.PluginMetadata.NAME,
|
||||
version = Constants.PluginMetadata.VERSION,
|
||||
description = "${description}",
|
||||
url = "${url}",
|
||||
authors = {"jmp"}
|
||||
)
|
||||
public final class MiniMOTDPlugin implements MiniMOTDPlatform<Favicon> {
|
||||
private static final Set<Class<?>> LISTENER_CLASSES = ImmutableSet.of(
|
||||
PingListener.class
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2022 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,9 +27,13 @@ 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.List;
|
||||
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;
|
||||
@@ -38,10 +42,12 @@ import xyz.jpenilla.minimotd.common.config.MiniMOTDConfig;
|
||||
@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
|
||||
@@ -53,7 +59,20 @@ public final class PingListener {
|
||||
final MiniMOTDConfig 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 {
|
||||
for (final String serverName : targetServers) {
|
||||
final @Nullable RegisteredServer server = this.proxy.getServer(serverName).orElse(null);
|
||||
if (server != null) {
|
||||
playersCount += server.getPlayersConnected().size();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"id": "minimotd-velocity",
|
||||
"name": "MiniMOTD",
|
||||
"version": "$version",
|
||||
"description": "$description",
|
||||
"url": "$url",
|
||||
"authors": [
|
||||
"jmp"
|
||||
],
|
||||
"dependencies": [],
|
||||
"main": "xyz.jpenilla.minimotd.velocity.MiniMOTDPlugin"
|
||||
}
|
||||
+31
-1
@@ -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): "
|
||||
}
|
||||
+3
-4
@@ -19,15 +19,14 @@ pluginManagement {
|
||||
repositories {
|
||||
gradlePluginPortal()
|
||||
maven("https://maven.fabricmc.net/")
|
||||
maven("https://maven.quiltmc.org/repository/release/")
|
||||
maven("https://repo.jpenilla.xyz/snapshots/")
|
||||
}
|
||||
includeBuild("build-logic")
|
||||
includeBuild("gradle/build-logic")
|
||||
}
|
||||
|
||||
plugins {
|
||||
id("ca.stellardrift.polyglot-version-catalogs") version "6.0.1"
|
||||
id("quiet-fabric-loom") version "1.1-SNAPSHOT"
|
||||
id("quiet-fabric-loom") version "1.5-SNAPSHOT"
|
||||
id("org.gradle.toolchains.foojay-resolver-convention") version "0.8.0"
|
||||
}
|
||||
|
||||
rootProject.name = "MiniMOTD"
|
||||
|
||||
Reference in new issue
Block a user