z0z0z

The Bit I changed

Jul 18th, 2019
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.86 KB | None | 0 0
  1. @Shadow public abstract boolean init();
  2.     @Shadow private long currentTime = getCurrentTimeMillis();
  3.     @Shadow public static long getCurrentTimeMillis();
  4.     @Shadow private final ServerStatusResponse statusResponse = new ServerStatusResponse();
  5.     @Shadow public abstract void applyServerIconToResponse(ServerStatusResponse statusResponse2);
  6.     @Shadow private String motd;
  7.     @Shadow public abstract boolean isServerRunning();
  8.     @Shadow private boolean serverRunning = true;
  9.     @Shadow private long timeOfLastWarning;
  10.     @Shadow protected abstract void tick();
  11.     @Shadow protected abstract void finalTick(CrashReport crashReport);
  12.     @Shadow public abstract CrashReport addServerInfoToCrashReport(CrashReport crashReport);
  13.     @Shadow public abstract File getDataDirectory();
  14.     @Shadow private boolean serverStopped;
  15.     @Shadow public abstract void systemExitNow();
  16.    
  17.     @Overwrite
  18.     public void run()
  19.     {
  20.         try
  21.         {
  22.             if (this.init())
  23.             {
  24.                 this.currentTime = getCurrentTimeMillis();
  25.                 long i = 0L;
  26.                 this.statusResponse.setServerDescription(new TextComponentString(this.motd));
  27.                 this.statusResponse.setVersion(new ServerStatusResponse.Version("1.12.2", 340));
  28.                 this.applyServerIconToResponse(this.statusResponse);
  29.  
  30.                 while (this.serverRunning)
  31.                 {
  32.                     long k = getCurrentTimeMillis();
  33.                     long j = k - this.currentTime;
  34.  
  35.                     if (j > 2000L && this.currentTime - this.timeOfLastWarning >= 15000L)
  36.                     {
  37.                         LOGGER.warn("Can't keep up! Did the system time change, or is the server overloaded? Running {}ms behind, skipping {} tick(s)", Long.valueOf(j), Long.valueOf(j / 50L));
  38.                         j = 2000L;
  39.                         this.timeOfLastWarning = this.currentTime;
  40.                     }
  41.  
  42.                     if (j < 0L)
  43.                     {
  44.                         LOGGER.warn("Time ran backwards! Did the system time change?");
  45.                         j = 0L;
  46.                     }
  47.  
  48.                     i += j;
  49.                     this.currentTime = k;
  50.  
  51.                     this.tick();
  52.                 }
  53.             }
  54.             else
  55.             {
  56.                 this.finalTick((CrashReport)null);
  57.             }
  58.         }
  59.         catch (Throwable throwable1)
  60.         {
  61.             LOGGER.error("Encountered an unexpected exception", throwable1);
  62.             CrashReport crashreport = null;
  63.  
  64.             if (throwable1 instanceof ReportedException)
  65.             {
  66.                 crashreport = this.addServerInfoToCrashReport(((ReportedException)throwable1).getCrashReport());
  67.             }
  68.             else
  69.             {
  70.                 crashreport = this.addServerInfoToCrashReport(new CrashReport("Exception in server tick loop", throwable1));
  71.             }
  72.  
  73.             File file1 = new File(new File(this.getDataDirectory(), "crash-reports"), "crash-" + (new SimpleDateFormat("yyyy-MM-dd_HH.mm.ss")).format(new Date()) + "-server.txt");
  74.  
  75.             if (crashreport.saveToFile(file1))
  76.             {
  77.                 LOGGER.error("This crash report has been saved to: {}", (Object)file1.getAbsolutePath());
  78.             }
  79.             else
  80.             {
  81.                 LOGGER.error("We were unable to save this crash report to disk.");
  82.             }
  83.  
  84.             this.finalTick(crashreport);
  85.         }
  86.         finally
  87.         {
  88.             try
  89.             {
  90.                 this.serverStopped = true;
  91.                 this.stopServer();
  92.             }
  93.             catch (Throwable throwable)
  94.             {
  95.                 LOGGER.error("Exception stopping the server", throwable);
  96.             }
  97.             finally
  98.             {
  99.                 this.systemExitNow();
  100.             }
  101.         }
  102.     }
Advertisement
Add Comment
Please, Sign In to add comment