mirror of
https://github.com/jpenilla/MiniMOTD.git
synced 2026-11-08 02:12:32 -05:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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.4</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,9 @@ 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));
|
||||
getMotdsLegacy().clear();
|
||||
getMotdsLegacy().addAll(config.getStringList(MOTDS_LEGACY));
|
||||
setMotdEnabled(config.getBoolean(MOTD_ENABLED));
|
||||
setMaxPlayersEnabled(config.getBoolean(MAX_PLAYERS_ENABLED));
|
||||
setJustXMoreEnabled(config.getBoolean(JUST_X_MORE_ENABLED));
|
||||
|
||||
@@ -51,8 +51,14 @@ 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];
|
||||
final String temp;
|
||||
if (e.getConnection().getVersion() >= 735 || cfg.getMotdsLegacy().size() == 0) {
|
||||
temp = cfg.getMOTD(onlinePlayers, maxPlayers);
|
||||
} else {
|
||||
temp = cfg.getLegacyMOTD(onlinePlayers, maxPlayers);
|
||||
}
|
||||
final Component motd = MiniMessage.get().parse(temp);
|
||||
final BaseComponent component = ComponentSerializer.parse(GsonComponentSerializer.builder().build().serialize(motd))[0];
|
||||
response.setDescriptionComponent(component);
|
||||
//response.setDescriptionComponent(BungeeCordComponentSerializer.get().serialize(motd)[0]);
|
||||
}
|
||||
|
||||
@@ -5,11 +5,13 @@ import lombok.Setter;
|
||||
import lombok.experimental.FieldNameConstants;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
@FieldNameConstants
|
||||
public abstract class MiniMOTDConfig {
|
||||
public final String MOTDS = "motd." + Fields.motds;
|
||||
public final String MOTDS_LEGACY = "motd." + Fields.motdsLegacy;
|
||||
public final String MOTD_ENABLED = "motd." + Fields.motdEnabled;
|
||||
public final String MAX_PLAYERS_ENABLED = Fields.maxPlayers + "." + Fields.maxPlayersEnabled;
|
||||
public final String JUST_X_MORE_ENABLED = Fields.maxPlayers + "." + Fields.justXMoreEnabled;
|
||||
@@ -18,6 +20,7 @@ public abstract class MiniMOTDConfig {
|
||||
public final String FAKE_PLAYERS_ENABLED = "bungeeOnly." + Fields.fakePlayersEnabled;
|
||||
public final String FAKE_PLAYERS = "bungeeOnly." + Fields.fakePlayers;
|
||||
@Getter private final ArrayList<String> motds = new ArrayList<>();
|
||||
@Getter private final ArrayList<String> motdsLegacy = new ArrayList<>();
|
||||
@Getter @Setter private boolean motdEnabled;
|
||||
@Getter @Setter private boolean maxPlayersEnabled;
|
||||
@Getter @Setter private boolean justXMoreEnabled;
|
||||
@@ -28,14 +31,25 @@ public abstract class MiniMOTDConfig {
|
||||
|
||||
public abstract void reload();
|
||||
|
||||
public String getMOTD(int onlinePlayers, int maxPlayers) {
|
||||
if (motds.size() == 1) {
|
||||
return motds.get(0);
|
||||
private String getMOTD(int onlinePlayers, int maxPlayers, List<String> strings) {
|
||||
String motd;
|
||||
if (strings.size() == 1) {
|
||||
motd = strings.get(0);
|
||||
} else {
|
||||
return motds.get(new Random().nextInt(motds.size()))
|
||||
.replace("{onlinePlayers}", String.valueOf(onlinePlayers))
|
||||
.replace("{maxPlayers}", String.valueOf(maxPlayers));
|
||||
motd = strings.get(new Random().nextInt(strings.size()));
|
||||
}
|
||||
return motd
|
||||
.replace("{onlinePlayers}", String.valueOf(onlinePlayers))
|
||||
.replace("{maxPlayers}", String.valueOf(maxPlayers))
|
||||
.replace("{br}", "\n");
|
||||
}
|
||||
|
||||
public String getMOTD(int onlinePlayers, int maxPlayers) {
|
||||
return getMOTD(onlinePlayers, maxPlayers, motds);
|
||||
}
|
||||
|
||||
public String getLegacyMOTD(int onlinePlayers, int maxPlayers) {
|
||||
return getMOTD(onlinePlayers, maxPlayers, motdsLegacy);
|
||||
}
|
||||
|
||||
public int getAdjustedMaxPlayers(int onlinePlayers, int actualMaxPlayers) {
|
||||
|
||||
@@ -26,7 +26,10 @@ public class SpigotConfig extends MiniMOTDConfig {
|
||||
} else {
|
||||
temp = motd;
|
||||
}
|
||||
getMotds().add(miniMessageToLegacy(temp.replace("{br}", "\n")));
|
||||
getMotds().add(miniMessageToLegacy(temp));
|
||||
}
|
||||
for (String motd : config.getStringList(MOTDS_LEGACY)) {
|
||||
getMotdsLegacy().add(miniMessageToLegacy(motd));
|
||||
}
|
||||
setMotdEnabled(config.getBoolean(MOTD_ENABLED));
|
||||
setMaxPlayersEnabled(config.getBoolean(MAX_PLAYERS_ENABLED));
|
||||
|
||||
@@ -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!
|
||||
@@ -9,6 +9,14 @@ motd:
|
||||
- "<bold><gradient:black:white>----====[</gradient> <gradient:green:blue>UltraCraft <gradient:red:yellow></bold><italic>Official</gradient></italic><bold> <gradient:white:black>]=====----</gradient></bold>{br}<bold> <gradient:#EEFF4A:#F7FFAE>Custom <italic>Survival</italic></gradient> <color:#0092FF>Discord</bold><gray>:</gray> <gradient:#5FDAFF:#B8A6FF><italic>Ab3d5f"
|
||||
- "<rainbow>|||||||||||||||||||||||||||||||||||||||||||||||||||||||||</rainbow>{br}<white>Hello <blue>{onlinePlayers} <gray>/</gray> {maxPlayers}</blue> Players Online"
|
||||
|
||||
# Only works on bungee. Will be added for Spigot in a future update
|
||||
# These motds will be shown to pre-1.16 clients
|
||||
# If this list is empty, the normal motd list above will be used.
|
||||
motdsLegacy:
|
||||
- "<red>This server requires version 1.16+</red>{br}<yellow>For you to see our cool RGB messages!"
|
||||
- "<green>Sample motd displayed on version 1.15.2 and below"
|
||||
- "<red>This function only works on bungeecord based platforms for now!"
|
||||
|
||||
maxPlayers:
|
||||
# Do you want to enable this feature?
|
||||
maxPlayersEnabled: true
|
||||
|
||||
@@ -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