Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Shadow public abstract boolean init();
- @Shadow private long currentTime = getCurrentTimeMillis();
- @Shadow public static long getCurrentTimeMillis();
- @Shadow private final ServerStatusResponse statusResponse = new ServerStatusResponse();
- @Shadow public abstract void applyServerIconToResponse(ServerStatusResponse statusResponse2);
- @Shadow private String motd;
- @Shadow public abstract boolean isServerRunning();
- @Shadow private boolean serverRunning = true;
- @Shadow private long timeOfLastWarning;
- @Shadow protected abstract void tick();
- @Shadow protected abstract void finalTick(CrashReport crashReport);
- @Shadow public abstract CrashReport addServerInfoToCrashReport(CrashReport crashReport);
- @Shadow public abstract File getDataDirectory();
- @Shadow private boolean serverStopped;
- @Shadow public abstract void systemExitNow();
- @Overwrite
- public void run()
- {
- try
- {
- if (this.init())
- {
- this.currentTime = getCurrentTimeMillis();
- long i = 0L;
- this.statusResponse.setServerDescription(new TextComponentString(this.motd));
- this.statusResponse.setVersion(new ServerStatusResponse.Version("1.12.2", 340));
- this.applyServerIconToResponse(this.statusResponse);
- while (this.serverRunning)
- {
- long k = getCurrentTimeMillis();
- long j = k - this.currentTime;
- if (j > 2000L && this.currentTime - this.timeOfLastWarning >= 15000L)
- {
- 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));
- j = 2000L;
- this.timeOfLastWarning = this.currentTime;
- }
- if (j < 0L)
- {
- LOGGER.warn("Time ran backwards! Did the system time change?");
- j = 0L;
- }
- i += j;
- this.currentTime = k;
- this.tick();
- }
- }
- else
- {
- this.finalTick((CrashReport)null);
- }
- }
- catch (Throwable throwable1)
- {
- LOGGER.error("Encountered an unexpected exception", throwable1);
- CrashReport crashreport = null;
- if (throwable1 instanceof ReportedException)
- {
- crashreport = this.addServerInfoToCrashReport(((ReportedException)throwable1).getCrashReport());
- }
- else
- {
- crashreport = this.addServerInfoToCrashReport(new CrashReport("Exception in server tick loop", throwable1));
- }
- File file1 = new File(new File(this.getDataDirectory(), "crash-reports"), "crash-" + (new SimpleDateFormat("yyyy-MM-dd_HH.mm.ss")).format(new Date()) + "-server.txt");
- if (crashreport.saveToFile(file1))
- {
- LOGGER.error("This crash report has been saved to: {}", (Object)file1.getAbsolutePath());
- }
- else
- {
- LOGGER.error("We were unable to save this crash report to disk.");
- }
- this.finalTick(crashreport);
- }
- finally
- {
- try
- {
- this.serverStopped = true;
- this.stopServer();
- }
- catch (Throwable throwable)
- {
- LOGGER.error("Exception stopping the server", throwable);
- }
- finally
- {
- this.systemExitNow();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment