Only update displayname on world change, not every teleport.

This commit is contained in:
KHobbits 2012-03-02 19:05:30 +00:00
parent a45c19a08b
commit 3e3c7f0d54
3 changed files with 38 additions and 27 deletions

View File

@ -233,18 +233,13 @@ public class EssentialsPlayerListener implements Listener
return;
}
final User user = ess.getUser(event.getPlayer());
//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())
{
final User user = ess.getUser(event.getPlayer());
user.setLastLocation();
}
if (ess.getSettings().changeDisplayName())
{
user.setDisplayNick();
}
updateCompass(user);
}
@EventHandler(priority = EventPriority.HIGH)
@ -307,9 +302,15 @@ public class EssentialsPlayerListener implements Listener
@EventHandler(priority = EventPriority.MONITOR)
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()))
{
User user = ess.getUser(event.getPlayer());
if (user.isGodModeEnabledRaw())
{
user.sendMessage(_("noGodWorldWarning"));

View File

@ -249,7 +249,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
return teleportRequestHere;
}
public String getNick(boolean addprefixsuffix)
public String getNick(final boolean addprefixsuffix)
{
final StringBuilder nickname = new StringBuilder();
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);
}
if (isOp())
{
try
{
nickname.insert(0, ess.getSettings().getOperatorColor().toString());
nickname.append("§f");
}
catch (Exception e)
{
}
}
if (addprefixsuffix && ess.getSettings().addPrefixSuffix())
{
if (isOp())
{
try
{
nickname.insert(0, ess.getSettings().getOperatorColor().toString());
}
catch (Exception e)
{
}
}
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);
}
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);
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();
}
@Override
public Teleport getTeleport()
{
return teleport;
@ -385,7 +386,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
catch (Throwable ex)
{
}
}
}
super.setMoney(value);
Trade.log("Update", "Set", "API", getName(), new Trade(value, ess), null, null, null, ess);
}

View File

@ -44,7 +44,7 @@ public abstract class UserData extends PlayerExtension implements IConf
savedInventory = _getSavedInventory();
teleportEnabled = getTeleportEnabled();
ignoredPlayers = getIgnoredPlayers();
godmode = getGodModeEnabled();
godmode = _getGodModeEnabled();
muted = getMuted();
muteTimeout = _getMuteTimeout();
jailed = getJailed();
@ -58,6 +58,7 @@ public abstract class UserData extends PlayerExtension implements IConf
isNPC = _isNPC();
arePowerToolsEnabled = _arePowerToolsEnabled();
kitTimestamps = _getKitTimestamps();
nickname = _getNickname();
}
private double money;
@ -189,13 +190,21 @@ public abstract class UserData extends PlayerExtension implements IConf
return false;
}
public String getNickname()
private String nickname;
public String _getNickname()
{
return config.getString("nickname");
}
public String getNickname()
{
return nickname;
}
public void setNickname(String nick)
{
nickname = nick;
config.setProperty("nickname", nick);
config.save();
}
@ -515,7 +524,7 @@ public abstract class UserData extends PlayerExtension implements IConf
}
private boolean godmode;
private boolean getGodModeEnabled()
private boolean _getGodModeEnabled()
{
return config.getBoolean("godmode", false);
}
@ -817,12 +826,12 @@ public abstract class UserData extends PlayerExtension implements IConf
private Map<String, Object> _getKitTimestamps()
{
if (config.isConfigurationSection("timestamps.kits"))
{
return config.getConfigurationSection("timestamps.kits").getValues(false);
}
return new HashMap<String, Object>();
return new HashMap<String, Object>();
}
public Long getKitTimestamp(final String name)