This commit is contained in:
Kenzie Togami
2019-09-04 20:55:47 -07:00
committed by Jesse Boyd
parent 1b07846746
commit 122f3b2562
14 changed files with 609 additions and 12 deletions

View File

@ -32,6 +32,7 @@ import com.sk89q.worldedit.world.registry.Registries;
import net.minecraft.command.Commands;
import net.minecraft.entity.player.EntityPlayerMP;
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.world.WorldServer;
@ -48,11 +49,16 @@ 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() {
@ -84,6 +90,16 @@ class ForgePlatform extends AbstractPlatform implements MultiUserPlatform {
Iterable<WorldServer> worlds = server.getWorlds();
List<com.sk89q.worldedit.world.World> ret = new ArrayList<>();
for (WorldServer world : worlds) {
@Nullable
public ForgeWatchdog getWatchdog() {
return watchdog;
}
@Override
public List<? extends World> getWorlds() {
Iterable<ServerWorld> worlds = server.getWorlds();
List<World> ret = new ArrayList<>();
for (ServerWorld world : worlds) {
ret.add(new ForgeWorld(world));
}
return ret;

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