mirror of
https://github.com/cnaude/PurpleIRC-spigot.git
synced 2024-11-29 05:26:19 +01:00
Merge pull request #59 from Firepup6500/master
Add support for %NICKNAME%
This commit is contained in:
commit
6e5683b6b4
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,7 +1,7 @@
|
||||
/target/
|
||||
/nbactions.xml
|
||||
/dependency-reduced-pom.xml
|
||||
|
||||
/.vscode/
|
||||
/.idea/
|
||||
/*.iml
|
||||
|
||||
|
@ -49,4 +49,14 @@ public class EssentialsHook {
|
||||
return false;
|
||||
}
|
||||
|
||||
public String getNickname(Player player) {
|
||||
if (essentials != null) {
|
||||
User user = essentials.getUser(player);
|
||||
if (user != null) {
|
||||
return user.getNickname();
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1232,6 +1232,31 @@ public class PurpleIRC extends JavaPlugin {
|
||||
return displayName;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
public String getNickname(String player) {
|
||||
String nickname = "";
|
||||
try {
|
||||
UUID uuid = getPlayerUuid(player);
|
||||
if (essentialsChatHook != null && uuid != null) {
|
||||
Player user = getServer().getPlayer(uuid);
|
||||
if (user != null) {
|
||||
logDebug("getNickname: " + user.getName());
|
||||
nickname = essentialsChatHook.getNickname(user);
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
logDebug("getNickname (" + player + "): " + ex.getMessage());
|
||||
}
|
||||
if (nickname == null) {
|
||||
nickname = player;
|
||||
}
|
||||
return ChatColor.translateAlternateColorCodes('&', nickname);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param player
|
||||
|
@ -941,11 +941,14 @@ public class ChatTokenizer {
|
||||
public String playerTokenizer(Player player, String message) {
|
||||
String pName;
|
||||
String displayName;
|
||||
String pNickname;
|
||||
if (plugin.pingFixTemplate) {
|
||||
pName = addZeroWidthSpace(player.getName());
|
||||
pNickname = addZeroWidthSpace(plugin.getNickname(player.getName()));
|
||||
displayName = player.getDisplayName().replace(player.getName(), pName);
|
||||
} else {
|
||||
pName = player.getName();
|
||||
pNickname = plugin.getNickname(pName);
|
||||
displayName = player.getDisplayName();
|
||||
}
|
||||
plugin.logDebug("Tokenizing " + pName + "(O: " + player.isOnline() + ")");
|
||||
@ -968,6 +971,9 @@ public class ChatTokenizer {
|
||||
String worldColor = "";
|
||||
String jobShort = "";
|
||||
String job = "";
|
||||
if (pNickname == null) {
|
||||
pNickname = "";
|
||||
}
|
||||
if (pSuffix == null) {
|
||||
pSuffix = "";
|
||||
}
|
||||
@ -1007,6 +1013,7 @@ public class ChatTokenizer {
|
||||
}
|
||||
|
||||
return message.replace("%DISPLAYNAME%", displayName)
|
||||
.replace("%NICKNAME%", pNickname)
|
||||
.replace("%UUID%", uuid.toString())
|
||||
.replace("%JOBS%", job)
|
||||
.replace("%JOBSSHORT%", jobShort)
|
||||
@ -1051,6 +1058,7 @@ public class ChatTokenizer {
|
||||
}
|
||||
|
||||
String displayName = plugin.getDisplayName(playerName);
|
||||
String nickname = plugin.getNickname(playerName);
|
||||
String uuid = "";
|
||||
plugin.logDebug("playerTokenizer: 7 ");
|
||||
String worldAlias = "";
|
||||
@ -1099,6 +1107,7 @@ public class ChatTokenizer {
|
||||
|
||||
plugin.logDebug("[S]Raw message: " + message);
|
||||
return message.replace("%DISPLAYNAME%", displayName)
|
||||
.replace("%NICKNAME%", nickname)
|
||||
.replace("%UUID%", uuid)
|
||||
.replace("%JOBS%", job)
|
||||
.replace("%JOBSSHORT%", jobShort)
|
||||
|
Loading…
Reference in New Issue
Block a user