mirror of
https://github.com/EssentialsX/Essentials.git
synced 2025-01-21 23:51:42 +01:00
Moved user.setDisplayName() from EssentialsChat to Essentials
Added new config: change-displayname (default to true) It allows users to disable the setDisplayName, if they have other plugins that modify the display name Updated user.getNick() to use StringBuilder
This commit is contained in:
parent
ae7275c7ad
commit
d2db6348d9
@ -60,6 +60,10 @@ public class EssentialsPlayerListener extends PlayerListener
|
||||
{
|
||||
}
|
||||
}
|
||||
if (ess.getSettings().changeDisplayName())
|
||||
{
|
||||
user.setDisplayName(user.getNick());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -85,6 +89,10 @@ public class EssentialsPlayerListener extends PlayerListener
|
||||
user.setAfk(false);
|
||||
ess.broadcastMessage(user.getName(), Util.format("userIsNotAway", user.getDisplayName()));
|
||||
}
|
||||
if (ess.getSettings().changeDisplayName())
|
||||
{
|
||||
user.setDisplayName(user.getNick());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -266,9 +274,13 @@ public class EssentialsPlayerListener extends PlayerListener
|
||||
return;
|
||||
}
|
||||
|
||||
if (ess.getSettings().changeDisplayName())
|
||||
{
|
||||
user.setDisplayName(user.getNick());
|
||||
}
|
||||
user.setAfk(false);
|
||||
if (user.isAuthorized("essentials.sleepingignored")) {
|
||||
if (user.isAuthorized("essentials.sleepingignored"))
|
||||
{
|
||||
user.setSleepingIgnored(true);
|
||||
}
|
||||
|
||||
@ -344,6 +356,10 @@ public class EssentialsPlayerListener extends PlayerListener
|
||||
return;
|
||||
}
|
||||
User user = ess.getUser(event.getPlayer());
|
||||
if (ess.getSettings().changeDisplayName())
|
||||
{
|
||||
user.setDisplayName(user.getNick());
|
||||
}
|
||||
if (!user.isJailed() || user.getJail() == null || user.getJail().isEmpty())
|
||||
{
|
||||
return;
|
||||
@ -637,7 +653,10 @@ public class EssentialsPlayerListener extends PlayerListener
|
||||
@Override
|
||||
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event)
|
||||
{
|
||||
if (event.isCancelled()) return;
|
||||
if (event.isCancelled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
User user = ess.getUser(event.getPlayer());
|
||||
String cmd = event.getMessage().toLowerCase().split(" ")[0].replace("/", "").toLowerCase();
|
||||
if (("msg".equals(cmd) || "r".equals(cmd) || "mail".equals(cmd)))
|
||||
|
@ -396,4 +396,9 @@ public class Settings implements IConf
|
||||
return config.getBoolean("remove-god-on-disconnect", false);
|
||||
}
|
||||
|
||||
boolean changeDisplayName()
|
||||
{
|
||||
return config.getBoolean("change-displayname", true);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -223,26 +223,39 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
|
||||
public String getNick()
|
||||
{
|
||||
String nickname = getNickname();
|
||||
if (ess.getSettings().isCommandDisabled("nick") || nickname == null || nickname.isEmpty() || nickname.equals(getName()))
|
||||
final StringBuilder nickname = new StringBuilder();
|
||||
final String nick = getNickname();
|
||||
if (ess.getSettings().isCommandDisabled("nick") || nick == null || nick.isEmpty() || nick.equals(getName()))
|
||||
{
|
||||
nickname = getName();
|
||||
nickname.append(getName());
|
||||
}
|
||||
else
|
||||
{
|
||||
nickname = ess.getSettings().getNicknamePrefix() + nickname;
|
||||
nickname.append(ess.getSettings().getNicknamePrefix()).append(nick);
|
||||
}
|
||||
if (isOp())
|
||||
{
|
||||
try
|
||||
{
|
||||
nickname = ess.getSettings().getOperatorColor().toString() + nickname + "§f";
|
||||
nickname.insert(0, ess.getSettings().getOperatorColor().toString());
|
||||
nickname.append("§f");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
}
|
||||
return nickname;
|
||||
|
||||
final String prefix = ess.getPermissionsHandler().getPrefix(this).replace('&', '§').replace("{WORLDNAME}", this.getWorld().getName());
|
||||
final String suffix = ess.getPermissionsHandler().getSuffix(this).replace('&', '§').replace("{WORLDNAME}", this.getWorld().getName());
|
||||
|
||||
nickname.insert(0, prefix);
|
||||
nickname.append(suffix);
|
||||
if (suffix.length() > 1 && suffix.substring(suffix.length() - 2, suffix.length() - 1).equals("§"))
|
||||
{
|
||||
nickname.append("§f");
|
||||
}
|
||||
|
||||
return nickname.toString();
|
||||
}
|
||||
|
||||
public Teleport getTeleport()
|
||||
|
@ -34,6 +34,9 @@ ops-name-color: 'c'
|
||||
# The character(s) to prefix all nicknames, so that you know they are not true usernames.
|
||||
nickname-prefix: '~'
|
||||
|
||||
# Disable this if you have any other plugin, that modifies the displayname of a user.
|
||||
change-displayname: true
|
||||
|
||||
# The delay, in seconds, required between /home, /tp, etc.
|
||||
teleport-cooldown: 0
|
||||
|
||||
|
@ -35,15 +35,6 @@ public class EssentialsChatPlayerListener extends PlayerListener
|
||||
public void onPlayerJoin(final PlayerJoinEvent event)
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
updateDisplayName(user);
|
||||
}
|
||||
|
||||
private void updateDisplayName(final User user)
|
||||
{
|
||||
final String prefix = ess.getPermissionsHandler().getPrefix(user).replace('&', '§').replace("{WORLDNAME}", user.getWorld().getName());
|
||||
final String suffix = ess.getPermissionsHandler().getSuffix(user).replace('&', '§').replace("{WORLDNAME}", user.getWorld().getName());
|
||||
|
||||
user.setDisplayName(prefix + user.getNick() + suffix + (suffix.length() > 1 && suffix.substring(suffix.length() - 2, suffix.length() - 1).equals("§") ? "" : "§f"));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -58,7 +49,6 @@ public class EssentialsChatPlayerListener extends PlayerListener
|
||||
return;
|
||||
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
updateDisplayName(user);
|
||||
|
||||
if (user.isAuthorized("essentials.chat.color"))
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user