Skip to content

Commit

Permalink
Use old logic for glowing colour in 1.12, remove unnecessary respawn …
Browse files Browse the repository at this point in the history
…in /npc rename for non-Player NPCs
  • Loading branch information
fullwall committed Mar 21, 2020
1 parent 5f6026f commit 1e507a1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
5 changes: 0 additions & 5 deletions main/src/main/java/net/citizensnpcs/commands/NPCCommands.java
Expand Up @@ -1472,12 +1472,7 @@ public void rename(CommandContext args, CommandSender sender, NPC npc) {
Messaging.sendErrorTr(sender, Messages.NPC_NAME_TOO_LONG);
newName = newName.substring(0, nameLength);
}
Location prev = npc.isSpawned() ? npc.getEntity().getLocation() : null;
npc.despawn(DespawnReason.PENDING_RESPAWN);
npc.setName(newName);
if (prev != null) {
npc.spawn(prev, SpawnReason.RESPAWN);
}

Messaging.sendTr(sender, Messages.NPC_RENAMED, oldName, newName);
}
Expand Down
14 changes: 7 additions & 7 deletions main/src/main/java/net/citizensnpcs/npc/CitizensNPC.java
Expand Up @@ -402,13 +402,13 @@ private void updateFlyableState() {
EntityType type = isSpawned() ? getEntity().getType() : getTrait(MobType.class).getType();
if (type == null)
return;
if (Util.isAlwaysFlyable(type)) {
if (!data().has(NPC.FLYABLE_METADATA)) {
data().setPersistent(NPC.FLYABLE_METADATA, true);
}
if (!hasTrait(Gravity.class)) {
getTrait(Gravity.class).setEnabled(true);
}
if (!Util.isAlwaysFlyable(type))
return;
if (!data().has(NPC.FLYABLE_METADATA)) {
data().setPersistent(NPC.FLYABLE_METADATA, true);
}
if (!hasTrait(Gravity.class)) {
getTrait(Gravity.class).setEnabled(true);
}
}

Expand Down
Expand Up @@ -14,6 +14,7 @@
import net.citizensnpcs.api.trait.Trait;
import net.citizensnpcs.api.trait.TraitName;
import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util;

@TraitName("scoreboardtrait")
public class ScoreboardTrait extends Trait {
Expand Down Expand Up @@ -67,6 +68,9 @@ public void apply(Team team, boolean nameVisibility) {
npc.data().remove(NPC.GLOWING_COLOR_METADATA);
}
if (color != null) {
if (SUPPORT_GLOWING_COLOR && Util.getMinecraftRevision().contains("1_12_R1")) {
SUPPORT_GLOWING_COLOR = false;
}
if (SUPPORT_GLOWING_COLOR) {
try {
if (team.getColor() == null || previousGlowingColor == null
Expand Down

0 comments on commit 1e507a1

Please sign in to comment.