2014-04-03 02:08:50 +00:00
|
|
|
/*
|
2014-04-04 22:03:18 +00:00
|
|
|
* WorldEdit, a Minecraft world manipulation toolkit
|
|
|
|
* Copyright (C) sk89q <http://www.sk89q.com>
|
|
|
|
* Copyright (C) WorldEdit team and contributors
|
2014-04-03 02:08:50 +00:00
|
|
|
*
|
2014-04-04 22:03:18 +00:00
|
|
|
* 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
|
2014-04-03 02:08:50 +00:00
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
2014-04-04 22:03:18 +00:00
|
|
|
* 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.
|
2014-04-03 02:08:50 +00:00
|
|
|
*
|
2014-04-04 22:03:18 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
2014-04-03 02:08:50 +00:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2014-04-04 22:03:18 +00:00
|
|
|
*/
|
2014-04-03 02:08:50 +00:00
|
|
|
|
|
|
|
package com.sk89q.worldedit.command;
|
|
|
|
|
2018-08-12 14:03:07 +00:00
|
|
|
import com.boydti.fawe.Fawe;
|
|
|
|
import com.boydti.fawe.FaweVersion;
|
|
|
|
import com.boydti.fawe.config.BBC;
|
|
|
|
import com.boydti.fawe.config.Settings;
|
2019-06-06 22:39:51 +00:00
|
|
|
import com.boydti.fawe.util.IncendoPaster;
|
2018-07-30 13:26:06 +00:00
|
|
|
import com.sk89q.worldedit.LocalSession;
|
|
|
|
import com.sk89q.worldedit.WorldEdit;
|
|
|
|
import com.sk89q.worldedit.WorldEditException;
|
2019-07-06 00:46:48 +00:00
|
|
|
import com.sk89q.worldedit.command.util.CommandPermissions;
|
|
|
|
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
|
2019-07-18 17:10:04 +00:00
|
|
|
import com.sk89q.worldedit.command.util.CommandQueued;
|
|
|
|
import com.sk89q.worldedit.command.util.CommandQueuedConditionGenerator;
|
2019-07-06 00:46:48 +00:00
|
|
|
import com.sk89q.worldedit.command.util.PrintCommandHelp;
|
2014-06-28 08:01:49 +00:00
|
|
|
import com.sk89q.worldedit.entity.Player;
|
2014-07-28 03:44:05 +00:00
|
|
|
import com.sk89q.worldedit.event.platform.ConfigurationLoadEvent;
|
2018-12-18 09:28:55 +00:00
|
|
|
import com.sk89q.worldedit.extension.platform.Actor;
|
|
|
|
import com.sk89q.worldedit.extension.platform.Capability;
|
2019-08-06 15:29:49 +00:00
|
|
|
import com.sk89q.worldedit.extension.platform.NoCapablePlatformException;
|
2019-06-06 22:39:51 +00:00
|
|
|
import com.sk89q.worldedit.extension.platform.Platform;
|
|
|
|
import com.sk89q.worldedit.extension.platform.PlatformManager;
|
2018-12-18 09:28:55 +00:00
|
|
|
import java.io.IOException;
|
2019-07-06 00:46:48 +00:00
|
|
|
import java.time.ZoneId;
|
|
|
|
import java.time.ZonedDateTime;
|
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
|
import java.time.format.TextStyle;
|
|
|
|
import java.time.zone.ZoneRulesException;
|
2019-06-06 22:39:51 +00:00
|
|
|
import java.util.Date;
|
|
|
|
import java.util.GregorianCalendar;
|
2019-07-06 00:46:48 +00:00
|
|
|
import java.util.List;
|
|
|
|
import java.util.Locale;
|
2019-06-06 22:39:51 +00:00
|
|
|
import java.util.Map;
|
2019-07-06 00:46:48 +00:00
|
|
|
import org.enginehub.piston.annotation.Command;
|
|
|
|
import org.enginehub.piston.annotation.CommandContainer;
|
|
|
|
import org.enginehub.piston.annotation.param.Arg;
|
|
|
|
import org.enginehub.piston.annotation.param.ArgFlag;
|
|
|
|
import org.enginehub.piston.annotation.param.Switch;
|
2014-04-03 02:08:50 +00:00
|
|
|
|
2019-07-18 17:10:04 +00:00
|
|
|
@CommandContainer(superTypes = {CommandPermissionsConditionGenerator.Registration.class, CommandQueuedConditionGenerator.Registration.class})
|
2014-04-03 02:08:50 +00:00
|
|
|
public class WorldEditCommands {
|
2019-07-06 00:46:48 +00:00
|
|
|
|
|
|
|
private static final DateTimeFormatter dateFormat = DateTimeFormatter
|
|
|
|
.ofPattern("yyyy-MM-dd HH:mm:ss z");
|
2018-08-12 14:03:07 +00:00
|
|
|
|
2014-04-03 02:08:50 +00:00
|
|
|
private final WorldEdit we;
|
2018-08-12 14:03:07 +00:00
|
|
|
|
2014-04-03 02:08:50 +00:00
|
|
|
public WorldEditCommands(WorldEdit we) {
|
|
|
|
this.we = we;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
2019-07-06 00:46:48 +00:00
|
|
|
name = "version",
|
|
|
|
aliases = { "ver" },
|
|
|
|
desc = "Get WorldEdit/FAWE version"
|
2014-04-03 02:08:50 +00:00
|
|
|
)
|
2019-07-18 17:10:04 +00:00
|
|
|
@CommandQueued(false)
|
2019-07-06 00:46:48 +00:00
|
|
|
public void version(Actor actor) {
|
2018-08-12 14:03:07 +00:00
|
|
|
FaweVersion fVer = Fawe.get().getVersion();
|
2019-05-05 08:37:11 +00:00
|
|
|
String fVerStr = fVer == null ? "unknown" : "-" + fVer.build;
|
2019-07-06 00:46:48 +00:00
|
|
|
actor.print("FastAsyncWorldEdit" + fVerStr + " created by Empire92");
|
2019-07-18 06:56:57 +00:00
|
|
|
|
2018-08-12 14:03:07 +00:00
|
|
|
if (fVer != null) {
|
2019-06-06 22:39:51 +00:00
|
|
|
actor.printDebug("----------- Platforms -----------");
|
2018-08-12 14:03:07 +00:00
|
|
|
FaweVersion version = Fawe.get().getVersion();
|
2019-07-06 00:46:48 +00:00
|
|
|
Date date = new GregorianCalendar(2000 + version.year, version.month - 1, version.day)
|
|
|
|
.getTime();
|
2018-08-12 14:03:07 +00:00
|
|
|
actor.printDebug(" - DATE: " + date.toLocaleString());
|
|
|
|
actor.printDebug(" - COMMIT: " + Integer.toHexString(version.hash));
|
2019-04-28 18:11:05 +00:00
|
|
|
actor.printDebug(" - BUILD: " + version.build);
|
2018-08-12 14:03:07 +00:00
|
|
|
actor.printDebug(" - PLATFORM: " + Settings.IMP.PLATFORM);
|
|
|
|
actor.printDebug("------------------------------------");
|
|
|
|
}
|
2014-04-06 06:27:10 +00:00
|
|
|
PlatformManager pm = we.getPlatformManager();
|
2019-06-06 22:39:51 +00:00
|
|
|
|
|
|
|
actor.printDebug("----------- Platforms -----------");
|
2014-04-06 06:27:10 +00:00
|
|
|
for (Platform platform : pm.getPlatforms()) {
|
2019-07-06 00:46:48 +00:00
|
|
|
actor.printDebug(String.format("* %s (%s)", platform.getPlatformName(), platform.getPlatformVersion()));
|
2014-06-27 20:14:55 +00:00
|
|
|
}
|
2019-06-06 22:39:51 +00:00
|
|
|
|
|
|
|
actor.printDebug("----------- Capabilities -----------");
|
2014-06-27 20:14:55 +00:00
|
|
|
for (Capability capability : Capability.values()) {
|
2019-08-06 15:29:49 +00:00
|
|
|
try {
|
|
|
|
Platform platform = pm.queryCapability(capability);
|
|
|
|
actor.printDebug(String.format("%s: %s", capability.name(),
|
|
|
|
platform != null ? platform.getPlatformName() : "NONE"));
|
|
|
|
} catch (NoCapablePlatformException e) {
|
|
|
|
actor.printDebug(String.format("%s: %s", capability.name(), "NONE"));
|
|
|
|
}
|
2014-04-06 06:27:10 +00:00
|
|
|
}
|
2019-07-25 18:44:10 +00:00
|
|
|
actor.printDebug("");
|
2019-09-14 03:05:16 +00:00
|
|
|
actor.printDebug("Wiki: https://github.com/IntellectualSites/FastAsyncWorldEdit-1.13/wiki");
|
2014-04-03 02:08:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
2019-07-06 00:46:48 +00:00
|
|
|
name = "reload",
|
|
|
|
desc = "Reload configuration and translations"
|
2014-04-03 02:08:50 +00:00
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.reload")
|
2019-07-06 00:46:48 +00:00
|
|
|
public void reload(Actor actor) {
|
2018-06-17 12:04:35 +00:00
|
|
|
we.getPlatformManager().queryCapability(Capability.CONFIGURATION).reload();
|
2014-07-28 03:44:05 +00:00
|
|
|
we.getEventBus().post(new ConfigurationLoadEvent(we.getPlatformManager().queryCapability(Capability.CONFIGURATION).getConfiguration()));
|
2018-08-12 14:03:07 +00:00
|
|
|
Fawe.get().setupConfigs();
|
2019-06-06 22:39:51 +00:00
|
|
|
actor.print("Configuration and translations reloaded!");
|
2018-08-12 14:03:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
2019-07-06 00:46:48 +00:00
|
|
|
name = "report",
|
|
|
|
aliases = { "debugpaste" },
|
2019-08-06 15:29:49 +00:00
|
|
|
desc = "Writes a report of latest.log, config.yml, message.yml https://athion.net/ISPaster/paste"
|
2018-08-12 14:03:07 +00:00
|
|
|
)
|
2019-07-18 17:10:04 +00:00
|
|
|
@CommandQueued(false)
|
2019-07-06 00:46:48 +00:00
|
|
|
@CommandPermissions({"worldedit.report", "worldedit.debugpaste"})
|
|
|
|
public void report(Actor actor) throws WorldEditException, IOException {
|
2019-03-24 22:02:32 +00:00
|
|
|
BBC.DOWNLOAD_LINK.send(actor, IncendoPaster.debugPaste());
|
2014-04-03 02:08:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
2019-07-06 00:46:48 +00:00
|
|
|
name = "threads",
|
|
|
|
desc = "Print all thread stacks"
|
2014-04-03 02:08:50 +00:00
|
|
|
)
|
2019-07-18 17:10:04 +00:00
|
|
|
@CommandQueued(false)
|
2018-08-12 14:03:07 +00:00
|
|
|
@CommandPermissions("worldedit.threads")
|
|
|
|
public void threads(Actor actor) throws WorldEditException {
|
|
|
|
Map<Thread, StackTraceElement[]> stacks = Thread.getAllStackTraces();
|
|
|
|
for (Map.Entry<Thread, StackTraceElement[]> entry : stacks.entrySet()) {
|
|
|
|
Thread thread = entry.getKey();
|
2019-07-06 00:46:48 +00:00
|
|
|
actor.printDebug(
|
|
|
|
"--------------------------------------------------------------------------------------------");
|
|
|
|
actor.printDebug(
|
|
|
|
"Thread: " + thread.getName() + " | Id: " + thread.getId() + " | Alive: " + thread
|
|
|
|
.isAlive());
|
2018-08-12 14:03:07 +00:00
|
|
|
for (StackTraceElement elem : entry.getValue()) {
|
|
|
|
actor.printDebug(elem.toString());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
2019-07-06 00:46:48 +00:00
|
|
|
name = "cui",
|
|
|
|
desc = "Complete CUI handshake (internal usage)"
|
2018-08-12 14:03:07 +00:00
|
|
|
)
|
2019-07-06 00:46:48 +00:00
|
|
|
public void cui(Player player, LocalSession session) {
|
2014-04-03 02:08:50 +00:00
|
|
|
session.setCUISupport(true);
|
|
|
|
session.dispatchCUISetup(player);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
2019-07-06 00:46:48 +00:00
|
|
|
name = "tz",
|
|
|
|
desc = "Set your timezone for snapshots"
|
2014-04-03 02:08:50 +00:00
|
|
|
)
|
2019-08-06 15:29:49 +00:00
|
|
|
public void tz(Actor actor, LocalSession session,
|
2019-07-06 00:46:48 +00:00
|
|
|
@Arg(desc = "The timezone to set")
|
|
|
|
String timezone) {
|
|
|
|
try {
|
|
|
|
ZoneId tz = ZoneId.of(timezone);
|
|
|
|
session.setTimezone(tz);
|
2019-08-06 15:29:49 +00:00
|
|
|
BBC.TIMEZONE_SET.send(actor, tz.getDisplayName(
|
2019-07-06 00:46:48 +00:00
|
|
|
TextStyle.FULL, Locale.ENGLISH
|
|
|
|
));
|
|
|
|
BBC.TIMEZONE_DISPLAY
|
2019-08-06 15:29:49 +00:00
|
|
|
.send(actor, dateFormat.format(ZonedDateTime.now(tz)));
|
2019-07-06 00:46:48 +00:00
|
|
|
} catch (ZoneRulesException e) {
|
2019-08-06 15:29:49 +00:00
|
|
|
actor.printError("Invalid timezone");
|
2019-07-06 00:46:48 +00:00
|
|
|
}
|
2014-04-03 02:08:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
2019-07-06 00:46:48 +00:00
|
|
|
name = "help",
|
|
|
|
desc = "Displays help for FAWE commands"
|
2014-04-03 02:08:50 +00:00
|
|
|
)
|
2019-07-18 17:10:04 +00:00
|
|
|
@CommandQueued(false)
|
2019-06-06 22:39:51 +00:00
|
|
|
@CommandPermissions("worldedit.help")
|
2019-07-06 00:46:48 +00:00
|
|
|
public void help(Actor actor,
|
|
|
|
@Switch(name = 's', desc = "List sub-commands of the given command, if applicable")
|
|
|
|
boolean listSubCommands,
|
|
|
|
@ArgFlag(name = 'p', desc = "The page to retrieve", def = "1")
|
|
|
|
int page,
|
|
|
|
@Arg(desc = "The command to retrieve help for", def = "", variable = true)
|
2019-08-06 20:18:44 +00:00
|
|
|
List<String> commandStr) throws WorldEditException {
|
2019-09-14 03:05:16 +00:00
|
|
|
PrintCommandHelp.help(commandStr, page, listSubCommands,
|
|
|
|
we.getPlatformManager().getPlatformCommandManager().getCommandManager(), actor, "/worldedit help");
|
2014-04-03 02:08:50 +00:00
|
|
|
}
|
|
|
|
}
|