Initial watchdog setup. Bukkit needs adapters, everything needs testing.

This commit is contained in:
Kenzie Togami
2019-09-04 20:55:47 -07:00
parent a515ed0a30
commit 8af68fc884
15 changed files with 293 additions and 1 deletions

View File

@ -32,6 +32,7 @@ import com.sk89q.worldedit.world.registry.Registries;
import net.minecraft.command.Commands;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.dedicated.DedicatedServer;
import net.minecraft.server.management.PlayerList;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SharedConstants;
@ -56,12 +57,15 @@ class ForgePlatform extends AbstractPlatform implements MultiUserPlatform {
private final ForgeWorldEdit mod;
private final MinecraftServer server;
private final ForgeDataFixer dataFixer;
private final @Nullable ForgeWatchdog watchdog;
private boolean hookingEvents = false;
ForgePlatform(ForgeWorldEdit mod) {
this.mod = mod;
this.server = ServerLifecycleHooks.getCurrentServer();
this.dataFixer = new ForgeDataFixer(getDataVersion());
this.watchdog = server instanceof DedicatedServer
? new ForgeWatchdog((DedicatedServer) server) : null;
}
boolean isHookingEvents() {
@ -98,6 +102,12 @@ class ForgePlatform extends AbstractPlatform implements MultiUserPlatform {
return -1;
}
@Override
@Nullable
public ForgeWatchdog getWatchdog() {
return watchdog;
}
@Override
public List<? extends World> getWorlds() {
Iterable<ServerWorld> worlds = server.getWorlds();

View File

@ -0,0 +1,38 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.forge;
import com.sk89q.worldedit.extension.platform.Watchdog;
import net.minecraft.server.dedicated.DedicatedServer;
import net.minecraft.util.Util;
class ForgeWatchdog implements Watchdog {
private final DedicatedServer server;
ForgeWatchdog(DedicatedServer server) {
this.server = server;
}
@Override
public void tick() {
server.serverTime = Util.milliTime();
}
}

View File

@ -0,0 +1 @@
public net.minecraft.server.MinecraftServer field_211151_aa # serverTime