public static void updateMarker(Spawn point) {
   Marker m = set.findMarker(point.getName());
   if (m != null) {
     if (m.getX() != point.getX() || m.getY() != point.getY() || m.getZ() != point.getZ()) {
       m.setLocation(point.getWorldName(), point.getX(), point.getY(), point.getZ());
     }
   }
   set.createMarker(
       point.getName(),
       point.getName(),
       point.getWorldName(),
       point.getX(),
       point.getY(),
       point.getZ(),
       icon,
       true);
 }
 private void updateAllNPCs(MarkerSet npcset) {
   Iterable<NPCRegistry> reg = CitizensAPI.getNPCRegistries();
   HashSet<String> toremove = new HashSet<String>(existingnpcs);
   if (reg != null) {
     for (NPCRegistry r : reg) {
       for (NPC npc : r) {
         processNPC(npcset, npc, toremove);
       }
     }
   }
   for (String s : toremove) {
     Marker m = npcset.findMarker(s);
     if (m != null) {
       m.deleteMarker();
     }
     existingnpcs.remove(s);
   }
 }
  public ReaperMarkers(FearTheReaper plugin, DynmapAPI dm) {
    // Setup the API
    api = dm;
    mApi = api.getMarkerAPI();
    if (mApi == null) {
      return;
    }
    icon = mApi.getMarkerIcon("tomb");
    if (icon == null) {
      InputStream in = getClass().getResourceAsStream("/tomb.png");
      icon = mApi.createMarkerIcon("tomb", "Graveyards", in);
    }

    set = mApi.getMarkerSet("graveyard.markerset");
    if (set == null) {
      set = mApi.createMarkerSet("graveyard.markerset", "Graveyards", null, true);
      set.setLayerPriority(10);
      set.setHideByDefault(false);
      set.setMinZoom(0);
    }

    for (Entry<String, Spawn> entry : FearTheReaper.getSpawnList().entrySet()) {
      Marker m = set.findMarker(entry.getKey());
      Spawn s = entry.getValue();
      if (m != null) {
        if (m.getX() != s.getX() || m.getY() != s.getY() || m.getZ() != s.getZ()) {
          m.setLocation(s.getWorldName(), s.getX(), s.getY(), s.getZ());
        }
      }

      set.createMarker(
          entry.getKey(),
          entry.getKey(),
          s.getWorldName(),
          s.getX(),
          s.getY(),
          s.getZ(),
          icon,
          true);
    }
  }
 private void processNPC(MarkerSet set, NPC npc, Set<String> toremove) {
   UUID uuid = npc.getUniqueId();
   String id =
       "npc_" + Long.toHexString(uuid.getMostSignificantBits() ^ uuid.getLeastSignificantBits());
   Entity ent = null;
   if (npc.isSpawned()) {
     ent = npc.getEntity();
   }
   if (ent == null) { // If null, see if we need to remove it
     if (existingnpcs.contains(id)) { // Found?
       Marker m = set.findMarker(id);
       if (m != null) {
         m.deleteMarker();
       }
       existingnpcs.remove(id);
     }
   } else {
     Location loc = ent.getLocation();
     Marker m = set.findMarker(id);
     if (m == null) {
       m =
           set.createMarker(
               id,
               npc.getName(),
               false,
               loc.getWorld().getName(),
               loc.getX(),
               loc.getY(),
               loc.getZ(),
               deficon,
               false);
       existingnpcs.add(id);
     } else {
       m.setLocation(loc.getWorld().getName(), loc.getX(), loc.getY(), loc.getZ());
       m.setLabel(npc.getName());
     }
     if (toremove != null) {
       toremove.remove(id);
     }
   }
 }
 public static void deleteMarker(Spawn point) {
   Marker m = set.findMarker(point.getName());
   if (m != null) {
     m.deleteMarker();
   }
 }