Advertisement
Guest User

Untitled

a guest
Feb 28th, 2017
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.29 KB | None | 0 0
  1. @Override
  2. public final void run() {
  3. while (!CoresManager.shutdown) {
  4. long currentTime = Utils.currentTimeMillis();
  5. try {
  6. // long debug = Utils.currentTimeMillis();
  7. WorldTasksManager.processTasks();
  8. // System.out.print("TASKS: "+(Utils.currentTimeMillis()-debug));
  9. // debug = Utils.currentTimeMillis();
  10. for (Player player : World.getPlayers()) {
  11. if (player == null || !player.hasStarted()
  12. || player.hasFinished())
  13. continue;
  14. if (currentTime - player.getPacketsDecoderPing() > Settings.MAX_PACKETS_DECODER_PING_DELAY
  15. && player.getSession().getChannel().isOpen())
  16. player.getSession().getChannel().close();
  17. player.processEntity();
  18. }
  19. // System.out.print(" ,PLAYERS PROCESS: "+(Utils.currentTimeMillis()-debug));
  20. // debug = Utils.currentTimeMillis();
  21. for (NPC npc : World.getNPCs()) {
  22. if (npc == null || npc.hasFinished())
  23. continue;
  24. npc.processEntity();
  25. }
  26. } catch (Throwable e) {
  27. Logger.handle(e);
  28. }
  29. try {
  30. // System.out.print(" ,NPCS PROCESS: "+(Utils.currentTimeMillis()-debug));
  31. // debug = Utils.currentTimeMillis();
  32.  
  33. for (Player player : World.getPlayers()) {
  34. if (player == null || !player.hasStarted()
  35. || player.hasFinished())
  36. continue;
  37. player.getPackets().sendLocalPlayersUpdate();
  38. player.getPackets().sendLocalNPCsUpdate();
  39. }
  40. // System.out.print(" ,PLAYER UPDATE: "+(Utils.currentTimeMillis()-debug)+", "+World.getPlayers().size()+", "+World.getNPCs().size());
  41. // debug = Utils.currentTimeMillis();
  42. for (Player player : World.getPlayers()) {
  43. if (player == null || !player.hasStarted()
  44. || player.hasFinished())
  45. continue;
  46. player.resetMasks();
  47. }
  48. for (NPC npc : World.getNPCs()) {
  49. if (npc == null || npc.hasFinished())
  50. continue;
  51. npc.resetMasks();
  52. }
  53. } catch (Throwable e) {
  54. Logger.handle(e);
  55. }
  56. // System.out.println(" ,TOTAL: "+(Utils.currentTimeMillis()-currentTime));
  57. LAST_CYCLE_CTM = Utils.currentTimeMillis();
  58. long sleepTime = Settings.WORLD_CYCLE_TIME + currentTime
  59. - LAST_CYCLE_CTM;
  60. if (sleepTime <= 0)
  61. continue;
  62. try {
  63. Thread.sleep(sleepTime);
  64. } catch (InterruptedException e) {
  65. Logger.handle(e);
  66. }
  67. }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement