Reverts changes since they didnt resolve issues

This commit is contained in:
Sotr
2018-07-14 02:40:35 +08:00
parent 269e1c30f1
commit ca8e0d7c0f
6 changed files with 4 additions and 67 deletions

View File

@@ -7,8 +7,6 @@ import java.util.concurrent.ExecutorCompletionService;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadFactory;
import javax.annotation.Nonnull;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import com.google.common.collect.Queues;
@@ -17,11 +15,7 @@ import com.google.common.util.concurrent.ThreadFactoryBuilder;
import co.aikar.timings.Timing;
import co.aikar.timings.Timings;
import io.akarin.server.core.AkarinGlobalConfig;
import net.minecraft.server.Entity;
import net.minecraft.server.EntityTracker;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.Packet;
import net.minecraft.server.PlayerConnection;
@SuppressWarnings("restriction")
public abstract class Akari {
@@ -40,15 +34,6 @@ public abstract class Akari {
*/
public static final Queue<Runnable> callbackQueue = Queues.newConcurrentLinkedQueue();
/**
* Lock-free packet queue for slack service
*/
public static final Queue<Packet<?>> slackPackets = Queues.newConcurrentLinkedQueue();
public static void sendPacket(PlayerConnection conn, @Nonnull Packet<?> packet) {
if (!conn.processedDisconnect) slackPackets.add(packet);
}
public static class AssignableThread extends Thread {
public AssignableThread(Runnable run) {
super(run);

View File

@@ -1,7 +0,0 @@
package io.akarin.api.internal.mixin;
import net.minecraft.server.EnumDifficulty;
public interface IMixinWorldData {
public void setDifficultyAsync(EnumDifficulty diff);
}

View File

@@ -4,7 +4,6 @@ import com.google.common.base.Predicate;
import com.google.common.collect.Iterables;
import io.akarin.api.internal.Akari;
import io.akarin.api.internal.mixin.IMixinWorldData;
import net.minecraft.server.EntityPlayer;
import net.minecraft.server.EnumDifficulty;
import net.minecraft.server.MinecraftServer;
@@ -46,7 +45,7 @@ public class AkarinSlackScheduler extends Thread {
if (++updateTime >= AkarinGlobalConfig.timeUpdateInterval) {
for (EntityPlayer player : server.getPlayerList().players) {
// Add support for per player time
Akari.sendPacket(player.playerConnection, new PacketPlayOutUpdateTime(player.world.getTime(), player.getPlayerTime(), player.world.getGameRules().getBoolean("doDaylightCycle")));
player.playerConnection.sendPacket(new PacketPlayOutUpdateTime(player.world.getTime(), player.getPlayerTime(), player.world.getGameRules().getBoolean("doDaylightCycle")));
}
updateTime = 0;
}
@@ -71,7 +70,7 @@ public class AkarinSlackScheduler extends Thread {
conn.setPendingPing(true);
conn.setLastPing(currentTime);
conn.setKeepAliveID(currentTime);
Akari.sendPacket(conn, new PacketPlayOutKeepAlive(conn.getKeepAliveID())); // 15s lagg you should stop your server
conn.sendPacket(new PacketPlayOutKeepAlive(conn.getKeepAliveID())); // 15s lagg you should stop your server
}
}
}
@@ -80,14 +79,14 @@ public class AkarinSlackScheduler extends Thread {
if (AkarinGlobalConfig.forceHardcoreDifficulty)
for (WorldServer world : server.worlds) {
if (world.getWorldData().isHardcore() && world.getDifficulty() != EnumDifficulty.HARD) {
((IMixinWorldData) world.getWorldData()).setDifficultyAsync(EnumDifficulty.HARD);
world.getWorldData().setDifficulty(EnumDifficulty.HARD);
}
}
// Update player info, from PlayerList#tick
if (++resendPlayersInfo > AkarinGlobalConfig.playersInfoUpdateInterval) {
for (EntityPlayer player : server.getPlayerList().players) {
Akari.sendPacket(player.playerConnection, new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.UPDATE_LATENCY, Iterables.filter(server.getPlayerList().players, new Predicate<EntityPlayer>() {
player.playerConnection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.UPDATE_LATENCY, Iterables.filter(server.getPlayerList().players, new Predicate<EntityPlayer>() {
@Override
public boolean apply(EntityPlayer each) {
return player.getBukkitEntity().canSee(each.getBukkitEntity());

View File

@@ -1,32 +0,0 @@
package io.akarin.server.mixin.core;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import io.akarin.api.internal.Akari;
import io.akarin.api.internal.mixin.IMixinWorldData;
import net.minecraft.server.EntityHuman;
import net.minecraft.server.EntityPlayer;
import net.minecraft.server.EnumDifficulty;
import net.minecraft.server.PacketPlayOutServerDifficulty;
import net.minecraft.server.WorldData;
import net.minecraft.server.WorldServer;
@Mixin(value = WorldData.class, remap = false)
public abstract class MixinWorldData implements IMixinWorldData {
@Shadow(aliases = "C") private volatile EnumDifficulty difficulty;
@Shadow public WorldServer world;
@Shadow abstract public EnumDifficulty getDifficulty();
@Shadow abstract public boolean isDifficultyLocked();
@Override
public void setDifficultyAsync(EnumDifficulty diff) {
difficulty = diff;
PacketPlayOutServerDifficulty packet = new PacketPlayOutServerDifficulty(this.getDifficulty(), this.isDifficultyLocked());
for (EntityHuman player : world.players) {
Akari.sendPacket(((EntityPlayer) player).playerConnection, packet);
}
}
}

View File

@@ -8,7 +8,6 @@ import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;
import io.akarin.api.internal.Akari;
import io.akarin.api.internal.collections.CheckedConcurrentLinkedQueue;
import io.netty.channel.Channel;
import io.netty.util.concurrent.Future;
@@ -32,12 +31,6 @@ public abstract class OptimisticNetworkManager {
@Overwrite // PAIL: trySendQueue
private boolean m() {
// Akarin start - process slack packets
while (!Akari.slackPackets.isEmpty()) {
// Plugins that hook into those packets will notify their listeners later, so keep sync
dispatchPacket(Akari.slackPackets.poll(), null);
}
// Akarin end
if (this.channel != null && this.channel.isOpen()) {
if (this.packets.isEmpty()) { // return if the packet queue is empty so that the write lock by Anti-Xray doesn't affect the vanilla performance at all
return true;

View File

@@ -15,7 +15,6 @@
"core.MixinWorld",
"core.MixinMCUtil",
"core.MixinWorldData",
"core.MixinPlayerList",
"core.MixinCommandBan",
"core.MixinCommandKick",