mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-12-25 18:47:40 +01:00
Make /npc glowing --color work more reliably
This commit is contained in:
parent
df6c566f96
commit
03abd6384d
@ -559,9 +559,16 @@ public class NPCCommands {
|
||||
public void glowing(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||
if (args.hasValueFlag("color")) {
|
||||
ChatColor chatColor = Util.matchEnum(ChatColor.values(), args.getFlag("color"));
|
||||
if (chatColor == null || !(npc.getEntity() instanceof Player))
|
||||
if (!(npc.getEntity() instanceof Player))
|
||||
throw new CommandException();
|
||||
npc.data().setPersistent(NPC.GLOWING_COLOR_METADATA, chatColor.name());
|
||||
if (chatColor == null) {
|
||||
npc.data().remove(NPC.GLOWING_COLOR_METADATA);
|
||||
} else {
|
||||
npc.data().setPersistent(NPC.GLOWING_COLOR_METADATA, chatColor.name());
|
||||
}
|
||||
Messaging.sendTr(sender, Messages.GLOWING_COLOR_SET, npc.getName(),
|
||||
chatColor == null ? ChatColor.WHITE + "white" : chatColor + Util.prettyEnum(chatColor));
|
||||
return;
|
||||
}
|
||||
npc.data().setPersistent(NPC.GLOWING_METADATA, !npc.data().get(NPC.GLOWING_METADATA, false));
|
||||
boolean glowing = npc.data().get(NPC.GLOWING_METADATA);
|
||||
|
@ -291,9 +291,14 @@ public class CitizensNPC extends AbstractNPC {
|
||||
String teamName = data().get(NPC.SCOREBOARD_FAKE_TEAM_NAME_METADATA);
|
||||
Team team = Bukkit.getScoreboardManager().getMainScoreboard().getTeam(teamName);
|
||||
team.setOption(Option.NAME_TAG_VISIBILITY, nameVisibility);
|
||||
if (data().has(NPC.GLOWING_COLOR_METADATA) && team.getPrefix() == null) {
|
||||
team.setPrefix(
|
||||
ChatColor.valueOf(data().<String> get(NPC.GLOWING_COLOR_METADATA)).toString());
|
||||
if (data().has(NPC.GLOWING_COLOR_METADATA)) {
|
||||
if (team.getPrefix() == null || team.getPrefix().length() == 0
|
||||
|| (data().has("previous-glowing-color")
|
||||
&& !team.getPrefix().equals(data().get("previous-glowing-color")))) {
|
||||
team.setPrefix(
|
||||
ChatColor.valueOf(data().<String> get(NPC.GLOWING_COLOR_METADATA)).toString());
|
||||
data().set("previous-glowing-color", team.getPrefix());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -84,6 +84,7 @@ public class Messages {
|
||||
public static final String GAMEMODE_DESCRIBE = "citizens.commands.npc.gamemode.describe";
|
||||
public static final String GAMEMODE_INVALID = "citizens.commands.npc.gamemode.invalid";
|
||||
public static final String GAMEMODE_SET = "citizens.commands.npc.gamemode.set";
|
||||
public static final String GLOWING_COLOR_SET = "citizens.commands.npc.glowing.color-set";
|
||||
public static final String GLOWING_SET = "citizens.commands.npc.glowing.set";
|
||||
public static final String GLOWING_UNSET = "citizens.commands.npc.glowing.unset";
|
||||
public static final String GRAVITY_DISABLED = "citizens.commands.npc.gravity.disabled";
|
||||
|
@ -46,6 +46,7 @@ citizens.commands.npc.gravity.disabled=Gravity [[disabled]].
|
||||
citizens.commands.npc.gravity.enabled=Gravity [[enabled]].
|
||||
citizens.commands.npc.glowing.set=[[{0}]] is now glowing.
|
||||
citizens.commands.npc.glowing.unset=[[{0}]] is no longer glowing.
|
||||
citizens.commands.npc.glowing.color-set=[[{0}]]''s glowing color set to {1}]].
|
||||
citizens.commands.npc.guardian.elder-unset=[[{0}]] is no longer an elder guardian.
|
||||
citizens.commands.npc.guardian.elder-set=[[{0}]] is now an elder guardian.
|
||||
citizens.commands.npc.horse.chest-set=The horse is now carrying a chest.
|
||||
|
Loading…
Reference in New Issue
Block a user