Skip to content

Commit

Permalink
Implement new method
Browse files Browse the repository at this point in the history
  • Loading branch information
fullwall committed Jan 12, 2014
1 parent 5d5cda3 commit f43cb55
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 7 additions & 1 deletion src/main/java/net/citizensnpcs/npc/CitizensNPCRegistry.java
Expand Up @@ -95,7 +95,12 @@ private CitizensNPC getByType(EntityType type, UUID uuid, int id, String name) {

@Override
public NPC getByUniqueId(UUID uuid) {
NPC npc = npcs.get(uuid);
return npcs.get(uuid);
}

@Override
public NPC getByUniqueIdGlobal(UUID uuid) {
NPC npc = getByUniqueId(uuid);
if (npc != null)
return npc;
for (NPCRegistry registry : CitizensAPI.getNPCRegistries()) {
Expand Down Expand Up @@ -232,6 +237,7 @@ public int compare(NPC o1, NPC o2) {
return o1.getId() - o2.getId();
}
};

private static boolean TROVE_EXISTS = false;
static {
// allow trove dependency to be optional for debugging purposes
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/net/citizensnpcs/npc/NPCSelector.java
Expand Up @@ -48,7 +48,7 @@ public NPC getSelected(CommandSender sender) {
} else if (sender instanceof ConsoleCommandSender) {
if (consoleSelectedNPC == null)
return null;
return CitizensAPI.getNPCRegistry().getByUniqueId(consoleSelectedNPC);
return CitizensAPI.getNPCRegistry().getByUniqueIdGlobal(consoleSelectedNPC);
}
return null;
}
Expand All @@ -57,7 +57,7 @@ private NPC getSelectedFromMetadatable(Metadatable sender) {
List<MetadataValue> metadata = sender.getMetadata("selected");
if (metadata.size() == 0)
return null;
return CitizensAPI.getNPCRegistry().getByUniqueId((UUID) metadata.get(0).value());
return CitizensAPI.getNPCRegistry().getByUniqueIdGlobal((UUID) metadata.get(0).value());
}

@EventHandler
Expand Down

0 comments on commit f43cb55

Please sign in to comment.