mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-12-24 01:57:58 +01:00
Only update displayname on world change, not every teleport.
This commit is contained in:
parent
a45c19a08b
commit
3e3c7f0d54
@ -233,18 +233,13 @@ public class EssentialsPlayerListener implements Listener
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final User user = ess.getUser(event.getPlayer());
|
|
||||||
//There is TeleportCause.COMMMAND but plugins have to actively pass the cause in on their teleports.
|
//There is TeleportCause.COMMMAND but plugins have to actively pass the cause in on their teleports.
|
||||||
if ((event.getCause() == TeleportCause.PLUGIN || event.getCause() == TeleportCause.COMMAND) && ess.getSettings().registerBackInListener())
|
if ((event.getCause() == TeleportCause.PLUGIN || event.getCause() == TeleportCause.COMMAND) && ess.getSettings().registerBackInListener())
|
||||||
{
|
{
|
||||||
|
final User user = ess.getUser(event.getPlayer());
|
||||||
user.setLastLocation();
|
user.setLastLocation();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ess.getSettings().changeDisplayName())
|
|
||||||
{
|
|
||||||
user.setDisplayNick();
|
|
||||||
}
|
|
||||||
updateCompass(user);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
@ -307,9 +302,15 @@ public class EssentialsPlayerListener implements Listener
|
|||||||
@EventHandler(priority = EventPriority.MONITOR)
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void onPlayerChangedWorld(final PlayerChangedWorldEvent event)
|
public void onPlayerChangedWorld(final PlayerChangedWorldEvent event)
|
||||||
{
|
{
|
||||||
|
final User user = ess.getUser(event.getPlayer());
|
||||||
|
if (ess.getSettings().changeDisplayName())
|
||||||
|
{
|
||||||
|
user.setDisplayNick();
|
||||||
|
}
|
||||||
|
updateCompass(user);
|
||||||
|
|
||||||
if (ess.getSettings().getNoGodWorlds().contains(event.getPlayer().getLocation().getWorld().getName()))
|
if (ess.getSettings().getNoGodWorlds().contains(event.getPlayer().getLocation().getWorld().getName()))
|
||||||
{
|
{
|
||||||
User user = ess.getUser(event.getPlayer());
|
|
||||||
if (user.isGodModeEnabledRaw())
|
if (user.isGodModeEnabledRaw())
|
||||||
{
|
{
|
||||||
user.sendMessage(_("noGodWorldWarning"));
|
user.sendMessage(_("noGodWorldWarning"));
|
||||||
|
@ -249,7 +249,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
|||||||
return teleportRequestHere;
|
return teleportRequestHere;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getNick(boolean addprefixsuffix)
|
public String getNick(final boolean addprefixsuffix)
|
||||||
{
|
{
|
||||||
final StringBuilder nickname = new StringBuilder();
|
final StringBuilder nickname = new StringBuilder();
|
||||||
final String nick = getNickname();
|
final String nick = getNickname();
|
||||||
@ -261,28 +261,28 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
|||||||
{
|
{
|
||||||
nickname.append(ess.getSettings().getNicknamePrefix()).append(nick);
|
nickname.append(ess.getSettings().getNicknamePrefix()).append(nick);
|
||||||
}
|
}
|
||||||
if (isOp())
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
nickname.insert(0, ess.getSettings().getOperatorColor().toString());
|
|
||||||
nickname.append("§f");
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (addprefixsuffix && ess.getSettings().addPrefixSuffix())
|
if (addprefixsuffix && ess.getSettings().addPrefixSuffix())
|
||||||
{
|
{
|
||||||
|
if (isOp())
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
nickname.insert(0, ess.getSettings().getOperatorColor().toString());
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!ess.getSettings().disablePrefix())
|
if (!ess.getSettings().disablePrefix())
|
||||||
{
|
{
|
||||||
final String prefix = ess.getPermissionsHandler().getPrefix(base).replace('&', '§').replace("{WORLDNAME}", this.getWorld().getName());
|
final String prefix = ess.getPermissionsHandler().getPrefix(base).replace('&', '§');
|
||||||
nickname.insert(0, prefix);
|
nickname.insert(0, prefix);
|
||||||
}
|
}
|
||||||
if (!ess.getSettings().disableSuffix())
|
if (!ess.getSettings().disableSuffix())
|
||||||
{
|
{
|
||||||
final String suffix = ess.getPermissionsHandler().getSuffix(base).replace('&', '§').replace("{WORLDNAME}", this.getWorld().getName());
|
final String suffix = ess.getPermissionsHandler().getSuffix(base).replace('&', '§');
|
||||||
nickname.append(suffix);
|
nickname.append(suffix);
|
||||||
if (suffix.length() < 2 || !suffix.substring(suffix.length() - 2, suffix.length() - 1).equals("§"))
|
if (suffix.length() < 2 || !suffix.substring(suffix.length() - 2, suffix.length() - 1).equals("§"))
|
||||||
{
|
{
|
||||||
@ -330,6 +330,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
|||||||
return super.getDisplayName() == null ? super.getName() : super.getDisplayName();
|
return super.getDisplayName() == null ? super.getName() : super.getDisplayName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Teleport getTeleport()
|
public Teleport getTeleport()
|
||||||
{
|
{
|
||||||
return teleport;
|
return teleport;
|
||||||
@ -385,7 +386,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
|||||||
catch (Throwable ex)
|
catch (Throwable ex)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
super.setMoney(value);
|
super.setMoney(value);
|
||||||
Trade.log("Update", "Set", "API", getName(), new Trade(value, ess), null, null, null, ess);
|
Trade.log("Update", "Set", "API", getName(), new Trade(value, ess), null, null, null, ess);
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ public abstract class UserData extends PlayerExtension implements IConf
|
|||||||
savedInventory = _getSavedInventory();
|
savedInventory = _getSavedInventory();
|
||||||
teleportEnabled = getTeleportEnabled();
|
teleportEnabled = getTeleportEnabled();
|
||||||
ignoredPlayers = getIgnoredPlayers();
|
ignoredPlayers = getIgnoredPlayers();
|
||||||
godmode = getGodModeEnabled();
|
godmode = _getGodModeEnabled();
|
||||||
muted = getMuted();
|
muted = getMuted();
|
||||||
muteTimeout = _getMuteTimeout();
|
muteTimeout = _getMuteTimeout();
|
||||||
jailed = getJailed();
|
jailed = getJailed();
|
||||||
@ -58,6 +58,7 @@ public abstract class UserData extends PlayerExtension implements IConf
|
|||||||
isNPC = _isNPC();
|
isNPC = _isNPC();
|
||||||
arePowerToolsEnabled = _arePowerToolsEnabled();
|
arePowerToolsEnabled = _arePowerToolsEnabled();
|
||||||
kitTimestamps = _getKitTimestamps();
|
kitTimestamps = _getKitTimestamps();
|
||||||
|
nickname = _getNickname();
|
||||||
}
|
}
|
||||||
private double money;
|
private double money;
|
||||||
|
|
||||||
@ -189,13 +190,21 @@ public abstract class UserData extends PlayerExtension implements IConf
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getNickname()
|
private String nickname;
|
||||||
|
|
||||||
|
public String _getNickname()
|
||||||
{
|
{
|
||||||
return config.getString("nickname");
|
return config.getString("nickname");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getNickname()
|
||||||
|
{
|
||||||
|
return nickname;
|
||||||
|
}
|
||||||
|
|
||||||
public void setNickname(String nick)
|
public void setNickname(String nick)
|
||||||
{
|
{
|
||||||
|
nickname = nick;
|
||||||
config.setProperty("nickname", nick);
|
config.setProperty("nickname", nick);
|
||||||
config.save();
|
config.save();
|
||||||
}
|
}
|
||||||
@ -515,7 +524,7 @@ public abstract class UserData extends PlayerExtension implements IConf
|
|||||||
}
|
}
|
||||||
private boolean godmode;
|
private boolean godmode;
|
||||||
|
|
||||||
private boolean getGodModeEnabled()
|
private boolean _getGodModeEnabled()
|
||||||
{
|
{
|
||||||
return config.getBoolean("godmode", false);
|
return config.getBoolean("godmode", false);
|
||||||
}
|
}
|
||||||
@ -817,12 +826,12 @@ public abstract class UserData extends PlayerExtension implements IConf
|
|||||||
|
|
||||||
private Map<String, Object> _getKitTimestamps()
|
private Map<String, Object> _getKitTimestamps()
|
||||||
{
|
{
|
||||||
|
|
||||||
if (config.isConfigurationSection("timestamps.kits"))
|
if (config.isConfigurationSection("timestamps.kits"))
|
||||||
{
|
{
|
||||||
return config.getConfigurationSection("timestamps.kits").getValues(false);
|
return config.getConfigurationSection("timestamps.kits").getValues(false);
|
||||||
}
|
}
|
||||||
return new HashMap<String, Object>();
|
return new HashMap<String, Object>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getKitTimestamp(final String name)
|
public Long getKitTimestamp(final String name)
|
||||||
|
Loading…
Reference in New Issue
Block a user