Add {PREFIX} and {SUFFIX} to custom join/quit messages (#4169)

This commit is contained in:
l1ttleO 2021-05-21 10:28:22 -07:00 committed by GitHub
parent e9169b890d
commit 887772a428
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 3 deletions

View File

@ -6,6 +6,7 @@ import com.earth2me.essentials.textreader.KeywordReplacer;
import com.earth2me.essentials.textreader.TextInput; import com.earth2me.essentials.textreader.TextInput;
import com.earth2me.essentials.textreader.TextPager; import com.earth2me.essentials.textreader.TextPager;
import com.earth2me.essentials.utils.DateUtil; import com.earth2me.essentials.utils.DateUtil;
import com.earth2me.essentials.utils.FormatUtil;
import com.earth2me.essentials.utils.LocationUtil; import com.earth2me.essentials.utils.LocationUtil;
import com.earth2me.essentials.utils.MaterialUtil; import com.earth2me.essentials.utils.MaterialUtil;
import com.earth2me.essentials.utils.VersionUtil; import com.earth2me.essentials.utils.VersionUtil;
@ -223,7 +224,9 @@ public class EssentialsPlayerListener implements Listener {
.replace("{PLAYER}", player.getDisplayName()) .replace("{PLAYER}", player.getDisplayName())
.replace("{USERNAME}", player.getName()) .replace("{USERNAME}", player.getName())
.replace("{ONLINE}", NumberFormat.getInstance().format(ess.getOnlinePlayers().size())) .replace("{ONLINE}", NumberFormat.getInstance().format(ess.getOnlinePlayers().size()))
.replace("{UPTIME}", DateUtil.formatDateDiff(ManagementFactory.getRuntimeMXBean().getStartTime())); .replace("{UPTIME}", DateUtil.formatDateDiff(ManagementFactory.getRuntimeMXBean().getStartTime()))
.replace("{PREFIX}", FormatUtil.replaceFormat(ess.getPermissionsHandler().getPrefix(player)))
.replace("{SUFFIX}", FormatUtil.replaceFormat(ess.getPermissionsHandler().getSuffix(player)));
event.setQuitMessage(msg.isEmpty() ? null : msg); event.setQuitMessage(msg.isEmpty() ? null : msg);
} }
@ -336,7 +339,9 @@ public class EssentialsPlayerListener implements Listener {
.replace("{PLAYER}", player.getDisplayName()).replace("{USERNAME}", player.getName()) .replace("{PLAYER}", player.getDisplayName()).replace("{USERNAME}", player.getName())
.replace("{UNIQUE}", NumberFormat.getInstance().format(ess.getUserMap().getUniqueUsers())) .replace("{UNIQUE}", NumberFormat.getInstance().format(ess.getUserMap().getUniqueUsers()))
.replace("{ONLINE}", NumberFormat.getInstance().format(ess.getOnlinePlayers().size())) .replace("{ONLINE}", NumberFormat.getInstance().format(ess.getOnlinePlayers().size()))
.replace("{UPTIME}", DateUtil.formatDateDiff(ManagementFactory.getRuntimeMXBean().getStartTime())); .replace("{UPTIME}", DateUtil.formatDateDiff(ManagementFactory.getRuntimeMXBean().getStartTime()))
.replace("{PREFIX}", FormatUtil.replaceFormat(ess.getPermissionsHandler().getPrefix(player)))
.replace("{SUFFIX}", FormatUtil.replaceFormat(ess.getPermissionsHandler().getSuffix(player)));
if (!msg.isEmpty()) { if (!msg.isEmpty()) {
ess.getServer().broadcastMessage(msg); ess.getServer().broadcastMessage(msg);
} }

View File

@ -506,7 +506,7 @@ allow-silent-join-quit: false
# You can set custom join and quit messages here. Set this to "none" to use the default Minecraft message, # You can set custom join and quit messages here. Set this to "none" to use the default Minecraft message,
# or set this to "" to hide the message entirely. # or set this to "" to hide the message entirely.
# You may use color codes, {USERNAME} for the player's name, and {PLAYER} for the player's displayname. # You may use color codes, {USERNAME} for the player's name, {PLAYER} for the player's displayname, {PREFIX} for the player's prefix, and {SUFFIX} for the player's suffix.
custom-join-message: "none" custom-join-message: "none"
custom-quit-message: "none" custom-quit-message: "none"