mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-12-22 09:08:01 +01:00
Discord: Add start time placeholder for start message (#5686)
Co-authored-by: Josh Roy <10731363+JRoy@users.noreply.github.com>
This commit is contained in:
parent
38e42f9f90
commit
1af1565059
@ -9,10 +9,12 @@ import net.dv8tion.jda.api.OnlineStatus;
|
|||||||
import net.dv8tion.jda.api.entities.Activity;
|
import net.dv8tion.jda.api.entities.Activity;
|
||||||
import net.dv8tion.jda.api.entities.Role;
|
import net.dv8tion.jda.api.entities.Role;
|
||||||
import net.essentialsx.api.v2.ChatType;
|
import net.essentialsx.api.v2.ChatType;
|
||||||
|
import net.essentialsx.discord.util.MessageUtil;
|
||||||
import org.apache.logging.log4j.Level;
|
import org.apache.logging.log4j.Level;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.lang.management.ManagementFactory;
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@ -427,7 +429,12 @@ public class DiscordSettings implements IConf {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getStartMessage() {
|
public String getStartMessage() {
|
||||||
return config.getString("messages.server-start", ":white_check_mark: The server has started!");
|
final MessageFormat format = generateMessageFormat(getFormatString("server-start"), ":white_check_mark: The server has started in {starttimeseconds} seconds!", false,
|
||||||
|
"starttimeseconds");
|
||||||
|
return MessageUtil.formatMessage(format,
|
||||||
|
// measures time since the JVM started and converts it to seconds
|
||||||
|
String.format("%.2f", (float)Math.abs(ManagementFactory.getRuntimeMXBean().getStartTime() - System.currentTimeMillis()) / 1000)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getStopMessage() {
|
public String getStopMessage() {
|
||||||
|
@ -423,7 +423,8 @@ messages:
|
|||||||
# ... PlaceholderAPI placeholders are also supported here too!
|
# ... PlaceholderAPI placeholders are also supported here too!
|
||||||
action: ":person_biking: {displayname} *{action}*"
|
action: ":person_biking: {displayname} *{action}*"
|
||||||
# This is the message sent to Discord when the server starts.
|
# This is the message sent to Discord when the server starts.
|
||||||
server-start: ":white_check_mark: The server has started!"
|
# - {starttimeseconds}: The amount of seconds it took to start the server (measured from JVM start time).
|
||||||
|
server-start: ":white_check_mark: The server has started in {starttimeseconds} seconds!"
|
||||||
# This is the message sent to Discord when the server stops.
|
# This is the message sent to Discord when the server stops.
|
||||||
server-stop: ":octagonal_sign: The server has stopped!"
|
server-stop: ":octagonal_sign: The server has stopped!"
|
||||||
# This is the message sent to Discord when a player is kicked from the server.
|
# This is the message sent to Discord when a player is kicked from the server.
|
||||||
|
Loading…
Reference in New Issue
Block a user