mirror of
https://github.com/plexusorg/Plex.git
synced 2025-01-08 16:37:38 +00:00
- Add samples to config for motd
This commit is contained in:
parent
ae61503df4
commit
e446002567
@ -1,15 +1,19 @@
|
|||||||
package dev.plex.listener.impl;
|
package dev.plex.listener.impl;
|
||||||
|
|
||||||
|
import com.destroystokyo.paper.event.server.PaperServerListPingEvent;
|
||||||
import dev.plex.listener.PlexListener;
|
import dev.plex.listener.PlexListener;
|
||||||
import dev.plex.util.PlexUtils;
|
import dev.plex.util.PlexUtils;
|
||||||
|
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.event.EventHandler;
|
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
|
public class ServerListener extends PlexListener
|
||||||
{
|
{
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onServerPing(ServerListPingEvent event)
|
public void onServerPing(PaperServerListPingEvent event)
|
||||||
{
|
{
|
||||||
String baseMotd = plugin.config.getString("server.motd");
|
String baseMotd = plugin.config.getString("server.motd");
|
||||||
baseMotd = baseMotd.replace("\\n", "\n");
|
baseMotd = baseMotd.replace("\\n", "\n");
|
||||||
@ -22,11 +26,18 @@ public class ServerListener extends PlexListener
|
|||||||
{
|
{
|
||||||
motd.append(PlexUtils.randomChatColor()).append(word).append(" ");
|
motd.append(PlexUtils.randomChatColor()).append(word).append(" ");
|
||||||
}
|
}
|
||||||
event.setMotd(motd.toString().trim());
|
event.motd(LegacyComponentSerializer.legacyAmpersand().deserialize(motd.toString().trim()));
|
||||||
}
|
} else
|
||||||
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()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,8 @@ server:
|
|||||||
name: "Plexus"
|
name: "Plexus"
|
||||||
motd: "%servername% - Minecraft %mcversion%"
|
motd: "%servername% - Minecraft %mcversion%"
|
||||||
colorize_motd: true
|
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.
|
# Ban message is customized in the messages.yml file. The URL to appeal at is below.
|
||||||
banning:
|
banning:
|
||||||
|
Loading…
Reference in New Issue
Block a user