mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-08-05 12:02:53 +00:00
Add config option for new username join messages (#4290)
Co-authored-by: Josh Roy <10731363+JRoy@users.noreply.github.com>
This commit is contained in:
parent
5e178943a0
commit
ff58d8e443
4 changed files with 54 additions and 3 deletions
|
@ -305,11 +305,15 @@ public class EssentialsPlayerListener implements Listener {
|
||||||
|
|
||||||
user.startTransaction();
|
user.startTransaction();
|
||||||
|
|
||||||
|
final String lastAccountName = user.getLastAccountName(); // For comparison
|
||||||
user.setLastAccountName(user.getBase().getName());
|
user.setLastAccountName(user.getBase().getName());
|
||||||
user.setLastLogin(currentTime);
|
user.setLastLogin(currentTime);
|
||||||
user.setDisplayNick();
|
user.setDisplayNick();
|
||||||
updateCompass(user);
|
updateCompass(user);
|
||||||
|
|
||||||
|
// Check for new username. If they don't want the message, let's just say it's false.
|
||||||
|
final boolean newUsername = ess.getSettings().isCustomNewUsernameMessage() && lastAccountName != null && !lastAccountName.equals(user.getBase().getName());
|
||||||
|
|
||||||
if (!ess.getVanishedPlayersNew().isEmpty() && !user.isAuthorized("essentials.vanish.see")) {
|
if (!ess.getVanishedPlayersNew().isEmpty() && !user.isAuthorized("essentials.vanish.see")) {
|
||||||
for (final String p : ess.getVanishedPlayersNew()) {
|
for (final String p : ess.getVanishedPlayersNew()) {
|
||||||
final Player toVanish = ess.getServer().getPlayerExact(p);
|
final Player toVanish = ess.getServer().getPlayerExact(p);
|
||||||
|
@ -335,13 +339,14 @@ public class EssentialsPlayerListener implements Listener {
|
||||||
} else if (message == null || hideJoinQuitMessages()) {
|
} else if (message == null || hideJoinQuitMessages()) {
|
||||||
effectiveMessage = null;
|
effectiveMessage = null;
|
||||||
} else if (ess.getSettings().isCustomJoinMessage()) {
|
} else if (ess.getSettings().isCustomJoinMessage()) {
|
||||||
final String msg = ess.getSettings().getCustomJoinMessage()
|
final String msg = (newUsername ? ess.getSettings().getCustomNewUsernameMessage() : ess.getSettings().getCustomJoinMessage())
|
||||||
.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("{PREFIX}", FormatUtil.replaceFormat(ess.getPermissionsHandler().getPrefix(player)))
|
||||||
.replace("{SUFFIX}", FormatUtil.replaceFormat(ess.getPermissionsHandler().getSuffix(player)));
|
.replace("{SUFFIX}", FormatUtil.replaceFormat(ess.getPermissionsHandler().getSuffix(player)))
|
||||||
|
.replace("{OLDUSERNAME}", lastAccountName);
|
||||||
if (!msg.isEmpty()) {
|
if (!msg.isEmpty()) {
|
||||||
ess.getServer().broadcastMessage(msg);
|
ess.getServer().broadcastMessage(msg);
|
||||||
}
|
}
|
||||||
|
|
|
@ -275,6 +275,10 @@ public interface ISettings extends IConf {
|
||||||
|
|
||||||
String getCustomQuitMessage();
|
String getCustomQuitMessage();
|
||||||
|
|
||||||
|
String getCustomNewUsernameMessage();
|
||||||
|
|
||||||
|
boolean isCustomNewUsernameMessage();
|
||||||
|
|
||||||
boolean isCustomServerFullMessage();
|
boolean isCustomServerFullMessage();
|
||||||
|
|
||||||
boolean isNotifyNoNewMail();
|
boolean isNotifyNoNewMail();
|
||||||
|
|
|
@ -116,6 +116,8 @@ public class Settings implements net.ess3.api.ISettings {
|
||||||
private boolean isCustomJoinMessage;
|
private boolean isCustomJoinMessage;
|
||||||
private String customQuitMessage;
|
private String customQuitMessage;
|
||||||
private boolean isCustomQuitMessage;
|
private boolean isCustomQuitMessage;
|
||||||
|
private String customNewUsernameMessage;
|
||||||
|
private boolean isCustomNewUsernameMessage;
|
||||||
private List<String> spawnOnJoinGroups;
|
private List<String> spawnOnJoinGroups;
|
||||||
private Map<Pattern, Long> commandCooldowns;
|
private Map<Pattern, Long> commandCooldowns;
|
||||||
private boolean npcsInBalanceRanking = false;
|
private boolean npcsInBalanceRanking = false;
|
||||||
|
@ -717,6 +719,8 @@ public class Settings implements net.ess3.api.ISettings {
|
||||||
isCustomJoinMessage = !customJoinMessage.equals("none");
|
isCustomJoinMessage = !customJoinMessage.equals("none");
|
||||||
customQuitMessage = _getCustomQuitMessage();
|
customQuitMessage = _getCustomQuitMessage();
|
||||||
isCustomQuitMessage = !customQuitMessage.equals("none");
|
isCustomQuitMessage = !customQuitMessage.equals("none");
|
||||||
|
customNewUsernameMessage = _getCustomNewUsernameMessage();
|
||||||
|
isCustomNewUsernameMessage = !customNewUsernameMessage.equals("none");
|
||||||
muteCommands = _getMuteCommands();
|
muteCommands = _getMuteCommands();
|
||||||
spawnOnJoinGroups = _getSpawnOnJoinGroups();
|
spawnOnJoinGroups = _getSpawnOnJoinGroups();
|
||||||
commandCooldowns = _getCommandCooldowns();
|
commandCooldowns = _getCommandCooldowns();
|
||||||
|
@ -1372,6 +1376,20 @@ public class Settings implements net.ess3.api.ISettings {
|
||||||
return isCustomQuitMessage;
|
return isCustomQuitMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String _getCustomNewUsernameMessage() {
|
||||||
|
return FormatUtil.replaceFormat(config.getString("custom-new-username-message", "none"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getCustomNewUsernameMessage() {
|
||||||
|
return customNewUsernameMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isCustomNewUsernameMessage() {
|
||||||
|
return isCustomNewUsernameMessage;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isCustomServerFullMessage() {
|
public boolean isCustomServerFullMessage() {
|
||||||
return config.getBoolean("use-custom-server-full-message", true);
|
return config.getBoolean("use-custom-server-full-message", true);
|
||||||
|
|
|
@ -520,10 +520,34 @@ 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, {PLAYER} for the player's displayname, {PREFIX} for the player's prefix, and {SUFFIX} for the player's suffix.
|
|
||||||
|
# Available placeholders:
|
||||||
|
# {PLAYER} - The player's displayname.
|
||||||
|
# {USERNAME} - The player's username.
|
||||||
|
# {PREFIX} - The player's prefix.
|
||||||
|
# {SUFFIX} - The player's suffix.
|
||||||
|
# {ONLINE} - The number of players online.
|
||||||
|
# {UNIQUE} - The number of unique players to join the server.
|
||||||
|
# {UPTIME} - The amount of time the server has been online.
|
||||||
custom-join-message: "none"
|
custom-join-message: "none"
|
||||||
custom-quit-message: "none"
|
custom-quit-message: "none"
|
||||||
|
|
||||||
|
# You can set a custom join message for users who join with a new username here.
|
||||||
|
# This message will only be used if a user has joined before and have since changed their username.
|
||||||
|
# This will be displayed INSTEAD OF custom-join-message, so if you intend to keep them similar, make sure they match.
|
||||||
|
# Set this to "none" to use the the "custom-join-message" above for every join.
|
||||||
|
|
||||||
|
# Available placeholders:
|
||||||
|
# {PLAYER} - The player's displayname.
|
||||||
|
# {USERNAME} - The player's username.
|
||||||
|
# {OLDUSERNAME} - The player's old username.
|
||||||
|
# {PREFIX} - The player's prefix.
|
||||||
|
# {SUFFIX} - The player's suffix.
|
||||||
|
# {ONLINE} - The number of players online.
|
||||||
|
# {UNIQUE} - The number of unique players to join the server.
|
||||||
|
# {UPTIME} - The amount of time the server has been online.
|
||||||
|
custom-new-username-message: "none"
|
||||||
|
|
||||||
# Should Essentials override the vanilla "Server Full" message with its own from the language file?
|
# Should Essentials override the vanilla "Server Full" message with its own from the language file?
|
||||||
# Set to false to keep the vanilla message.
|
# Set to false to keep the vanilla message.
|
||||||
use-custom-server-full-message: true
|
use-custom-server-full-message: true
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue