예제 #1
0
 // Registers a new NPC.
 public static int register(String name, Location loc, String owner, NPCCreateReason reason) {
   int UID = PropertyManager.getBasic().getNewNpcID();
   PropertyManager.getBasic().saveLocation(loc, UID);
   PropertyManager.getBasic().saveLookWhenClose(UID, Settings.getBoolean("DefaultLookAt"));
   PropertyManager.getBasic().saveTalkWhenClose(UID, Settings.getBoolean("DefaultTalkClose"));
   PropertyManager.getBasic().saveName(UID, name);
   register(UID, owner, reason);
   return UID;
 }
예제 #2
0
 @CommandRequirements()
 @Command(
     aliases = "citizens",
     usage = "debug",
     desc = "toggle debug mode for Citizens",
     modifiers = "debug",
     min = 1,
     max = 1)
 @ServerCommand()
 @CommandPermissions("admin.debug")
 public static void debug(CommandContext args, CommandSender sender, HumanNPC npc) {
   boolean debug = Settings.getBoolean("DebugMode");
   UtilityProperties.getConfig().setRaw("general.debug-mode", !debug);
   debug = !debug;
   if (debug) {
     Messaging.log("Debug mode is now on.");
     if (sender instanceof Player) {
       Messaging.send(sender, npc, "Debug mode is now " + ChatColor.GREEN + "on");
     }
   } else {
     Messaging.log("Debug mode is now off.");
     if (sender instanceof Player) {
       Messaging.send(sender, npc, "Debug mode is now " + ChatColor.RED + "off");
     }
   }
 }
예제 #3
0
 // Rotates an NPC.
 public static void faceEntity(HumanNPC npc, Entity entity) {
   if (npc.getWorld() != entity.getWorld()) return;
   if (Settings.getBoolean("RealisticPathing")
       && !npc.getHandle().isInSight(((CraftEntity) entity).getHandle())) return;
   Location loc = npc.getLocation(), pl = entity.getLocation();
   double xDiff = pl.getX() - loc.getX();
   double yDiff = pl.getY() - loc.getY();
   double zDiff = pl.getZ() - loc.getZ();
   double DistanceXZ = Math.sqrt(xDiff * xDiff + zDiff * zDiff);
   double DistanceY = Math.sqrt(DistanceXZ * DistanceXZ + yDiff * yDiff);
   double yaw = (Math.acos(xDiff / DistanceXZ) * 180 / Math.PI);
   double pitch = (Math.acos(yDiff / DistanceY) * 180 / Math.PI) - 90;
   if (zDiff < 0.0) {
     yaw = yaw + (Math.abs(180 - yaw) * 2);
   }
   npc.getHandle().yaw = (float) yaw - 90;
   npc.getHandle().az = npc.getHandle().yaw;
   npc.getHandle().pitch = (float) pitch;
 }