Compare commits

...
7 Commits
Author SHA1 Message Date
jmp b9c3f505eb minor clean up 2020-07-13 12:17:58 -07:00
Jason bcc15def17 Merge pull request #5 from wkonowrocki/master
Adds a second list of MOTDs to be used for pre-1.16 clients. Currently bungee only.
2020-07-13 11:37:07 -07:00
Jason ef1b13d08f GitHub Actions 2020-07-13 11:34:15 -07:00
wkonowrocki 7edccb6ea4 added different motd for older versions 2020-07-13 20:15:43 +02:00
Jason c87f3c4321 Merge pull request #2 from jmanpenilla/dependabot/maven/org.apache.maven.plugins-maven-shade-plugin-3.2.4
Bump maven-shade-plugin from 3.2.2 to 3.2.4
2020-07-10 15:18:39 -07:00
dependabot[bot] 4aff316770 Bump maven-shade-plugin from 3.2.2 to 3.2.4
Bumps [maven-shade-plugin](https://github.com/apache/maven-shade-plugin) from 3.2.2 to 3.2.4.
- [Release notes](https://github.com/apache/maven-shade-plugin/releases)
- [Commits](https://github.com/apache/maven-shade-plugin/compare/maven-shade-plugin-3.2.2...maven-shade-plugin-3.2.4)

Signed-off-by: dependabot[bot] <support@github.com>
2020-07-10 22:17:19 +00:00
Jason 702a6a7d66 Create dependabot.yml 2020-07-10 15:16:36 -07:00
8 changed files with 78 additions and 14 deletions

No files matched your search

+6
View File
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: "maven"
directory: "/"
schedule:
interval: "daily"
+27
View File
@@ -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
+2 -2
View File
@@ -6,7 +6,7 @@
<groupId>xyz.jpenilla</groupId>
<artifactId>MiniMOTD</artifactId>
<version>1.1.2</version>
<version>1.1.3</version>
<packaging>jar</packaging>
<name>MiniMOTD</name>
@@ -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>
@@ -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));
+8
View File
@@ -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