Move difficulty detect to slack service

This commit is contained in:
Sotr
2018-06-18 01:50:48 +08:00
parent 30f6e3f56f
commit 1e93929534
3 changed files with 12 additions and 3 deletions

View File

@@ -2,10 +2,12 @@ package io.akarin.server.core;
import io.akarin.api.internal.Akari;
import net.minecraft.server.EntityPlayer;
import net.minecraft.server.EnumDifficulty;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.PacketPlayOutKeepAlive;
import net.minecraft.server.PacketPlayOutUpdateTime;
import net.minecraft.server.PlayerConnection;
import net.minecraft.server.WorldServer;
public class AkarinSlackScheduler extends Thread {
public static AkarinSlackScheduler get() {
@@ -63,6 +65,12 @@ public class AkarinSlackScheduler extends Thread {
}
}
for (WorldServer world : server.worlds) {
if (world.getWorldData().isHardcore() && world.getDifficulty() != EnumDifficulty.HARD) {
world.getWorldData().setDifficulty(EnumDifficulty.HARD);
}
}
try {
Thread.sleep(100);
} catch (InterruptedException ex) {

View File

@@ -47,7 +47,7 @@ public class WorldData {
private boolean z;
private boolean A;
private boolean B;
private EnumDifficulty C;
private volatile EnumDifficulty C; // Akarin - volatile
private boolean D;
private double E;
private double F;

View File

@@ -277,9 +277,10 @@ public class WorldServer extends World implements IAsyncTaskHandler {
@Override
public void doTick() {
super.doTick();
if (this.getWorldData().isHardcore() && this.getDifficulty() != EnumDifficulty.HARD) {
// Akarin start - goes to slack service
/* if (this.getWorldData().isHardcore() && this.getDifficulty() != EnumDifficulty.HARD) {
this.getWorldData().setDifficulty(EnumDifficulty.HARD);
}
} */ // Akarin end
this.worldProvider.k().b();
if (this.everyoneDeeplySleeping()) {