Add ability to customize name above head
This commit is contained in:
parent
1ed3a149ea
commit
1795e03e31
@ -261,6 +261,9 @@ public class DisguiseConfig {
|
|||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
private static boolean copyPlayerTeamInfo;
|
private static boolean copyPlayerTeamInfo;
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
private static String nameAboveDisguise;
|
||||||
|
|
||||||
public static boolean isArmorstandsName() {
|
public static boolean isArmorstandsName() {
|
||||||
return getPlayerNameType() == PlayerNameType.ARMORSTANDS;
|
return getPlayerNameType() == PlayerNameType.ARMORSTANDS;
|
||||||
@ -663,6 +666,7 @@ public class DisguiseConfig {
|
|||||||
setMovementPacketsEnabled(config.getBoolean("PacketsEnabled.Movement"));
|
setMovementPacketsEnabled(config.getBoolean("PacketsEnabled.Movement"));
|
||||||
setNameAboveHeadAlwaysVisible(config.getBoolean("NameAboveHeadAlwaysVisible"));
|
setNameAboveHeadAlwaysVisible(config.getBoolean("NameAboveHeadAlwaysVisible"));
|
||||||
setNameOfPlayerShownAboveDisguise(config.getBoolean("ShowNamesAboveDisguises"));
|
setNameOfPlayerShownAboveDisguise(config.getBoolean("ShowNamesAboveDisguises"));
|
||||||
|
setNameAboveDisguise(config.getString("NameAboveDisguise"));
|
||||||
setPlayerDisguisesTablistExpires(config.getInt("PlayerDisguisesTablistExpiry"));
|
setPlayerDisguisesTablistExpires(config.getInt("PlayerDisguisesTablistExpiry"));
|
||||||
setPlayerHideArmor(config.getBoolean("PlayerHideArmor"));
|
setPlayerHideArmor(config.getBoolean("PlayerHideArmor"));
|
||||||
setRetaliationCombat(config.getBoolean("RetaliationCombat"));
|
setRetaliationCombat(config.getBoolean("RetaliationCombat"));
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package me.libraryaddict.disguise.commands;
|
package me.libraryaddict.disguise.commands;
|
||||||
|
|
||||||
|
import me.libraryaddict.disguise.DisguiseConfig;
|
||||||
import me.libraryaddict.disguise.commands.disguise.DisguiseCommand;
|
import me.libraryaddict.disguise.commands.disguise.DisguiseCommand;
|
||||||
import me.libraryaddict.disguise.commands.disguise.DisguiseEntityCommand;
|
import me.libraryaddict.disguise.commands.disguise.DisguiseEntityCommand;
|
||||||
import me.libraryaddict.disguise.commands.disguise.DisguisePlayerCommand;
|
import me.libraryaddict.disguise.commands.disguise.DisguisePlayerCommand;
|
||||||
@ -209,7 +210,13 @@ public abstract class DisguiseBaseCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected String getDisplayName(CommandSender player) {
|
protected String getDisplayName(CommandSender player) {
|
||||||
return DisguiseUtilities.getDisplayName(player);
|
String name = DisguiseConfig.getNameAboveDisguise().replace("%simple%", player.getName());
|
||||||
|
|
||||||
|
if (name.contains("%complex%")) {
|
||||||
|
name = name.replace("%complex%", DisguiseUtilities.getDisplayName(player));
|
||||||
|
}
|
||||||
|
|
||||||
|
return ChatColor.translateAlternateColorCodes('&', name);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ArrayList<String> getAllowedDisguises(DisguisePermissions permissions) {
|
protected ArrayList<String> getAllowedDisguises(DisguisePermissions permissions) {
|
||||||
|
@ -11,6 +11,8 @@ import me.libraryaddict.disguise.utilities.LibsEntityInteract;
|
|||||||
import me.libraryaddict.disguise.utilities.parser.DisguiseParseException;
|
import me.libraryaddict.disguise.utilities.parser.DisguiseParseException;
|
||||||
import me.libraryaddict.disguise.utilities.parser.DisguiseParser;
|
import me.libraryaddict.disguise.utilities.parser.DisguiseParser;
|
||||||
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -38,15 +40,13 @@ public class DisguiseEntityInteraction implements LibsEntityInteract {
|
|||||||
try {
|
try {
|
||||||
disguise = DisguiseParser.parseDisguise(p, entity, "disguiseentity", disguiseArgs,
|
disguise = DisguiseParser.parseDisguise(p, entity, "disguiseentity", disguiseArgs,
|
||||||
DisguiseParser.getPermissions(p, "disguiseentity"));
|
DisguiseParser.getPermissions(p, "disguiseentity"));
|
||||||
}
|
} catch (DisguiseParseException e) {
|
||||||
catch (DisguiseParseException e) {
|
|
||||||
if (e.getMessage() != null) {
|
if (e.getMessage() != null) {
|
||||||
DisguiseUtilities.sendMessage(p, e.getMessage());
|
DisguiseUtilities.sendMessage(p, e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -58,10 +58,7 @@ public class DisguiseEntityInteraction implements LibsEntityInteract {
|
|||||||
if (entity instanceof Player && DisguiseConfig.isNameOfPlayerShownAboveDisguise() &&
|
if (entity instanceof Player && DisguiseConfig.isNameOfPlayerShownAboveDisguise() &&
|
||||||
!entity.hasPermission("libsdisguises.hidename")) {
|
!entity.hasPermission("libsdisguises.hidename")) {
|
||||||
if (disguise.getWatcher() instanceof LivingWatcher) {
|
if (disguise.getWatcher() instanceof LivingWatcher) {
|
||||||
Team team = ((Player) entity).getScoreboard().getEntryTeam(entity.getName());
|
disguise.getWatcher().setCustomName(getDisplayName(entity));
|
||||||
|
|
||||||
disguise.getWatcher().setCustomName((team == null ? "" : team.getPrefix()) + entity.getName() +
|
|
||||||
(team == null ? "" : team.getSuffix()));
|
|
||||||
|
|
||||||
if (DisguiseConfig.isNameAboveHeadAlwaysVisible()) {
|
if (DisguiseConfig.isNameAboveHeadAlwaysVisible()) {
|
||||||
disguise.getWatcher().setCustomNameVisible(true);
|
disguise.getWatcher().setCustomNameVisible(true);
|
||||||
@ -105,4 +102,14 @@ public class DisguiseEntityInteraction implements LibsEntityInteract {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected String getDisplayName(CommandSender player) {
|
||||||
|
String name = DisguiseConfig.getNameAboveDisguise().replace("%simple%", player.getName());
|
||||||
|
|
||||||
|
if (name.contains("%complex%")) {
|
||||||
|
name = name.replace("%complex%", DisguiseUtilities.getDisplayName(player));
|
||||||
|
}
|
||||||
|
|
||||||
|
return ChatColor.translateAlternateColorCodes('&', name);
|
||||||
|
}
|
||||||
}
|
}
|
@ -206,6 +206,12 @@ ShowNamesAboveDisguises: false
|
|||||||
# If this is true, then the name shown above the head appears regardless of if you are looking at the disguise directly or not.
|
# If this is true, then the name shown above the head appears regardless of if you are looking at the disguise directly or not.
|
||||||
NameAboveHeadAlwaysVisible: true
|
NameAboveHeadAlwaysVisible: true
|
||||||
|
|
||||||
|
# What should the name be shown as?
|
||||||
|
# Two placeholders can be used.
|
||||||
|
# %simple% = The very basic name, 'libraryaddict'
|
||||||
|
# %complex% = Name will be grabbed from scoreboard or display name if scoreboard fails.
|
||||||
|
NameAboveDisguise: %complex%
|
||||||
|
|
||||||
# This modifies the bounding box, This is stuff like can a arrow hit them.
|
# This modifies the bounding box, This is stuff like can a arrow hit them.
|
||||||
# If you turn this to true, arrows will act like they hit the disguise in the right place!
|
# If you turn this to true, arrows will act like they hit the disguise in the right place!
|
||||||
# Clients will not see any difference in the hitboxes they are attacking, this is a server-sided calculation!
|
# Clients will not see any difference in the hitboxes they are attacking, this is a server-sided calculation!
|
||||||
|
Loading…
Reference in New Issue
Block a user