mirror of
https://github.com/jpenilla/MiniMOTD.git
synced 2026-11-06 09:32:33 -05:00
Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
efc1d825a7 | ||
|
|
b192a4c5e1 | ||
|
|
e1b6aff732 | ||
|
|
7f255f3921 | ||
|
|
b363f279a8 | ||
|
|
2a2a6dea59 |
No files matched your search
@@ -6,4 +6,3 @@ indent_size = 2
|
||||
indent_style = space
|
||||
insert_final_newline = true
|
||||
max_line_length = off
|
||||
ij_java_imports_layout=*,|,$*
|
||||
@@ -17,4 +17,3 @@ jobs:
|
||||
modrinth-publish: true
|
||||
hangar-publish: true
|
||||
loom: true
|
||||
jdk-version: 25
|
||||
@@ -117,5 +117,3 @@ run/
|
||||
|
||||
# Ignore Gradle build output directory
|
||||
build/
|
||||
|
||||
.kotlin/
|
||||
@@ -1,37 +1,30 @@
|
||||

|
||||

|
||||
|
||||
[](https://github.com/jpenilla/MiniMOTD/actions) [](https://github.com/jpenilla/MiniMOTD/releases)
|
||||
|
||||
### MiniMOTD is a basic server list MOTD plugin/mod for Minecraft servers and proxies
|
||||
|
||||
- MiniMOTD supports RGB colors and gradients through [MiniMessage](https://docs.papermc.io/adventure/minimessage/), which is also where MiniMOTD gets its name.
|
||||
- For more detailed info on formatting text, refer to the [MiniMessage docs](https://docs.papermc.io/adventure/minimessage/format/).
|
||||
- MiniMOTD supports RGB colors and gradients through [MiniMessage](https://github.com/KyoriPowered/adventure-text-minimessage), which is also where MiniMOTD gets it's name.
|
||||
- For more detailed info on formatting text, refer to the [MiniMessage docs](https://docs.adventure.kyori.net/minimessage.html).
|
||||
- RGB colors are automatically downsampled for outdated clients.
|
||||
- RGB colors are only able to be sent by proxies and 1.16+ servers, and can only be seen by 1.16+ clients.
|
||||
|
||||
#### Server Platforms
|
||||
- [Paper](https://papermc.io/)
|
||||
- [Paper](https://papermc.io/) / Spigot
|
||||
- MiniMOTD is compatible with Spigot, however many features will not work. It is recommended to use Paper for full compatibility.
|
||||
- [Sponge API 8](https://www.spongepowered.org/)
|
||||
- [Sponge API 7](https://www.spongepowered.org/)
|
||||
- [Fabric](https://fabricmc.net/) (requires [Fabric API](https://modrinth.com/mod/fabric-api))
|
||||
- [NeoForge](https://neoforged.net/)
|
||||
- [Fabric](https://fabricmc.net/) (requires [Fabric API](https://www.curseforge.com/minecraft/mc-mods/fabric-api))
|
||||
|
||||
#### Proxy Platforms
|
||||
- [Velocity](https://velocitypowered.com/)
|
||||
- [Waterfall](https://papermc.io/downloads#Waterfall) / Bungeecord
|
||||
|
||||
#### Downloads
|
||||
Downloads can be obtained from any of:
|
||||
- [Modrinth](https://modrinth.com/plugin/minimotd)
|
||||
- [Hangar](https://hangar.papermc.io/jmp/MiniMOTD)
|
||||
- [GitHub releases](https://github.com/jpenilla/MiniMOTD/releases)
|
||||
|
||||
There is a separate jar for each platform. Waterfall and Bungeecord share the same jar.
|
||||
There are two distributions for Bukkit-based servers: one for Paper >=1.21.8 only (`-paper` jar),
|
||||
and one for all other supported versions (1.8.8 - 1.21.7, Spigot and Paper) (`-bukkit` jar).
|
||||
Downloads can be obtained from [GitHub releases](https://github.com/jpenilla/MiniMOTD/releases). There is a separate jar for each platform, as well as a universal jar for all platforms. Paper and Spigot share the same jar, as do Waterfall and Bungeecord.
|
||||
|
||||
#### Configuration
|
||||
See the [wiki](https://github.com/jpenilla/MiniMOTD/wiki) for configuration details
|
||||
|
||||
#### Screenshots
|
||||

|
||||

|
||||
@@ -1,4 +1,3 @@
|
||||
plugins {
|
||||
id("minimotd.build-logic")
|
||||
alias(libs.plugins.run.paper) apply false
|
||||
}
|
||||
@@ -19,11 +19,9 @@ dependencies {
|
||||
}
|
||||
api(libs.minimessage)
|
||||
compileOnlyApi(libs.slf4jApi)
|
||||
compileOnlyApi(libs.jspecify)
|
||||
compileOnlyApi(libs.checkerQual)
|
||||
compileOnlyApi(libs.gson)
|
||||
testImplementation(libs.gson)
|
||||
compileOnly(libs.brigadier)
|
||||
compileOnly(libs.miniplaceholders)
|
||||
}
|
||||
|
||||
sourceSets.main {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2025 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-2025 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,7 +27,9 @@ import java.util.stream.Stream;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
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;
|
||||
@@ -41,7 +43,7 @@ import static net.kyori.adventure.text.format.NamedTextColor.WHITE;
|
||||
import static net.kyori.adventure.text.format.TextColor.color;
|
||||
import static net.kyori.adventure.text.format.TextDecoration.STRIKETHROUGH;
|
||||
|
||||
@NullMarked
|
||||
@DefaultQualifier(NonNull.class)
|
||||
public final class CommandHandler {
|
||||
private final MiniMOTD<?> miniMOTD;
|
||||
|
||||
@@ -75,7 +77,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(Component.textOfChildren(
|
||||
audience.sendMessage(Components.ofChildren(
|
||||
Constants.COMMAND_PREFIX,
|
||||
space(),
|
||||
text("Failed to reload MiniMOTD. Ensure there are no errors in your config files. See console for more details.", RED)
|
||||
@@ -83,7 +85,7 @@ public final class CommandHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
audience.sendMessage(Component.textOfChildren(
|
||||
audience.sendMessage(Components.ofChildren(
|
||||
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-2025 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,8 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
import java.util.stream.Stream;
|
||||
import javax.imageio.ImageIO;
|
||||
import org.jspecify.annotations.NonNull;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public final class IconManager<I> {
|
||||
private final Map<String, I> icons = new ConcurrentHashMap<>();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2025 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,15 +29,17 @@ import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
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.MOTDConfig;
|
||||
import xyz.jpenilla.minimotd.common.util.MiniPlaceholdersUtil;
|
||||
import xyz.jpenilla.minimotd.common.config.MiniMOTDConfig;
|
||||
import xyz.jpenilla.minimotd.common.util.Components;
|
||||
|
||||
import static net.kyori.adventure.text.Component.newline;
|
||||
|
||||
@NullMarked
|
||||
@DefaultQualifier(NonNull.class)
|
||||
public final class MiniMOTD<I> {
|
||||
private final ConfigManager configManager;
|
||||
private final IconManager<I> iconManager;
|
||||
@@ -75,21 +77,21 @@ public final class MiniMOTD<I> {
|
||||
return this.configManager;
|
||||
}
|
||||
|
||||
public PingResponse<I> createMOTD(final MOTDConfig config, final int onlinePlayers, final int maxPlayers) {
|
||||
public PingResponse<I> createMOTD(final MiniMOTDConfig 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)
|
||||
.disablePlayerListHover(config.disablePlayerListHover())
|
||||
.hidePlayerCount(config.hidePlayerCount());
|
||||
|
||||
String iconString = null;
|
||||
@Nullable String iconString = null;
|
||||
if (config.motdEnabled()) {
|
||||
if (config.motds().isEmpty()) {
|
||||
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 MOTDConfig.MOTD motdConfig = config.motds().get(index);
|
||||
final Component motd = Component.textOfChildren(
|
||||
final MiniMOTDConfig.MOTD motdConfig = config.motds().get(index);
|
||||
final Component motd = Components.ofChildren(
|
||||
parse(motdConfig.line1(), count),
|
||||
newline(),
|
||||
parse(motdConfig.line2(), count)
|
||||
@@ -110,11 +112,7 @@ public final class MiniMOTD<I> {
|
||||
final String max = Integer.toString(count.maxPlayers());
|
||||
return MiniMessage.miniMessage().deserialize(
|
||||
replacePlayerCount(input, online, max),
|
||||
TagResolver.resolver(
|
||||
Placeholder.unparsed("online_players", online),
|
||||
Placeholder.unparsed("max_players", max),
|
||||
MiniPlaceholdersUtil.tagResolver()
|
||||
)
|
||||
TagResolver.resolver(Placeholder.unparsed("online_players", online), Placeholder.unparsed("max_players", max))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2025 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
|
||||
@@ -25,7 +25,7 @@ package xyz.jpenilla.minimotd.common;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.nio.file.Path;
|
||||
import org.jspecify.annotations.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
public interface MiniMOTDPlatform<I> {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2025 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,12 +26,13 @@ package xyz.jpenilla.minimotd.common;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.IntConsumer;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import org.checkerframework.framework.qual.DefaultQualifier;
|
||||
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
@NullMarked
|
||||
@DefaultQualifier(NonNull.class)
|
||||
public final class PingResponse<I> {
|
||||
private final @Nullable I icon;
|
||||
private final @Nullable Component motd;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2025 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,8 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.UnaryOperator;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.framework.qual.DefaultQualifier;
|
||||
import org.spongepowered.configurate.CommentedConfigurationNode;
|
||||
import org.spongepowered.configurate.ConfigurateException;
|
||||
import org.spongepowered.configurate.ConfigurationOptions;
|
||||
@@ -38,7 +39,7 @@ import org.spongepowered.configurate.objectmapping.ObjectMapper;
|
||||
import org.spongepowered.configurate.serialize.SerializationException;
|
||||
import org.spongepowered.configurate.serialize.TypeSerializerCollection;
|
||||
|
||||
@NullMarked
|
||||
@DefaultQualifier(NonNull.class)
|
||||
public final class ConfigLoader<C> {
|
||||
private static final TypeSerializerCollection SERIALIZERS;
|
||||
|
||||
@@ -93,13 +94,13 @@ public final class ConfigLoader<C> {
|
||||
}
|
||||
|
||||
public ConfigLoader(
|
||||
final Class<C> configClass,
|
||||
final Path configPath
|
||||
final @NonNull Class<C> configClass,
|
||||
final @NonNull Path configPath
|
||||
) {
|
||||
this(configClass, configPath, options -> options);
|
||||
}
|
||||
|
||||
public C load() throws ConfigurateException {
|
||||
public @NonNull C load() throws ConfigurateException {
|
||||
final CommentedConfigurationNode node = this.loader.load();
|
||||
final C config = this.mapper.load(node);
|
||||
for (final Consumer<C> processor : this.postProcess) {
|
||||
@@ -108,7 +109,7 @@ public final class ConfigLoader<C> {
|
||||
return config;
|
||||
}
|
||||
|
||||
public void save(final C config) throws ConfigurateException {
|
||||
public void save(final @NonNull C config) throws ConfigurateException {
|
||||
final CommentedConfigurationNode node = this.loader.createNode();
|
||||
this.mapper.save(config, node);
|
||||
this.loader.save(node);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2025 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,8 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
import org.jspecify.annotations.NonNull;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import org.spongepowered.configurate.ConfigurateException;
|
||||
import xyz.jpenilla.minimotd.common.MiniMOTD;
|
||||
import xyz.jpenilla.minimotd.common.util.Pair;
|
||||
@@ -46,18 +46,18 @@ public final class ConfigManager {
|
||||
|
||||
private final MiniMOTD<?> miniMOTD;
|
||||
|
||||
private final ConfigLoader<MOTDConfig> mainConfigLoader;
|
||||
private MOTDConfig mainConfig;
|
||||
private final ConfigLoader<MiniMOTDConfig> mainConfigLoader;
|
||||
private MiniMOTDConfig mainConfig;
|
||||
|
||||
private final ConfigLoader<PluginSettings> pluginSettingsLoader;
|
||||
private PluginSettings pluginSettings;
|
||||
|
||||
private final Map<String, MOTDConfig> extraConfigs = new HashMap<>();
|
||||
private final Map<String, MiniMOTDConfig> extraConfigs = new HashMap<>();
|
||||
|
||||
public ConfigManager(final @NonNull MiniMOTD<?> miniMOTD) {
|
||||
this.miniMOTD = miniMOTD;
|
||||
this.mainConfigLoader = new ConfigLoader<>(
|
||||
MOTDConfig.class,
|
||||
MiniMOTDConfig.class,
|
||||
this.miniMOTD.dataDirectory().resolve("main.conf"),
|
||||
options -> options.header("MiniMOTD Main Configuration")
|
||||
);
|
||||
@@ -94,12 +94,12 @@ public final class ConfigManager {
|
||||
continue;
|
||||
}
|
||||
final String name = path.getFileName().toString().replace(".conf", "");
|
||||
final ConfigLoader<MOTDConfig> loader = new ConfigLoader<>(
|
||||
MOTDConfig.class,
|
||||
final ConfigLoader<MiniMOTDConfig> loader = new ConfigLoader<>(
|
||||
MiniMOTDConfig.class,
|
||||
path,
|
||||
options -> options.header(String.format("Extra MiniMOTD config '%s'", name))
|
||||
);
|
||||
final MOTDConfig config = loader.load();
|
||||
final MiniMOTDConfig config = loader.load();
|
||||
loader.save(config);
|
||||
this.extraConfigs.put(name, config);
|
||||
}
|
||||
@@ -110,20 +110,20 @@ public final class ConfigManager {
|
||||
}
|
||||
|
||||
private void createDefaultExtraConfigs(final @NonNull Path extraConfigsDir) throws ConfigurateException {
|
||||
final List<Pair<Path, 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"))
|
||||
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, MOTDConfig.MOTD> pair : defaults) {
|
||||
final ConfigLoader<MOTDConfig> loader = new ConfigLoader<>(
|
||||
MOTDConfig.class,
|
||||
for (final Pair<Path, MiniMOTDConfig.MOTD> pair : defaults) {
|
||||
final ConfigLoader<MiniMOTDConfig> loader = new ConfigLoader<>(
|
||||
MiniMOTDConfig.class,
|
||||
pair.left()
|
||||
);
|
||||
loader.save(new MOTDConfig(pair.right()));
|
||||
loader.save(new MiniMOTDConfig(pair.right()));
|
||||
}
|
||||
}
|
||||
|
||||
public @NonNull MOTDConfig mainConfig() {
|
||||
public @NonNull MiniMOTDConfig mainConfig() {
|
||||
if (this.mainConfig == null) {
|
||||
throw new IllegalStateException("Config has not yet been loaded");
|
||||
}
|
||||
@@ -137,7 +137,7 @@ public final class ConfigManager {
|
||||
return this.pluginSettings;
|
||||
}
|
||||
|
||||
public @NonNull MOTDConfig resolveConfig(final @Nullable InetSocketAddress address) {
|
||||
public @NonNull MiniMOTDConfig resolveConfig(final @Nullable InetSocketAddress address) {
|
||||
if (address == null) {
|
||||
return this.mainConfig();
|
||||
}
|
||||
@@ -153,11 +153,11 @@ public final class ConfigManager {
|
||||
return this.resolveConfig(configString);
|
||||
}
|
||||
|
||||
public @NonNull MOTDConfig resolveConfig(final @NonNull String name) {
|
||||
public @NonNull MiniMOTDConfig resolveConfig(final @NonNull String name) {
|
||||
if ("default".equals(name)) {
|
||||
return this.mainConfig();
|
||||
}
|
||||
final MOTDConfig cfg = this.extraConfigs.get(name);
|
||||
final MiniMOTDConfig cfg = this.extraConfigs.get(name);
|
||||
if (cfg != null) {
|
||||
return cfg;
|
||||
}
|
||||
|
||||
+7
-7
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2025 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,7 +26,7 @@ package xyz.jpenilla.minimotd.common.config;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import org.jspecify.annotations.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.spongepowered.configurate.objectmapping.ConfigSerializable;
|
||||
import org.spongepowered.configurate.objectmapping.meta.Comment;
|
||||
import xyz.jpenilla.minimotd.common.PingResponse;
|
||||
@@ -34,16 +34,16 @@ import xyz.jpenilla.minimotd.common.PingResponse;
|
||||
import static xyz.jpenilla.minimotd.common.PingResponse.PlayerCount.playerCount;
|
||||
|
||||
@ConfigSerializable
|
||||
public final class MOTDConfig {
|
||||
public final class MiniMOTDConfig {
|
||||
|
||||
public MOTDConfig() {
|
||||
public MiniMOTDConfig() {
|
||||
this(
|
||||
new MOTD(),
|
||||
new MOTD("<blue>Another <bold><red>MOTD", "<italic><underlined><gradient:red:green>much wow")
|
||||
);
|
||||
}
|
||||
|
||||
public MOTDConfig(final @NonNull MOTD @NonNull ... defaults) {
|
||||
public MiniMOTDConfig(final @NonNull MOTD @NonNull ... defaults) {
|
||||
this.motds.addAll(Arrays.asList(defaults));
|
||||
}
|
||||
|
||||
@@ -123,9 +123,9 @@ public final class MOTDConfig {
|
||||
+ "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"
|
||||
@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 & list as determined by the proxy will be used.")
|
||||
+ "When set to an empty list, the default count determined by the proxy will be used.")
|
||||
private final List<String> servers = new ArrayList<>();
|
||||
|
||||
@ConfigSerializable
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2025 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,8 +26,8 @@ package xyz.jpenilla.minimotd.common.config;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
import java.util.function.Predicate;
|
||||
import org.jspecify.annotations.NonNull;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import org.spongepowered.configurate.serialize.ScalarSerializer;
|
||||
import org.spongepowered.configurate.serialize.SerializationException;
|
||||
import xyz.jpenilla.minimotd.common.util.Int2IntFunction;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2025 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,9 +26,9 @@ package xyz.jpenilla.minimotd.common.config;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import org.jspecify.annotations.NonNull;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
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;
|
||||
import org.spongepowered.configurate.objectmapping.meta.Comment;
|
||||
|
||||
@@ -63,7 +63,7 @@ public final class PluginSettings {
|
||||
+ "checked in the order they are declared if there are no exact matches.")
|
||||
private final Map<String, String> virtualHostConfigs = new LinkedHashMap<>();
|
||||
|
||||
private transient @Nullable Map<String[], String> splitVirtualHostConfigs;
|
||||
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.")
|
||||
@@ -74,7 +74,6 @@ public final class PluginSettings {
|
||||
}
|
||||
|
||||
public @Nullable String findConfigStringForHost(@NonNull String host, final int port) {
|
||||
Objects.requireNonNull(this.splitVirtualHostConfigs, "processVirtualHosts must be called first");
|
||||
host = processTcpShieldHostname(host).toLowerCase(Locale.ENGLISH) + ':' + port;
|
||||
|
||||
final @Nullable String exactMatch = this.virtualHostConfigs.get(host);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2025 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,66 +0,0 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2025 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 com.mojang.brigadier.Command;
|
||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Predicate;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import xyz.jpenilla.minimotd.common.CommandHandler;
|
||||
|
||||
@NullMarked
|
||||
public final class BrigadierUtil {
|
||||
private BrigadierUtil() {
|
||||
}
|
||||
|
||||
public static <S> LiteralArgumentBuilder<S> buildTree(
|
||||
final CommandHandler handler,
|
||||
final Function<S, Audience> audienceExtractor,
|
||||
final Predicate<S> permissionChecker
|
||||
) {
|
||||
final class WrappingExecutor implements Command<S> {
|
||||
private final CommandHandler.Executor handler;
|
||||
|
||||
WrappingExecutor(final CommandHandler.Executor handler) {
|
||||
this.handler = handler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int run(final CommandContext<S> context) {
|
||||
this.handler.execute(audienceExtractor.apply(context.getSource()));
|
||||
return Command.SINGLE_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
return LiteralArgumentBuilder.<S>literal("minimotd")
|
||||
.requires(permissionChecker)
|
||||
.executes(new WrappingExecutor(handler::help))
|
||||
.then(LiteralArgumentBuilder.<S>literal("help").executes(new WrappingExecutor(handler::help)))
|
||||
.then(LiteralArgumentBuilder.<S>literal("about").executes(new WrappingExecutor(handler::about)))
|
||||
.then(LiteralArgumentBuilder.<S>literal("reload").executes(new WrappingExecutor(handler::reload)));
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2025 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
|
||||
@@ -25,7 +25,7 @@ package xyz.jpenilla.minimotd.common.util;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||
import org.jspecify.annotations.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
public interface ComponentColorDownsampler {
|
||||
static @NonNull ComponentColorDownsampler downsampler() {
|
||||
|
||||
+21
-6
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2025 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
|
||||
@@ -21,12 +21,27 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package xyz.jpenilla.minimotd.neoforge.access;
|
||||
package xyz.jpenilla.minimotd.common.util;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
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;
|
||||
|
||||
public interface ServerStatusFaviconAccess {
|
||||
@Nullable String cachedEncodedIcon();
|
||||
import static net.kyori.adventure.text.Component.empty;
|
||||
import static net.kyori.adventure.text.Component.text;
|
||||
|
||||
void cacheEncodedIcon();
|
||||
@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-2025 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,68 +0,0 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2025 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 io.github.miniplaceholders.api.MiniPlaceholders;
|
||||
import java.util.Objects;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@NullMarked
|
||||
public final class MiniPlaceholdersUtil {
|
||||
private static final String KYORI_PREFIX = new String(new char[]{'n', 'e', 't', '.', 'k', 'y', 'o', 'r', 'i'});
|
||||
private static byte miniPlaceholdersLoaded = -1;
|
||||
|
||||
private MiniPlaceholdersUtil() {
|
||||
}
|
||||
|
||||
private static boolean miniPlaceholdersLoaded() {
|
||||
if (miniPlaceholdersLoaded == -1) {
|
||||
if (!TagResolver.class.getName().startsWith(KYORI_PREFIX)) {
|
||||
miniPlaceholdersLoaded = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
final String name = MiniPlaceholders.class.getName();
|
||||
Objects.requireNonNull(name);
|
||||
miniPlaceholdersLoaded = 1;
|
||||
} catch (final NoClassDefFoundError error) {
|
||||
miniPlaceholdersLoaded = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return miniPlaceholdersLoaded == 1;
|
||||
}
|
||||
|
||||
public static TagResolver tagResolver() {
|
||||
if (!miniPlaceholdersLoaded()) {
|
||||
return TagResolver.empty();
|
||||
}
|
||||
return tagResolver_();
|
||||
}
|
||||
|
||||
private static TagResolver tagResolver_() {
|
||||
return MiniPlaceholders.globalPlaceholders();
|
||||
}
|
||||
}
|
||||
@@ -1,129 +0,0 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2025 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 java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
public abstract class Nag {
|
||||
private static final String EQUALS_LINE = "====================================================";
|
||||
|
||||
private final List<String> lines = new ArrayList<>();
|
||||
private boolean exception = false;
|
||||
private boolean error = false;
|
||||
|
||||
public Nag lines(final String... lines) {
|
||||
this.lines.addAll(Arrays.asList(lines));
|
||||
return this;
|
||||
}
|
||||
|
||||
public Nag line(final String line) {
|
||||
this.lines.add(line);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Nag error(final boolean withException) {
|
||||
this.error = true;
|
||||
this.exception = withException;
|
||||
return this;
|
||||
}
|
||||
|
||||
protected abstract void logError(String message, @Nullable Throwable throwable);
|
||||
|
||||
protected abstract void logWarn(String message, @Nullable Throwable throwable);
|
||||
|
||||
public void logBanner() {
|
||||
final List<String> toLog = new ArrayList<>();
|
||||
toLog.add(EQUALS_LINE);
|
||||
toLog.addAll(this.lines);
|
||||
toLog.add(EQUALS_LINE);
|
||||
|
||||
for (final String line : toLog) {
|
||||
if (this.error) {
|
||||
this.logError(line, null);
|
||||
} else {
|
||||
this.logWarn(line, null);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.exception) {
|
||||
// this.exception implies this.error
|
||||
this.logError("Please see the above notice.", new RuntimeException("Please see the above notice."));
|
||||
}
|
||||
}
|
||||
|
||||
public static final class Slf4J extends Nag {
|
||||
private final org.slf4j.Logger logger;
|
||||
|
||||
public Slf4J(final org.slf4j.Logger logger) {
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void logError(final String message, @Nullable final Throwable throwable) {
|
||||
if (throwable != null) {
|
||||
this.logger.error(message, throwable);
|
||||
} else {
|
||||
this.logger.error(message);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void logWarn(final String message, @Nullable final Throwable throwable) {
|
||||
if (throwable != null) {
|
||||
this.logger.warn(message, throwable);
|
||||
} else {
|
||||
this.logger.warn(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static final class JavaUtilLogging extends Nag {
|
||||
private final java.util.logging.Logger logger;
|
||||
|
||||
public JavaUtilLogging(final java.util.logging.Logger logger) {
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void logError(final String message, @Nullable final Throwable throwable) {
|
||||
if (throwable != null) {
|
||||
this.logger.log(java.util.logging.Level.SEVERE, message, throwable);
|
||||
} else {
|
||||
this.logger.severe(message);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void logWarn(final String message, @Nullable final Throwable throwable) {
|
||||
if (throwable != null) {
|
||||
this.logger.log(java.util.logging.Level.WARNING, message, throwable);
|
||||
} else {
|
||||
this.logger.warning(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2025 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
|
||||
@@ -24,8 +24,8 @@
|
||||
package xyz.jpenilla.minimotd.common.util;
|
||||
|
||||
import java.util.Objects;
|
||||
import org.jspecify.annotations.NonNull;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public final class Pair<L, R> {
|
||||
private final L left;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2025 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,7 @@ import java.util.LinkedHashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.jspecify.annotations.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import xyz.jpenilla.minimotd.common.Constants;
|
||||
|
||||
public final class UpdateChecker {
|
||||
@@ -67,8 +67,8 @@ public final class UpdateChecker {
|
||||
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 Modrinth at the link below:",
|
||||
"https://modrinth.com/plugin/minimotd"
|
||||
"Download the latest version, " + versionList.get(0) + " from GitHub at the link below:",
|
||||
versionMap.get(versionList.get(0))
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2025 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
|
||||
|
||||
+3
-3
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2025 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 = Component.textOfChildren(
|
||||
final Component fullColor = Components.ofChildren(
|
||||
text("Green ", GREEN),
|
||||
text("Orange Yellow ", ORANGE_YELLOW),
|
||||
text("Pink ", PINK),
|
||||
text("Blue ", BLUE),
|
||||
text("Lime Green", LIME_GREEN)
|
||||
);
|
||||
final Component expectedDownsample = Component.textOfChildren(
|
||||
final Component expectedDownsample = Components.ofChildren(
|
||||
text("Green ", nearestTo(GREEN)),
|
||||
text("Orange Yellow ", nearestTo(ORANGE_YELLOW)),
|
||||
text("Pink ", nearestTo(PINK)),
|
||||
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
plugins {
|
||||
id("minimotd.platform-conventions")
|
||||
}
|
||||
|
||||
tasks.jar {
|
||||
archiveClassifier.set("empty")
|
||||
}
|
||||
|
||||
val platforms = setOf(
|
||||
projects.minimotdBukkit,
|
||||
projects.minimotdBungeecord,
|
||||
).map { it.dependencyProject }
|
||||
|
||||
val dist = tasks.register<Jar>("bukkitAndBungeeJar") {
|
||||
artifacts.add("archives", this)
|
||||
archiveClassifier.set(null as String?)
|
||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||
|
||||
for (platform in platforms) {
|
||||
val jarTask = platform.miniMOTDPlatform.jarTask
|
||||
from(zipTree(jarTask.flatMap { it.archiveFile }))
|
||||
}
|
||||
}
|
||||
|
||||
miniMOTDPlatform {
|
||||
jarTask.set(dist)
|
||||
}
|
||||
+2
-1
@@ -1,7 +1,8 @@
|
||||
group=xyz.jpenilla
|
||||
version=2.2.6-SNAPSHOT
|
||||
version=2.0.15-SNAPSHOT
|
||||
description=Use MiniMessage text formatting in the server list MOTD.
|
||||
|
||||
org.gradle.caching=true
|
||||
org.gradle.configureondemand=true
|
||||
org.gradle.jvmargs=-Xmx2G
|
||||
org.gradle.parallel=true
|
||||
@@ -2,5 +2,5 @@ object Constants {
|
||||
const val GITHUB_USER = "jpenilla"
|
||||
const val GITHUB_REPO = "MiniMOTD"
|
||||
const val GITHUB_URL = "https://github.com/$GITHUB_USER/$GITHUB_REPO"
|
||||
const val RELOCATION_BASE_PACKAGE = "minimotd"
|
||||
const val RELOCATION_BASE_PACKAGE = "xyz.jpenilla.minimotd.lib"
|
||||
}
|
||||
@@ -1,12 +1,11 @@
|
||||
import net.kyori.indra.git.IndraGitExtension
|
||||
import org.gradle.accessors.dm.LibrariesForLibs
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.attributes.Attribute
|
||||
import org.gradle.api.provider.Provider
|
||||
import org.gradle.kotlin.dsl.getByType
|
||||
|
||||
fun Project.lastCommitHash(): String =
|
||||
extensions.getByType<IndraGitExtension>().commit().orNull?.name?.substring(0, 7) ?: "unknown"
|
||||
extensions.getByType<IndraGitExtension>().commit()?.name?.substring(0, 7) ?: "unknown"
|
||||
|
||||
val Project.libs: LibrariesForLibs
|
||||
get() = extensions.getByType()
|
||||
@@ -31,28 +30,5 @@ val bukkitVersions = listOf(
|
||||
"1.17.1",
|
||||
"1.18.2",
|
||||
"1.19.4",
|
||||
"1.20.4",
|
||||
"1.20.5",
|
||||
"1.20.6",
|
||||
"1.21.1",
|
||||
"1.21.2",
|
||||
"1.21.3",
|
||||
"1.21.4",
|
||||
"1.21.5",
|
||||
"1.21.6",
|
||||
"1.21.7",
|
||||
"1.20.4"
|
||||
)
|
||||
|
||||
val paperVersions = listOf(
|
||||
"1.21.8",
|
||||
"1.21.9",
|
||||
"1.21.10",
|
||||
"1.21.11",
|
||||
"26.1",
|
||||
"26.1.1",
|
||||
"26.1.2",
|
||||
"26.2",
|
||||
"26.3",
|
||||
)
|
||||
|
||||
val productionJarAttribute = Attribute.of("minimotd.productionJar", String::class.java)
|
||||
@@ -11,35 +11,15 @@ version = (version as String)
|
||||
|
||||
indra {
|
||||
javaVersions {
|
||||
target(17)
|
||||
minimumToolchain(25)
|
||||
testWith(17, 21, 25)
|
||||
minimumToolchain(17)
|
||||
target(8)
|
||||
}
|
||||
github(Constants.GITHUB_USER, Constants.GITHUB_REPO)
|
||||
mitLicense()
|
||||
}
|
||||
|
||||
java.disableAutoTargetJvm()
|
||||
|
||||
repositories {
|
||||
mavenCentral {
|
||||
mavenContent { releasesOnly() }
|
||||
}
|
||||
maven("https://repo.jpenilla.xyz/snapshots/") {
|
||||
mavenContent {
|
||||
snapshotsOnly()
|
||||
includeGroup("xyz.jpenilla")
|
||||
}
|
||||
}
|
||||
maven("https://central.sonatype.com/repository/maven-snapshots/") {
|
||||
mavenContent { snapshotsOnly() }
|
||||
}
|
||||
maven("https://repo.papermc.io/repository/maven-public/")
|
||||
maven("https://repo.spongepowered.org/repository/maven-public/")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
testImplementation(libs.junitJupiter)
|
||||
testImplementation(libs.jupiterEngine)
|
||||
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
|
||||
}
|
||||
|
||||
|
||||
@@ -14,22 +14,20 @@ hangarPublish.publications.register("plugin") {
|
||||
apiKey.set(providers.environmentVariable("HANGAR_UPLOAD_KEY"))
|
||||
platforms {
|
||||
paper {
|
||||
jar.set(jar("paper"))
|
||||
platformVersions = paperVersions
|
||||
dependencies.hangar("MiniPlaceholders") {
|
||||
required = false
|
||||
}
|
||||
jar.set(jar("bukkit"))
|
||||
val vers = bukkitVersions.toMutableList()
|
||||
vers -= "1.8.8"
|
||||
vers -= "1.8.9"
|
||||
vers += "1.8"
|
||||
platformVersions.addAll(vers)
|
||||
}
|
||||
velocity {
|
||||
jar.set(jar("velocity"))
|
||||
platformVersions.addAll("3.4")
|
||||
dependencies.hangar("MiniPlaceholders") {
|
||||
required = false
|
||||
}
|
||||
platformVersions.addAll("3.2")
|
||||
}
|
||||
waterfall {
|
||||
jar.set(jar("bungeecord"))
|
||||
platformVersions.addAll("1.21")
|
||||
platformVersions.addAll("1.20")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -32,10 +32,3 @@ if (name != "minimotd-bukkit-bungeecord") {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
configurations.consumable("productionJar") {
|
||||
outgoing {
|
||||
artifact(platformExtension.jarTask)
|
||||
}
|
||||
attributes.attribute(productionJarAttribute, "true")
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
plugins {
|
||||
id("minimotd.platform-conventions")
|
||||
id("com.gradleup.shadow")
|
||||
id("com.github.johnrengelman.shadow")
|
||||
}
|
||||
|
||||
tasks {
|
||||
|
||||
@@ -1,17 +1,14 @@
|
||||
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
||||
import org.gradle.api.file.DuplicatesStrategy
|
||||
|
||||
fun ShadowJar.commonRelocation(pkg: String) {
|
||||
relocate(pkg, "${Constants.RELOCATION_BASE_PACKAGE}.$pkg")
|
||||
}
|
||||
|
||||
fun ShadowJar.commonConfiguration() {
|
||||
mergeServiceFiles()
|
||||
// Needed for mergeServiceFiles to work properly in Shadow 9+
|
||||
filesMatching("META-INF/services/**") {
|
||||
duplicatesStrategy = DuplicatesStrategy.INCLUDE
|
||||
}
|
||||
fun ShadowJar.platformRelocation(platform: String, pkg: String) {
|
||||
relocate(pkg, "${Constants.RELOCATION_BASE_PACKAGE}.platform_$platform.$pkg")
|
||||
}
|
||||
|
||||
fun ShadowJar.commonConfiguration() {
|
||||
commonRelocation("org.spongepowered.configurate")
|
||||
commonRelocation("com.typesafe.config")
|
||||
dependencies {
|
||||
|
||||
+33
-45
@@ -1,37 +1,33 @@
|
||||
[versions]
|
||||
run-task = "3.1.0"
|
||||
resource-factory = "1.3.1"
|
||||
mod-publish-plugin = "2.2.0"
|
||||
hangarPublishPlugin = "0.1.4"
|
||||
indra = "4.1.0"
|
||||
shadow = "9.6.1"
|
||||
adventure = "4.26.1"
|
||||
adventurePlatform = "4.4.1"
|
||||
adventurePlatformMod = "7.2.0"
|
||||
configurate = "4.2.0"
|
||||
slf4j = "1.7.36"
|
||||
gson = "2.8.0"
|
||||
bstats = "3.2.1"
|
||||
paperApiLegacy = "1.16.5-R0.1-SNAPSHOT"
|
||||
paperApi = "1.21.11-R0.1-SNAPSHOT"
|
||||
paperlib = "1.0.8"
|
||||
waterfallApi = "1.16-R0.5-SNAPSHOT"
|
||||
fabricApi = "0.160.7+26.3"
|
||||
fabricLoader = "0.19.5"
|
||||
minecraft = "26.3"
|
||||
spongeApi7 = "7.4.0"
|
||||
velocityApi = "3.4.0"
|
||||
neoforge = "26.3.0.4-beta"
|
||||
|
||||
[plugins]
|
||||
blossom = { id = "net.kyori.blossom", version = "2.2.0" }
|
||||
sponge-gradle-plugin = { id = "org.spongepowered.gradle.plugin", version = "2.3.0" }
|
||||
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" }
|
||||
run-waterfall = { id = "xyz.jpenilla.run-waterfall" }
|
||||
resource-factory-bukkit = { id = "xyz.jpenilla.resource-factory-bukkit-convention", version.ref = "resource-factory" }
|
||||
resource-factory-paper = { id = "xyz.jpenilla.resource-factory-paper-convention", version.ref = "resource-factory" }
|
||||
resource-factory-velocity = { id = "xyz.jpenilla.resource-factory-velocity-convention", version.ref = "resource-factory" }
|
||||
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" }
|
||||
@@ -40,17 +36,13 @@ adventureTextSerializerPlain = { group = "net.kyori", name = "adventure-text-ser
|
||||
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 = "adventurePlatformMod" }
|
||||
adventurePlatformNeoforge = { group = "net.kyori", name = "adventure-platform-neoforge", version.ref = "adventurePlatformMod" }
|
||||
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" }
|
||||
miniplaceholders = "io.github.miniplaceholders:miniplaceholders-api:3.2.0"
|
||||
|
||||
brigadier = "com.mojang:brigadier:1.3.10"
|
||||
|
||||
configurateHocon = { group = "org.spongepowered", name = "configurate-hocon", version.ref = "configurate" }
|
||||
|
||||
jspecify = "org.jspecify:jspecify:1.0.0"
|
||||
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" }
|
||||
@@ -62,8 +54,7 @@ bstatsBungeecord = { group = "org.bstats", name = "bstats-bungeecord", version.r
|
||||
bstatsVelocity = { group = "org.bstats", name = "bstats-velocity", version.ref = "bstats" }
|
||||
bstatsSponge = { group = "org.bstats", name = "bstats-sponge", version.ref = "bstats" }
|
||||
|
||||
paperApiLegacy = { group = "com.destroystokyo.paper", name = "paper-api", version.ref = "paperApiLegacy" }
|
||||
paperApi = { group = "io.papermc.paper", name = "paper-api", version.ref = "paperApi" }
|
||||
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" }
|
||||
@@ -72,19 +63,16 @@ fabricApi = { group = "net.fabricmc.fabric-api", name = "fabric-api", version.re
|
||||
fabricLoader = { group = "net.fabricmc", name = "fabric-loader", version.ref = "fabricLoader" }
|
||||
minecraft = { group = "com.mojang", name = "minecraft", version.ref = "minecraft" }
|
||||
|
||||
# for renovate
|
||||
zNeoforge = { module = "net.neoforged:neoforge", version.ref = "neoforge" }
|
||||
|
||||
spongeApi7 = { group = "org.spongepowered", name = "spongeapi", version.ref = "spongeApi7" }
|
||||
|
||||
velocityApi = { group = "com.velocitypowered", name = "velocity-api", version.ref = "velocityApi" }
|
||||
|
||||
junitJupiter = "org.junit.jupiter:junit-jupiter:6.1.3"
|
||||
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.gradleup.shadow", name = "shadow-gradle-plugin", version.ref = "shadow" }
|
||||
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" }
|
||||
|
||||
|
||||
Vendored
BIN
Binary file not shown.
+1
-3
@@ -1,9 +1,7 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-9.7.1-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
|
||||
networkTimeout=10000
|
||||
retries=0
|
||||
retryBackOffMs=500
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright © 2015 the original authors.
|
||||
# Copyright © 2015-2021 the original authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
@@ -15,12 +15,10 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
# gradlew start up script for POSIX generated by Gradle.
|
||||
# Gradle start up script for POSIX generated by Gradle.
|
||||
#
|
||||
# Important for running:
|
||||
#
|
||||
@@ -29,7 +27,7 @@
|
||||
# bash, then to run this script, type that shell name before the whole
|
||||
# command line, like:
|
||||
#
|
||||
# ksh gradlew
|
||||
# ksh Gradle
|
||||
#
|
||||
# Busybox and similar reduced shells will NOT work, because this script
|
||||
# requires all of these POSIX shell features:
|
||||
@@ -57,7 +55,7 @@
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
@@ -86,7 +84,7 @@ done
|
||||
# shellcheck disable=SC2034
|
||||
APP_BASE_NAME=${0##*/}
|
||||
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
|
||||
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
|
||||
@@ -114,6 +112,7 @@ case "$( uname )" in #(
|
||||
NONSTOP* ) nonstop=true ;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
@@ -171,6 +170,7 @@ fi
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if "$cygwin" || "$msys" ; then
|
||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||
|
||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||
|
||||
@@ -203,14 +203,15 @@ fi
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Collect all arguments for the java command:
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||
# * 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" \
|
||||
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
|
||||
-classpath "$CLASSPATH" \
|
||||
org.gradle.wrapper.GradleWrapperMain \
|
||||
"$@"
|
||||
|
||||
# Stop when "xargs" is not available.
|
||||
|
||||
Vendored
+34
-24
@@ -13,18 +13,16 @@
|
||||
@rem See the License for the specific language governing permissions and
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
@rem SPDX-License-Identifier: Apache-2.0
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%"=="" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem gradlew startup script for Windows
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables, and ensure extensions are enabled
|
||||
setlocal EnableExtensions
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%"=="" set DIRNAME=.
|
||||
@@ -45,13 +43,13 @@ set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if %ERRORLEVEL% equ 0 goto execute
|
||||
|
||||
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
|
||||
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.
|
||||
|
||||
"%COMSPEC%" /c exit 1
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
@@ -59,24 +57,36 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
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
|
||||
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.
|
||||
|
||||
"%COMSPEC%" /c exit 1
|
||||
goto fail
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
|
||||
@rem Execute gradlew
|
||||
@rem endlocal doesn't take effect until after the line is parsed and variables are expanded
|
||||
@rem which allows us to clear the local environment before executing the java command
|
||||
endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||
|
||||
:exitWithErrorLevel
|
||||
@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts
|
||||
"%COMSPEC%" /c exit %ERRORLEVEL%
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
set EXIT_CODE=%ERRORLEVEL%
|
||||
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||
exit /b %EXIT_CODE%
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2020-2025 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-2025 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")
|
||||
alias(libs.plugins.run.paper)
|
||||
alias(libs.plugins.resource.factory.bukkit)
|
||||
}
|
||||
|
||||
dependencies {
|
||||
@@ -10,43 +9,37 @@ dependencies {
|
||||
implementation(libs.adventurePlatformBukkit)
|
||||
implementation(libs.bstatsBukkit)
|
||||
implementation(libs.paperlib)
|
||||
compileOnly(libs.paperApiLegacy)
|
||||
compileOnly(libs.paperApi)
|
||||
}
|
||||
|
||||
tasks {
|
||||
runServer {
|
||||
minecraftVersion("1.21.7")
|
||||
minecraftVersion(minecraftVersion)
|
||||
}
|
||||
shadowJar {
|
||||
platformRelocation("bukkit", "xyz.jpenilla.minimotd.common")
|
||||
commonRelocation("org.slf4j")
|
||||
commonRelocation("io.leangen.geantyref")
|
||||
commonRelocation("net.kyori")
|
||||
commonRelocation("org.bstats")
|
||||
commonRelocation("io.papermc.lib")
|
||||
manifest {
|
||||
attributes("paperweight-mappings-namespace" to "mojang")
|
||||
}
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bukkitPluginYaml {
|
||||
name = "MiniMOTD"
|
||||
main = "xyz.jpenilla.minimotd.bukkit.MiniMOTDBukkit"
|
||||
foliaSupported = true
|
||||
authors = listOf("jmp")
|
||||
website = Constants.GITHUB_URL
|
||||
commands.register("minimotd") {
|
||||
description = "MiniMOTD Command"
|
||||
permission = "minimotd.admin"
|
||||
usage = "/minimotd help"
|
||||
}
|
||||
apiVersion = "1.13"
|
||||
softDepend = listOf("ViaVersion")
|
||||
}
|
||||
|
||||
runPaper.folia.registerTask()
|
||||
|
||||
publishMods.modrinth {
|
||||
modLoaders.addAll("paper", "folia")
|
||||
minecraftVersions = bukkitVersions
|
||||
minecraftVersions.addAll(bukkitVersions)
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2025 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.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
import org.jspecify.annotations.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import xyz.jpenilla.minimotd.common.CommandHandler;
|
||||
|
||||
import static net.kyori.adventure.text.Component.text;
|
||||
@@ -39,10 +39,10 @@ import static net.kyori.adventure.text.event.ClickEvent.runCommand;
|
||||
import static net.kyori.adventure.text.format.NamedTextColor.RED;
|
||||
|
||||
final class BukkitCommand implements CommandExecutor, TabCompleter {
|
||||
private final MiniMOTDBukkit plugin;
|
||||
private final MiniMOTDPlugin plugin;
|
||||
private final CommandHandler handler;
|
||||
|
||||
BukkitCommand(final @NonNull MiniMOTDBukkit plugin) {
|
||||
BukkitCommand(final @NonNull MiniMOTDPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
this.handler = new CommandHandler(plugin.miniMOTD());
|
||||
}
|
||||
|
||||
+4
-22
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2025 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,20 +29,18 @@ import java.nio.file.Path;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
|
||||
import org.bstats.bukkit.Metrics;
|
||||
import org.bstats.charts.SimplePie;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.util.CachedServerIcon;
|
||||
import org.jspecify.annotations.NonNull;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import xyz.jpenilla.minimotd.common.MiniMOTD;
|
||||
import xyz.jpenilla.minimotd.common.MiniMOTDPlatform;
|
||||
import xyz.jpenilla.minimotd.common.util.Nag;
|
||||
import xyz.jpenilla.minimotd.common.util.UpdateChecker;
|
||||
|
||||
public final class MiniMOTDBukkit extends JavaPlugin implements MiniMOTDPlatform<CachedServerIcon> {
|
||||
public final class MiniMOTDPlugin extends JavaPlugin implements MiniMOTDPlatform<CachedServerIcon> {
|
||||
private static final boolean PAPER_PING_EVENT_EXISTS = findClass("com.destroystokyo.paper.event.server.PaperServerListPingEvent") != null;
|
||||
|
||||
private Logger logger;
|
||||
@@ -52,21 +50,6 @@ public final class MiniMOTDBukkit extends JavaPlugin implements MiniMOTDPlatform
|
||||
@Override
|
||||
public void onEnable() {
|
||||
this.logger = LoggerFactory.getLogger(this.getName());
|
||||
|
||||
if (PaperLib.getMinecraftVersion() > 21 || PaperLib.getMinecraftVersion() == 21 && PaperLib.getMinecraftPatchVersion() > 7) {
|
||||
new Nag.Slf4J(this.logger).lines(
|
||||
"You are using the incorrect MiniMOTD build for your server software.",
|
||||
"This build is for Spigot/Paper 1.8.8 through 1.21.7.",
|
||||
"Builds for Paper 1.21.8+ are available on Modrinth (https://modrinth.com/plugin/minimotd)",
|
||||
"and Hangar (https://hangar.papermc.io/jmp/MiniMOTD).",
|
||||
"When downloading be sure to check the supported versions/platforms",
|
||||
"field on the versions page, and/or make the correct selections in",
|
||||
"the download menu."
|
||||
).error(true).logBanner();
|
||||
this.getServer().getPluginManager().disablePlugin(this);
|
||||
return;
|
||||
}
|
||||
|
||||
this.miniMOTD = new MiniMOTD<>(this);
|
||||
this.audiences = BukkitAudiences.create(this);
|
||||
|
||||
@@ -87,7 +70,6 @@ public final class MiniMOTDBukkit extends JavaPlugin implements MiniMOTDPlatform
|
||||
}
|
||||
|
||||
final Metrics metrics = new Metrics(this, 8132);
|
||||
metrics.addCustomChart(new SimplePie("variant", () -> "bukkit"));
|
||||
|
||||
if (this.miniMOTD.configManager().pluginSettings().updateChecker()) {
|
||||
try {
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2025 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
|
||||
@@ -25,32 +25,17 @@ package xyz.jpenilla.minimotd.bukkit;
|
||||
|
||||
import com.destroystokyo.paper.event.server.PaperServerListPingEvent;
|
||||
import io.papermc.lib.PaperLib;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.List;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.util.CachedServerIcon;
|
||||
import org.jspecify.annotations.NonNull;
|
||||
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.MOTDConfig;
|
||||
import xyz.jpenilla.minimotd.common.config.MiniMOTDConfig;
|
||||
|
||||
public final class PaperPingListener implements Listener {
|
||||
private static final Method WORK_AROUND_PAPER_BUG;
|
||||
|
||||
static {
|
||||
Method paperWorkaround;
|
||||
try {
|
||||
paperWorkaround = PaperServerListPingEvent.class.getMethod("getListedPlayers");
|
||||
} catch (final NoSuchMethodException e) {
|
||||
paperWorkaround = null;
|
||||
}
|
||||
WORK_AROUND_PAPER_BUG = paperWorkaround;
|
||||
}
|
||||
|
||||
private final LegacyComponentSerializer unusualHexSerializer = LegacyComponentSerializer.builder().hexColors().useUnusualXRepeatedCharacterHexFormat().build();
|
||||
private final MiniMOTD<CachedServerIcon> miniMOTD;
|
||||
|
||||
@@ -60,7 +45,7 @@ public final class PaperPingListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void handlePing(final @NonNull PaperServerListPingEvent event) {
|
||||
final MOTDConfig cfg = this.miniMOTD.configManager().mainConfig();
|
||||
final MiniMOTDConfig cfg = this.miniMOTD.configManager().mainConfig();
|
||||
|
||||
final PingResponse<CachedServerIcon> response = this.miniMOTD.createMOTD(cfg, event.getNumPlayers(), event.getMaxPlayers());
|
||||
|
||||
@@ -75,17 +60,7 @@ public final class PaperPingListener implements Listener {
|
||||
response.icon(event::setServerIcon);
|
||||
|
||||
if (response.disablePlayerListHover()) {
|
||||
if (WORK_AROUND_PAPER_BUG != null) {
|
||||
// Newer Paper replaces getPlayerSample with getListedPlayers,
|
||||
// the old method is supposed to still work, but it just silently does nothing on 1.20.6 (fixed in 1.21.1)
|
||||
try {
|
||||
((List) WORK_AROUND_PAPER_BUG.invoke(event)).clear();
|
||||
} catch (final IllegalAccessException | InvocationTargetException e) {
|
||||
throw new RuntimeException("Failed to invoke " + WORK_AROUND_PAPER_BUG.getName(), e);
|
||||
}
|
||||
} else {
|
||||
event.getPlayerSample().clear();
|
||||
}
|
||||
event.getPlayerSample().clear();
|
||||
}
|
||||
if (response.hidePlayerCount()) {
|
||||
event.setHidePlayers(true);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2025 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,10 +29,10 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.server.ServerListPingEvent;
|
||||
import org.bukkit.util.CachedServerIcon;
|
||||
import org.jspecify.annotations.NonNull;
|
||||
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.MOTDConfig;
|
||||
import xyz.jpenilla.minimotd.common.config.MiniMOTDConfig;
|
||||
|
||||
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 MOTDConfig cfg = this.miniMOTD.configManager().mainConfig();
|
||||
final MiniMOTDConfig cfg = this.miniMOTD.configManager().mainConfig();
|
||||
|
||||
final PingResponse<CachedServerIcon> response = this.miniMOTD.createMOTD(cfg, event.getNumPlayers(), event.getMaxPlayers());
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -12,12 +12,13 @@ dependencies {
|
||||
|
||||
tasks {
|
||||
shadowJar {
|
||||
platformRelocation("bungee", "xyz.jpenilla.minimotd.common")
|
||||
commonRelocation("io.leangen.geantyref")
|
||||
commonRelocation("net.kyori")
|
||||
commonRelocation("org.bstats")
|
||||
}
|
||||
runWaterfall {
|
||||
waterfallVersion("1.21")
|
||||
waterfallVersion("1.20")
|
||||
}
|
||||
processResources {
|
||||
val props = mapOf(
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2025 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,7 +26,7 @@ package xyz.jpenilla.minimotd.bungee;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.plugin.Command;
|
||||
import org.jspecify.annotations.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import xyz.jpenilla.minimotd.common.CommandHandler;
|
||||
|
||||
import static net.kyori.adventure.text.Component.text;
|
||||
@@ -34,10 +34,10 @@ import static net.kyori.adventure.text.event.ClickEvent.runCommand;
|
||||
import static net.kyori.adventure.text.format.NamedTextColor.RED;
|
||||
|
||||
final class BungeeCommand extends Command {
|
||||
private final MiniMOTDBungee plugin;
|
||||
private final MiniMOTDPlugin plugin;
|
||||
private final CommandHandler handler;
|
||||
|
||||
BungeeCommand(final @NonNull MiniMOTDBungee plugin) {
|
||||
BungeeCommand(final @NonNull MiniMOTDPlugin plugin) {
|
||||
super("minimotd");
|
||||
this.plugin = plugin;
|
||||
this.handler = new CommandHandler(plugin.miniMOTD());
|
||||
|
||||
+6
-6
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2025 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,17 +33,17 @@ import net.md_5.bungee.api.Favicon;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.plugin.Plugin;
|
||||
import org.bstats.bungeecord.Metrics;
|
||||
import org.jspecify.annotations.NonNull;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import xyz.jpenilla.minimotd.common.MiniMOTD;
|
||||
import xyz.jpenilla.minimotd.common.MiniMOTDPlatform;
|
||||
import xyz.jpenilla.minimotd.common.PingResponse;
|
||||
import xyz.jpenilla.minimotd.common.config.MOTDConfig;
|
||||
import xyz.jpenilla.minimotd.common.config.MiniMOTDConfig;
|
||||
import xyz.jpenilla.minimotd.common.util.UpdateChecker;
|
||||
|
||||
public final class MiniMOTDBungee extends Plugin implements MiniMOTDPlatform<Favicon> {
|
||||
public final class MiniMOTDPlugin extends Plugin implements MiniMOTDPlatform<Favicon> {
|
||||
private Logger logger;
|
||||
private BungeeAudiences audiences;
|
||||
private MiniMOTD<Favicon> miniMOTD;
|
||||
@@ -116,7 +116,7 @@ public final class MiniMOTDBungee extends Plugin implements MiniMOTDPlatform<Fav
|
||||
}
|
||||
|
||||
private void preload() {
|
||||
final MOTDConfig cfg = this.miniMOTD.configManager().mainConfig();
|
||||
final MiniMOTDConfig cfg = this.miniMOTD.configManager().mainConfig();
|
||||
final PingResponse<Favicon> mini = this.miniMOTD.createMOTD(cfg, 0, 0);
|
||||
mini.motd(motd -> BungeeComponentSerializer.get().serialize(motd));
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2025 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,11 +31,11 @@ import net.md_5.bungee.api.chat.TextComponent;
|
||||
import net.md_5.bungee.api.event.ProxyPingEvent;
|
||||
import net.md_5.bungee.api.plugin.Listener;
|
||||
import net.md_5.bungee.event.EventHandler;
|
||||
import org.jspecify.annotations.NonNull;
|
||||
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.MOTDConfig;
|
||||
import xyz.jpenilla.minimotd.common.config.MiniMOTDConfig;
|
||||
|
||||
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 MOTDConfig cfg = this.miniMOTD.configManager().resolveConfig(e.getConnection().getVirtualHost());
|
||||
final MiniMOTDConfig cfg = this.miniMOTD.configManager().resolveConfig(e.getConnection().getVirtualHost());
|
||||
final PingResponse<Favicon> mini = this.miniMOTD.createMOTD(cfg, players.getOnline(), players.getMax());
|
||||
|
||||
if (mini.hidePlayerCount()) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
name: MiniMOTD
|
||||
main: xyz.jpenilla.minimotd.bungee.MiniMOTDBungee
|
||||
main: xyz.jpenilla.minimotd.bungee.MiniMOTDPlugin
|
||||
version: $version
|
||||
author: jmp
|
||||
description: $description
|
||||
@@ -1,44 +1,44 @@
|
||||
import me.modmuss50.mpp.platforms.modrinth.ModrinthEnvironment
|
||||
|
||||
plugins {
|
||||
id("xyz.jpenilla.quiet-fabric-loom")
|
||||
id("quiet-fabric-loom")
|
||||
id("minimotd.platform-conventions")
|
||||
id("com.gradleup.shadow")
|
||||
id("com.github.johnrengelman.shadow")
|
||||
}
|
||||
|
||||
val shade: Configuration by configurations.creating
|
||||
|
||||
dependencies {
|
||||
minecraft(libs.minecraft)
|
||||
implementation(libs.fabricLoader)
|
||||
implementation(libs.fabricApi)
|
||||
mappings(loom.officialMojangMappings())
|
||||
modImplementation(libs.fabricLoader)
|
||||
modImplementation(libs.fabricApi)
|
||||
|
||||
shade(implementation(projects.minimotdCommon) {
|
||||
exclude("net.kyori")
|
||||
exclude("com.google.errorprone")
|
||||
})
|
||||
|
||||
implementation(libs.adventurePlatformFabric)
|
||||
modImplementation(libs.adventurePlatformFabric)
|
||||
include(libs.adventurePlatformFabric)
|
||||
}
|
||||
|
||||
miniMOTDPlatform {
|
||||
jarTask.set(tasks.shadowJar)
|
||||
jarTask.set(tasks.remapJar)
|
||||
}
|
||||
|
||||
indra {
|
||||
javaVersions {
|
||||
target(25)
|
||||
target(17)
|
||||
}
|
||||
}
|
||||
|
||||
tasks {
|
||||
shadowJar {
|
||||
archiveFileName.set("${project.name}-mc$minecraftVersion-${project.version}.jar")
|
||||
configurations = listOf(shade)
|
||||
commonConfiguration()
|
||||
commonRelocation("io.leangen.geantyref")
|
||||
}
|
||||
remapJar {
|
||||
archiveFileName.set("${project.name}-mc$minecraftVersion-${project.version}.jar")
|
||||
}
|
||||
processResources {
|
||||
val replacements = mapOf(
|
||||
"modid" to project.name,
|
||||
@@ -55,8 +55,6 @@ tasks {
|
||||
}
|
||||
|
||||
publishMods.modrinth {
|
||||
environment = ModrinthEnvironment.DEDICATED_SERVER_ONLY
|
||||
modLoaders.add("fabric")
|
||||
minecraftVersions.addAll(minecraftVersion)
|
||||
optional("miniplaceholders")
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2025 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,21 +34,21 @@ import net.fabricmc.api.ModInitializer;
|
||||
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
|
||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.kyori.adventure.platform.modcommon.MinecraftServerAudiences;
|
||||
import net.kyori.adventure.platform.fabric.FabricServerAudiences;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.network.protocol.status.ServerStatus;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import org.jspecify.annotations.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import xyz.jpenilla.minimotd.common.CommandHandler;
|
||||
import xyz.jpenilla.minimotd.common.MiniMOTD;
|
||||
import xyz.jpenilla.minimotd.common.MiniMOTDPlatform;
|
||||
import xyz.jpenilla.minimotd.common.util.BrigadierUtil;
|
||||
import xyz.jpenilla.minimotd.common.util.UpdateChecker;
|
||||
import xyz.jpenilla.minimotd.fabric.access.ServerStatusFaviconAccess;
|
||||
|
||||
import static net.minecraft.commands.Commands.literal;
|
||||
|
||||
public final class MiniMOTDFabric implements ModInitializer, MiniMOTDPlatform<ServerStatus.Favicon> {
|
||||
private static MiniMOTDFabric instance = null;
|
||||
|
||||
@@ -57,7 +57,7 @@ public final class MiniMOTDFabric implements ModInitializer, MiniMOTDPlatform<Se
|
||||
private final MiniMOTD<ServerStatus.Favicon> miniMOTD = new MiniMOTD<>(this);
|
||||
|
||||
private MinecraftServer server;
|
||||
private MinecraftServerAudiences audiences;
|
||||
private FabricServerAudiences audiences;
|
||||
|
||||
public MiniMOTDFabric() {
|
||||
if (instance != null) {
|
||||
@@ -75,7 +75,7 @@ public final class MiniMOTDFabric implements ModInitializer, MiniMOTDPlatform<Se
|
||||
this.registerCommand();
|
||||
ServerLifecycleEvents.SERVER_STARTING.register(minecraftServer -> {
|
||||
this.server = minecraftServer;
|
||||
this.audiences = MinecraftServerAudiences.of(minecraftServer);
|
||||
this.audiences = FabricServerAudiences.of(minecraftServer);
|
||||
});
|
||||
ServerLifecycleEvents.SERVER_STARTED.register(minecraftServer -> {
|
||||
if (this.miniMOTD.configManager().pluginSettings().updateChecker()) {
|
||||
@@ -104,16 +104,17 @@ public final class MiniMOTDFabric implements ModInitializer, MiniMOTDPlatform<Se
|
||||
}
|
||||
}
|
||||
|
||||
final CommandHandler handler = new CommandHandler(this.miniMOTD);
|
||||
CommandRegistrationCallback.EVENT.register((dispatcher, commandBuildContext, commandSelection) -> dispatcher.register(
|
||||
BrigadierUtil.buildTree(
|
||||
new CommandHandler(this.miniMOTD),
|
||||
sourceStack -> this.audiences().audience(sourceStack),
|
||||
Commands.hasPermission(Commands.LEVEL_ADMINS)
|
||||
)
|
||||
literal("minimotd")
|
||||
.requires(source -> source.hasPermission(4))
|
||||
.then(literal("reload").executes(new WrappingExecutor(handler::reload)))
|
||||
.then(literal("about").executes(new WrappingExecutor(handler::about)))
|
||||
.then(literal("help").executes(new WrappingExecutor(handler::help)))
|
||||
));
|
||||
}
|
||||
|
||||
public @NonNull MinecraftServerAudiences audiences() {
|
||||
public @NonNull FabricServerAudiences audiences() {
|
||||
return this.audiences;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2025 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-2025 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,7 +23,7 @@
|
||||
*/
|
||||
package xyz.jpenilla.minimotd.fabric.access;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public interface ServerStatusFaviconAccess {
|
||||
@Nullable String cachedEncodedIcon();
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2025 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-2025 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-2025 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
|
||||
@@ -28,7 +28,7 @@ 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.jspecify.annotations.Nullable;
|
||||
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;
|
||||
|
||||
+5
-5
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2025 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.MOTDConfig;
|
||||
import xyz.jpenilla.minimotd.common.config.MiniMOTDConfig;
|
||||
import xyz.jpenilla.minimotd.common.util.ComponentColorDownsampler;
|
||||
import xyz.jpenilla.minimotd.fabric.MiniMOTDFabric;
|
||||
import xyz.jpenilla.minimotd.fabric.access.ConnectionAccess;
|
||||
@@ -58,7 +58,7 @@ abstract class ServerStatusPacketListenerImplMixin {
|
||||
final ServerStatus vanillaStatus = Objects.requireNonNull(minecraftServer.getStatus(), "vanillaStatus");
|
||||
|
||||
final MiniMOTD<ServerStatus.Favicon> miniMOTD = miniMOTDFabric.miniMOTD();
|
||||
final MOTDConfig config = miniMOTD.configManager().mainConfig();
|
||||
final MiniMOTDConfig config = miniMOTD.configManager().mainConfig();
|
||||
|
||||
final PingResponse<ServerStatus.Favicon> response = miniMOTD.createMOTD(
|
||||
config,
|
||||
@@ -69,9 +69,9 @@ abstract class ServerStatusPacketListenerImplMixin {
|
||||
final MutableServerStatus modifiedStatus = new MutableServerStatus(vanillaStatus);
|
||||
response.motd(motd -> {
|
||||
if (((ConnectionAccess) this.connection).protocolVersion() >= Constants.MINECRAFT_1_16_PROTOCOL_VERSION) {
|
||||
modifiedStatus.description(miniMOTDFabric.audiences().asNative(motd));
|
||||
modifiedStatus.description(miniMOTDFabric.audiences().toNative(motd));
|
||||
} else {
|
||||
modifiedStatus.description(miniMOTDFabric.audiences().asNative(ComponentColorDownsampler.downsampler().downsample(motd)));
|
||||
modifiedStatus.description(miniMOTDFabric.audiences().toNative(ComponentColorDownsampler.downsampler().downsample(motd)));
|
||||
}
|
||||
});
|
||||
response.icon(favicon -> modifiedStatus.favicon(Optional.of(favicon)));
|
||||
|
||||
+4
-3
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2025 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,10 +27,11 @@ import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.protocol.status.ServerStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.framework.qual.DefaultQualifier;
|
||||
|
||||
@SuppressWarnings({"OptionalUsedAsFieldOrParameterType", "unused"})
|
||||
@NullMarked
|
||||
@DefaultQualifier(NonNull.class)
|
||||
public final class MutableServerStatus {
|
||||
private Component description;
|
||||
private Optional<ServerStatus.Players> players;
|
||||
|
||||
@@ -23,9 +23,8 @@
|
||||
"minimotd-fabric.mixins.json"
|
||||
],
|
||||
"depends": {
|
||||
"fabricloader": ">=0.19.5",
|
||||
"fabric-api": "*",
|
||||
"minecraft": ">=26.3",
|
||||
"adventure-platform-fabric": "*"
|
||||
"fabricloader": ">=0.15.3",
|
||||
"fabric": "*",
|
||||
"minecraft": "~1.20.4"
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
"required": true,
|
||||
"minVersion": "0.8.4",
|
||||
"package": "xyz.jpenilla.minimotd.fabric.mixin",
|
||||
"compatibilityLevel": "JAVA_21",
|
||||
"compatibilityLevel": "JAVA_16",
|
||||
"mixins": [
|
||||
"ConnectionMixin",
|
||||
"ServerHandshakePacketListenerImplMixin",
|
||||
|
||||
@@ -1,68 +0,0 @@
|
||||
import me.modmuss50.mpp.platforms.modrinth.ModrinthEnvironment
|
||||
|
||||
plugins {
|
||||
id("net.neoforged.moddev")
|
||||
id("minimotd.platform-conventions")
|
||||
id("com.gradleup.shadow")
|
||||
}
|
||||
|
||||
neoForge {
|
||||
enable {
|
||||
version = libs.versions.neoforge.get()
|
||||
}
|
||||
}
|
||||
|
||||
val shade: Configuration by configurations.creating
|
||||
|
||||
dependencies {
|
||||
shade(implementation(projects.minimotdCommon) {
|
||||
exclude("net.kyori")
|
||||
exclude("com.google.errorprone")
|
||||
})
|
||||
|
||||
implementation(libs.adventurePlatformNeoforge)
|
||||
jarJar(libs.adventurePlatformNeoforge)
|
||||
}
|
||||
|
||||
indra {
|
||||
javaVersions {
|
||||
target(25)
|
||||
}
|
||||
}
|
||||
|
||||
tasks {
|
||||
shadowJar {
|
||||
configurations = listOf(shade)
|
||||
commonConfiguration()
|
||||
commonRelocation("io.leangen.geantyref")
|
||||
}
|
||||
processResources {
|
||||
val replacements = mapOf(
|
||||
"version" to project.version.toString(),
|
||||
"description" to project.description.toString(),
|
||||
"github_url" to Constants.GITHUB_URL
|
||||
)
|
||||
inputs.properties(replacements)
|
||||
filesMatching("META-INF/neoforge.mods.toml") {
|
||||
expand(replacements)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val productionJar = tasks.register<Zip>("productionJar") {
|
||||
archiveFileName = "${project.name}-mc$minecraftVersion-${project.version}.jar"
|
||||
destinationDirectory = layout.buildDirectory.dir("libs")
|
||||
from(zipTree(tasks.shadowJar.flatMap { it.archiveFile }))
|
||||
from(tasks.jarJar.flatMap { it.outputDirectory })
|
||||
}
|
||||
|
||||
miniMOTDPlatform {
|
||||
jarTask.set(productionJar)
|
||||
}
|
||||
|
||||
publishMods.modrinth {
|
||||
environment = ModrinthEnvironment.DEDICATED_SERVER_ONLY
|
||||
modLoaders.add("neoforge")
|
||||
minecraftVersions.addAll(minecraftVersion)
|
||||
optional("miniplaceholders")
|
||||
}
|
||||
@@ -1,134 +0,0 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2025 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.neoforge;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.nio.file.Path;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import javax.imageio.ImageIO;
|
||||
import net.kyori.adventure.platform.modcommon.MinecraftServerAudiences;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.network.protocol.status.ServerStatus;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.neoforged.fml.common.Mod;
|
||||
import net.neoforged.neoforge.common.NeoForge;
|
||||
import net.neoforged.neoforge.event.RegisterCommandsEvent;
|
||||
import net.neoforged.neoforge.event.server.ServerStartedEvent;
|
||||
import net.neoforged.neoforge.event.server.ServerStartingEvent;
|
||||
import net.neoforged.neoforge.event.server.ServerStoppedEvent;
|
||||
import org.jspecify.annotations.NonNull;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import xyz.jpenilla.minimotd.common.CommandHandler;
|
||||
import xyz.jpenilla.minimotd.common.MiniMOTD;
|
||||
import xyz.jpenilla.minimotd.common.MiniMOTDPlatform;
|
||||
import xyz.jpenilla.minimotd.common.util.BrigadierUtil;
|
||||
import xyz.jpenilla.minimotd.common.util.UpdateChecker;
|
||||
import xyz.jpenilla.minimotd.neoforge.access.ServerStatusFaviconAccess;
|
||||
|
||||
@Mod("minimotd")
|
||||
public final class MiniMOTDNeoForge implements MiniMOTDPlatform<ServerStatus.Favicon> {
|
||||
private static MiniMOTDNeoForge instance = null;
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(MiniMOTD.class);
|
||||
private final Path dataDirectory = Path.of("config", "MiniMOTD");
|
||||
private final MiniMOTD<ServerStatus.Favicon> miniMOTD = new MiniMOTD<>(this);
|
||||
|
||||
private MinecraftServer server;
|
||||
private MinecraftServerAudiences audiences;
|
||||
|
||||
public MiniMOTDNeoForge() {
|
||||
if (instance != null) {
|
||||
throw new IllegalStateException("Cannot create a second instance of " + this.getClass().getName());
|
||||
}
|
||||
instance = this;
|
||||
|
||||
this.registerCommand();
|
||||
NeoForge.EVENT_BUS.addListener((ServerStartingEvent event) -> {
|
||||
this.server = event.getServer();
|
||||
this.audiences = MinecraftServerAudiences.of(event.getServer());
|
||||
});
|
||||
NeoForge.EVENT_BUS.addListener((ServerStartedEvent event) -> {
|
||||
if (this.miniMOTD.configManager().pluginSettings().updateChecker()) {
|
||||
CompletableFuture.runAsync(() -> new UpdateChecker().checkVersion().forEach(this.logger()::info));
|
||||
}
|
||||
});
|
||||
NeoForge.EVENT_BUS.addListener((ServerStoppedEvent event) -> {
|
||||
this.server = null;
|
||||
this.audiences = null;
|
||||
});
|
||||
this.miniMOTD.logger().info("Done initializing MiniMOTD");
|
||||
}
|
||||
|
||||
public @NonNull MiniMOTD<ServerStatus.Favicon> miniMOTD() {
|
||||
return this.miniMOTD;
|
||||
}
|
||||
|
||||
private void registerCommand() {
|
||||
NeoForge.EVENT_BUS.addListener((RegisterCommandsEvent event) -> {
|
||||
event.getDispatcher().register(
|
||||
BrigadierUtil.buildTree(
|
||||
new CommandHandler(this.miniMOTD),
|
||||
sourceStack -> this.audiences().audience(sourceStack),
|
||||
Commands.hasPermission(Commands.LEVEL_ADMINS)
|
||||
)
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
public @NonNull MinecraftServerAudiences audiences() {
|
||||
return this.audiences;
|
||||
}
|
||||
|
||||
public static @NonNull MiniMOTDNeoForge get() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public @NonNull MinecraftServer requireServer() {
|
||||
if (this.server == null) {
|
||||
throw new IllegalStateException("Server requested before started");
|
||||
}
|
||||
return this.server;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull Path dataDirectory() {
|
||||
return this.dataDirectory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull Logger logger() {
|
||||
return this.logger;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServerStatus.@NonNull Favicon loadIcon(final @NonNull BufferedImage bufferedImage) throws Exception {
|
||||
final ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
ImageIO.write(bufferedImage, "PNG", out);
|
||||
final ServerStatus.Favicon favicon = new ServerStatus.Favicon(out.toByteArray());
|
||||
((ServerStatusFaviconAccess) (Object) favicon).cacheEncodedIcon();
|
||||
return favicon;
|
||||
}
|
||||
}
|
||||
-30
@@ -1,30 +0,0 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2025 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.neoforge.access;
|
||||
|
||||
public interface ConnectionAccess {
|
||||
void protocolVersion(int protocolVersion);
|
||||
|
||||
int protocolVersion();
|
||||
}
|
||||
-46
@@ -1,46 +0,0 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2025 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.neoforge.mixin;
|
||||
|
||||
import net.minecraft.network.Connection;
|
||||
import org.spongepowered.asm.mixin.Implements;
|
||||
import org.spongepowered.asm.mixin.Interface;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import xyz.jpenilla.minimotd.neoforge.access.ConnectionAccess;
|
||||
|
||||
@Unique
|
||||
@Mixin(Connection.class)
|
||||
@Implements({@Interface(iface = ConnectionAccess.class, prefix = "miniMOTD$")})
|
||||
abstract class ConnectionMixin {
|
||||
private int miniMOTD$protocolVersion = -1;
|
||||
|
||||
public void miniMOTD$protocolVersion(final int protocolVersion) {
|
||||
this.miniMOTD$protocolVersion = protocolVersion;
|
||||
}
|
||||
|
||||
public int miniMOTD$protocolVersion() {
|
||||
return this.miniMOTD$protocolVersion;
|
||||
}
|
||||
}
|
||||
-45
@@ -1,45 +0,0 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2025 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.neoforge.mixin;
|
||||
|
||||
import net.minecraft.network.Connection;
|
||||
import net.minecraft.network.protocol.handshake.ClientIntentionPacket;
|
||||
import net.minecraft.server.network.ServerHandshakePacketListenerImpl;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import xyz.jpenilla.minimotd.neoforge.access.ConnectionAccess;
|
||||
|
||||
@Mixin(ServerHandshakePacketListenerImpl.class)
|
||||
abstract class ServerHandshakePacketListenerImplMixin {
|
||||
@Shadow @Final private Connection connection;
|
||||
|
||||
@Inject(method = "handleIntention", at = @At("HEAD"))
|
||||
public void injectHandleIntention(final ClientIntentionPacket packet, final CallbackInfo ci) {
|
||||
((ConnectionAccess) this.connection).protocolVersion(packet.protocolVersion());
|
||||
}
|
||||
}
|
||||
-78
@@ -1,78 +0,0 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2025 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.neoforge.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.jspecify.annotations.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.neoforge.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);
|
||||
}
|
||||
}
|
||||
-94
@@ -1,94 +0,0 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2025 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.neoforge.mixin;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import net.minecraft.network.Connection;
|
||||
import net.minecraft.network.protocol.status.ServerStatus;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.network.ServerStatusPacketListenerImpl;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
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.MOTDConfig;
|
||||
import xyz.jpenilla.minimotd.common.util.ComponentColorDownsampler;
|
||||
import xyz.jpenilla.minimotd.neoforge.MiniMOTDNeoForge;
|
||||
import xyz.jpenilla.minimotd.neoforge.access.ConnectionAccess;
|
||||
import xyz.jpenilla.minimotd.neoforge.util.MutableServerStatus;
|
||||
|
||||
@Mixin(ServerStatusPacketListenerImpl.class)
|
||||
abstract class ServerStatusPacketListenerImplMixin {
|
||||
@Shadow @Final private Connection connection;
|
||||
|
||||
@Redirect(
|
||||
method = "handleStatusRequest",
|
||||
at = @At(value = "FIELD", target = "Lnet/minecraft/server/network/ServerStatusPacketListenerImpl;status:Lnet/minecraft/network/protocol/status/ServerStatus;")
|
||||
)
|
||||
public ServerStatus injectHandleStatusRequest(final ServerStatusPacketListenerImpl instance) {
|
||||
final MiniMOTDNeoForge miniMOTDNeoForge = MiniMOTDNeoForge.get();
|
||||
final MinecraftServer minecraftServer = miniMOTDNeoForge.requireServer();
|
||||
final ServerStatus vanillaStatus = Objects.requireNonNull(minecraftServer.getStatus(), "vanillaStatus");
|
||||
|
||||
final MiniMOTD<ServerStatus.Favicon> miniMOTD = miniMOTDNeoForge.miniMOTD();
|
||||
final MOTDConfig config = miniMOTD.configManager().mainConfig();
|
||||
|
||||
final PingResponse<ServerStatus.Favicon> response = miniMOTD.createMOTD(
|
||||
config,
|
||||
minecraftServer.getPlayerCount(),
|
||||
vanillaStatus.players().map(ServerStatus.Players::max).orElseGet(minecraftServer::getMaxPlayers)
|
||||
);
|
||||
|
||||
final MutableServerStatus modifiedStatus = new MutableServerStatus(vanillaStatus);
|
||||
response.motd(motd -> {
|
||||
if (((ConnectionAccess) this.connection).protocolVersion() >= Constants.MINECRAFT_1_16_PROTOCOL_VERSION) {
|
||||
modifiedStatus.description(miniMOTDNeoForge.audiences().asNative(motd));
|
||||
} else {
|
||||
modifiedStatus.description(miniMOTDNeoForge.audiences().asNative(ComponentColorDownsampler.downsampler().downsample(motd)));
|
||||
}
|
||||
});
|
||||
response.icon(favicon -> modifiedStatus.favicon(Optional.of(favicon)));
|
||||
|
||||
if (response.hidePlayerCount()) {
|
||||
modifiedStatus.players(Optional.empty());
|
||||
} else {
|
||||
final ServerStatus.Players newPlayers = new ServerStatus.Players(
|
||||
response.playerCount().maxPlayers(),
|
||||
response.playerCount().onlinePlayers(),
|
||||
response.disablePlayerListHover()
|
||||
? Collections.emptyList()
|
||||
: vanillaStatus.players().map(ServerStatus.Players::sample).orElse(Collections.emptyList())
|
||||
);
|
||||
modifiedStatus.players(Optional.of(newPlayers));
|
||||
}
|
||||
|
||||
return modifiedStatus.toServerStatus();
|
||||
}
|
||||
}
|
||||
-98
@@ -1,98 +0,0 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2025 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.neoforge.util;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.protocol.status.ServerStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@SuppressWarnings({"OptionalUsedAsFieldOrParameterType", "unused"})
|
||||
@NullMarked
|
||||
public final class MutableServerStatus {
|
||||
private Component description;
|
||||
private Optional<ServerStatus.Players> players;
|
||||
private Optional<ServerStatus.Version> version;
|
||||
private Optional<ServerStatus.Favicon> favicon;
|
||||
private boolean enforcesSecureChat;
|
||||
private boolean isModded; // NeoForge addition
|
||||
|
||||
public MutableServerStatus(final ServerStatus status) {
|
||||
this.description = status.description();
|
||||
this.players = status.players();
|
||||
this.version = status.version();
|
||||
this.favicon = status.favicon();
|
||||
this.enforcesSecureChat = status.enforcesSecureChat();
|
||||
this.isModded = status.isModded(); // NeoForge addition
|
||||
}
|
||||
|
||||
public ServerStatus toServerStatus() {
|
||||
return new ServerStatus(this.description, this.players, this.version, this.favicon, this.enforcesSecureChat, this.isModded);
|
||||
}
|
||||
|
||||
public Component description() {
|
||||
return this.description;
|
||||
}
|
||||
|
||||
public void description(final Component description) {
|
||||
Objects.requireNonNull(description, "description");
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public Optional<ServerStatus.Players> players() {
|
||||
return this.players;
|
||||
}
|
||||
|
||||
public void players(final Optional<ServerStatus.Players> players) {
|
||||
Objects.requireNonNull(players, "players");
|
||||
this.players = players;
|
||||
}
|
||||
|
||||
public Optional<ServerStatus.Version> version() {
|
||||
return this.version;
|
||||
}
|
||||
|
||||
public void version(final Optional<ServerStatus.Version> version) {
|
||||
Objects.requireNonNull(version, "version");
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public Optional<ServerStatus.Favicon> favicon() {
|
||||
return this.favicon;
|
||||
}
|
||||
|
||||
public void favicon(final Optional<ServerStatus.Favicon> favicon) {
|
||||
Objects.requireNonNull(favicon, "favicon");
|
||||
this.favicon = favicon;
|
||||
}
|
||||
|
||||
public boolean enforcesSecureChat() {
|
||||
return this.enforcesSecureChat;
|
||||
}
|
||||
|
||||
public void enforcesSecureChat(final boolean enforcesSecureChat) {
|
||||
this.enforcesSecureChat = enforcesSecureChat;
|
||||
}
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
modLoader = "javafml"
|
||||
loaderVersion = "[1,)"
|
||||
license = "MIT"
|
||||
issueTrackerURL = "${github_url}/issues/"
|
||||
showAsResourcePack = false
|
||||
|
||||
[[mods]]
|
||||
modId = "minimotd"
|
||||
version = "${version}"
|
||||
displayName = "MiniMOTD"
|
||||
displayURL = "${github_url}"
|
||||
authors = "jmp"
|
||||
description = "${description}"
|
||||
displayTest = "IGNORE_ALL_VERSION"
|
||||
|
||||
[[dependencies.minimotd]]
|
||||
modId = "neoforge"
|
||||
type = "required"
|
||||
versionRange = "[21.0,)"
|
||||
ordering = "NONE"
|
||||
side = "BOTH"
|
||||
|
||||
[[dependencies.minimotd]]
|
||||
modId = "minecraft"
|
||||
type = "required"
|
||||
versionRange = "[26.3,)"
|
||||
ordering = "NONE"
|
||||
side = "BOTH"
|
||||
|
||||
[[dependencies.minimotd]]
|
||||
modId = "adventure_platform_neoforge"
|
||||
type = "required"
|
||||
versionRange = "*"
|
||||
ordering = "AFTER"
|
||||
side = "BOTH"
|
||||
|
||||
[[mixins]]
|
||||
config = "minimotd-neoforge.mixins.json"
|
||||
@@ -1,17 +0,0 @@
|
||||
{
|
||||
"required": true,
|
||||
"minVersion": "0.8.4",
|
||||
"package": "xyz.jpenilla.minimotd.neoforge.mixin",
|
||||
"compatibilityLevel": "JAVA_21",
|
||||
"mixins": [
|
||||
"ConnectionMixin",
|
||||
"ServerHandshakePacketListenerImplMixin",
|
||||
"ServerStatusFaviconMixin",
|
||||
"ServerStatusPacketListenerImplMixin"
|
||||
],
|
||||
"client": [
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
}
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
import xyz.jpenilla.resourcefactory.paper.PaperPluginYaml.Load
|
||||
|
||||
plugins {
|
||||
id("minimotd.shadow-platform")
|
||||
alias(libs.plugins.run.paper)
|
||||
alias(libs.plugins.resource.factory.bukkit)
|
||||
alias(libs.plugins.resource.factory.paper)
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(projects.minimotdCommon)
|
||||
implementation(libs.bstatsBukkit)
|
||||
compileOnly(libs.paperApi)
|
||||
}
|
||||
|
||||
tasks {
|
||||
runServer {
|
||||
minecraftVersion(minecraftVersion)
|
||||
}
|
||||
shadowJar {
|
||||
configureForNativeAdventurePlatform()
|
||||
commonRelocation("org.bstats")
|
||||
dependencies {
|
||||
exclude(dependency("io.leangen.geantyref:geantyref"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
indra {
|
||||
javaVersions {
|
||||
target(21)
|
||||
}
|
||||
}
|
||||
|
||||
bukkitPluginYaml {
|
||||
name = "MiniMOTD"
|
||||
main = "xyz.jpenilla.minimotd.paper.MiniMOTDStub"
|
||||
foliaSupported = true
|
||||
authors = listOf("jmp")
|
||||
website = Constants.GITHUB_URL
|
||||
apiVersion = "1.13"
|
||||
}
|
||||
|
||||
paperPluginYaml {
|
||||
name = "MiniMOTD"
|
||||
main = "xyz.jpenilla.minimotd.paper.MiniMOTDPaper"
|
||||
foliaSupported = true
|
||||
authors = listOf("jmp")
|
||||
website = Constants.GITHUB_URL
|
||||
apiVersion = "1.21.8"
|
||||
dependencies.server.register("MiniPlaceholders") {
|
||||
required = false
|
||||
load = Load.BEFORE
|
||||
joinClasspath = true
|
||||
}
|
||||
}
|
||||
|
||||
runPaper.folia.registerTask()
|
||||
|
||||
publishMods.modrinth {
|
||||
modLoaders.addAll("paper", "folia")
|
||||
minecraftVersions = paperVersions
|
||||
optional("miniplaceholders")
|
||||
}
|
||||
@@ -1,100 +0,0 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2025 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.paper;
|
||||
|
||||
import io.papermc.paper.command.brigadier.CommandSourceStack;
|
||||
import io.papermc.paper.plugin.lifecycle.event.types.LifecycleEvents;
|
||||
import io.papermc.paper.threadedregions.RegionizedServerInitEvent;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import org.bstats.bukkit.Metrics;
|
||||
import org.bstats.charts.SimplePie;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.util.CachedServerIcon;
|
||||
import org.jspecify.annotations.NonNull;
|
||||
import org.slf4j.Logger;
|
||||
import xyz.jpenilla.minimotd.common.CommandHandler;
|
||||
import xyz.jpenilla.minimotd.common.MiniMOTD;
|
||||
import xyz.jpenilla.minimotd.common.MiniMOTDPlatform;
|
||||
import xyz.jpenilla.minimotd.common.util.BrigadierUtil;
|
||||
import xyz.jpenilla.minimotd.common.util.UpdateChecker;
|
||||
|
||||
public final class MiniMOTDPaper extends JavaPlugin implements MiniMOTDPlatform<CachedServerIcon>, Listener {
|
||||
|
||||
private MiniMOTD<CachedServerIcon> miniMOTD;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
this.miniMOTD = new MiniMOTD<>(this);
|
||||
|
||||
this.getServer().getPluginManager().registerEvents(this, this);
|
||||
this.getServer().getPluginManager().registerEvents(new PingListener(this.miniMOTD), this);
|
||||
|
||||
this.getLifecycleManager().registerEventHandler(LifecycleEvents.COMMANDS, event -> event.registrar().register(
|
||||
this.getPluginMeta(),
|
||||
BrigadierUtil.<CommandSourceStack>buildTree(
|
||||
new CommandHandler(this.miniMOTD),
|
||||
sourceStack -> Objects.requireNonNullElse(sourceStack.getExecutor(), sourceStack.getSender()),
|
||||
sourceStack -> sourceStack.getSender().hasPermission("minimotd.admin")
|
||||
).build(),
|
||||
"MiniMOTD Command",
|
||||
List.of()
|
||||
));
|
||||
|
||||
final Metrics metrics = new Metrics(this, 8132);
|
||||
metrics.addCustomChart(new SimplePie("variant", () -> "paper"));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void updateCheck(final RegionizedServerInitEvent event) {
|
||||
if (!this.miniMOTD.configManager().pluginSettings().updateChecker()) {
|
||||
return;
|
||||
}
|
||||
CompletableFuture.runAsync(() -> new UpdateChecker().checkVersion().forEach(this.getComponentLogger()::info)).whenComplete(($, thr) -> {
|
||||
if (thr != null) {
|
||||
this.getComponentLogger().warn("Exception checking for updates", thr);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull Path dataDirectory() {
|
||||
return this.getDataFolder().toPath();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull Logger logger() {
|
||||
return this.getComponentLogger();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull CachedServerIcon loadIcon(final @NonNull BufferedImage image) throws Exception {
|
||||
return this.getServer().loadServerIcon(image);
|
||||
}
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2025 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.paper;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import xyz.jpenilla.minimotd.common.util.Nag;
|
||||
|
||||
public final class MiniMOTDStub extends JavaPlugin {
|
||||
@Override
|
||||
public void onEnable() {
|
||||
if (lavaChicken() && !Bukkit.getBukkitVersion().contains("1.21.7-")) {
|
||||
// 1.21.8+, non-Paper
|
||||
new Nag.JavaUtilLogging(this.getLogger()).lines(
|
||||
"MiniMOTD does not support Spigot on Minecraft 1.21.8 or newer.",
|
||||
"To continue using MiniMOTD on the latest Minecraft versions,",
|
||||
"switch to Paper (https://papermc.io/software/paper)."
|
||||
).error(true).logBanner();
|
||||
this.getServer().getPluginManager().disablePlugin(this);
|
||||
return;
|
||||
}
|
||||
|
||||
// Pre-Paper-plugins or non-Paper
|
||||
new Nag.JavaUtilLogging(this.getLogger()).lines(
|
||||
"You are using the incorrect MiniMOTD build for your server software.",
|
||||
"This build is for Paper 1.21.8+.",
|
||||
"Builds for Spigot/Paper 1.8.8 through 1.21.7 are available on Modrinth (https://modrinth.com/plugin/minimotd).",
|
||||
"When downloading be sure to check the supported versions/platforms",
|
||||
"field on the versions page, and/or make the correct selections in",
|
||||
"the download menu."
|
||||
).error(true).logBanner();
|
||||
this.getServer().getPluginManager().disablePlugin(this);
|
||||
|
||||
// Sadly I don't think there is any way to display a custom message for servers that support
|
||||
// Paper plugins but are < 1.21.8 (without lying in the plugin yaml)...
|
||||
// Hopefully users will realize they need to try a different build.
|
||||
}
|
||||
|
||||
// Crude 1.21.7+ check
|
||||
private static boolean lavaChicken() {
|
||||
try {
|
||||
final Material mat = Material.MUSIC_DISC_LAVA_CHICKEN;
|
||||
new ItemStack(mat);
|
||||
return true;
|
||||
} catch (final Throwable thr) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2025 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.paper;
|
||||
|
||||
import com.destroystokyo.paper.event.server.PaperServerListPingEvent;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.util.CachedServerIcon;
|
||||
import org.jspecify.annotations.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.MOTDConfig;
|
||||
import xyz.jpenilla.minimotd.common.util.ComponentColorDownsampler;
|
||||
|
||||
public final class PingListener implements Listener {
|
||||
private final MiniMOTD<CachedServerIcon> miniMOTD;
|
||||
|
||||
PingListener(final @NonNull MiniMOTD<CachedServerIcon> miniMOTD) {
|
||||
this.miniMOTD = miniMOTD;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void handlePing(final @NonNull PaperServerListPingEvent event) {
|
||||
final MOTDConfig cfg = this.miniMOTD.configManager().mainConfig();
|
||||
|
||||
final PingResponse<CachedServerIcon> response = this.miniMOTD.createMOTD(cfg, event.getNumPlayers(), event.getMaxPlayers());
|
||||
|
||||
response.playerCount().applyCount(event::setNumPlayers, event::setMaxPlayers);
|
||||
response.motd(motd -> {
|
||||
if (event.getClient().getProtocolVersion() < Constants.MINECRAFT_1_16_PROTOCOL_VERSION) {
|
||||
event.motd(ComponentColorDownsampler.downsampler().downsample(motd));
|
||||
} else {
|
||||
event.motd(motd);
|
||||
}
|
||||
});
|
||||
response.icon(event::setServerIcon);
|
||||
|
||||
if (response.disablePlayerListHover()) {
|
||||
event.getListedPlayers().clear();
|
||||
}
|
||||
if (response.hidePlayerCount()) {
|
||||
event.setHidePlayers(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
+4
-4
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2025 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
|
||||
@@ -25,13 +25,13 @@ package xyz.jpenilla.minimotd.sponge7;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import net.kyori.adventure.text.serializer.spongeapi.SpongeComponentSerializer;
|
||||
import org.jspecify.annotations.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.spongepowered.api.event.EventListener;
|
||||
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.MOTDConfig;
|
||||
import xyz.jpenilla.minimotd.common.config.MiniMOTDConfig;
|
||||
|
||||
final class ClientPingServerEventListener implements EventListener<ClientPingServerEvent> {
|
||||
private final MiniMOTD<Favicon> miniMOTD;
|
||||
@@ -58,7 +58,7 @@ final class ClientPingServerEventListener implements EventListener<ClientPingSer
|
||||
}
|
||||
}
|
||||
|
||||
final MOTDConfig config = this.miniMOTD.configManager().mainConfig();
|
||||
final MiniMOTDConfig 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-2025 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 java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import net.kyori.adventure.platform.spongeapi.SpongeAudiences;
|
||||
import org.bstats.sponge.Metrics;
|
||||
import org.jspecify.annotations.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.slf4j.Logger;
|
||||
import org.spongepowered.api.Game;
|
||||
import org.spongepowered.api.Sponge;
|
||||
|
||||
@@ -34,11 +34,6 @@ sponge {
|
||||
loadOrder(PluginDependency.LoadOrder.AFTER)
|
||||
optional(false)
|
||||
}
|
||||
dependency("miniplaceholders") {
|
||||
loadOrder(PluginDependency.LoadOrder.AFTER)
|
||||
optional(true)
|
||||
version = "3.0.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,19 +50,9 @@ publishMods.modrinth {
|
||||
modLoaders.add("sponge")
|
||||
minecraftVersions.addAll(
|
||||
"1.16.5",
|
||||
"1.17.1",
|
||||
"1.18.2",
|
||||
"1.19.4",
|
||||
"1.20.6",
|
||||
"1.21.1",
|
||||
"1.21.3",
|
||||
"1.21.4",
|
||||
"1.21.5",
|
||||
"1.21.8",
|
||||
"1.21.10",
|
||||
"1.21.11",
|
||||
"26.1.2",
|
||||
"26.2",
|
||||
"26.3",
|
||||
"1.20.4"
|
||||
)
|
||||
optional("miniplaceholders")
|
||||
}
|
||||
+4
-4
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2025 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
|
||||
@@ -25,7 +25,7 @@ package xyz.jpenilla.minimotd.sponge8;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import java.lang.reflect.Method;
|
||||
import org.jspecify.annotations.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.spongepowered.api.MinecraftVersion;
|
||||
import org.spongepowered.api.event.EventListener;
|
||||
import org.spongepowered.api.event.server.ClientPingServerEvent;
|
||||
@@ -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.MOTDConfig;
|
||||
import xyz.jpenilla.minimotd.common.config.MiniMOTDConfig;
|
||||
import xyz.jpenilla.minimotd.common.util.ComponentColorDownsampler;
|
||||
|
||||
final class ClientPingServerEventListener implements EventListener<ClientPingServerEvent> {
|
||||
@@ -72,7 +72,7 @@ final class ClientPingServerEventListener implements EventListener<ClientPingSer
|
||||
}
|
||||
}
|
||||
|
||||
final MOTDConfig config = this.miniMOTD.configManager().mainConfig();
|
||||
final MiniMOTDConfig 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-2025 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,7 @@ import com.google.inject.Injector;
|
||||
import com.google.inject.TypeLiteral;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.nio.file.Path;
|
||||
import org.jspecify.annotations.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.spongepowered.api.Sponge;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
plugins {
|
||||
id("minimotd.shadow-platform")
|
||||
alias(libs.plugins.run.velocity)
|
||||
alias(libs.plugins.resource.factory.velocity)
|
||||
}
|
||||
|
||||
dependencies {
|
||||
@@ -10,11 +9,7 @@ dependencies {
|
||||
compileOnly(libs.velocityApi)
|
||||
}
|
||||
|
||||
indra {
|
||||
javaVersions {
|
||||
target(21)
|
||||
}
|
||||
}
|
||||
java.disableAutoTargetJvm()
|
||||
|
||||
tasks {
|
||||
shadowJar {
|
||||
@@ -25,19 +20,20 @@ tasks {
|
||||
runVelocity {
|
||||
velocityVersion(libs.versions.velocityApi.get())
|
||||
}
|
||||
}
|
||||
|
||||
velocityPluginJson {
|
||||
name = "MiniMOTD"
|
||||
id = "minimotd-velocity"
|
||||
url = Constants.GITHUB_URL
|
||||
authors = listOf("jmp")
|
||||
main = "xyz.jpenilla.minimotd.velocity.MiniMOTDVelocity"
|
||||
dependency("miniplaceholders", true)
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
publishMods.modrinth {
|
||||
modLoaders.add("velocity")
|
||||
minecraftVersions.addAll(minecraftVersion)
|
||||
optional("miniplaceholders")
|
||||
}
|
||||
+31
-16
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2025 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
|
||||
@@ -28,8 +28,12 @@ import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.TypeLiteral;
|
||||
import com.mojang.brigadier.Command;
|
||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import com.velocitypowered.api.command.BrigadierCommand;
|
||||
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.annotation.DataDirectory;
|
||||
@@ -39,15 +43,14 @@ import java.awt.image.BufferedImage;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Set;
|
||||
import org.bstats.velocity.Metrics;
|
||||
import org.jspecify.annotations.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.slf4j.Logger;
|
||||
import xyz.jpenilla.minimotd.common.CommandHandler;
|
||||
import xyz.jpenilla.minimotd.common.MiniMOTD;
|
||||
import xyz.jpenilla.minimotd.common.MiniMOTDPlatform;
|
||||
import xyz.jpenilla.minimotd.common.util.BrigadierUtil;
|
||||
import xyz.jpenilla.minimotd.common.util.UpdateChecker;
|
||||
|
||||
public final class MiniMOTDVelocity implements MiniMOTDPlatform<Favicon> {
|
||||
public final class MiniMOTDPlugin implements MiniMOTDPlatform<Favicon> {
|
||||
private static final Set<Class<?>> LISTENER_CLASSES = ImmutableSet.of(
|
||||
PingListener.class
|
||||
);
|
||||
@@ -61,7 +64,7 @@ public final class MiniMOTDVelocity implements MiniMOTDPlatform<Favicon> {
|
||||
private final Injector injector;
|
||||
|
||||
@Inject
|
||||
public MiniMOTDVelocity(
|
||||
public MiniMOTDPlugin(
|
||||
final @NonNull ProxyServer server,
|
||||
final @NonNull Logger logger,
|
||||
final @NonNull CommandManager commandManager,
|
||||
@@ -80,7 +83,7 @@ public final class MiniMOTDVelocity implements MiniMOTDPlatform<Favicon> {
|
||||
@Override
|
||||
protected void configure() {
|
||||
this.bind(new TypeLiteral<MiniMOTD<Favicon>>() {
|
||||
}).toInstance(MiniMOTDVelocity.this.miniMOTD);
|
||||
}).toInstance(MiniMOTDPlugin.this.miniMOTD);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -101,16 +104,28 @@ public final class MiniMOTDVelocity implements MiniMOTDPlatform<Favicon> {
|
||||
}
|
||||
|
||||
private void registerCommand() {
|
||||
this.commandManager.register(
|
||||
this.commandManager.metaBuilder("minimotd").plugin(this).build(),
|
||||
new BrigadierCommand(
|
||||
BrigadierUtil.buildTree(
|
||||
new CommandHandler(this.miniMOTD),
|
||||
source -> source,
|
||||
source -> source.hasPermission("minimotd.admin")
|
||||
)
|
||||
)
|
||||
);
|
||||
final class WrappingExecutor implements Command<CommandSource> {
|
||||
private final CommandHandler.Executor handler;
|
||||
|
||||
WrappingExecutor(final CommandHandler.@NonNull Executor handler) {
|
||||
this.handler = handler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int run(final @NonNull CommandContext<CommandSource> context) {
|
||||
this.handler.execute(context.getSource());
|
||||
return Command.SINGLE_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
final CommandHandler handler = new CommandHandler(this.miniMOTD);
|
||||
this.commandManager.register(this.commandManager.metaBuilder("minimotd").build(), new BrigadierCommand(
|
||||
LiteralArgumentBuilder.<CommandSource>literal("minimotd")
|
||||
.requires(source -> source.hasPermission("minimotd.admin"))
|
||||
.then(LiteralArgumentBuilder.<CommandSource>literal("help").executes(new WrappingExecutor(handler::help)))
|
||||
.then(LiteralArgumentBuilder.<CommandSource>literal("about").executes(new WrappingExecutor(handler::about)))
|
||||
.then(LiteralArgumentBuilder.<CommandSource>literal("reload").executes(new WrappingExecutor(handler::reload)))
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of MiniMOTD, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) 2020-2025 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,17 +31,15 @@ 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.jspecify.annotations.NullMarked;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
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.MOTDConfig;
|
||||
import xyz.jpenilla.minimotd.common.config.MiniMOTDConfig;
|
||||
|
||||
@NullMarked
|
||||
@DefaultQualifier(NonNull.class)
|
||||
public final class PingListener {
|
||||
private final MiniMOTD<Favicon> miniMOTD;
|
||||
private final ProxyServer proxy;
|
||||
@@ -58,7 +56,7 @@ public final class PingListener {
|
||||
}
|
||||
|
||||
private void handle(final ProxyPingEvent event) {
|
||||
final MOTDConfig config = this.miniMOTD.configManager().resolveConfig(event.getConnection().getVirtualHost().orElse(null));
|
||||
final MiniMOTDConfig config = this.miniMOTD.configManager().resolveConfig(event.getConnection().getVirtualHost().orElse(null));
|
||||
final ServerPing.Builder pong = event.getPing().asBuilder();
|
||||
|
||||
final List<String> targetServers = config.targetServers();
|
||||
@@ -66,18 +64,12 @@ public final class PingListener {
|
||||
if (targetServers.isEmpty()) {
|
||||
playersCount = pong.getOnlinePlayers();
|
||||
} else {
|
||||
final Set<ServerPing.SamplePlayer> players = new HashSet<>();
|
||||
for (final String serverName : targetServers) {
|
||||
final @Nullable RegisteredServer server = this.proxy.getServer(serverName).orElse(null);
|
||||
if (server != null) {
|
||||
playersCount += server.getPlayersConnected().size();
|
||||
players.addAll(server.getPlayersConnected().stream()
|
||||
.map(p -> new ServerPing.SamplePlayer(p.getGameProfile().getName(), p.getUniqueId()))
|
||||
.collect(Collectors.toList()));
|
||||
}
|
||||
}
|
||||
pong.clearSamplePlayers();
|
||||
pong.samplePlayers(players.toArray(new ServerPing.SamplePlayer[0]));
|
||||
}
|
||||
|
||||
final PingResponse<Favicon> response = this.miniMOTD.createMOTD(config, playersCount, pong.getMaximumPlayers());
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"id": "minimotd-velocity",
|
||||
"name": "MiniMOTD",
|
||||
"version": "$version",
|
||||
"description": "$description",
|
||||
"url": "$url",
|
||||
"authors": [
|
||||
"jmp"
|
||||
],
|
||||
"dependencies": [],
|
||||
"main": "xyz.jpenilla.minimotd.velocity.MiniMOTDPlugin"
|
||||
}
|
||||
+6
-24
@@ -1,10 +1,10 @@
|
||||
{
|
||||
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
||||
"extends": [
|
||||
"config:recommended"
|
||||
"config:base"
|
||||
],
|
||||
"ignoreDeps": [
|
||||
"xyz.jpenilla.quiet-fabric-loom",
|
||||
"quiet-fabric-loom",
|
||||
"com.mojang:minecraft",
|
||||
"com.google.code.gson:gson"
|
||||
],
|
||||
@@ -14,37 +14,19 @@
|
||||
"packageRules": [
|
||||
{
|
||||
"description": "Correct Fabric API version handling",
|
||||
"matchPackageNames": [
|
||||
"net.fabricmc.fabric-api:fabric-api",
|
||||
"net.fabricmc.fabric-api:fabric-api-deprecated"
|
||||
],
|
||||
"matchPackageNames": ["net.fabricmc.fabric-api:fabric-api", "net.fabricmc.fabric-api:fabric-api-deprecated"],
|
||||
"versioning": "regex:^(?<major>\\d+)(\\.(?<minor>\\d+))?(\\.(?<patch>\\d+))?(?:\\+(?<compatibility>.*))?$"
|
||||
},
|
||||
{
|
||||
"description": "Correct NeoForge version handling",
|
||||
"matchPackageNames": [
|
||||
"net.neoforged:neoforge"
|
||||
],
|
||||
"versioning": "regex:^(?<compatibility>(?:\\d+\\.){3})(?<minor>\\d+)(?:-beta)?$"
|
||||
},
|
||||
{
|
||||
"matchManagers": [
|
||||
"github-actions",
|
||||
"gradle-wrapper"
|
||||
],
|
||||
"matchManagers": ["github-actions", "gradle-wrapper"],
|
||||
"groupName": "gradle and github actions"
|
||||
},
|
||||
{
|
||||
"matchDepTypes": [
|
||||
"plugin"
|
||||
],
|
||||
"matchDepTypes": ["plugin"],
|
||||
"groupName": "gradle and github actions"
|
||||
},
|
||||
{
|
||||
"matchFileNames": [
|
||||
"build-logic/*",
|
||||
"buildSrc/*"
|
||||
],
|
||||
"matchPaths": ["build-logic/*", "buildSrc/*"],
|
||||
"groupName": "gradle and github actions"
|
||||
}
|
||||
],
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 105 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 118 KiB |
+20
-8
@@ -1,21 +1,32 @@
|
||||
enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")
|
||||
|
||||
dependencyResolutionManagement {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven("https://s01.oss.sonatype.org/content/repositories/snapshots/") {
|
||||
mavenContent { snapshotsOnly() }
|
||||
}
|
||||
maven("https://repo.papermc.io/repository/maven-public/")
|
||||
maven("https://repo.spongepowered.org/repository/maven-public/")
|
||||
maven("https://repo.jpenilla.xyz/snapshots/") {
|
||||
mavenContent { snapshotsOnly() }
|
||||
}
|
||||
}
|
||||
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
|
||||
}
|
||||
|
||||
pluginManagement {
|
||||
repositories {
|
||||
gradlePluginPortal()
|
||||
maven("https://maven.fabricmc.net/")
|
||||
maven("https://maven.neoforged.net/releases/") {
|
||||
mavenContent { releasesOnly() }
|
||||
}
|
||||
maven("https://repo.jpenilla.xyz/snapshots/")
|
||||
}
|
||||
includeBuild("gradle/build-logic")
|
||||
}
|
||||
|
||||
plugins {
|
||||
id("net.neoforged.moddev.repositories") version "2.0.147" apply false
|
||||
id("xyz.jpenilla.quiet-fabric-loom") version "1.18-SNAPSHOT" apply false
|
||||
id("org.gradle.toolchains.foojay-resolver-convention") version "1.0.0"
|
||||
id("quiet-fabric-loom") version "1.5-SNAPSHOT"
|
||||
id("org.gradle.toolchains.foojay-resolver-convention") version "0.8.0"
|
||||
}
|
||||
|
||||
rootProject.name = "MiniMOTD"
|
||||
@@ -26,16 +37,17 @@ fun setup(name: String, dir: String) {
|
||||
}
|
||||
|
||||
fun platform(name: String) = setup("minimotd-$name", "platform/$name")
|
||||
fun dist(name: String) = setup("minimotd-$name", "dist/$name")
|
||||
|
||||
setup("minimotd-common", "common")
|
||||
|
||||
sequenceOf(
|
||||
"paper",
|
||||
"bukkit",
|
||||
"sponge8",
|
||||
"sponge7",
|
||||
"bungeecord",
|
||||
"velocity",
|
||||
"fabric",
|
||||
"neoforge",
|
||||
).forEach(::platform)
|
||||
|
||||
dist("bukkit-bungeecord")
|
||||
Reference in new issue
Block a user