mirror of
https://github.com/jpenilla/MiniMOTD.git
synced 2026-11-08 02:12:32 -05:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
574eca67e2 | ||
|
|
6556e92e5e | ||
|
|
91a6973288 | ||
|
|
afd3de54ed | ||
|
|
b9c3f505eb | ||
|
|
bcc15def17 | ||
|
|
ef1b13d08f | ||
|
|
7edccb6ea4 | ||
|
|
c87f3c4321 | ||
|
|
4aff316770 | ||
|
|
702a6a7d66 |
No files matched your search
@@ -0,0 +1,6 @@
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: "maven"
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "daily"
|
||||
@@ -0,0 +1,27 @@
|
||||
name: MiniMOTD
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ master ]
|
||||
pull_request:
|
||||
branches: [ master ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- run: sed "s/{BUILDID}/$GITHUB_RUN_NUMBER/g" pom.xml > _pom.xml; rm pom.xml; mv _pom.xml pom.xml
|
||||
- name: Set up JDK 1.8
|
||||
uses: actions/setup-java@v1
|
||||
with:
|
||||
java-version: 1.8
|
||||
- name: Build with Maven
|
||||
run: mvn clean package
|
||||
- run: mkdir staging && cp target/MiniMOTD*.jar staging
|
||||
- uses: actions/upload-artifact@v1
|
||||
with:
|
||||
name: Package
|
||||
path: staging
|
||||
@@ -6,12 +6,12 @@
|
||||
|
||||
<groupId>xyz.jpenilla</groupId>
|
||||
<artifactId>MiniMOTD</artifactId>
|
||||
<version>1.1.2</version>
|
||||
<version>1.1.5</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>MiniMOTD</name>
|
||||
|
||||
<description>Set the server MOTD using MiniMessage!</description>
|
||||
<description>Set the server list MOTD using MiniMessage!</description>
|
||||
<properties>
|
||||
<java.version>1.8</java.version>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
@@ -32,7 +32,7 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.2.2</version>
|
||||
<version>3.2.4</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
@@ -114,7 +114,7 @@
|
||||
<dependency>
|
||||
<groupId>net.md-5</groupId>
|
||||
<artifactId>bungeecord-api</artifactId>
|
||||
<version>1.16-R0.1</version>
|
||||
<version>1.16-R0.2</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
||||
@@ -22,9 +22,7 @@ public class BungeeConfig extends MiniMOTDConfig {
|
||||
final Configuration config = loadFromDisk();
|
||||
|
||||
getMotds().clear();
|
||||
for (String motd : config.getStringList(MOTDS)) {
|
||||
getMotds().add(motd.replace("{br}", "\n"));
|
||||
}
|
||||
getMotds().addAll(config.getStringList(MOTDS));
|
||||
setMotdEnabled(config.getBoolean(MOTD_ENABLED));
|
||||
setMaxPlayersEnabled(config.getBoolean(MAX_PLAYERS_ENABLED));
|
||||
setJustXMoreEnabled(config.getBoolean(JUST_X_MORE_ENABLED));
|
||||
|
||||
@@ -3,8 +3,8 @@ package xyz.jpenilla.minimotd.bungee;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import net.md_5.bungee.api.ServerPing;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import net.md_5.bungee.api.event.ProxyPingEvent;
|
||||
import net.md_5.bungee.api.plugin.Listener;
|
||||
import net.md_5.bungee.chat.ComponentSerializer;
|
||||
@@ -15,6 +15,9 @@ import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
public class PingListener implements Listener {
|
||||
private final BungeeConfig cfg;
|
||||
private final MiniMessage miniMessage = MiniMessage.get();
|
||||
private final LegacyComponentSerializer legacySerializer = LegacyComponentSerializer.builder().build();
|
||||
private final GsonComponentSerializer gsonSerializer = GsonComponentSerializer.builder().build();
|
||||
|
||||
public PingListener(MiniMOTD miniMOTD) {
|
||||
this.cfg = miniMOTD.getCfg();
|
||||
@@ -51,9 +54,12 @@ public class PingListener implements Listener {
|
||||
players.setMax(maxPlayers);
|
||||
|
||||
if (cfg.isMotdEnabled()) {
|
||||
Component motd = MiniMessage.get().parse(cfg.getMOTD(onlinePlayers, maxPlayers));
|
||||
BaseComponent component = ComponentSerializer.parse(GsonComponentSerializer.builder().build().serialize(motd))[0];
|
||||
response.setDescriptionComponent(component);
|
||||
Component motd = miniMessage.parse(cfg.getMOTD(onlinePlayers, maxPlayers));
|
||||
if (e.getConnection().getVersion() < 735) {
|
||||
motd = legacySerializer.deserialize(legacySerializer.serialize(motd));
|
||||
}
|
||||
|
||||
response.setDescriptionComponent(ComponentSerializer.parse(gsonSerializer.serialize(motd))[0]);
|
||||
//response.setDescriptionComponent(BungeeCordComponentSerializer.get().serialize(motd)[0]);
|
||||
}
|
||||
|
||||
|
||||
@@ -29,13 +29,16 @@ public abstract class MiniMOTDConfig {
|
||||
public abstract void reload();
|
||||
|
||||
public String getMOTD(int onlinePlayers, int maxPlayers) {
|
||||
String motd;
|
||||
if (motds.size() == 1) {
|
||||
return motds.get(0);
|
||||
motd = motds.get(0);
|
||||
} else {
|
||||
return motds.get(new Random().nextInt(motds.size()))
|
||||
.replace("{onlinePlayers}", String.valueOf(onlinePlayers))
|
||||
.replace("{maxPlayers}", String.valueOf(maxPlayers));
|
||||
motd = motds.get(new Random().nextInt(motds.size()));
|
||||
}
|
||||
return motd
|
||||
.replace("{onlinePlayers}", String.valueOf(onlinePlayers))
|
||||
.replace("{maxPlayers}", String.valueOf(maxPlayers))
|
||||
.replace("{br}", "\n");
|
||||
}
|
||||
|
||||
public int getAdjustedMaxPlayers(int onlinePlayers, int actualMaxPlayers) {
|
||||
|
||||
@@ -6,9 +6,9 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public final class MiniMOTD extends JavaPlugin {
|
||||
@Getter private static MiniMOTD instance;
|
||||
@Getter private SpigotConfig cfg;
|
||||
@Getter private PrismaHook prisma;
|
||||
@Getter private static MiniMOTD instance;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
|
||||
@@ -7,6 +7,8 @@ import xyz.jpenilla.minimotd.common.MiniMOTDConfig;
|
||||
|
||||
public class SpigotConfig extends MiniMOTDConfig {
|
||||
private final MiniMOTD miniMOTD;
|
||||
private final LegacyComponentSerializer serializer = LegacyComponentSerializer.builder().hexColors().useUnusualXRepeatedCharacterHexFormat().build();
|
||||
private final MiniMessage miniMessage = MiniMessage.get();
|
||||
|
||||
public SpigotConfig(MiniMOTD miniMOTD) {
|
||||
this.miniMOTD = miniMOTD;
|
||||
@@ -26,7 +28,7 @@ public class SpigotConfig extends MiniMOTDConfig {
|
||||
} else {
|
||||
temp = motd;
|
||||
}
|
||||
getMotds().add(miniMessageToLegacy(temp.replace("{br}", "\n")));
|
||||
getMotds().add(serializer.serialize(miniMessage.parse(temp)));
|
||||
}
|
||||
setMotdEnabled(config.getBoolean(MOTD_ENABLED));
|
||||
setMaxPlayersEnabled(config.getBoolean(MAX_PLAYERS_ENABLED));
|
||||
@@ -34,8 +36,4 @@ public class SpigotConfig extends MiniMOTDConfig {
|
||||
setMaxPlayers(config.getInt(MAX_PLAYERS));
|
||||
setXValue(config.getInt(X_VALUE));
|
||||
}
|
||||
|
||||
private String miniMessageToLegacy(String message) {
|
||||
return LegacyComponentSerializer.builder().hexColors().useUnusualXRepeatedCharacterHexFormat().build().serialize(MiniMessage.get().parse(message));
|
||||
}
|
||||
}
|
||||
@@ -2,4 +2,4 @@ name: MiniMOTD
|
||||
version: ${project.version}
|
||||
main: xyz.jpenilla.minimotd.bungee.MiniMOTD
|
||||
author: jmp
|
||||
description: Set the MOTD using MiniMessage!
|
||||
description: Set the server list MOTD using MiniMessage!
|
||||
@@ -1,10 +1,9 @@
|
||||
name: MiniMOTD
|
||||
version: ${project.version}
|
||||
main: xyz.jpenilla.minimotd.spigot.MiniMOTD
|
||||
load: STARTUP
|
||||
softdepend: [Prisma]
|
||||
authors: [jmp]
|
||||
description: Set the server MOTD using MiniMessage!
|
||||
description: Set the server list MOTD using MiniMessage!
|
||||
website: https://www.spigotmc.org/resources/minimotd.81254/
|
||||
commands:
|
||||
minimotd:
|
||||
|
||||
Reference in new issue
Block a user