- Add samples to config for motd

This commit is contained in:
Taah 2022-02-21 17:26:50 -08:00
parent ae61503df4
commit e446002567
2 changed files with 19 additions and 6 deletions

View File

@ -1,15 +1,19 @@
package dev.plex.listener.impl;
import com.destroystokyo.paper.event.server.PaperServerListPingEvent;
import dev.plex.listener.PlexListener;
import dev.plex.util.PlexUtils;
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.server.ServerListPingEvent;
import java.util.List;
import java.util.stream.Collectors;
public class ServerListener extends PlexListener
{
@EventHandler
public void onServerPing(ServerListPingEvent event)
public void onServerPing(PaperServerListPingEvent event)
{
String baseMotd = plugin.config.getString("server.motd");
baseMotd = baseMotd.replace("\\n", "\n");
@ -22,11 +26,18 @@ public class ServerListener extends PlexListener
{
motd.append(PlexUtils.randomChatColor()).append(word).append(" ");
}
event.setMotd(motd.toString().trim());
}
else
event.motd(LegacyComponentSerializer.legacyAmpersand().deserialize(motd.toString().trim()));
} else
{
event.setMotd(baseMotd.trim());
event.motd(LegacyComponentSerializer.legacyAmpersand().deserialize(baseMotd.trim()));
}
if (plugin.config.contains("server.sample"))
{
List<String> samples = plugin.config.getStringList("server.sample");
if (!samples.isEmpty())
{
event.getPlayerSample().addAll(samples.stream().map(string -> string.replace("&", "§")).map(Bukkit::createProfile).collect(Collectors.toList()));
}
}
}
}

View File

@ -5,6 +5,8 @@ server:
name: "Plexus"
motd: "%servername% - Minecraft %mcversion%"
colorize_motd: true
sample:
- "&cForums: https://forum.plex.us.org"
# Ban message is customized in the messages.yml file. The URL to appeal at is below.
banning: