Advertisement
Guest User

Untitled

a guest
Feb 2nd, 2013
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.98 KB | None | 0 0
  1. if (args[0].equalsIgnoreCase("create")) {
  2. if (!(sender instanceof Player)) {
  3. sender.sendMessage("You have to be a player to do this!");
  4. return true;
  5. }
  6. if (!sender.hasPermission("quests.npc.create")) {
  7. sender.sendMessage(cmnd.getPermissionMessage());
  8. return true;
  9. }
  10. if (args.length == 1) {
  11. sender.sendMessage("Correct usage: /npc create <name> [type]");
  12. sender.sendMessage("Default [type] is Human");
  13. return true;
  14. }
  15. RemoteEntityType type = null;
  16. if (args.length == 2) {
  17. type = RemoteEntityType.Human;
  18. } else {
  19. for(RemoteEntityType t : RemoteEntityType.values()){
  20. if(t.toString().equalsIgnoreCase(args[2])){
  21. type = t;
  22. break;
  23. }
  24. }
  25. }
  26. if (type == null) {
  27. sender.sendMessage("NPC type " + args[2] + " not found!");
  28. return true;
  29. }
  30. RemoteEntity ent = plugin.getEntityManager().prepareEntity(type)
  31. .withMaxHealth(plugin.getSettings().getDefaultHealth())
  32. .asPushable(plugin.getSettings().isDefaultPushable())
  33. .asStationary(plugin.getSettings().isDefaultStationary())
  34. .atLocation(((Player)sender).getLocation())
  35. .withName(args[1])
  36. .create();
  37. plugin.getNPCManager().createAndAddNPCWrapper(ent.getID());
  38. sender.sendMessage("NPC " + args[1] + " created, ID " + ent.getID());
  39. plugin.getUserManager().getUser(sender.getName()).setSelectedEntity(ent.getID());
  40. this.npcSelected.put(sender.getName(), ent.getID());
  41. plugin.getEntityManager().saveEntities();
  42. return true;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement