DisplayName should not be set. Only gotten. Possibly from a watcher perspective.
This commit is contained in:
parent
951367c586
commit
944aaf6853
@ -3,5 +3,5 @@ package com.massivecraft.massivecore.mixin;
|
||||
public interface DisplayNameMixin
|
||||
{
|
||||
public String getDisplayName(Object senderObject);
|
||||
public void setDisplayName(Object senderObject, String displayName);
|
||||
public String getDisplayName(Object senderObject, Object watcherObject);
|
||||
}
|
||||
|
@ -2,5 +2,14 @@ package com.massivecraft.massivecore.mixin;
|
||||
|
||||
public abstract class DisplayNameMixinAbstract implements DisplayNameMixin
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public String getDisplayName(Object senderObject)
|
||||
{
|
||||
return this.getDisplayName(senderObject, null);
|
||||
}
|
||||
|
||||
}
|
@ -1,8 +1,5 @@
|
||||
package com.massivecraft.massivecore.mixin;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@ -19,24 +16,18 @@ public class DisplayNameMixinDefault extends DisplayNameMixinAbstract
|
||||
private static DisplayNameMixinDefault i = new DisplayNameMixinDefault();
|
||||
public static DisplayNameMixinDefault get() { return i; }
|
||||
|
||||
// -------------------------------------------- //
|
||||
// FIELDS
|
||||
// -------------------------------------------- //
|
||||
|
||||
protected Map<String, String> idToDisplayName = new TreeMap<String, String>(String.CASE_INSENSITIVE_ORDER);
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public String getDisplayName(Object senderObject)
|
||||
public String getDisplayName(Object senderObject, Object watcherObject)
|
||||
{
|
||||
String senderId = IdUtil.getId(senderObject);
|
||||
if (senderId == null) return null;
|
||||
|
||||
// Our Map
|
||||
String ret = this.idToDisplayName.get(senderId);
|
||||
// Ret
|
||||
String ret = null;
|
||||
|
||||
// Bukkit
|
||||
if (ret == null)
|
||||
@ -63,30 +54,10 @@ public class DisplayNameMixinDefault extends DisplayNameMixinAbstract
|
||||
// Ensure Colored
|
||||
if (ChatColor.stripColor(ret).equals(ret))
|
||||
{
|
||||
ret = DEFAULT_COLOR.toString()+ret;
|
||||
ret = DEFAULT_COLOR.toString() + ret;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDisplayName(Object senderObject, String displayName)
|
||||
{
|
||||
String senderId = IdUtil.getId(senderObject);
|
||||
if (senderId == null) return;
|
||||
|
||||
if (displayName == null)
|
||||
{
|
||||
this.idToDisplayName.remove(senderId);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.idToDisplayName.put(senderId, displayName);
|
||||
}
|
||||
|
||||
Player player = IdUtil.getPlayer(senderObject);
|
||||
if (player == null) return;
|
||||
player.setDisplayName(this.getDisplayName(senderObject));
|
||||
}
|
||||
|
||||
}
|
@ -124,9 +124,9 @@ public class Mixin
|
||||
return getDisplayNameMixin().getDisplayName(senderObject);
|
||||
}
|
||||
|
||||
public static void setDisplayName(Object senderObject, String displayName)
|
||||
public static String getDisplayName(Object senderObject, Object watcherObject)
|
||||
{
|
||||
getDisplayNameMixin().setDisplayName(senderObject, displayName);
|
||||
return getDisplayNameMixin().getDisplayName(senderObject, watcherObject);
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
|
@ -100,9 +100,9 @@ public abstract class SenderEntity<E extends SenderEntity<E>> extends Entity<E>
|
||||
return Mixin.getDisplayName(this.getId());
|
||||
}
|
||||
|
||||
public void setDisplayName(String displayName)
|
||||
public String getDisplayName(Object watcherObject)
|
||||
{
|
||||
Mixin.setDisplayName(this.getId(), displayName);
|
||||
return Mixin.getDisplayName(this.getId(), watcherObject);
|
||||
}
|
||||
|
||||
// CONVENIENCE SEND MESSAGE
|
||||
|
Loading…
Reference in New Issue
Block a user