Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void run() {
- try {
- if(this.init()) {
- this.ab = az();
- this.r.setMOTD(new ChatComponentText(this.motd));
- this.r.setServerInfo(new ServerData("1.8.8", 47));
- this.a(this.r);
- Arrays.fill(this.recentTps, 20.0D);
- long start = System.nanoTime();
- long lastTick = start - 50000000L;
- long catchupTime = 0L;
- for(long tickSection = start; this.isRunning; this.Q = true) {
- long curTime = System.nanoTime();
- long wait = 50000000L - (curTime - lastTick);
- if(wait > 0L) {
- if((double)catchupTime < 2000000.0D) {
- wait += Math.abs(catchupTime);
- } else if(wait < catchupTime) {
- catchupTime -= wait;
- wait = 0L;
- } else {
- wait -= catchupTime;
- catchupTime = 0L;
- }
- }
- if(wait > 0L) {
- Thread.sleep(wait / 1000000L);
- curTime = System.nanoTime();
- wait = 50000000L - (curTime - lastTick);
- }
- catchupTime = Math.min(60000000000L, catchupTime - wait);
- if(++currentTick % 20 == 0) {
- long diff = curTime - tickSection;
- double currentTps = 1.0E9D / (double)diff * 20.0D;
- this.tps1.add(currentTps, diff);
- this.tps5.add(currentTps, diff);
- this.tps15.add(currentTps, diff);
- this.recentTps[0] = this.tps1.getAverage();
- this.recentTps[1] = this.tps5.getAverage();
- this.recentTps[2] = this.tps15.getAverage();
- tickSection = curTime;
- }
- lastTick = curTime;
- this.A();
- }
- } else {
- this.a((CrashReport)null);
- }
- } catch (Throwable var82) {
- LOGGER.error("Encountered an unexpected exception", var82);
- if(var82.getCause() != null) {
- LOGGER.error("\tCause of unexpected exception was", var82.getCause());
- }
- CrashReport crashreport = null;
- if(var82 instanceof ReportedException) {
- crashreport = this.b(((ReportedException)var82).a());
- } else {
- crashreport = this.b(new CrashReport("Exception in server tick loop", var82));
- }
- File file = new File(new File(this.y(), "crash-reports"), "crash-" + (new SimpleDateFormat("yyyy-MM-dd_HH.mm.ss")).format(new Date()) + "-server.txt");
- if(crashreport.a(file)) {
- LOGGER.error("This crash report has been saved to: " + file.getAbsolutePath());
- } else {
- LOGGER.error("We were unable to save this crash report to disk.");
- }
- this.a(crashreport);
- } finally {
- try {
- WatchdogThread.doStop();
- this.isStopped = true;
- this.stop();
- } catch (Throwable var80) {
- LOGGER.error("Exception stopping the server", var80);
- } finally {
- try {
- this.reader.getTerminal().restore();
- } catch (Exception var79) {
- ;
- }
- this.z();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement