Skip to content

Commit

Permalink
Add --registry to /npc list, let getNPC(Entity) use the Entity handle
Browse files Browse the repository at this point in the history
  • Loading branch information
fullwall committed Mar 4, 2014
1 parent aec7293 commit c9b7c9d
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/main/java/net/citizensnpcs/commands/NPCCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -1075,7 +1075,7 @@ public void rename(CommandContext args, CommandSender sender, NPC npc) {
}
Location prev = npc.isSpawned() ? npc.getEntity().getLocation() : null;
npc.despawn(DespawnReason.PENDING_RESPAWN);
npc.setName(Colorizer.parseColors(newName));
npc.setName(newName);
if (prev != null)
npc.spawn(prev);

Expand Down
5 changes: 1 addition & 4 deletions src/main/java/net/citizensnpcs/npc/CitizensNPCRegistry.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import org.bukkit.Bukkit;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;

import com.google.common.base.Preconditions;
import com.google.common.collect.Maps;
Expand Down Expand Up @@ -120,9 +119,7 @@ public NPC getNPC(Entity entity) {
return null;
if (entity instanceof NPCHolder)
return ((NPCHolder) entity).getNPC();
if (!(entity instanceof LivingEntity))
return null;
Object handle = NMS.getHandle((LivingEntity) entity);
Object handle = NMS.getHandle(entity);
return handle instanceof NPCHolder ? ((NPCHolder) handle).getNPC() : null;
}

Expand Down
4 changes: 0 additions & 4 deletions src/main/java/net/citizensnpcs/trait/Controllable.java
Original file line number Diff line number Diff line change
Expand Up @@ -353,10 +353,6 @@ public void run(Player rider) {
handle.motY *= 0.98F;
}
}

public static void registerControllerType(EntityType type, Class<? extends MovementController> clazz) {
controllerTypes.put(type, clazz);
}

private static final Map<EntityType, Class<? extends MovementController>> controllerTypes = Maps
.newEnumMap(EntityType.class);
Expand Down

0 comments on commit c9b7c9d

Please sign in to comment.