From bf56a6dcb2923555e18e20fb40ebbb9d310a8594 Mon Sep 17 00:00:00 2001 From: fullwall Date: Tue, 15 Feb 2022 01:35:07 +0800 Subject: [PATCH] Add glowing for non-player characters, stop 1.8.8 noDamageTicks from going down too fast --- .../main/java/net/citizensnpcs/commands/NPCCommands.java | 8 ++++---- main/src/main/java/net/citizensnpcs/npc/CitizensNPC.java | 4 +--- .../citizensnpcs/nms/v1_8_R3/entity/EntityHumanNPC.java | 4 ---- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/main/src/main/java/net/citizensnpcs/commands/NPCCommands.java b/main/src/main/java/net/citizensnpcs/commands/NPCCommands.java index 34f1aecb5..67f0a048f 100644 --- a/main/src/main/java/net/citizensnpcs/commands/NPCCommands.java +++ b/main/src/main/java/net/citizensnpcs/commands/NPCCommands.java @@ -816,8 +816,6 @@ 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 (!(npc.getEntity() instanceof Player)) - throw new CommandException(Messages.GLOWING_COLOR_PLAYER_ONLY); npc.getOrAddTrait(ScoreboardTrait.class).setColor(chatColor); if (!npc.data().has(NPC.GLOWING_METADATA)) { npc.data().setPersistent(NPC.GLOWING_METADATA, true); @@ -2518,11 +2516,13 @@ public class NPCCommands { public void useitem(CommandContext args, CommandSender sender, NPC npc) throws CommandException { boolean offhand = args.hasFlag('o'); if (offhand) { - npc.data().set(NPC.Metadata.USING_OFFHAND_ITEM, !npc.data().get(NPC.Metadata.USING_OFFHAND_ITEM, false)); + npc.data().setPersistent(NPC.Metadata.USING_OFFHAND_ITEM, + !npc.data().get(NPC.Metadata.USING_OFFHAND_ITEM, false)); Messaging.sendTr(sender, Messages.TOGGLED_USING_OFFHAND_ITEM, npc.data().get(NPC.Metadata.USING_OFFHAND_ITEM)); } else { - npc.data().set(NPC.Metadata.USING_HELD_ITEM, !npc.data().get(NPC.Metadata.USING_HELD_ITEM, false)); + npc.data().setPersistent(NPC.Metadata.USING_HELD_ITEM, + !npc.data().get(NPC.Metadata.USING_HELD_ITEM, false)); Messaging.sendTr(sender, Messages.TOGGLED_USING_HELD_ITEM, npc.data().get(NPC.Metadata.USING_HELD_ITEM)); } } diff --git a/main/src/main/java/net/citizensnpcs/npc/CitizensNPC.java b/main/src/main/java/net/citizensnpcs/npc/CitizensNPC.java index 7f9e95f15..9c03c72d8 100644 --- a/main/src/main/java/net/citizensnpcs/npc/CitizensNPC.java +++ b/main/src/main/java/net/citizensnpcs/npc/CitizensNPC.java @@ -427,8 +427,7 @@ public class CitizensNPC extends AbstractNPC { String teamName = data().get(NPC.Metadata.SCOREBOARD_FAKE_TEAM_NAME, ""); Team team = null; - if (!(getEntity() instanceof Player) || teamName.length() == 0 - || (team = Util.getDummyScoreboard().getTeam(teamName)) == null) + if (teamName.length() == 0 || (team = Util.getDummyScoreboard().getTeam(teamName)) == null) return; if (!Setting.USE_SCOREBOARD_TEAMS.asBoolean()) { @@ -436,7 +435,6 @@ public class CitizensNPC extends AbstractNPC { data().remove(NPC.SCOREBOARD_FAKE_TEAM_NAME_METADATA); return; } - getOrAddTrait(ScoreboardTrait.class).apply(team, nameVisibility); } diff --git a/v1_8_R3/src/main/java/net/citizensnpcs/nms/v1_8_R3/entity/EntityHumanNPC.java b/v1_8_R3/src/main/java/net/citizensnpcs/nms/v1_8_R3/entity/EntityHumanNPC.java index f52c3cd5a..1e236d5a5 100644 --- a/v1_8_R3/src/main/java/net/citizensnpcs/nms/v1_8_R3/entity/EntityHumanNPC.java +++ b/v1_8_R3/src/main/java/net/citizensnpcs/nms/v1_8_R3/entity/EntityHumanNPC.java @@ -402,10 +402,6 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable boolean navigating = npc.getNavigator().isNavigating(); updatePackets(navigating); - if (noDamageTicks > 0) { - --noDamageTicks; - } - npc.update(); }