Skip to content
Permalink
Browse files

Properly use mixins to implement Watchdog

  • Loading branch information...
kenzierocks committed Sep 30, 2019
1 parent da0ef12 commit a273e27eda69fd165daa2cb689f648829c04a132
@@ -26,7 +26,7 @@
import com.sk89q.worldedit.extension.platform.Capability;
import com.sk89q.worldedit.extension.platform.MultiUserPlatform;
import com.sk89q.worldedit.extension.platform.Preference;
import com.sk89q.worldedit.fabric.mixin.MixinMinecraftServer;
import com.sk89q.worldedit.extension.platform.Watchdog;
import com.sk89q.worldedit.world.DataFixer;
import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.registry.Registries;
@@ -58,15 +58,15 @@
private final FabricWorldEdit mod;
private final MinecraftServer server;
private final FabricDataFixer dataFixer;
private final @Nullable FabricWatchdog watchdog;
private final @Nullable Watchdog watchdog;
private boolean hookingEvents = false;

FabricPlatform(FabricWorldEdit mod, MinecraftServer server) {
this.mod = mod;
this.server = server;
this.dataFixer = new FabricDataFixer(getDataVersion());
this.watchdog = server instanceof MinecraftDedicatedServer
? new FabricWatchdog((MinecraftDedicatedServer) server) : null;
? (Watchdog) server : null;
}

boolean isHookingEvents() {
@@ -105,7 +105,7 @@ public int schedule(long delay, long period, Runnable task) {

@Override
@Nullable
public FabricWatchdog getWatchdog() {
public Watchdog getWatchdog() {
return watchdog;
}

This file was deleted.

@@ -19,21 +19,26 @@

package com.sk89q.worldedit.fabric.mixin;

import com.sk89q.worldedit.extension.platform.Watchdog;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.ServerTask;
import net.minecraft.server.command.CommandOutput;
import net.minecraft.util.NonBlockingThreadExecutor;
import net.minecraft.util.snooper.SnooperListener;
import net.minecraft.util.SystemUtil;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;

@Mixin(MinecraftServer.class)
public abstract class MixinMinecraftServer extends NonBlockingThreadExecutor<ServerTask> implements SnooperListener, CommandOutput, AutoCloseable, Runnable {
public abstract class MixinMinecraftServer extends NonBlockingThreadExecutor implements Watchdog {

public MixinMinecraftServer(String name) {
super(name);
}

@Shadow
public long timeReference;
private long timeReference;

@Override
public void tick() {
timeReference = SystemUtil.getMeasuringTimeMs();
}

}
@@ -11,4 +11,4 @@
"injectors": {
"defaultRequire": 1
}
}
}

0 comments on commit a273e27

Please sign in to comment.
You can’t perform that action at this time.