mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-06 04:46:40 +00:00
Major command changes that don't work yet.
This commit is contained in:
@ -24,36 +24,40 @@ import com.boydti.fawe.FaweVersion;
|
||||
import com.boydti.fawe.config.BBC;
|
||||
import com.boydti.fawe.config.Settings;
|
||||
import com.boydti.fawe.util.IncendoPaster;
|
||||
import com.sk89q.minecraft.util.commands.Command;
|
||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
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.PrintCommandHelp;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.event.platform.ConfigurationLoadEvent;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.extension.platform.Capability;
|
||||
import com.sk89q.worldedit.extension.platform.Capability;
|
||||
import com.sk89q.worldedit.extension.platform.CommandManager;
|
||||
import com.sk89q.worldedit.extension.platform.Platform;
|
||||
import com.sk89q.worldedit.extension.platform.Platform;
|
||||
import com.sk89q.worldedit.extension.platform.PlatformManager;
|
||||
import com.sk89q.worldedit.extension.platform.PlatformManager;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.format.TextStyle;
|
||||
import java.time.zone.ZoneRulesException;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.TimeZone;
|
||||
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;
|
||||
|
||||
@Command(aliases = {"worldedit", "we", "fawe"}, desc = "Updating, informational, debug and help commands")
|
||||
@CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class)
|
||||
public class WorldEditCommands {
|
||||
private static final DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z");
|
||||
|
||||
private static final DateTimeFormatter dateFormat = DateTimeFormatter
|
||||
.ofPattern("yyyy-MM-dd HH:mm:ss z");
|
||||
|
||||
private final WorldEdit we;
|
||||
|
||||
@ -62,21 +66,20 @@ public class WorldEditCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "version", "ver" },
|
||||
usage = "",
|
||||
desc = "Get WorldEdit/FAWE version",
|
||||
min = 0,
|
||||
max = 0,
|
||||
queued = false
|
||||
name = "version",
|
||||
aliases = { "ver" },
|
||||
desc = "Get WorldEdit/FAWE version"
|
||||
//queued = false
|
||||
)
|
||||
public void version(Actor actor) throws WorldEditException {
|
||||
public void version(Actor actor) {
|
||||
FaweVersion fVer = Fawe.get().getVersion();
|
||||
String fVerStr = fVer == null ? "unknown" : "-" + fVer.build;
|
||||
actor.print("FastAsyncWorldEdit-1.13" + fVerStr + " by Empire92");
|
||||
actor.print("FastAsyncWorldEdit" + fVerStr + " created by Empire92");
|
||||
if (fVer != null) {
|
||||
actor.printDebug("----------- Platforms -----------");
|
||||
FaweVersion version = Fawe.get().getVersion();
|
||||
Date date = new GregorianCalendar(2000 + version.year, version.month - 1, version.day).getTime();
|
||||
Date date = new GregorianCalendar(2000 + version.year, version.month - 1, version.day)
|
||||
.getTime();
|
||||
actor.printDebug(" - DATE: " + date.toLocaleString());
|
||||
actor.printDebug(" - COMMIT: " + Integer.toHexString(version.hash));
|
||||
actor.printDebug(" - BUILD: " + version.build);
|
||||
@ -87,61 +90,55 @@ public class WorldEditCommands {
|
||||
|
||||
actor.printDebug("----------- Platforms -----------");
|
||||
for (Platform platform : pm.getPlatforms()) {
|
||||
actor.printDebug(String.format("* %s", platform.getPlatformName()));
|
||||
actor.printDebug(String.format("* %s (%s)", platform.getPlatformName(), platform.getPlatformVersion()));
|
||||
}
|
||||
|
||||
actor.printDebug("----------- Capabilities -----------");
|
||||
for (Capability capability : Capability.values()) {
|
||||
Platform platform = pm.queryCapability(capability);
|
||||
actor.printDebug(String.format(" - %s: %s", capability.name(), platform != null ? platform.getPlatformName() : "NONE"));
|
||||
actor.printDebug(String.format("%s: %s", capability.name(), platform != null ? platform.getPlatformName() : "NONE"));
|
||||
}
|
||||
actor.printDebug("------------------------------------");
|
||||
actor.printDebug("Wiki: " + "https://github.com/boy0001/FastAsyncWorldedit/wiki");
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "reload" },
|
||||
usage = "",
|
||||
desc = "Reload configuration and translations",
|
||||
min = 0,
|
||||
max = 0
|
||||
name = "reload",
|
||||
desc = "Reload configuration and translations"
|
||||
)
|
||||
@CommandPermissions("worldedit.reload")
|
||||
public void reload(Actor actor) throws WorldEditException {
|
||||
public void reload(Actor actor) {
|
||||
we.getPlatformManager().queryCapability(Capability.CONFIGURATION).reload();
|
||||
we.getEventBus().post(new ConfigurationLoadEvent(we.getPlatformManager().queryCapability(Capability.CONFIGURATION).getConfiguration()));
|
||||
Fawe.get().setupConfigs();
|
||||
CommandManager.getInstance().register(we.getPlatformManager().queryCapability(Capability.USER_COMMANDS));
|
||||
actor.print("Configuration and translations reloaded!");
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"debugpaste"},
|
||||
usage = "",
|
||||
desc = "Upload latest.log, config.yml, message.yml and your commands.yml to https://athion.net/ISPaster/paste",
|
||||
min = 0,
|
||||
max = 0
|
||||
name = "report",
|
||||
aliases = { "debugpaste" },
|
||||
desc = "Writes a report of latest.log, config.yml, message.yml and your commands.yml to https://athion.net/ISPaster/paste"
|
||||
)
|
||||
@CommandPermissions("worldedit.debugpaste")
|
||||
public void debugpaste(Actor actor) throws WorldEditException, IOException {
|
||||
@CommandPermissions({"worldedit.report", "worldedit.debugpaste"})
|
||||
public void report(Actor actor) throws WorldEditException, IOException {
|
||||
BBC.DOWNLOAD_LINK.send(actor, IncendoPaster.debugPaste());
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"threads"},
|
||||
usage = "",
|
||||
desc = "Print all thread stacks",
|
||||
min = 0,
|
||||
max = 0,
|
||||
queued = false
|
||||
name = "threads",
|
||||
desc = "Print all thread stacks"
|
||||
//queued = false
|
||||
)
|
||||
@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();
|
||||
actor.printDebug("--------------------------------------------------------------------------------------------");
|
||||
actor.printDebug("Thread: " + thread.getName() + " | Id: " + thread.getId() + " | Alive: " + thread.isAlive());
|
||||
actor.printDebug(
|
||||
"--------------------------------------------------------------------------------------------");
|
||||
actor.printDebug(
|
||||
"Thread: " + thread.getName() + " | Id: " + thread.getId() + " | Alive: " + thread
|
||||
.isAlive());
|
||||
for (StackTraceElement elem : entry.getValue()) {
|
||||
actor.printDebug(elem.toString());
|
||||
}
|
||||
@ -149,41 +146,47 @@ public class WorldEditCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "cui" },
|
||||
usage = "",
|
||||
desc = "Complete CUI handshake (internal usage)",
|
||||
min = 0,
|
||||
max = 0
|
||||
name = "cui",
|
||||
desc = "Complete CUI handshake (internal usage)"
|
||||
)
|
||||
public void cui(Player player, LocalSession session) throws WorldEditException {
|
||||
public void cui(Player player, LocalSession session) {
|
||||
session.setCUISupport(true);
|
||||
session.dispatchCUISetup(player);
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "tz" },
|
||||
usage = "[timezone]",
|
||||
desc = "Set your timezone for snapshots",
|
||||
min = 1,
|
||||
max = 1
|
||||
name = "tz",
|
||||
desc = "Set your timezone for snapshots"
|
||||
)
|
||||
public void tz(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||
TimeZone tz = TimeZone.getTimeZone(args.getString(0));
|
||||
session.setTimezone(tz);
|
||||
BBC.TIMEZONE_SET.send(player, tz.getDisplayName());
|
||||
BBC.TIMEZONE_DISPLAY.send(player, dateFormat.format(Calendar.getInstance(tz).getTime()));
|
||||
public void tz(Player player, LocalSession session,
|
||||
@Arg(desc = "The timezone to set")
|
||||
String timezone) {
|
||||
try {
|
||||
ZoneId tz = ZoneId.of(timezone);
|
||||
session.setTimezone(tz);
|
||||
BBC.TIMEZONE_SET.send(player, tz.getDisplayName(
|
||||
TextStyle.FULL, Locale.ENGLISH
|
||||
));
|
||||
BBC.TIMEZONE_DISPLAY
|
||||
.send(player, dateFormat.format(ZonedDateTime.now(tz)));
|
||||
} catch (ZoneRulesException e) {
|
||||
player.printError("Invalid timezone");
|
||||
}
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "help" },
|
||||
usage = "[<command>]",
|
||||
desc = "Displays help for FAWE commands",
|
||||
min = 0,
|
||||
max = -1,
|
||||
queued = false
|
||||
name = "help",
|
||||
desc = "Displays help for FAWE commands"
|
||||
//queued = false
|
||||
)
|
||||
@CommandPermissions("worldedit.help")
|
||||
public void help(Actor actor, CommandContext args) throws WorldEditException {
|
||||
UtilityCommands.help(args, we, actor);
|
||||
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)
|
||||
List<String> command) throws WorldEditException {
|
||||
PrintCommandHelp.help(command, page, listSubCommands, we, actor);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user