mirror of
https://github.com/boy0001/FastAsyncWorldedit.git
synced 2024-11-28 13:45:36 +01:00
Styling and documentation improvements
This commit is contained in:
parent
b5e500e716
commit
87341ab4fe
3
.gitignore
vendored
3
.gitignore
vendored
@ -25,4 +25,5 @@ gradle.log
|
||||
/bukkit18/build
|
||||
build
|
||||
/mvn
|
||||
spigot-1.10
|
||||
spigot-1.10
|
||||
wiki_permissions.md
|
@ -8,9 +8,6 @@ load: STARTUP
|
||||
database: false
|
||||
#softdepend: [WorldGuard, PlotSquared, MCore, Factions, GriefPrevention, Residence, Towny, PlotMe, PreciousStones]
|
||||
commands:
|
||||
fawe:
|
||||
description: (FAWE) Reload the plugin
|
||||
aliases: [/fawe,/fawereload]
|
||||
fcancel:
|
||||
description: (FAWE) Cancel your edit
|
||||
aliases: [fawecancel,/fcancel,/cancel,/fawecancel]
|
||||
|
@ -1,7 +1,6 @@
|
||||
package com.boydti.fawe;
|
||||
|
||||
import com.boydti.fawe.command.Cancel;
|
||||
import com.boydti.fawe.command.Reload;
|
||||
import com.boydti.fawe.config.BBC;
|
||||
import com.boydti.fawe.config.Commands;
|
||||
import com.boydti.fawe.config.Settings;
|
||||
@ -113,6 +112,10 @@ import com.sk89q.worldedit.util.command.SimpleDispatcher;
|
||||
import com.sk89q.worldedit.util.command.parametric.ParameterData;
|
||||
import com.sk89q.worldedit.util.command.parametric.ParametricBuilder;
|
||||
import com.sk89q.worldedit.util.command.parametric.ParametricCallable;
|
||||
import com.sk89q.worldedit.util.formatting.Fragment;
|
||||
import com.sk89q.worldedit.util.formatting.component.CommandListBox;
|
||||
import com.sk89q.worldedit.util.formatting.component.CommandUsageBox;
|
||||
import com.sk89q.worldedit.util.formatting.component.MessageBox;
|
||||
import com.sk89q.worldedit.world.registry.BundledBlockData;
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
@ -277,15 +280,29 @@ public class Fawe {
|
||||
if (Settings.IMP.UPDATE && isJava8()) {
|
||||
// Delayed updating
|
||||
updater = new Updater();
|
||||
TaskManager.IMP.async(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
update();
|
||||
}
|
||||
});
|
||||
TaskManager.IMP.repeatAsync(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
updater.update(IMP.getPlatform(), getVersion());
|
||||
update();
|
||||
}
|
||||
}, 36000);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean update() {
|
||||
if (updater != null) {
|
||||
updater.update(IMP.getPlatform(), getVersion());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isJava8 = MainUtil.getJavaVersion() >= 1.8;
|
||||
|
||||
public boolean isJava8() {
|
||||
@ -331,7 +348,6 @@ public class Fawe {
|
||||
}
|
||||
|
||||
private void setupCommands() {
|
||||
this.IMP.setupCommand("fawe", new Reload());
|
||||
this.IMP.setupCommand("fcancel", new Cancel());
|
||||
}
|
||||
|
||||
@ -404,6 +420,11 @@ public class Fawe {
|
||||
ParameterData.inject(); // Translations
|
||||
ToolUtilCommands.inject(); // Fixes + Translations
|
||||
GeneralCommands.inject(); // Translations + gmask args
|
||||
// Formatting
|
||||
MessageBox.inject();
|
||||
Fragment.inject();
|
||||
CommandListBox.inject();
|
||||
CommandUsageBox.inject();
|
||||
// Schematic
|
||||
SchematicReader.inject(); // Optimizations
|
||||
SchematicWriter.inject(); // Optimizations
|
||||
|
@ -54,6 +54,7 @@ import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
@Command(aliases = "/anvil", desc = "Manipulate billions of blocks: [More Info](https://github.com/boy0001/FastAsyncWorldedit/wiki/Anvil-API)")
|
||||
public class AnvilCommands {
|
||||
|
||||
private final WorldEdit worldEdit;
|
||||
|
@ -1,128 +0,0 @@
|
||||
package com.boydti.fawe.command;
|
||||
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.FaweVersion;
|
||||
import com.boydti.fawe.config.BBC;
|
||||
import com.boydti.fawe.object.FaweCommand;
|
||||
import com.boydti.fawe.object.FawePlayer;
|
||||
import com.boydti.fawe.util.HastebinUtility;
|
||||
import com.boydti.fawe.util.MainUtil;
|
||||
import com.boydti.fawe.util.Updater;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.Map;
|
||||
import java.util.Scanner;
|
||||
|
||||
public class Reload extends FaweCommand {
|
||||
|
||||
public Reload() {
|
||||
super("fawe.reload");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(final FawePlayer player, final String... args) {
|
||||
if (args.length != 1) {
|
||||
BBC.COMMAND_SYNTAX.send(player, "/fawe [reload|version|debugpaste|threads|changelog]");
|
||||
return false;
|
||||
}
|
||||
switch (args[0].toLowerCase()) {
|
||||
case "version": {
|
||||
FaweVersion version = Fawe.get().getVersion();
|
||||
if (version == null) {
|
||||
MainUtil.sendMessage(player, "No version information available.");
|
||||
return false;
|
||||
}
|
||||
Date date = new GregorianCalendar(2000 + version.year, version.month - 1, version.day).getTime();
|
||||
MainUtil.sendMessage(player, "Version Date: " + date.toLocaleString());
|
||||
MainUtil.sendMessage(player, "Version Commit: " + Integer.toHexString(version.hash));
|
||||
MainUtil.sendMessage(player, "Version Build: #" + version.build);
|
||||
return true;
|
||||
}
|
||||
case "threads": {
|
||||
Map<Thread, StackTraceElement[]> stacks = Thread.getAllStackTraces();
|
||||
for (Map.Entry<Thread, StackTraceElement[]> entry : stacks.entrySet()) {
|
||||
Thread thread = entry.getKey();
|
||||
Fawe.debug("--------------------------------------------------------------------------------------------");
|
||||
Fawe.debug("Thread: " + thread.getName() + " | Id: " + thread.getId() + " | Alive: " + thread.isAlive());
|
||||
for (StackTraceElement elem : entry.getValue()) {
|
||||
Fawe.debug(elem);
|
||||
}
|
||||
}
|
||||
if (player != null) {
|
||||
player.sendMessage("&cSee console.");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
case "changelog": {
|
||||
try {
|
||||
Updater updater = Fawe.get().getUpdater();
|
||||
String changes = updater != null ? updater.getChanges() : null;
|
||||
if (changes == null) {
|
||||
try (Scanner scanner = new Scanner(new URL("http://boydti.com/fawe/cl?" + Integer.toHexString(Fawe.get().getVersion().hash)).openStream(), "UTF-8")) {
|
||||
changes = scanner.useDelimiter("\\A").next();
|
||||
}
|
||||
}
|
||||
player.sendMessage(BBC.getPrefix() + changes);
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
case "debugpaste":
|
||||
case "paste": {
|
||||
try {
|
||||
String settingsYML = HastebinUtility.upload(new File(Fawe.imp().getDirectory(), "config.yml"));
|
||||
String messagesYML = HastebinUtility.upload(new File(Fawe.imp().getDirectory(), "message.yml"));
|
||||
String commandsYML = HastebinUtility.upload(new File(Fawe.imp().getDirectory(), "commands.yml"));
|
||||
String latestLOG;
|
||||
try {
|
||||
latestLOG = HastebinUtility.upload(new File(Fawe.imp().getDirectory(), "../../logs/latest.log"));
|
||||
} catch (IOException ignored) {
|
||||
MainUtil.sendMessage(player, "&clatest.log is too big to be pasted, will ignore");
|
||||
latestLOG = "too big :(";
|
||||
}
|
||||
StringBuilder b = new StringBuilder();
|
||||
b.append(
|
||||
"# Welcome to this paste\n# It is meant to provide us at IntellectualSites with better information about your "
|
||||
+ "problem\n\n# We will start with some informational files\n");
|
||||
b.append("links.config_yml: ").append(settingsYML).append('\n');
|
||||
b.append("links.messages_yml: ").append(messagesYML).append('\n');
|
||||
b.append("links.commands_yml: ").append(commandsYML).append('\n');
|
||||
b.append("links.latest_log: ").append(latestLOG).append('\n');
|
||||
b.append("\n# Server Information\n");
|
||||
b.append("version.server: ").append(Fawe.imp().getPlatform()).append('\n');
|
||||
b.append("\n\n# YAY! Now, let's see what we can find in your JVM\n");
|
||||
Runtime runtime = Runtime.getRuntime();
|
||||
b.append("memory.free: ").append(runtime.freeMemory()).append('\n');
|
||||
b.append("memory.max: ").append(runtime.maxMemory()).append('\n');
|
||||
b.append("java.specification.version: '").append(System.getProperty("java.specification.version")).append("'\n");
|
||||
b.append("java.vendor: '").append(System.getProperty("java.vendor")).append("'\n");
|
||||
b.append("java.version: '").append(System.getProperty("java.version")).append("'\n");
|
||||
b.append("os.arch: '").append(System.getProperty("os.arch")).append("'\n");
|
||||
b.append("os.name: '").append(System.getProperty("os.name")).append("'\n");
|
||||
b.append("os.version: '").append(System.getProperty("os.version")).append("'\n\n");
|
||||
b.append("# Okay :D Great. You are now ready to create your bug report!");
|
||||
b.append("\n# You can do so at https://github.com/boy0001/FastAsyncWorldedit/issues");
|
||||
|
||||
String link = HastebinUtility.upload(b.toString());
|
||||
BBC.DOWNLOAD_LINK.send(player, link);
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
case "reload": {
|
||||
Fawe.get().setupConfigs();
|
||||
MainUtil.sendMessage(player, "Reloaded (" + Fawe.get().getVersion() + ").");
|
||||
return true;
|
||||
}
|
||||
default:
|
||||
BBC.COMMAND_SYNTAX.send(player, "/fawe [reload|version|debugpaste|threads]");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
@ -216,6 +216,8 @@ public enum BBC {
|
||||
COMMAND_INVALID_SYNTAX("The command was not used properly (no more help available).", "WorldEdit.Command"),
|
||||
|
||||
HELP_HEADER_CATEGORIES("Command Types", "WorldEdit.Help"),
|
||||
HELP_HEADER_SUBCOMMANDS("Subcommands", "WorldEdit.Help"),
|
||||
HELP_HEADER_COMMAND("&cHelp for: &7%s0", "WorldEdit.Help"),
|
||||
HELP_ITEM_ALLOWED("&a%s0&8 - &7%s1", "WorldEdit.Help"),
|
||||
HELP_ITEM_DENIED("&c%s0&8 - &7%s1", "WorldEdit.Help"),
|
||||
HELP_HEADER("Help: page %s0/%s1", "WorldEdit.Help"),
|
||||
@ -272,7 +274,7 @@ public enum BBC {
|
||||
SEL_SPHERE("Sphere selector: left click=center, right click to set radius", "Selection"),
|
||||
SEL_CYLINDRICAL("Cylindrical selector: Left click=center, right click to extend.", "Selection"),
|
||||
SEL_MAX("%s0 points maximum.", "Selection"),
|
||||
SEL_FUZZY("Fuzzy selector: Left click to select all contingent blocks, right click to add", "Selection"),
|
||||
SEL_FUZZY("Fuzzy selector: Left click to select all contingent blocks, right click to add. To select an air cavity, use //pos1.", "Selection"),
|
||||
SEL_CONVEX_POLYHEDRAL("Convex polyhedral selector: Left click=First vertex, right click to add more.", "Selection"),
|
||||
SEL_LIST("For a list of selection types use:&c //sel list", "Selection"),
|
||||
SEL_MODES("Select one of the modes below:", "Selection"),
|
||||
|
@ -51,7 +51,7 @@ import javax.imageio.ImageIO;
|
||||
aliases = {"createfromheightmap", "createfromimage", "cfhm"},
|
||||
category = CommandCategory.APPEARANCE,
|
||||
requiredType = RequiredType.NONE,
|
||||
description = "Generate a world from an image",
|
||||
description = "Generate a world from an image heightmap: [More info](https://www.youtube.com/watch?v=cJZk1GTig7A)",
|
||||
usage = "/plots cfi [url or dimensions]"
|
||||
)
|
||||
public class CreateFromImage extends Command {
|
||||
|
@ -0,0 +1,179 @@
|
||||
/*
|
||||
* 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.boydti.fawe.util;
|
||||
|
||||
import com.boydti.fawe.command.AnvilCommands;
|
||||
import com.sk89q.minecraft.util.commands.Command;
|
||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||
import com.sk89q.minecraft.util.commands.NestedCommand;
|
||||
import com.sk89q.worldedit.command.BiomeCommands;
|
||||
import com.sk89q.worldedit.command.BrushCommands;
|
||||
import com.sk89q.worldedit.command.ChunkCommands;
|
||||
import com.sk89q.worldedit.command.ClipboardCommands;
|
||||
import com.sk89q.worldedit.command.GeneralCommands;
|
||||
import com.sk89q.worldedit.command.GenerationCommands;
|
||||
import com.sk89q.worldedit.command.HistoryCommands;
|
||||
import com.sk89q.worldedit.command.NavigationCommands;
|
||||
import com.sk89q.worldedit.command.RegionCommands;
|
||||
import com.sk89q.worldedit.command.SchematicCommands;
|
||||
import com.sk89q.worldedit.command.ScriptingCommands;
|
||||
import com.sk89q.worldedit.command.SelectionCommands;
|
||||
import com.sk89q.worldedit.command.SnapshotCommands;
|
||||
import com.sk89q.worldedit.command.SnapshotUtilCommands;
|
||||
import com.sk89q.worldedit.command.SuperPickaxeCommands;
|
||||
import com.sk89q.worldedit.command.ToolCommands;
|
||||
import com.sk89q.worldedit.command.ToolUtilCommands;
|
||||
import com.sk89q.worldedit.command.UtilityCommands;
|
||||
import com.sk89q.worldedit.command.WorldEditCommands;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintStream;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
@SuppressWarnings("UseOfSystemOutOrSystemErr")
|
||||
public final class DocumentationPrinter {
|
||||
|
||||
private DocumentationPrinter() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates documentation.
|
||||
*
|
||||
* @param args arguments
|
||||
* @throws IOException thrown on I/O error
|
||||
*/
|
||||
public static void main(String[] args) throws IOException {
|
||||
writePermissionsWikiTable();
|
||||
}
|
||||
|
||||
private static void writePermissionsWikiTable()
|
||||
throws IOException {
|
||||
try (FileOutputStream fos = new FileOutputStream("wiki_permissions.md")) {
|
||||
PrintStream stream = new PrintStream(fos);
|
||||
|
||||
stream.print("## Overview\n");
|
||||
stream.print("This page is generated from the source. " +
|
||||
"Click one of the edit buttons below to modify a command class. " +
|
||||
"You will need to find the parts which correspond to the documentation. " +
|
||||
"Command documentation will be consistent with what is available ingame");
|
||||
stream.println();
|
||||
stream.println();
|
||||
stream.print("To view this information ingame use `//help`");
|
||||
stream.println();
|
||||
stream.print("## See also\n");
|
||||
stream.print(" - [Masks](https://github.com/boy0001/FastAsyncWorldedit/wiki/WorldEdit---FAWE-mask-list)\n");
|
||||
stream.print(" - [Patterns](https://github.com/boy0001/FastAsyncWorldedit/wiki/WorldEdit-and-FAWE-patterns)\n");
|
||||
stream.print(" - [Transforms](https://github.com/boy0001/FastAsyncWorldedit/wiki/Transforms)\n");
|
||||
stream.println();
|
||||
stream.print("## Content");
|
||||
stream.println();
|
||||
StringBuilder builder = new StringBuilder();
|
||||
writePermissionsWikiTable(stream, builder, "/we ", WorldEditCommands.class);
|
||||
writePermissionsWikiTable(stream, builder, "/", GeneralCommands.class);
|
||||
writePermissionsWikiTable(stream, builder, "/", UtilityCommands.class);
|
||||
writePermissionsWikiTable(stream, builder, "/", RegionCommands.class);
|
||||
writePermissionsWikiTable(stream, builder, "/", SelectionCommands.class);
|
||||
writePermissionsWikiTable(stream, builder, "/", HistoryCommands.class);
|
||||
writePermissionsWikiTable(stream, builder, "/", SchematicCommands.class);
|
||||
writePermissionsWikiTable(stream, builder, "/", ClipboardCommands.class);
|
||||
writePermissionsWikiTable(stream, builder, "/", GenerationCommands.class);
|
||||
writePermissionsWikiTable(stream, builder, "/", BiomeCommands.class);
|
||||
writePermissionsWikiTable(stream, builder, "/tool ", ToolCommands.class);
|
||||
writePermissionsWikiTable(stream, builder, "/", ToolUtilCommands.class);
|
||||
writePermissionsWikiTable(stream, builder, "/brush ", BrushCommands.class);
|
||||
writePermissionsWikiTable(stream, builder, "/anvil ", AnvilCommands.class);
|
||||
writePermissionsWikiTable(stream, builder, "/sp ", SuperPickaxeCommands.class);
|
||||
writePermissionsWikiTable(stream, builder, "/", NavigationCommands.class);
|
||||
writePermissionsWikiTable(stream, builder, "/", SnapshotCommands.class);
|
||||
writePermissionsWikiTable(stream, builder, "/", SnapshotUtilCommands.class);
|
||||
writePermissionsWikiTable(stream, builder, "/", ScriptingCommands.class);
|
||||
writePermissionsWikiTable(stream, builder, "/", ChunkCommands.class);
|
||||
stream.println();
|
||||
stream.print("#### Uncategorized\n");
|
||||
stream.append("| Aliases | Permission | flags | Usage |\n");
|
||||
stream.append("| --- | --- | --- | --- |\n");
|
||||
stream.append("| //cancel | fawe.cancel | | Cancels your current operations |\n");
|
||||
stream.append("| /plot replaceall | plots.replaceall | | Replace all blocks in the plot world |\n");
|
||||
stream.append("| /plot createfromimage | plots.createfromimage | | Starts world creation from a heightmap image: [More Info](https://www.youtube.com/watch?v=cJZk1GTig7A) |\n");
|
||||
stream.print("\n---\n");
|
||||
|
||||
stream.print(builder);
|
||||
}
|
||||
}
|
||||
|
||||
private static void writePermissionsWikiTable(PrintStream stream, StringBuilder content, String prefix, Class<?> cls) {
|
||||
String title = cls.getSimpleName().replaceAll("(\\p{Ll})(\\p{Lu})", "$1 $2");
|
||||
stream.print(" - [`" + title + "`](#" + title.replaceAll(" ", "-") + "-) ");
|
||||
Command cmd = cls.getAnnotation(Command.class);
|
||||
if (cmd != null) {
|
||||
stream.print(" (" + cmd.desc() + ")");
|
||||
}
|
||||
stream.println();
|
||||
writePermissionsWikiTable(content, prefix, cls, true);
|
||||
}
|
||||
|
||||
private static void writePermissionsWikiTable(StringBuilder stream, String prefix, Class<?> cls, boolean title) {
|
||||
// //setbiome || worldedit.biome.set || //setbiome || p || Sets the biome of the player's current block or region.
|
||||
if (title) {
|
||||
String path = "https://github.com/boy0001/FastAsyncWorldedit/edit/master/core/src/main/java/" + cls.getName().replaceAll("\\.", "/") + ".java";
|
||||
stream.append("### **" + cls.getSimpleName().replaceAll("(\\p{Ll})(\\p{Lu})","$1 $2") + "** [`✎`](" + path + ")");
|
||||
stream.append("\n");
|
||||
stream.append("\n");
|
||||
stream.append("---");
|
||||
stream.append("\n");
|
||||
stream.append("\n");
|
||||
}
|
||||
for (Method method : cls.getMethods()) {
|
||||
if (!method.isAnnotationPresent(Command.class)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Command cmd = method.getAnnotation(Command.class);
|
||||
String[] aliases = cmd.aliases();
|
||||
String usage = prefix + aliases[0] + " " + cmd.usage();
|
||||
if (cmd.anyFlags()) {
|
||||
for (char c : cmd.flags().toCharArray()) {
|
||||
usage += " [-" + c + "]";
|
||||
}
|
||||
}
|
||||
// stream.append("#### [`" + usage + "`](" + "https://github.com/boy0001/FastAsyncWorldedit/wiki/" + aliases[0] + ")\n");
|
||||
stream.append("#### `" + usage + "`\n");
|
||||
if (method.isAnnotationPresent(CommandPermissions.class)) {
|
||||
CommandPermissions perms = method.getAnnotation(CommandPermissions.class);
|
||||
stream.append("**Perm**: `" + StringMan.join(perms.value(), "`, `") + "` \n");
|
||||
}
|
||||
stream.append("**Desc**: " + cmd.desc().trim().replaceAll("\n", "<br />") + " \n");
|
||||
|
||||
if (method.isAnnotationPresent(NestedCommand.class)) {
|
||||
NestedCommand nested =
|
||||
method.getAnnotation(NestedCommand.class);
|
||||
|
||||
Class<?>[] nestedClasses = nested.value();
|
||||
for (Class clazz : nestedClasses) {
|
||||
writePermissionsWikiTable(stream, prefix + cmd.aliases()[0] + " ", clazz, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
stream.append("\n");
|
||||
if (title) stream.append("---");
|
||||
stream.append("\n");
|
||||
stream.append("\n");
|
||||
}
|
||||
}
|
@ -1,5 +1,7 @@
|
||||
package com.boydti.fawe.util;
|
||||
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.config.BBC;
|
||||
import java.io.*;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
@ -60,4 +62,41 @@ public class HastebinUtility {
|
||||
return upload(content.toString());
|
||||
}
|
||||
|
||||
public static String debugPaste() throws IOException {
|
||||
String settingsYML = HastebinUtility.upload(new File(Fawe.imp().getDirectory(), "config.yml"));
|
||||
String messagesYML = HastebinUtility.upload(new File(Fawe.imp().getDirectory(), "message.yml"));
|
||||
String commandsYML = HastebinUtility.upload(new File(Fawe.imp().getDirectory(), "commands.yml"));
|
||||
String latestLOG;
|
||||
try {
|
||||
latestLOG = HastebinUtility.upload(new File(Fawe.imp().getDirectory(), "../../logs/latest.log"));
|
||||
} catch (IOException ignored) {
|
||||
latestLOG = "too big :(";
|
||||
}
|
||||
StringBuilder b = new StringBuilder();
|
||||
b.append(
|
||||
"# Welcome to this paste\n# It is meant to provide us at IntellectualSites with better information about your "
|
||||
+ "problem\n\n# We will start with some informational files\n");
|
||||
b.append("links.config_yml: ").append(settingsYML).append('\n');
|
||||
b.append("links.messages_yml: ").append(messagesYML).append('\n');
|
||||
b.append("links.commands_yml: ").append(commandsYML).append('\n');
|
||||
b.append("links.latest_log: ").append(latestLOG).append('\n');
|
||||
b.append("\n# Server Information\n");
|
||||
b.append("version.server: ").append(Fawe.imp().getPlatform()).append('\n');
|
||||
b.append("\n\n# YAY! Now, let's see what we can find in your JVM\n");
|
||||
Runtime runtime = Runtime.getRuntime();
|
||||
b.append("memory.free: ").append(runtime.freeMemory()).append('\n');
|
||||
b.append("memory.max: ").append(runtime.maxMemory()).append('\n');
|
||||
b.append("java.specification.version: '").append(System.getProperty("java.specification.version")).append("'\n");
|
||||
b.append("java.vendor: '").append(System.getProperty("java.vendor")).append("'\n");
|
||||
b.append("java.version: '").append(System.getProperty("java.version")).append("'\n");
|
||||
b.append("os.arch: '").append(System.getProperty("os.arch")).append("'\n");
|
||||
b.append("os.name: '").append(System.getProperty("os.name")).append("'\n");
|
||||
b.append("os.version: '").append(System.getProperty("os.version")).append("'\n\n");
|
||||
b.append("# Okay :D Great. You are now ready to create your bug report!");
|
||||
b.append("\n# You can do so at https://github.com/boy0001/FastAsyncWorldedit/issues");
|
||||
|
||||
String link = HastebinUtility.upload(b.toString());
|
||||
return link;
|
||||
}
|
||||
|
||||
}
|
||||
|
33
core/src/main/java/com/boydti/fawe/util/TextureUtil.java
Normal file
33
core/src/main/java/com/boydti/fawe/util/TextureUtil.java
Normal file
@ -0,0 +1,33 @@
|
||||
package com.boydti.fawe.util;
|
||||
|
||||
import com.sk89q.worldedit.world.registry.BundledBlockData;
|
||||
import java.awt.Color;
|
||||
import java.io.File;
|
||||
import java.io.FilenameFilter;
|
||||
|
||||
public class TextureUtil {
|
||||
private final File folder;
|
||||
private Color[] colors;
|
||||
|
||||
public TextureUtil(File folder) {
|
||||
this.folder = folder;
|
||||
BundledBlockData bundled = BundledBlockData.getInstance();
|
||||
for (File file : folder.listFiles(new FilenameFilter() {
|
||||
@Override
|
||||
public boolean accept(File dir, String name) {
|
||||
return name.endsWith(".png");
|
||||
}
|
||||
})) {
|
||||
String name = file.getName().split("\\.")[0];
|
||||
|
||||
}
|
||||
}
|
||||
//
|
||||
// public Color getColor(BaseBlock block) {
|
||||
// long r;
|
||||
// long b;
|
||||
// long g;
|
||||
// long a;
|
||||
//
|
||||
// }
|
||||
}
|
@ -14,15 +14,22 @@ public class Updater {
|
||||
private FaweVersion newVersion;
|
||||
private String changes;
|
||||
|
||||
public String getChanges() throws IOException {
|
||||
public String getChanges() {
|
||||
if (changes == null) {
|
||||
try (Scanner scanner = new Scanner(new URL("http://boydti.com/fawe/cl?" + Integer.toHexString(Fawe.get().getVersion().hash)).openStream(), "UTF-8")) {
|
||||
changes = scanner.useDelimiter("\\A").next();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return "";
|
||||
}
|
||||
}
|
||||
return changes;
|
||||
}
|
||||
|
||||
public boolean isOutdated() {
|
||||
return newVersion != null;
|
||||
}
|
||||
|
||||
public void update(String platform, FaweVersion currentVersion) {
|
||||
if (currentVersion == null || platform == null) {
|
||||
return;
|
||||
|
@ -63,6 +63,7 @@ import static com.sk89q.minecraft.util.commands.Logging.LogMode.REGION;
|
||||
/**
|
||||
* Implements biome-related commands such as "/biomelist".
|
||||
*/
|
||||
@Command(aliases = "/biome", desc = "Change, list and inspect biomes")
|
||||
public class BiomeCommands {
|
||||
|
||||
private final WorldEdit worldEdit;
|
||||
|
@ -109,6 +109,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
/**
|
||||
* Commands to set brush shape.
|
||||
*/
|
||||
@Command(aliases = { "brush", "br" }, desc = "Commands to build and draw from far away: [More Info](https://github.com/boy0001/FastAsyncWorldedit/wiki/Brushes)")
|
||||
public class BrushCommands {
|
||||
|
||||
private final WorldEdit worldEdit;
|
||||
@ -810,8 +811,7 @@ public class BrushCommands {
|
||||
help = "Flatten brush makes terrain flatter\n" +
|
||||
"The -r flag enables random off-axis rotation\n" +
|
||||
"The -l flag will work on snow layers",
|
||||
desc =
|
||||
"This brush raises and lowers land towards the clicked point\n",
|
||||
desc = "This brush raises and lowers land towards the clicked point\n",
|
||||
min = 1,
|
||||
max = 4
|
||||
)
|
||||
|
@ -41,6 +41,7 @@ import static com.sk89q.minecraft.util.commands.Logging.LogMode.REGION;
|
||||
/**
|
||||
* Commands for working with chunks.
|
||||
*/
|
||||
@Command(aliases = {}, desc = "[legacy] Inspect chunks: [More Info](http://wiki.sk89q.com/wiki/WorldEdit/Chunk_tools)")
|
||||
public class ChunkCommands {
|
||||
|
||||
private final WorldEdit worldEdit;
|
||||
|
@ -73,6 +73,7 @@ import static com.sk89q.minecraft.util.commands.Logging.LogMode.REGION;
|
||||
/**
|
||||
* Clipboard commands.
|
||||
*/
|
||||
@Command(aliases = {}, desc = "Related commands to copy and pasting blocks: [More Info](http://wiki.sk89q.com/wiki/WorldEdit/Clipboard)")
|
||||
public class ClipboardCommands {
|
||||
|
||||
private final WorldEdit worldEdit;
|
||||
@ -251,7 +252,7 @@ public class ClipboardCommands {
|
||||
if (!FawePlayer.wrap(player).hasPermission("fawe.tips")) BBC.TIP_LAZYCUT.send(player);
|
||||
}
|
||||
|
||||
@Command(aliases = { "download" }, desc = "Download your clipboard")
|
||||
@Command(aliases = { "download" }, desc = "Downloads your clipboard through the configured web interface")
|
||||
@Deprecated
|
||||
@CommandPermissions({ "worldedit.clipboard.download"})
|
||||
public void download(final Player player, final LocalSession session, @Optional("schematic") final String formatName) throws CommandException, WorldEditException {
|
||||
|
@ -24,6 +24,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
/**
|
||||
* General WorldEdit commands.
|
||||
*/
|
||||
@Command(aliases = {}, desc = "Player toggles, settings and item info")
|
||||
public class GeneralCommands {
|
||||
|
||||
private final WorldEdit worldEdit;
|
||||
@ -56,7 +57,7 @@ public class GeneralCommands {
|
||||
@Command(
|
||||
aliases = { "/fast" },
|
||||
usage = "[on|off]",
|
||||
desc = "Toggle fast mode",
|
||||
desc = "Toggles WorldEdit undo",
|
||||
min = 0,
|
||||
max = 1
|
||||
)
|
||||
|
@ -54,6 +54,7 @@ import static com.sk89q.minecraft.util.commands.Logging.LogMode.POSITION;
|
||||
/**
|
||||
* Commands for the generation of shapes and other objects.
|
||||
*/
|
||||
@Command(aliases = {}, desc = "Create structures and features: [More Info](http://wiki.sk89q.com/wiki/WorldEdit/Generation)")
|
||||
public class GenerationCommands {
|
||||
|
||||
private final WorldEdit worldEdit;
|
||||
|
@ -58,6 +58,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
/**
|
||||
* Commands to undo, redo, and clear history.
|
||||
*/
|
||||
@Command(aliases = {}, desc = "Commands to undo, redo, and clear history: [More Info](http://wiki.sk89q.com/wiki/WorldEdit/Features#History)")
|
||||
public class HistoryCommands {
|
||||
|
||||
private final WorldEdit worldEdit;
|
||||
@ -74,8 +75,8 @@ public class HistoryCommands {
|
||||
|
||||
@Command(
|
||||
aliases = { "/frb", "frb", "fawerollback", "/fawerollback", "/rollback" },
|
||||
usage = "<user> <radius> <time>",
|
||||
desc = "Undo edits within a radius",
|
||||
usage = "<user=Empire92> <radius=5> <time=3d4h>",
|
||||
desc = "Undo a specific edit. The time uses s, m, h, d, y.",
|
||||
min = 1,
|
||||
max = 3
|
||||
)
|
||||
|
@ -43,6 +43,7 @@ import static com.sk89q.minecraft.util.commands.Logging.LogMode.POSITION;
|
||||
/**
|
||||
* Commands for moving the player around.
|
||||
*/
|
||||
@Command(aliases = {}, desc = "Commands for moving the player around: [More Info](http://wiki.sk89q.com/wiki/WorldEdit/Getting_around)")
|
||||
public class NavigationCommands {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
|
@ -93,6 +93,7 @@ import static com.sk89q.worldedit.regions.Regions.minimumBlockY;
|
||||
/**
|
||||
* Commands that operate on regions.
|
||||
*/
|
||||
@Command(aliases = {}, desc = "Commands that operate on regions: [More Info](http://wiki.sk89q.com/wiki/WorldEdit/Region_operations)")
|
||||
public class RegionCommands {
|
||||
|
||||
private final WorldEdit worldEdit;
|
||||
|
@ -71,6 +71,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
/**
|
||||
* Commands that work with schematic files.
|
||||
*/
|
||||
@Command(aliases = {"schematic", "schem", "/schematic", "/schem"}, desc = "Commands that work with schematic files")
|
||||
public class SchematicCommands {
|
||||
|
||||
/**
|
||||
@ -90,7 +91,7 @@ public class SchematicCommands {
|
||||
this.worldEdit = worldEdit;
|
||||
}
|
||||
|
||||
@Command(aliases = { "loadall" }, usage = "[<format>] <filename|url>", desc = "Load a schematic into your clipboard")
|
||||
@Command(aliases = { "loadall" }, usage = "[<format>] <filename|url>", desc = "Load multiple clipboards (paste will randomly choose one)")
|
||||
@Deprecated
|
||||
@CommandPermissions({ "worldedit.clipboard.load", "worldedit.schematic.load", "worldedit.schematic.upload" })
|
||||
public void loadall(final Player player, final LocalSession session, @Optional("schematic") final String formatName, final String filename) throws FilenameException {
|
||||
|
@ -37,6 +37,7 @@ import static com.sk89q.minecraft.util.commands.Logging.LogMode.ALL;
|
||||
/**
|
||||
* Commands related to scripting.
|
||||
*/
|
||||
@Command(aliases = {}, desc = "Run craftscripts: [More Info](http://wiki.sk89q.com/wiki/WorldEdit/Scripting)")
|
||||
public class ScriptingCommands {
|
||||
|
||||
private final WorldEdit worldEdit;
|
||||
|
@ -73,6 +73,7 @@ import static com.sk89q.minecraft.util.commands.Logging.LogMode.REGION;
|
||||
/**
|
||||
* Selection commands.
|
||||
*/
|
||||
@Command(aliases = {}, desc = "Change your selection points, mode or view info about your selection: [More Info](http://wiki.sk89q.com/wiki/WorldEdit/Selection)")
|
||||
public class SelectionCommands {
|
||||
|
||||
private final WorldEdit we;
|
||||
@ -782,7 +783,7 @@ public class SelectionCommands {
|
||||
box.appendCommand("//sel cyl", "Select a cylinder");
|
||||
box.appendCommand("//sel convex", "Select a convex polyhedral");
|
||||
box.appendCommand("//sel polyhedral", "Select a hollow polyhedral");
|
||||
box.appendCommand("//sel fuzzy[=<mask>]", "Select all connected blocks");
|
||||
box.appendCommand("//sel fuzzy[=<mask>]", "Select all connected blocks (magic wand)");
|
||||
|
||||
player.printRaw(ColorCodeBuilder.asColorCodes(box));
|
||||
return;
|
||||
|
@ -42,6 +42,7 @@ import java.util.logging.Logger;
|
||||
/**
|
||||
* Snapshot commands.
|
||||
*/
|
||||
@Command(aliases = {"snapshot", "snap"}, desc = "List, load and view information related to snapshots")
|
||||
public class SnapshotCommands {
|
||||
|
||||
private static final Logger logger = Logger.getLogger("Minecraft.WorldEdit");
|
||||
|
@ -40,6 +40,7 @@ import java.util.logging.Logger;
|
||||
|
||||
import static com.sk89q.minecraft.util.commands.Logging.LogMode.REGION;
|
||||
|
||||
@Command(aliases = {}, desc = "[More Info](http://wiki.sk89q.com/wiki/WorldEdit/Snapshots)")
|
||||
public class SnapshotUtilCommands {
|
||||
|
||||
private static final Logger logger = Logger.getLogger("Minecraft.WorldEdit");
|
||||
|
@ -29,6 +29,7 @@ import com.sk89q.worldedit.command.tool.RecursivePickaxe;
|
||||
import com.sk89q.worldedit.command.tool.SinglePickaxe;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
|
||||
@Command(aliases = {"superpickaxe", "pickaxe", "sp"}, desc = "Super-pickaxe commands: [More Info](http://wiki.sk89q.com/wiki/WorldEdit/Super_pickaxe)")
|
||||
public class SuperPickaxeCommands {
|
||||
private final WorldEdit we;
|
||||
|
||||
|
@ -43,6 +43,7 @@ import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.util.TreeGenerator;
|
||||
import com.sk89q.worldedit.util.command.parametric.Optional;
|
||||
|
||||
@Command(aliases = {"tool"}, desc = "Bind functions to held items: [More Info](http://wiki.sk89q.com/wiki/WorldEdit/Tools)")
|
||||
public class ToolCommands {
|
||||
private final WorldEdit we;
|
||||
|
||||
|
@ -22,6 +22,7 @@ import com.sk89q.worldedit.util.command.parametric.Optional;
|
||||
/**
|
||||
* Tool commands.
|
||||
*/
|
||||
@Command(aliases = {}, desc = "Tool commands")
|
||||
public class ToolUtilCommands {
|
||||
private final WorldEdit we;
|
||||
private final DefaultTransformParser transformParser;
|
||||
|
@ -84,6 +84,7 @@ import static com.sk89q.minecraft.util.commands.Logging.LogMode.PLACEMENT;
|
||||
/**
|
||||
* Utility commands.
|
||||
*/
|
||||
@Command(aliases = {}, desc = "Various utility commands: [More Info](http://wiki.sk89q.com/wiki/WorldEdit/Utilities)")
|
||||
public class UtilityCommands {
|
||||
|
||||
private final WorldEdit we;
|
||||
@ -632,7 +633,7 @@ public class UtilityCommands {
|
||||
}
|
||||
}
|
||||
if (!(callable instanceof Dispatcher)) {
|
||||
actor.printRaw(ColorCodeBuilder.asColorCodes(new CommandUsageBox(callable, Joiner.on(" ").join(visited))));
|
||||
actor.printRaw(BBC.getPrefix() + ColorCodeBuilder.asColorCodes(new CommandUsageBox(callable, Joiner.on(" ").join(visited))));
|
||||
return;
|
||||
}
|
||||
dispatcher = (Dispatcher) callable;
|
||||
@ -697,7 +698,7 @@ public class UtilityCommands {
|
||||
actor.print(BBC.color(message.toString()));
|
||||
}
|
||||
} else {
|
||||
actor.printRaw(ColorCodeBuilder.asColorCodes(new CommandUsageBox(callable, Joiner.on(" ").join(visited))));
|
||||
actor.printRaw(BBC.getPrefix() + ColorCodeBuilder.asColorCodes(new CommandUsageBox(callable, Joiner.on(" ").join(visited))));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,12 @@
|
||||
|
||||
package com.sk89q.worldedit.command;
|
||||
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.FaweVersion;
|
||||
import com.boydti.fawe.config.BBC;
|
||||
import com.boydti.fawe.config.Settings;
|
||||
import com.boydti.fawe.util.HastebinUtility;
|
||||
import com.boydti.fawe.util.Updater;
|
||||
import com.sk89q.minecraft.util.commands.Command;
|
||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||
@ -32,11 +37,18 @@ import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.extension.platform.Capability;
|
||||
import com.sk89q.worldedit.extension.platform.Platform;
|
||||
import com.sk89q.worldedit.extension.platform.PlatformManager;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.Map;
|
||||
import java.util.Scanner;
|
||||
import java.util.TimeZone;
|
||||
|
||||
@Command(aliases = {"we", "worldedit", "fawe"}, desc = "Updating, informational, debug and help commands")
|
||||
public class WorldEditCommands {
|
||||
private static final DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z");
|
||||
|
||||
@ -49,40 +61,116 @@ public class WorldEditCommands {
|
||||
@Command(
|
||||
aliases = { "version", "ver" },
|
||||
usage = "",
|
||||
desc = "Get WorldEdit version",
|
||||
desc = "Get WorldEdit/FAWE version",
|
||||
min = 0,
|
||||
max = 0
|
||||
)
|
||||
public void version(Actor actor) throws WorldEditException {
|
||||
actor.print(BBC.getPrefix() + "WorldEdit version " + WorldEdit.getVersion());
|
||||
actor.print(BBC.getPrefix() + "https://github.com/sk89q/worldedit/");
|
||||
|
||||
actor.print(BBC.getPrefix() + "WorldEdit " + WorldEdit.getVersion());
|
||||
PlatformManager pm = we.getPlatformManager();
|
||||
|
||||
actor.printDebug("----------- Platforms -----------");
|
||||
actor.printDebug("------------------------------------");
|
||||
actor.printDebug("Platforms:");
|
||||
for (Platform platform : pm.getPlatforms()) {
|
||||
actor.printDebug(String.format("* %s (%s)", platform.getPlatformName(), platform.getPlatformVersion()));
|
||||
actor.printDebug(String.format(" - %s (%s)", platform.getPlatformName(), platform.getPlatformVersion()));
|
||||
}
|
||||
|
||||
actor.printDebug("----------- Capabilities -----------");
|
||||
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("------------------------------------");
|
||||
FaweVersion fVer = Fawe.get().getVersion();
|
||||
String fVerStr = fVer == null ? "unknown" : fVer.year + "." + fVer.month + "." + fVer.day + "-" + Integer.toHexString(fVer.hash) + "-" + fVer.build;
|
||||
actor.print(BBC.getPrefix() + "FAWE " + fVerStr);
|
||||
if (fVer != null) {
|
||||
actor.printDebug("------------------------------------");
|
||||
FaweVersion version = Fawe.get().getVersion();
|
||||
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);
|
||||
actor.printDebug(" - PLATFORM: " + Settings.IMP.PLATFORM);
|
||||
Updater updater = Fawe.get().getUpdater();
|
||||
if (updater == null) {
|
||||
actor.printDebug(" - UPDATES: DISABLED");
|
||||
} else if (updater.isOutdated()){
|
||||
actor.printDebug(" - UPDATES: " + updater.getChanges().split("\n").length + " (see /fawe cl)");
|
||||
} else {
|
||||
actor.printDebug(" - UPDATES: Latest Version");
|
||||
}
|
||||
actor.printDebug("------------------------------------");
|
||||
actor.printDebug("Wiki: " + "https://github.com/boy0001/FastAsyncWorldedit/wiki");
|
||||
}
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "reload" },
|
||||
usage = "",
|
||||
desc = "Reload configuration",
|
||||
min = 0,
|
||||
max = 0
|
||||
aliases = { "reload" },
|
||||
usage = "",
|
||||
desc = "Reload configuration",
|
||||
min = 0,
|
||||
max = 0
|
||||
)
|
||||
@CommandPermissions("worldedit.reload")
|
||||
public void reload(Actor actor) throws WorldEditException {
|
||||
we.getServer().reload();
|
||||
we.getEventBus().post(new ConfigurationLoadEvent(we.getPlatformManager().queryCapability(Capability.CONFIGURATION).getConfiguration()));
|
||||
actor.print(BBC.getPrefix() + "Configuration reloaded!");
|
||||
Fawe.get().setupConfigs();
|
||||
actor.print(BBC.getPrefix() + "Reloaded WorldEdit " + we.getVersion() + " and FAWE (" + Fawe.get().getVersion() + ")");
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "changelog", "cl" },
|
||||
usage = "",
|
||||
desc = "View the FAWE changelog",
|
||||
min = 0,
|
||||
max = 0
|
||||
)
|
||||
@CommandPermissions("worldedit.changelog")
|
||||
public void changelog(Actor actor) throws WorldEditException {
|
||||
try {
|
||||
Updater updater = Fawe.get().getUpdater();
|
||||
String changes = updater != null ? updater.getChanges() : null;
|
||||
if (changes == null) {
|
||||
try (Scanner scanner = new Scanner(new URL("http://boydti.com/fawe/cl?" + Integer.toHexString(Fawe.get().getVersion().hash)).openStream(), "UTF-8")) {
|
||||
changes = scanner.useDelimiter("\\A").next();
|
||||
}
|
||||
}
|
||||
actor.print(BBC.getPrefix() + changes);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "debugpaste" },
|
||||
usage = "",
|
||||
desc = "Upload debug information to hastebin.com",
|
||||
min = 0,
|
||||
max = 0
|
||||
)
|
||||
@CommandPermissions("worldedit.debugpaste")
|
||||
public void debugpaste(Actor actor) throws WorldEditException, IOException {
|
||||
BBC.DOWNLOAD_LINK.send(actor, HastebinUtility.debugPaste());
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "threads" },
|
||||
usage = "",
|
||||
desc = "Print all thread stacks",
|
||||
min = 0,
|
||||
max = 0
|
||||
)
|
||||
@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());
|
||||
for (StackTraceElement elem : entry.getValue()) {
|
||||
actor.printDebug(elem.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Command(
|
||||
|
@ -235,7 +235,7 @@ public final class CommandManager {
|
||||
.registerMethods(new ToolUtilCommands(worldEdit))
|
||||
.registerMethods(new ToolCommands(worldEdit))
|
||||
.registerMethods(new UtilityCommands(worldEdit))
|
||||
.group("worldedit", "we")
|
||||
.group("worldedit", "we", "fawe")
|
||||
.describeAs("WorldEdit commands")
|
||||
.registerMethods(new WorldEditCommands(worldEdit)).parent().group("schematic", "schem", "/schematic", "/schem")
|
||||
.describeAs("Schematic commands for saving/loading areas")
|
||||
@ -391,14 +391,14 @@ public final class CommandManager {
|
||||
BBC.NO_PERM.send(finalActor, StringMan.join(failedPermissions, " "));
|
||||
} catch (InvalidUsageException e) {
|
||||
if (e.isFullHelpSuggested()) {
|
||||
finalActor.printRaw(ColorCodeBuilder.asColorCodes(new CommandUsageBox(e.getCommand(), e.getCommandUsed("/", ""), locals)));
|
||||
finalActor.print(BBC.getPrefix() + ColorCodeBuilder.asColorCodes(new CommandUsageBox(e.getCommand(), e.getCommandUsed("/", ""), locals)));
|
||||
String message = e.getMessage();
|
||||
if (message != null) {
|
||||
finalActor.printError(message);
|
||||
}
|
||||
} else {
|
||||
String message = e.getMessage();
|
||||
finalActor.print(BBC.getPrefix() + (message != null ? message : "The command was not used properly (no more help available)."));
|
||||
finalActor.printRaw(BBC.getPrefix() + (message != null ? message : "The command was not used properly (no more help available)."));
|
||||
BBC.COMMAND_SYNTAX.send(finalActor, e.getSimpleUsageString("/"));
|
||||
}
|
||||
} catch (WrappedCommandException e) {
|
||||
|
@ -0,0 +1,95 @@
|
||||
/*
|
||||
* 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.util.formatting;
|
||||
|
||||
/**
|
||||
* A fragment of text.
|
||||
*/
|
||||
public class Fragment {
|
||||
|
||||
private final StringBuilder builder = new StringBuilder();
|
||||
|
||||
public Fragment() {
|
||||
}
|
||||
|
||||
public Fragment append(String str) {
|
||||
builder.append(str);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Fragment append(Object obj) {
|
||||
append(String.valueOf(obj));
|
||||
return this;
|
||||
}
|
||||
|
||||
public Fragment append(StringBuffer sb) {
|
||||
append(String.valueOf(sb));
|
||||
return this;
|
||||
}
|
||||
|
||||
public Fragment append(CharSequence s) {
|
||||
append(String.valueOf(s));
|
||||
return this;
|
||||
}
|
||||
|
||||
public Fragment append(boolean b) {
|
||||
append(String.valueOf(b));
|
||||
return this;
|
||||
}
|
||||
|
||||
public Fragment append(char c) {
|
||||
append(String.valueOf(c));
|
||||
return this;
|
||||
}
|
||||
|
||||
public Fragment append(int i) {
|
||||
append(String.valueOf(i));
|
||||
return this;
|
||||
}
|
||||
|
||||
public Fragment append(long lng) {
|
||||
append(String.valueOf(lng));
|
||||
return this;
|
||||
}
|
||||
|
||||
public Fragment append(float f) {
|
||||
append(String.valueOf(f));
|
||||
return this;
|
||||
}
|
||||
|
||||
public Fragment append(double d) {
|
||||
append(String.valueOf(d));
|
||||
return this;
|
||||
}
|
||||
|
||||
public Fragment newLine() {
|
||||
append("\n");
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
public static Class<?> inject() {
|
||||
return Fragment.class;
|
||||
}
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* 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.util.formatting.component;
|
||||
|
||||
import com.boydti.fawe.config.BBC;
|
||||
|
||||
public class CommandListBox extends MessageBox {
|
||||
|
||||
private boolean first = true;
|
||||
|
||||
/**
|
||||
* Create a new box.
|
||||
*
|
||||
* @param title the title
|
||||
*/
|
||||
public CommandListBox(String title) {
|
||||
super(title);
|
||||
}
|
||||
|
||||
public CommandListBox appendCommand(String alias, String description) {
|
||||
return appendCommand(alias, description, true);
|
||||
}
|
||||
|
||||
public CommandListBox appendCommand(String alias, String description, boolean allowed) {
|
||||
if (!first) {
|
||||
getContents().newLine();
|
||||
}
|
||||
getContents().append((allowed ? BBC.HELP_ITEM_ALLOWED : BBC.HELP_ITEM_DENIED).format(alias, description));
|
||||
first = false;
|
||||
return this;
|
||||
}
|
||||
|
||||
public static Class<?> inject() {
|
||||
return CommandListBox.class;
|
||||
}
|
||||
}
|
@ -0,0 +1,116 @@
|
||||
/*
|
||||
* 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.util.formatting.component;
|
||||
|
||||
import com.boydti.fawe.config.BBC;
|
||||
import com.sk89q.minecraft.util.commands.CommandLocals;
|
||||
import com.sk89q.worldedit.extension.platform.CommandManager;
|
||||
import com.sk89q.worldedit.util.command.CommandCallable;
|
||||
import com.sk89q.worldedit.util.command.CommandMapping;
|
||||
import com.sk89q.worldedit.util.command.Description;
|
||||
import com.sk89q.worldedit.util.command.Dispatcher;
|
||||
import com.sk89q.worldedit.util.command.PrimaryAliasComparator;
|
||||
import com.sk89q.worldedit.util.formatting.Style;
|
||||
import com.sk89q.worldedit.util.formatting.StyledFragment;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* A box to describe usage of a command.
|
||||
*/
|
||||
public class CommandUsageBox extends StyledFragment {
|
||||
|
||||
/**
|
||||
* Create a new usage box.
|
||||
*
|
||||
* @param command the command to describe
|
||||
* @param commandString the command that was used, such as "/we" or "/brush sphere"
|
||||
*/
|
||||
public CommandUsageBox(CommandCallable command, String commandString) {
|
||||
this(command, commandString, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new usage box.
|
||||
*
|
||||
* @param command the command to describe
|
||||
* @param commandString the command that was used, such as "/we" or "/brush sphere"
|
||||
* @param locals list of locals to use
|
||||
*/
|
||||
public CommandUsageBox(CommandCallable command, String commandString, @Nullable CommandLocals locals) {
|
||||
checkNotNull(command);
|
||||
checkNotNull(commandString);
|
||||
if (command instanceof Dispatcher) {
|
||||
attachDispatcherUsage((Dispatcher) command, commandString, locals);
|
||||
} else {
|
||||
attachCommandUsage(command.getDescription(), commandString);
|
||||
}
|
||||
}
|
||||
|
||||
private void attachDispatcherUsage(Dispatcher dispatcher, String commandString, @Nullable CommandLocals locals) {
|
||||
CommandListBox box = new CommandListBox(BBC.HELP_HEADER_SUBCOMMANDS.f());
|
||||
String prefix = !commandString.isEmpty() ? commandString + " " : "";
|
||||
|
||||
List<CommandMapping> list = new ArrayList<CommandMapping>(dispatcher.getCommands());
|
||||
Collections.sort(list, new PrimaryAliasComparator(CommandManager.COMMAND_CLEAN_PATTERN));
|
||||
|
||||
for (CommandMapping mapping : list) {
|
||||
boolean perm = locals == null || mapping.getCallable().testPermission(locals);
|
||||
box.appendCommand(prefix + mapping.getPrimaryAlias(), mapping.getDescription().getDescription(), perm);
|
||||
}
|
||||
|
||||
append(box);
|
||||
}
|
||||
|
||||
private void attachCommandUsage(Description description, String commandString) {
|
||||
MessageBox box = new MessageBox(BBC.HELP_HEADER_COMMAND.f(commandString));
|
||||
StyledFragment contents = box.getContents();
|
||||
|
||||
if (description.getUsage() != null) {
|
||||
contents.append(new Label().append(BBC.COMMAND_SYNTAX.f(description.getUsage())));
|
||||
} else {
|
||||
contents.createFragment(Style.GRAY);
|
||||
contents.append(new Subtle().append("Usage information is not available."));
|
||||
}
|
||||
|
||||
contents.newLine();
|
||||
|
||||
contents.createFragment(Style.GRAY);
|
||||
if (description.getHelp() != null) {
|
||||
contents.append(description.getHelp());
|
||||
} else if (description.getDescription() != null) {
|
||||
contents.append(description.getDescription());
|
||||
} else {
|
||||
contents.append(new Subtle().append("No further help is available."));
|
||||
}
|
||||
|
||||
append(box);
|
||||
}
|
||||
|
||||
public static Class<?> inject() {
|
||||
return CommandUsageBox.class;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
/*
|
||||
* 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.util.formatting.component;
|
||||
|
||||
import com.sk89q.worldedit.util.formatting.StyledFragment;
|
||||
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* Makes for a box with a border above and below.
|
||||
*/
|
||||
public class MessageBox extends StyledFragment {
|
||||
|
||||
private final StyledFragment contents = new StyledFragment();
|
||||
|
||||
/**
|
||||
* Create a new box.
|
||||
*/
|
||||
public MessageBox(String title) {
|
||||
checkNotNull(title);
|
||||
append(title);
|
||||
newLine();
|
||||
append(contents);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the internal contents.
|
||||
*
|
||||
* @return the contents
|
||||
*/
|
||||
public StyledFragment getContents() {
|
||||
return contents;
|
||||
}
|
||||
|
||||
public static Class<?> inject() {
|
||||
return MessageBox.class;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user