Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (args[0].equalsIgnoreCase("create")) {
- if (!(sender instanceof Player)) {
- sender.sendMessage("You have to be a player to do this!");
- return true;
- }
- if (!sender.hasPermission("quests.npc.create")) {
- sender.sendMessage(cmnd.getPermissionMessage());
- return true;
- }
- if (args.length == 1) {
- sender.sendMessage("Correct usage: /npc create <name> [type]");
- sender.sendMessage("Default [type] is Human");
- return true;
- }
- RemoteEntityType type = null;
- if (args.length == 2) {
- type = RemoteEntityType.Human;
- } else {
- for(RemoteEntityType t : RemoteEntityType.values()){
- if(t.toString().equalsIgnoreCase(args[2])){
- type = t;
- break;
- }
- }
- }
- if (type == null) {
- sender.sendMessage("NPC type " + args[2] + " not found!");
- return true;
- }
- RemoteEntity ent = plugin.getEntityManager().prepareEntity(type)
- .withMaxHealth(plugin.getSettings().getDefaultHealth())
- .asPushable(plugin.getSettings().isDefaultPushable())
- .asStationary(plugin.getSettings().isDefaultStationary())
- .atLocation(((Player)sender).getLocation())
- .withName(args[1])
- .create();
- plugin.getNPCManager().createAndAddNPCWrapper(ent.getID());
- sender.sendMessage("NPC " + args[1] + " created, ID " + ent.getID());
- plugin.getUserManager().getUser(sender.getName()).setSelectedEntity(ent.getID());
- this.npcSelected.put(sender.getName(), ent.getID());
- plugin.getEntityManager().saveEntities();
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement