3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-11-03 01:50:07 +01:00

Some command refactoring. Switch usages of page args to -p flag.

Dieser Commit ist enthalten in:
wizjany 2019-05-27 18:26:20 -04:00
Ursprung 620992dd57
Commit 9099a17fe5
13 geänderte Dateien mit 211 neuen und 141 gelöschten Zeilen

Datei anzeigen

@ -26,7 +26,9 @@ 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.Logging;
import com.sk89q.worldedit.command.util.WorldEditAsyncCommandBuilder;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extension.platform.Capability;
import com.sk89q.worldedit.function.FlatRegionFunction;
import com.sk89q.worldedit.function.FlatRegionMaskingFilter;
@ -50,10 +52,10 @@ import com.sk89q.worldedit.world.registry.BiomeRegistry;
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;
import java.util.HashSet;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
@ -77,17 +79,28 @@ public class BiomeCommands {
desc = "Gets all biomes available."
)
@CommandPermissions("worldedit.biome.list")
public void biomeList(Player player,
@Arg(desc = "Page number.", def = "1")
int page) throws WorldEditException {
public void biomeList(Actor actor,
@ArgFlag(name = 'p', desc = "Page number.", def = "1")
int page) {
WorldEditAsyncCommandBuilder.createAndSendMessage(actor, () -> {
BiomeRegistry biomeRegistry = WorldEdit.getInstance().getPlatformManager()
.queryCapability(Capability.GAME_HOOKS).getRegistries().getBiomeRegistry();
PaginationBox paginationBox = PaginationBox.fromStrings("Available Biomes", "/biomelist %page%",
PaginationBox paginationBox = PaginationBox.fromStrings("Available Biomes", "/biomelist -p %page%",
BiomeType.REGISTRY.values().stream()
.map(biomeRegistry::getData).filter(Objects::nonNull)
.map(BiomeData::getName).collect(Collectors.toList()));
player.print(paginationBox.create(page));
.map(biomeType -> {
String id = biomeType.getId();
final BiomeData data = biomeRegistry.getData(biomeType);
if (data != null) {
String name = data.getName();
return id + " (" + name + ")";
} else {
return id;
}
})
.collect(Collectors.toList()));
return paginationBox.create(page);
}, null);
}
@Command(

Datei anzeigen

@ -90,7 +90,7 @@ public class BrushCommands {
@CommandPermissions("worldedit.brush.sphere")
public void sphereBrush(Player player, LocalSession session,
@Arg(desc = "The pattern of blocks to set")
Pattern fill,
Pattern pattern,
@Arg(desc = "The radius of the sphere", def = "2")
double radius,
@Switch(name = 'h', desc = "Create hollow spheres instead")
@ -98,7 +98,7 @@ public class BrushCommands {
worldEdit.checkMaxBrushRadius(radius);
BrushTool tool = session.getBrushTool(player.getItemInHand(HandSide.MAIN_HAND).getType());
tool.setFill(fill);
tool.setFill(pattern);
tool.setSize(radius);
if (hollow) {
@ -118,7 +118,7 @@ public class BrushCommands {
@CommandPermissions("worldedit.brush.cylinder")
public void cylinderBrush(Player player, LocalSession session,
@Arg(desc = "The pattern of blocks to set")
Pattern fill,
Pattern pattern,
@Arg(desc = "The radius of the cylinder", def = "2")
double radius,
@Arg(desc = "The height of the cylinder", def = "1")
@ -129,7 +129,7 @@ public class BrushCommands {
worldEdit.checkMaxBrushRadius(height);
BrushTool tool = session.getBrushTool(player.getItemInHand(HandSide.MAIN_HAND).getType());
tool.setFill(fill);
tool.setFill(pattern);
tool.setSize(radius);
if (hollow) {

Datei anzeigen

@ -39,6 +39,7 @@ import com.sk89q.worldedit.world.storage.McRegionChunkStore;
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 java.io.FileOutputStream;
import java.io.IOException;
@ -86,10 +87,10 @@ public class ChunkCommands {
)
@CommandPermissions("worldedit.listchunks")
public void listChunks(Player player, LocalSession session,
@Arg(desc = "Page number.", def = "1") int page) throws WorldEditException {
@ArgFlag(name = 'p', desc = "Page number.", def = "1") int page) throws WorldEditException {
Set<BlockVector2> chunks = session.getSelection(player.getWorld()).getChunks();
PaginationBox paginationBox = PaginationBox.fromStrings("Selected Chunks", "/listchunks %page%",
PaginationBox paginationBox = PaginationBox.fromStrings("Selected Chunks", "/listchunks -p %page%",
chunks.stream().map(BlockVector2::toString).collect(Collectors.toList()));
player.print(paginationBox.create(page));
}

Datei anzeigen

@ -19,25 +19,35 @@
package com.sk89q.worldedit.command;
import com.google.common.collect.Sets;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.LocalConfiguration;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.command.util.AsyncCommandBuilder;
import com.sk89q.worldedit.command.util.CommandPermissions;
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
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.function.mask.Mask;
import com.sk89q.worldedit.util.formatting.component.PaginationBox;
import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.world.item.ItemType;
import com.sk89q.worldedit.world.item.ItemTypes;
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;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.TreeMap;
import java.util.concurrent.Callable;
import static com.google.common.base.Preconditions.checkNotNull;
/**
@ -65,7 +75,7 @@ public class GeneralCommands {
@CommandPermissions("worldedit.limit")
public void limit(Player player, LocalSession session,
@Arg(desc = "The limit to set", def = "")
Integer limit) throws WorldEditException {
Integer limit) {
LocalConfiguration config = worldEdit.getConfiguration();
boolean mayDisable = player.hasPermission("worldedit.limit.unrestricted");
@ -79,12 +89,8 @@ public class GeneralCommands {
}
session.setBlockChangeLimit(limit);
if (limit != config.defaultChangeLimit) {
player.print("Block change limit set to " + limit + ". (Use //limit to go back to the default.)");
} else {
player.print("Block change limit set to " + limit + ".");
}
player.print("Block change limit set to " + limit + "."
+ (limit == config.defaultChangeLimit ? "" : " (Use //limit to go back to the default.)"));
}
@Command(
@ -94,8 +100,7 @@ public class GeneralCommands {
@CommandPermissions("worldedit.timeout")
public void timeout(Player player, LocalSession session,
@Arg(desc = "The timeout time to set", def = "")
Integer limit) throws WorldEditException {
Integer limit) {
LocalConfiguration config = worldEdit.getConfiguration();
boolean mayDisable = player.hasPermission("worldedit.timeout.unrestricted");
@ -108,12 +113,8 @@ public class GeneralCommands {
}
session.setTimeout(limit);
if (limit != config.calculationTimeout) {
player.print("Timeout time set to " + limit + " ms. (Use //timeout to go back to the default.)");
} else {
player.print("Timeout time set to " + limit + " ms.");
}
player.print("Timeout time set to " + limit + " ms."
+ (limit == config.calculationTimeout ? "" : " (Use //timeout to go back to the default.)"));
}
@Command(
@ -123,7 +124,7 @@ public class GeneralCommands {
@CommandPermissions("worldedit.fast")
public void fast(Player player, LocalSession session,
@Arg(desc = "The new fast mode state", def = "")
Boolean fastMode) throws WorldEditException {
Boolean fastMode) {
boolean hasFastMode = session.hasFastMode();
if (fastMode != null && fastMode == hasFastMode) {
player.printError("Fast mode already " + (fastMode ? "enabled" : "disabled") + ".");
@ -146,7 +147,7 @@ public class GeneralCommands {
@CommandPermissions("worldedit.reorder")
public void reorderMode(Player player, LocalSession session,
@Arg(desc = "The reorder mode", def = "")
EditSession.ReorderMode reorderMode) throws WorldEditException {
EditSession.ReorderMode reorderMode) {
if (reorderMode == null) {
player.print("The reorder mode is " + session.getReorderMode().getDisplayName());
} else {
@ -190,9 +191,9 @@ public class GeneralCommands {
@CommandPermissions("worldedit.global-mask")
public void gmask(Player player, LocalSession session,
@Arg(desc = "The mask to set", def = "")
Mask mask) throws WorldEditException {
Mask mask) {
if (mask == null) {
session.setMask((Mask) null);
session.setMask(null);
player.print("Global mask disabled.");
} else {
session.setMask(mask);
@ -205,8 +206,7 @@ public class GeneralCommands {
aliases = {"/toggleplace"},
desc = "Switch between your position and pos1 for placement"
)
public void togglePlace(Player player, LocalSession session) throws WorldEditException {
public void togglePlace(Player player, LocalSession session) {
if (session.togglePlacementPosition()) {
player.print("Now placing at pos #1.");
} else {
@ -220,41 +220,48 @@ public class GeneralCommands {
desc = "Search for an item"
)
public void searchItem(Actor actor,
@Arg(desc = "Item query")
String query,
@Arg(desc = "Search query", variable = true)
List<String> query,
@Switch(name = 'b', desc = "Only search for blocks")
boolean blocksOnly,
@Switch(name = 'i', desc = "Only search for items")
boolean itemsOnly) throws WorldEditException {
ItemType type = ItemTypes.get(query);
if (type != null) {
actor.print(type.getId() + " (" + type.getName() + ")");
} else {
if (query.length() <= 2) {
boolean itemsOnly,
@ArgFlag(name = 'p', desc = "Page of results to return", def = "1")
int page) {
String search = String.join(" ", query);
if (search.length() <= 2) {
actor.printError("Enter a longer search string (len > 2).");
return;
}
if (!blocksOnly && !itemsOnly) {
actor.print("Searching for: " + query);
} else if (blocksOnly && itemsOnly) {
if (blocksOnly && itemsOnly) {
actor.printError("You cannot use both the 'b' and 'i' flags simultaneously.");
return;
} else if (blocksOnly) {
actor.print("Searching for blocks: " + query);
} else {
actor.print("Searching for items: " + query);
}
int found = 0;
WorldEditAsyncCommandBuilder.createAndSendMessage(actor, new ItemSearcher(search, blocksOnly, itemsOnly, page),
"(Please wait... searching items.)");
}
private static class ItemSearcher implements Callable<Component> {
private final boolean blocksOnly;
private final boolean itemsOnly;
private final String search;
private final int page;
ItemSearcher(String search, boolean blocksOnly, boolean itemsOnly, int page) {
this.blocksOnly = blocksOnly;
this.itemsOnly = itemsOnly;
this.search = search;
this.page = page;
}
@Override
public Component call() throws Exception {
String command = "/searchitem " + (blocksOnly ? "-b " : "") + (itemsOnly ? "-i " : "") + "-p %page% " + search;
Map<String, String> results = new TreeMap<>();
String idMatch = search.replace(' ', '_');
String nameMatch = search.toLowerCase(Locale.ROOT);
for (ItemType searchType : ItemType.REGISTRY) {
if (found >= 15) {
actor.print("Too many results!");
break;
}
if (blocksOnly && !searchType.hasBlockType()) {
continue;
}
@ -262,20 +269,16 @@ public class GeneralCommands {
if (itemsOnly && searchType.hasBlockType()) {
continue;
}
for (String alias : Sets.newHashSet(searchType.getId(), searchType.getName())) {
if (alias.contains(query)) {
actor.print(searchType.getId() + " (" + searchType.getName() + ")");
++found;
break;
final String id = searchType.getId();
String name = searchType.getName();
final boolean hasName = !name.equals(id);
name = name.toLowerCase(Locale.ROOT);
if (id.contains(idMatch) || (hasName && name.contains(nameMatch))) {
results.put(id, name + (hasName ? " (" + id + ")" : ""));
}
}
List<String> list = new ArrayList<>(results.values());
return PaginationBox.fromStrings("Search results for '" + search + "'", command, list).create(page);
}
}
}
if (found == 0) {
actor.printError("No items found.");
}
}
}
}

Datei anzeigen

@ -26,6 +26,7 @@ import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.command.util.AsyncCommandBuilder;
import com.sk89q.worldedit.command.util.CommandPermissions;
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
import com.sk89q.worldedit.command.util.WorldEditAsyncCommandBuilder;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
@ -39,8 +40,10 @@ import com.sk89q.worldedit.function.operation.Operations;
import com.sk89q.worldedit.math.transform.Transform;
import com.sk89q.worldedit.session.ClipboardHolder;
import com.sk89q.worldedit.util.formatting.component.CodeFormat;
import com.sk89q.worldedit.util.formatting.component.ErrorFormat;
import com.sk89q.worldedit.util.formatting.component.PaginationBox;
import com.sk89q.worldedit.util.formatting.component.SchematicPaginationBox;
import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.util.formatting.text.TextComponent;
import com.sk89q.worldedit.util.formatting.text.event.ClickEvent;
import com.sk89q.worldedit.util.formatting.text.format.TextColor;
@ -124,7 +127,7 @@ public class SchematicCommands {
.sendMessageAfterDelay("(Please wait... loading schematic.)")
.onSuccess(TextComponent.of(filename, TextColor.GOLD)
.append(TextComponent.of(" loaded. Paste it with ", TextColor.LIGHT_PURPLE))
.append(CodeFormat.wrap("//paste").clickEvent(ClickEvent.of(ClickEvent.Action.RUN_COMMAND, "//paste"))),
.append(CodeFormat.wrap("//paste").clickEvent(ClickEvent.of(ClickEvent.Action.SUGGEST_COMMAND, "//paste"))),
session::setClipboard)
.onFailure("Failed to load schematic", worldEdit.getPlatformManager().getPlatformCommandManager().getExceptionConverter())
.buildAndExec(worldEdit.getExecutorService());
@ -257,59 +260,17 @@ public class SchematicCommands {
@Switch(name = 'd', desc = "Sort by date, oldest first")
boolean oldFirst,
@Switch(name = 'n', desc = "Sort by date, newest first")
boolean newFirst) throws WorldEditException {
boolean newFirst) {
if (oldFirst && newFirst) {
throw new StopExecutionException(TextComponent.of("Cannot sort by oldest and newest."));
}
File dir = worldEdit.getWorkingDirectoryFile(worldEdit.getConfiguration().saveDir);
List<File> fileList = allFiles(dir);
if (fileList == null || fileList.isEmpty()) {
actor.printError("No schematics found.");
return;
}
File[] files = new File[fileList.size()];
fileList.toArray(files);
final String saveDir = worldEdit.getConfiguration().saveDir;
final int sortType = oldFirst ? -1 : newFirst ? 1 : 0;
// cleanup file list
Arrays.sort(files, (f1, f2) -> {
// http://stackoverflow.com/questions/203030/best-way-to-list-files-in-java-sorted-by-date-modified
int res;
if (sortType == 0) { // use name by default
int p = f1.getParent().compareTo(f2.getParent());
if (p == 0) { // same parent, compare names
res = f1.getName().compareTo(f2.getName());
} else { // different parent, sort by that
res = p;
}
} else {
res = Long.compare(f1.lastModified(), f2.lastModified()); // use date if there is a flag
if (sortType == 1) res = -res; // flip date for newest first instead of oldest first
}
return res;
});
final String pageCommand = actor.isPlayer()
? "//schem list -p %page%" + (sortType == -1 ? " -d" : sortType == 1 ? " -n" : "") : null;
String pageCommand = actor.isPlayer() ? "//schem list -p %page%" + (oldFirst ? " -d" : newFirst ? " -n" : "") : null;
PaginationBox paginationBox = new SchematicPaginationBox(worldEdit.getConfiguration().saveDir, files, pageCommand);
actor.print(paginationBox.create(page));
}
private List<File> allFiles(File root) {
File[] files = root.listFiles();
if (files == null) return null;
List<File> fileList = new ArrayList<>();
for (File f : files) {
if (f.isDirectory()) {
List<File> subFiles = allFiles(f);
if (subFiles == null) continue; // empty subdir
fileList.addAll(subFiles);
} else {
fileList.add(f);
}
}
return fileList;
WorldEditAsyncCommandBuilder.createAndSendMessage(actor,
new SchematicListTask(saveDir, sortType, page, pageCommand), "(Please wait... gathering schematic list.)");
}
private static class SchematicLoadTask implements Callable<ClipboardHolder> {
@ -379,4 +340,68 @@ public class SchematicCommands {
return null;
}
}
private static class SchematicListTask implements Callable<Component> {
private final String prefix;
private final int sortType;
private final int page;
private final File rootDir;
private final String pageCommand;
SchematicListTask(String prefix, int sortType, int page, String pageCommand) {
this.prefix = prefix;
this.sortType = sortType;
this.page = page;
this.rootDir = WorldEdit.getInstance().getWorkingDirectoryFile(prefix);
this.pageCommand = pageCommand;
}
@Override
public Component call() throws Exception {
List<File> fileList = allFiles(rootDir);
if (fileList == null || fileList.isEmpty()) {
return ErrorFormat.wrap("No schematics found.");
}
File[] files = new File[fileList.size()];
fileList.toArray(files);
// cleanup file list
Arrays.sort(files, (f1, f2) -> {
// http://stackoverflow.com/questions/203030/best-way-to-list-files-in-java-sorted-by-date-modified
int res;
if (sortType == 0) { // use name by default
int p = f1.getParent().compareTo(f2.getParent());
if (p == 0) { // same parent, compare names
res = f1.getName().compareTo(f2.getName());
} else { // different parent, sort by that
res = p;
}
} else {
res = Long.compare(f1.lastModified(), f2.lastModified()); // use date if there is a flag
if (sortType == 1) res = -res; // flip date for newest first instead of oldest first
}
return res;
});
PaginationBox paginationBox = new SchematicPaginationBox(prefix, files, pageCommand);
return paginationBox.create(page);
}
}
private static List<File> allFiles(File root) {
File[] files = root.listFiles();
if (files == null) return null;
List<File> fileList = new ArrayList<>();
for (File f : files) {
if (f.isDirectory()) {
List<File> subFiles = allFiles(f);
if (subFiles == null) continue; // empty subdir
fileList.addAll(subFiles);
} else {
fileList.add(f);
}
}
return fileList;
}
}

Datei anzeigen

@ -61,6 +61,7 @@ import com.sk89q.worldedit.world.block.BlockTypes;
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;
import java.text.DecimalFormat;
@ -517,7 +518,7 @@ public class UtilityCommands {
public void help(Actor actor,
@Switch(name = 's', desc = "List sub-commands of the given command, if applicable")
boolean listSubCommands,
@Arg(desc = "The page to retrieve", def = "1")
@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 {

Datei anzeigen

@ -39,6 +39,7 @@ import com.sk89q.worldedit.util.report.SystemInfoReport;
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;
import java.io.File;
@ -159,7 +160,7 @@ public class WorldEditCommands {
public void help(Actor actor,
@Switch(name = 's', desc = "List sub-commands of the given command, if applicable")
boolean listSubCommands,
@Arg(desc = "The page to retrieve", def = "1")
@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 {

Datei anzeigen

@ -22,7 +22,6 @@ package com.sk89q.worldedit.command.util;
import com.google.common.collect.ImmutableSet;
import org.enginehub.piston.Command;
import org.enginehub.piston.gen.CommandConditionGenerator;
import org.enginehub.piston.gen.CommandRegistration;
import org.enginehub.piston.util.NonnullByDefault;
import java.lang.reflect.Method;

Datei anzeigen

@ -135,7 +135,7 @@ public class PrintCommandHelp {
String used = commandList.isEmpty() ? null : toCommandString(commandList);
CommandListBox box = new CommandListBox(
(used == null ? "Help" : "Subcommands: " + used),
"//help -s %page%" + (used == null ? "" : " " + used));
"//help -s -p %page%" + (used == null ? "" : " " + used));
if (!actor.isPlayer()) {
box.formatForConsole();
}

Datei anzeigen

@ -0,0 +1,27 @@
package com.sk89q.worldedit.command.util;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.util.formatting.text.Component;
import javax.annotation.Nullable;
import java.util.concurrent.Callable;
/**
* For internal WorldEdit use only.
*/
public final class WorldEditAsyncCommandBuilder {
private WorldEditAsyncCommandBuilder() {
}
public static void createAndSendMessage(Actor actor, Callable<Component> task, @Nullable String desc) {
final AsyncCommandBuilder<Component> builder = AsyncCommandBuilder.wrap(task, actor);
if (desc != null) {
builder.sendMessageAfterDelay(desc);
}
builder
.onSuccess((String) null, actor::print)
.onFailure((String) null, WorldEdit.getInstance().getPlatformManager().getPlatformCommandManager().getExceptionConverter())
.buildAndExec(WorldEdit.getInstance().getExecutorService());
}
}

Datei anzeigen

@ -101,7 +101,6 @@ import com.sk89q.worldedit.util.formatting.text.format.TextColor;
import com.sk89q.worldedit.util.logging.DynamicStreamHandler;
import com.sk89q.worldedit.util.logging.LogFormat;
import com.sk89q.worldedit.world.World;
import org.enginehub.piston.ColorConfig;
import org.enginehub.piston.Command;
import org.enginehub.piston.CommandManager;
import org.enginehub.piston.TextConfig;
@ -477,6 +476,8 @@ public final class PlatformCommandManager {
} catch (ConditionFailedException e) {
if (e.getCondition() instanceof PermissionCondition) {
actor.printError("You are not permitted to do that. Are you in the right mode?");
} else {
actor.print(e.getRichMessage());
}
} catch (UsageException e) {
actor.print(TextComponent.builder("")
@ -487,7 +488,6 @@ public final class PlatformCommandManager {
if (!cmd.isEmpty()) {
actor.print(TextComponent.builder("Usage: ")
.color(TextColor.RED)
.append(TextComponent.of("/", ColorConfig.getMainText()))
.append(HelpGenerator.create(e.getCommandParseResult()).getUsage())
.build());
}

Datei anzeigen

@ -20,15 +20,12 @@
package com.sk89q.worldedit.internal.command;
import com.google.common.collect.ImmutableList;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
import com.sk89q.worldedit.internal.command.CommandLoggingHandler;
import org.enginehub.piston.CommandManager;
import org.enginehub.piston.gen.CommandCallListener;
import org.enginehub.piston.gen.CommandRegistration;
import java.util.List;
import java.util.logging.Logger;
public class CommandRegistrationHandler {

Datei anzeigen

@ -33,6 +33,7 @@ public class ItemType implements Keyed {
public static final NamespacedRegistry<ItemType> REGISTRY = new NamespacedRegistry<>("item type");
private String id;
private String name;
public ItemType(String id) {
// If it has no namespace, assume minecraft.
@ -53,13 +54,15 @@ public class ItemType implements Keyed {
* @return The name, or ID
*/
public String getName() {
String name = WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS).getRegistries().getItemRegistry().getName(this);
if (name == null) {
return getId();
} else {
return name;
name = WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS).getRegistries()
.getItemRegistry().getName(this);
if (name == null) {
name = "";
}
}
return name.isEmpty() ? getId() : name;
}
/**