mirror of
https://github.com/jpenilla/MiniMOTD.git
synced 2026-11-08 18:25:19 -05:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6ffce0713f |
No files matched your search
@@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>xyz.jpenilla</groupId>
|
||||
<artifactId>MiniMOTD</artifactId>
|
||||
<version>1.1.1</version>
|
||||
<version>1.1.2</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>MiniMOTD</name>
|
||||
@@ -122,6 +122,11 @@
|
||||
<artifactId>adventure-platform-bungeecord</artifactId>
|
||||
<version>4.0.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.kyori</groupId>
|
||||
<artifactId>adventure-text-serializer-bungeecord</artifactId>
|
||||
<version>4.0.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.kyori</groupId>
|
||||
<artifactId>adventure-platform-bukkit</artifactId>
|
||||
@@ -147,7 +152,7 @@
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.10</version>
|
||||
<version>1.18.12</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package xyz.jpenilla.minimotd.bungee;
|
||||
|
||||
import net.kyori.adventure.platform.bungeecord.BungeeAudiences;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import net.kyori.adventure.text.serializer.bungeecord.BungeeCordComponentSerializer;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.plugin.Command;
|
||||
@@ -11,12 +11,10 @@ import java.util.List;
|
||||
|
||||
public class BungeeCommand extends Command {
|
||||
private final MiniMOTD miniMOTD;
|
||||
private final BungeeAudiences audience;
|
||||
|
||||
public BungeeCommand(MiniMOTD miniMOTD) {
|
||||
super("minimotd");
|
||||
super("minimotdbungee");
|
||||
this.miniMOTD = miniMOTD;
|
||||
this.audience = BungeeAudiences.create(miniMOTD);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -85,7 +83,7 @@ public class BungeeCommand extends Command {
|
||||
} else {
|
||||
finalMessage = MiniMessage.get().stripTokens(message);
|
||||
}
|
||||
audience.audience(sender).sendMessage(MiniMessage.get().parse(finalMessage));
|
||||
sender.sendMessage(BungeeCordComponentSerializer.get().serialize(MiniMessage.get().parse(finalMessage)));
|
||||
}
|
||||
|
||||
private void send(CommandSender sender, List<String> messages) {
|
||||
|
||||
@@ -5,10 +5,18 @@ import lombok.Setter;
|
||||
import lombok.experimental.FieldNameConstants;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
import java.util.Random;
|
||||
|
||||
@FieldNameConstants
|
||||
public abstract class MiniMOTDConfig {
|
||||
public final String MOTDS = "motd." + Fields.motds;
|
||||
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;
|
||||
public final String MAX_PLAYERS = Fields.maxPlayers + "." + Fields.maxPlayers;
|
||||
public final String X_VALUE = Fields.maxPlayers + "." + Fields.xValue;
|
||||
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 @Setter private boolean motdEnabled;
|
||||
@Getter @Setter private boolean maxPlayersEnabled;
|
||||
@@ -18,22 +26,13 @@ public abstract class MiniMOTDConfig {
|
||||
@Getter @Setter private int maxPlayers;
|
||||
@Getter @Setter private String fakePlayers;
|
||||
|
||||
public final String MOTDS = "motd." + Fields.motds;
|
||||
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;
|
||||
public final String MAX_PLAYERS = Fields.maxPlayers + "." + Fields.maxPlayers;
|
||||
public final String X_VALUE = Fields.maxPlayers + "." + Fields.xValue;
|
||||
public final String FAKE_PLAYERS_ENABLED = "bungeeOnly." + Fields.fakePlayersEnabled;
|
||||
public final String FAKE_PLAYERS = "bungeeOnly." + Fields.fakePlayers;
|
||||
|
||||
public abstract void reload();
|
||||
|
||||
public String getMOTD(int onlinePlayers, int maxPlayers) {
|
||||
if (motds.size() == 1) {
|
||||
return motds.get(0);
|
||||
} else {
|
||||
return motds.get(ThreadLocalRandom.current().nextInt(motds.size()))
|
||||
return motds.get(new Random().nextInt(motds.size()))
|
||||
.replace("{onlinePlayers}", String.valueOf(onlinePlayers))
|
||||
.replace("{maxPlayers}", String.valueOf(maxPlayers));
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user