Beispiel #1
0
  public Banker spawnBanker(String name, Location l, String id, String bankName) {
    if (bankers.containsKey(id)) {
      Log.warning("NPC with that id already exists, existing NPC returned");
      return bankers.get(id);
    } else {
      if (name.length()
          > 16) { // Check and nag if name is too long, spawn NPC anyway with shortened name.
        String tmp = name.substring(0, 16);
        Log.warning("NPCs can't have names longer than 16 characters,");
        Log.warning(name + " has been shortened to " + tmp);
        name = tmp;
      }
      WorldServer ws = getWorldServer(l.getWorld());
      NPCEntity npcEntity = new NPCEntity(this, ws, name, new ItemInWorldManager(ws));
      npcEntity.setPositionRotation(l.getX(), l.getY(), l.getZ(), l.getYaw(), l.getPitch());
      ws.addEntity(npcEntity); // the right way
      Banker npc = new Banker(npcEntity, bankName);
      npc.setYaw(l.getYaw());

      if (Bukkit.getPluginManager().isPluginEnabled("Spout")) {
        SpoutPlayer sp = npc.getSpoutPlayer();
        sp.setSkin("http://dl.dropbox.com/u/18216599/images/bankersskin.png");
        sp.setTitle(ChatColor.GOLD + "Banker\n" + ChatColor.WHITE + "[" + bankName + "]");
      }

      bankers.put(id, npc);
      return npc;
    }
  }
 public void setTitle(LivingEntity entity, String title) {
   if (entity instanceof SpoutPlayer) {
     ((SpoutPlayer) entity).setTitle(title);
   }
   titles.put(entity.getEntityId(), title);
   ArrayList<LivingEntity> entities = new ArrayList<LivingEntity>(1);
   entities.add(entity);
   for (SpoutPlayer player : getOnlinePlayers()) {
     player.updateEntitySkins(entities);
   }
 }