mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-04 03:56:41 +00:00
Disable watchdog ticking by default, //watchdog to turn on
This commit is contained in:
@ -26,10 +26,12 @@ import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.command.util.CommandPermissions;
|
||||
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
|
||||
import com.sk89q.worldedit.command.util.HookMode;
|
||||
import com.sk89q.worldedit.command.util.WorldEditAsyncCommandBuilder;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.extension.input.DisallowedUsageException;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.extension.platform.Capability;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.util.formatting.component.PaginationBox;
|
||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||
@ -198,6 +200,29 @@ public class GeneralCommands {
|
||||
}
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "/watchdog",
|
||||
desc = "Changes watchdog hook state.",
|
||||
descFooter = "This is dependent on platform implementation. " +
|
||||
"Not all platforms support watchdog hooks, or contain a watchdog."
|
||||
)
|
||||
@CommandPermissions("worldedit.watchdog")
|
||||
public void watchdog(Actor actor, LocalSession session,
|
||||
@Arg(desc = "The mode to set the watchdog hook to", def = "")
|
||||
HookMode hookMode) {
|
||||
if (WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS).getWatchdog() == null) {
|
||||
actor.printError("This platform has no watchdog hook.");
|
||||
return;
|
||||
}
|
||||
boolean previousMode = session.isTickingWatchdog();
|
||||
if (hookMode != null && (hookMode == HookMode.ACTIVE) == previousMode) {
|
||||
actor.printError("Watchdog hook already " + (previousMode ? "active" : "inactive") + ".");
|
||||
return;
|
||||
}
|
||||
session.setTickingWatchdog(!previousMode);
|
||||
actor.print("Watchdog hook now " + (previousMode ? "inactive" : "active") + ".");
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "gmask",
|
||||
aliases = {"/gmask"},
|
||||
|
@ -21,6 +21,7 @@ package com.sk89q.worldedit.command.argument;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.command.util.HookMode;
|
||||
import com.sk89q.worldedit.util.TreeGenerator;
|
||||
import org.enginehub.piston.CommandManager;
|
||||
import org.enginehub.piston.converter.ArgumentConverter;
|
||||
@ -46,6 +47,8 @@ public final class EnumConverter {
|
||||
full(EditSession.ReorderMode.class,
|
||||
r -> ImmutableSet.of(r.getDisplayName()),
|
||||
null));
|
||||
commandManager.registerConverter(Key.of(HookMode.class),
|
||||
basic(HookMode.class));
|
||||
}
|
||||
|
||||
private static <E extends Enum<E>> ArgumentConverter<E> basic(Class<E> enumClass) {
|
||||
|
@ -0,0 +1,24 @@
|
||||
/*
|
||||
* 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.command.util;
|
||||
|
||||
public enum HookMode {
|
||||
ACTIVE, INACTIVE
|
||||
}
|
Reference in New Issue
Block a user