mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-16 03:34:03 +00:00
Upstream changes (#717)
* Perform part of the move of //fast to //perf (#1377) This re-adds a deprecated `//fast` and moves the current logic to `//perf`. Later `//perf` will have its syntax reworked, when Piston finally supports sub-commands properly! * Names via Translation (#1268) * Deprecate BiomeRegistry, etc. * Update some libraries, e.g. text * Move to new translation renderer * Revert "Deprecate BiomeRegistry, etc." This reverts commit 59a5d6c92aec52739a8dc68ac3d23898af7593dd. This was not a good idea for potential mod shenanigans. * Move BiomeData#getName to BiomeRegistry, use i18n * Use getRichName instead of getName * Implement getRichName for NullBiomeRegistry * Add getRichName for blocks * Relocate net.kyori.minecraft * Update adapters for getRichBlockName * Add getRichName for items * Update adapters for getRichItemName * Update adapters JAR for merge (cherry picked from commit cfd26253b6fb59ff6c65a0157a6780be7db4ea5a) * Follow-up fixes for 92f877679622a27b16b9e5cd61cfec1a6545be33 * Don't send deprecation warning and improve info message * Fix click command for perf box (cherry picked from commit 7ee60060c31df2f8b41212b430a0875312189339) * update R3 adapter§ Co-authored-by: Octavia Togami <octavia.togami@gmail.com> Co-authored-by: NotMyFault <mc.cache@web.de> Co-authored-by: Aurora <21148213+aurorasmiles@users.noreply.github.com> Co-authored-by: Aurora <aurora@relanet.eu>
This commit is contained in:
@@ -49,7 +49,6 @@ import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.event.HoverEvent;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.biome.BiomeData;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.registry.BiomeRegistry;
|
||||
import org.enginehub.piston.annotation.Command;
|
||||
@@ -87,23 +86,19 @@ public class BiomeCommands {
|
||||
@ArgFlag(name = 'p', desc = "Page number.", def = "1")
|
||||
int page) {
|
||||
WorldEditAsyncCommandBuilder.createAndSendMessage(actor, () -> {
|
||||
BiomeRegistry biomeRegistry =
|
||||
WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS)
|
||||
.getRegistries().getBiomeRegistry();
|
||||
BiomeRegistry biomeRegistry = WorldEdit.getInstance().getPlatformManager()
|
||||
.queryCapability(Capability.GAME_HOOKS).getRegistries().getBiomeRegistry();
|
||||
|
||||
PaginationBox paginationBox = PaginationBox
|
||||
.fromStrings("Available Biomes", "/biomelist -p %page%",
|
||||
BiomeType.REGISTRY.values().stream().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);
|
||||
PaginationBox paginationBox = PaginationBox.fromComponents("Available Biomes", "/biomelist -p %page%",
|
||||
BiomeType.REGISTRY.values().stream()
|
||||
.map(biomeType -> TextComponent.builder()
|
||||
.append(biomeType.getId())
|
||||
.append(" (")
|
||||
.append(biomeRegistry.getRichName(biomeType))
|
||||
.append(")")
|
||||
.build())
|
||||
.collect(Collectors.toList()));
|
||||
return paginationBox.create(page);
|
||||
}, (Component) null);
|
||||
}
|
||||
|
||||
@@ -150,14 +145,11 @@ public class BiomeCommands {
|
||||
messageKey = "worldedit.biomeinfo.selection";
|
||||
}
|
||||
|
||||
List<Component> components = biomes.stream().map(biome -> {
|
||||
BiomeData data = biomeRegistry.getData(biome);
|
||||
if (data != null) {
|
||||
return TextComponent.of(data.getName()).hoverEvent(HoverEvent.showText(TextComponent.of(biome.getId())));
|
||||
} else {
|
||||
return TextComponent.of(biome.getId());
|
||||
}
|
||||
}).collect(Collectors.toList());
|
||||
List<Component> components = biomes.stream().map(biome ->
|
||||
biomeRegistry.getRichName(biome).hoverEvent(
|
||||
HoverEvent.showText(TextComponent.of(biome.getId()))
|
||||
)
|
||||
).collect(Collectors.toList());
|
||||
player.printInfo(TranslatableComponent.of(messageKey, TextUtils.join(components, TextComponent.of(", "))));
|
||||
}
|
||||
|
||||
|
@@ -153,6 +153,7 @@ public class BrushCommands {
|
||||
this.worldEdit = worldEdit;
|
||||
}
|
||||
|
||||
/* Covered by ToolCommands
|
||||
@Command(
|
||||
name = "none",
|
||||
aliases = "unbind",
|
||||
@@ -161,6 +162,7 @@ public class BrushCommands {
|
||||
void none(Player player, LocalSession session) throws WorldEditException {
|
||||
ToolCommands.setToolNone(player, session, true);
|
||||
}
|
||||
*/
|
||||
|
||||
@Command(name = "blendball",
|
||||
aliases = {
|
||||
|
@@ -174,17 +174,22 @@ public class ChunkCommands {
|
||||
.clickEvent(ClickEvent.of(ClickEvent.Action.SUGGEST_COMMAND, "/stop"))));
|
||||
}
|
||||
|
||||
private static class ChunkListPaginationBox extends PaginationBox.ListPaginationBox {
|
||||
private static class ChunkListPaginationBox extends PaginationBox {
|
||||
//private final Region region;
|
||||
private final List<BlockVector2> chunks = null;
|
||||
|
||||
ChunkListPaginationBox(Region region) {
|
||||
super("Selected Chunks", "/listchunks -p %page%", region.getChunks());
|
||||
super("Selected Chunks", "/listchunks -p %page%");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getComponent(int number) {
|
||||
return create(number);
|
||||
return TextComponent.of(chunks.get(number).toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getComponentsSize() {
|
||||
return chunks.size();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -28,6 +28,7 @@ import com.boydti.fawe.util.MathMan;
|
||||
import com.boydti.fawe.util.RandomTextureUtil;
|
||||
import com.boydti.fawe.util.StringMan;
|
||||
import com.boydti.fawe.util.TextureUtil;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.LocalConfiguration;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
@@ -36,6 +37,7 @@ import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.command.util.CommandPermissions;
|
||||
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
|
||||
import com.sk89q.worldedit.command.util.HookMode;
|
||||
import com.sk89q.worldedit.command.util.WorldEditAsyncCommandBuilder;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.extension.input.DisallowedUsageException;
|
||||
import com.sk89q.worldedit.extension.input.InputParseException;
|
||||
@@ -44,6 +46,8 @@ import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.extension.platform.Capability;
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.internal.command.CommandRegistrationHandler;
|
||||
import com.sk89q.worldedit.internal.command.CommandUtil;
|
||||
import com.sk89q.worldedit.util.SideEffect;
|
||||
import com.sk89q.worldedit.util.SideEffectSet;
|
||||
import com.sk89q.worldedit.util.formatting.component.PaginationBox;
|
||||
@@ -54,6 +58,9 @@ import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.format.TextColor;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.item.ItemType;
|
||||
import org.enginehub.piston.CommandManager;
|
||||
import org.enginehub.piston.CommandManagerService;
|
||||
import org.enginehub.piston.CommandParameters;
|
||||
import org.enginehub.piston.annotation.Command;
|
||||
import org.enginehub.piston.annotation.CommandContainer;
|
||||
import org.enginehub.piston.annotation.param.Arg;
|
||||
@@ -65,8 +72,10 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeMap;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
@@ -76,6 +85,65 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
@CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class)
|
||||
public class GeneralCommands {
|
||||
|
||||
public static void register(CommandRegistrationHandler registration,
|
||||
CommandManager commandManager,
|
||||
CommandManagerService commandManagerService,
|
||||
WorldEdit worldEdit) {
|
||||
// Collect the tool commands
|
||||
CommandManager collect = commandManagerService.newCommandManager();
|
||||
|
||||
registration.register(
|
||||
collect,
|
||||
GeneralCommandsRegistration.builder(),
|
||||
new GeneralCommands(worldEdit)
|
||||
);
|
||||
|
||||
|
||||
Set<org.enginehub.piston.Command> commands = collect.getAllCommands()
|
||||
.collect(Collectors.toSet());
|
||||
for (org.enginehub.piston.Command command : commands) {
|
||||
/*if in FAWE, //fast will remain for now
|
||||
(command.getName().equals("/fast")) {
|
||||
|
||||
// deprecate to `//perf`
|
||||
commandManager.register(CommandUtil.deprecate(
|
||||
command, "//fast duplicates //perf " +
|
||||
"and will be removed in WorldEdit 8",
|
||||
GeneralCommands::replaceFastForPerf
|
||||
));
|
||||
continue;
|
||||
}
|
||||
*/
|
||||
|
||||
commandManager.register(command);
|
||||
}
|
||||
}
|
||||
|
||||
private static Component replaceFastForPerf(org.enginehub.piston.Command oldCmd,
|
||||
CommandParameters oldParams) {
|
||||
if (oldParams.getMetadata() == null) {
|
||||
return CommandUtil.createNewCommandReplacementText("//perf");
|
||||
}
|
||||
ImmutableList<String> args = oldParams.getMetadata().getArguments();
|
||||
if (args.isEmpty()) {
|
||||
return TextComponent.of("There is not yet a replacement for //fast" +
|
||||
" with no arguments");
|
||||
}
|
||||
String arg0 = args.get(0).toLowerCase(Locale.ENGLISH);
|
||||
String flipped;
|
||||
switch (arg0) {
|
||||
case "on":
|
||||
flipped = "off";
|
||||
break;
|
||||
case "off":
|
||||
flipped = "on";
|
||||
break;
|
||||
default:
|
||||
return TextComponent.of("There is no replacement for //fast " + arg0);
|
||||
}
|
||||
return CommandUtil.createNewCommandReplacementText("//perf " + flipped);
|
||||
}
|
||||
|
||||
private final WorldEdit worldEdit;
|
||||
|
||||
/**
|
||||
@@ -145,22 +213,48 @@ public class GeneralCommands {
|
||||
|
||||
@Command(
|
||||
name = "/fast",
|
||||
desc = "Toggle fast mode side effects"
|
||||
desc = "Toggle fast mode"
|
||||
)
|
||||
@CommandPermissions("worldedit.fast")
|
||||
public void fast(Actor actor, LocalSession session,
|
||||
@Arg(desc = "The side effect", def = "")
|
||||
SideEffect sideEffect,
|
||||
@Arg(desc = "The new side effect state", def = "")
|
||||
SideEffect.State newState,
|
||||
@Switch(name = 'h', desc = "Show the info box")
|
||||
boolean showInfoBox) throws WorldEditException {
|
||||
@Deprecated
|
||||
void fast(Actor actor, LocalSession session,
|
||||
@Arg(desc = "The new fast mode state", def = "")
|
||||
Boolean fastMode) {
|
||||
boolean hasFastMode = session.hasFastMode();
|
||||
if (fastMode != null && fastMode == hasFastMode) {
|
||||
actor.printError(TranslatableComponent.of(fastMode ? "worldedit.fast.enabled.already" : "worldedit.fast.disabled.already"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (hasFastMode) {
|
||||
session.setFastMode(false);
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.fast.disabled"));
|
||||
} else {
|
||||
session.setFastMode(true);
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.fast.enabled"));
|
||||
}
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "/perf",
|
||||
desc = "Toggle side effects for performance",
|
||||
descFooter = "Note that this command is GOING to change in the future." +
|
||||
" Do not depend on the exact format of this command yet."
|
||||
)
|
||||
@CommandPermissions("worldedit.perf")
|
||||
void perf(Actor actor, LocalSession session,
|
||||
@Arg(desc = "The side effect", def = "")
|
||||
SideEffect sideEffect,
|
||||
@Arg(desc = "The new side effect state", def = "")
|
||||
SideEffect.State newState,
|
||||
@Switch(name = 'h', desc = "Show the info box")
|
||||
boolean showInfoBox) throws WorldEditException {
|
||||
if (sideEffect != null) {
|
||||
SideEffect.State currentState = session.getSideEffectSet().getState(sideEffect);
|
||||
if (newState != null && newState == currentState) {
|
||||
if (!showInfoBox) {
|
||||
actor.printError(TranslatableComponent.of(
|
||||
"worldedit.fast.sideeffect.already-set",
|
||||
"worldedit.perf.sideeffect.already-set",
|
||||
TranslatableComponent.of(sideEffect.getDisplayName()),
|
||||
TranslatableComponent.of(newState.getDisplayName())
|
||||
));
|
||||
@@ -172,14 +266,14 @@ public class GeneralCommands {
|
||||
session.setSideEffectSet(session.getSideEffectSet().with(sideEffect, newState));
|
||||
if (!showInfoBox) {
|
||||
actor.printInfo(TranslatableComponent.of(
|
||||
"worldedit.fast.sideeffect.set",
|
||||
"worldedit.perf.sideeffect.set",
|
||||
TranslatableComponent.of(sideEffect.getDisplayName()),
|
||||
TranslatableComponent.of(newState.getDisplayName())
|
||||
));
|
||||
}
|
||||
} else {
|
||||
actor.printInfo(TranslatableComponent.of(
|
||||
"worldedit.fast.sideeffect.get",
|
||||
"worldedit.perf.sideeffect.get",
|
||||
TranslatableComponent.of(sideEffect.getDisplayName()),
|
||||
TranslatableComponent.of(currentState.getDisplayName())
|
||||
));
|
||||
@@ -192,7 +286,7 @@ public class GeneralCommands {
|
||||
session.setSideEffectSet(applier);
|
||||
if (!showInfoBox) {
|
||||
actor.printInfo(TranslatableComponent.of(
|
||||
"worldedit.fast.sideeffect.set-all",
|
||||
"worldedit.perf.sideeffect.set-all",
|
||||
TranslatableComponent.of(newState.getDisplayName())
|
||||
));
|
||||
}
|
||||
@@ -331,7 +425,7 @@ public class GeneralCommands {
|
||||
@ArgFlag(name = 'p', desc = "Page of results to return", def = "1")
|
||||
int page,
|
||||
@Arg(desc = "Search query", variable = true)
|
||||
List<String> query) throws Exception {
|
||||
List<String> query) {
|
||||
String search = String.join(" ", query);
|
||||
if (search.length() <= 2) {
|
||||
actor.printError(TranslatableComponent.of("worldedit.searchitem.too-short"));
|
||||
@@ -342,7 +436,8 @@ public class GeneralCommands {
|
||||
return;
|
||||
}
|
||||
|
||||
actor.print(new ItemSearcher(search, blocksOnly, itemsOnly, page).call());
|
||||
WorldEditAsyncCommandBuilder.createAndSendMessage(actor, new ItemSearcher(search, blocksOnly, itemsOnly, page),
|
||||
TranslatableComponent.of("worldedit.searchitem.searching"));
|
||||
}
|
||||
|
||||
private static class ItemSearcher implements Callable<Component> {
|
||||
@@ -361,7 +456,7 @@ public class GeneralCommands {
|
||||
@Override
|
||||
public Component call() throws Exception {
|
||||
String command = "/searchitem " + (blocksOnly ? "-b " : "") + (itemsOnly ? "-i " : "") + "-p %page% " + search;
|
||||
Map<String, String> results = new TreeMap<>();
|
||||
Map<String, Component> results = new TreeMap<>();
|
||||
String idMatch = search.replace(' ', '_');
|
||||
String nameMatch = search.toLowerCase(Locale.ROOT);
|
||||
for (ItemType searchType : ItemType.REGISTRY) {
|
||||
@@ -373,15 +468,17 @@ public class GeneralCommands {
|
||||
continue;
|
||||
}
|
||||
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 + ")" : ""));
|
||||
if (id.contains(idMatch)) {
|
||||
Component name = searchType.getRichName();
|
||||
results.put(id, TextComponent.builder()
|
||||
.append(name)
|
||||
.append(" (" + id + ")")
|
||||
.build());
|
||||
}
|
||||
}
|
||||
List<String> list = new ArrayList<>(results.values());
|
||||
return PaginationBox.fromStrings("Search results for '" + search + "'", command, list).create(page);
|
||||
List<Component> list = new ArrayList<>(results.values());
|
||||
return PaginationBox.fromComponents("Search results for '" + search + "'", command, list)
|
||||
.create(page);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -561,7 +561,7 @@ public class SchematicCommands {
|
||||
|
||||
return msg.create();
|
||||
});
|
||||
PaginationBox paginationBox = PaginationBox.fromStrings("Available schematics", pageCommand, components);
|
||||
PaginationBox paginationBox = PaginationBox.fromComponents("Available schematics", pageCommand, components);
|
||||
actor.print(paginationBox.create(page));
|
||||
}
|
||||
|
||||
|
@@ -715,7 +715,7 @@ public class SelectionCommands {
|
||||
|
||||
final BlockState state = c.getID();
|
||||
final BlockType blockType = state.getBlockType();
|
||||
TextComponent blockName = TextComponent.of(blockType.getName(), TextColor.LIGHT_PURPLE);
|
||||
Component blockName = blockType.getRichName().color(TextColor.LIGHT_PURPLE);
|
||||
TextComponent toolTip;
|
||||
if (separateStates && state != blockType.getDefaultState()) {
|
||||
toolTip = TextComponent.of(state.getAsString(), TextColor.GRAY);
|
||||
|
@@ -25,8 +25,10 @@ import com.sk89q.worldedit.LocalConfiguration;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||
import com.sk89q.worldedit.command.tool.BlockDataCyler;
|
||||
import com.sk89q.worldedit.command.tool.BlockReplacer;
|
||||
import com.sk89q.worldedit.command.tool.BrushTool;
|
||||
import com.sk89q.worldedit.command.tool.DistanceWand;
|
||||
import com.sk89q.worldedit.command.tool.FloatingTreeRemover;
|
||||
import com.sk89q.worldedit.command.tool.FloodFillTool;
|
||||
@@ -35,19 +37,23 @@ import com.sk89q.worldedit.command.tool.LongRangeBuildTool;
|
||||
import com.sk89q.worldedit.command.tool.NavigationWand;
|
||||
import com.sk89q.worldedit.command.tool.QueryTool;
|
||||
import com.sk89q.worldedit.command.tool.SelectionWand;
|
||||
import com.sk89q.worldedit.command.tool.StackTool;
|
||||
import com.sk89q.worldedit.command.tool.Tool;
|
||||
import com.sk89q.worldedit.command.tool.TreePlanter;
|
||||
import com.sk89q.worldedit.command.util.CommandPermissions;
|
||||
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
|
||||
import com.sk89q.worldedit.command.util.SubCommandPermissionCondition;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.internal.command.CommandRegistrationHandler;
|
||||
import com.sk89q.worldedit.internal.command.CommandUtil;
|
||||
import com.sk89q.worldedit.util.HandSide;
|
||||
import com.sk89q.worldedit.util.TreeGenerator;
|
||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.item.ItemType;
|
||||
import org.enginehub.piston.CommandManager;
|
||||
import org.enginehub.piston.CommandManagerService;
|
||||
import org.enginehub.piston.CommandMetadata;
|
||||
@@ -82,14 +88,19 @@ public class ToolCommands {
|
||||
.collect(Collectors.toSet());
|
||||
for (org.enginehub.piston.Command command : commands) {
|
||||
if (command.getAliases().contains("unbind")) {
|
||||
// Don't register new /tool unbind alias
|
||||
// Don't register new /tool <whatever> alias
|
||||
command = command.toBuilder().aliases(
|
||||
Collections2.filter(command.getAliases(), alias -> !"unbind".equals(alias))
|
||||
).build();
|
||||
}
|
||||
if (command.getName().equals("stacker")) {
|
||||
// Don't register /stacker
|
||||
continue;
|
||||
}
|
||||
commandManager.register(CommandUtil.deprecate(
|
||||
command, "Global tool names cause conflicts "
|
||||
+ "and will be removed in WorldEdit 8", ToolCommands::asNonGlobal
|
||||
+ "and will be removed in WorldEdit 8",
|
||||
CommandUtil.ReplacementMessageGenerator.forNewCommand(ToolCommands::asNonGlobal)
|
||||
));
|
||||
}
|
||||
|
||||
@@ -110,6 +121,8 @@ public class ToolCommands {
|
||||
.required()
|
||||
.build());
|
||||
command.description(TextComponent.of("Binds a tool to the item in your hand"));
|
||||
|
||||
command.condition(new SubCommandPermissionCondition.Generator(nonGlobalCommands).build());
|
||||
});
|
||||
}
|
||||
|
||||
@@ -124,15 +137,33 @@ public class ToolCommands {
|
||||
|
||||
static void setToolNone(Player player, LocalSession session, boolean isBrush)
|
||||
throws InvalidToolBindException {
|
||||
session.setTool(player, null);
|
||||
isBrush = session.getTool(player) instanceof BrushTool;
|
||||
session.setTool(player.getItemInHand(HandSide.MAIN_HAND).getType(), null);
|
||||
player.printInfo(TranslatableComponent.of(isBrush ? "worldedit.brush.none.equip" : "worldedit.tool.none.equip"));
|
||||
}
|
||||
|
||||
private static void setTool(Player player, LocalSession session, Tool tool,
|
||||
String translationKey) throws InvalidToolBindException {
|
||||
BaseItemStack itemStack = player.getItemInHand(HandSide.MAIN_HAND);
|
||||
session.setTool(itemStack.getType(), tool);
|
||||
player.printInfo(TranslatableComponent.of(translationKey, itemStack.getRichName()));
|
||||
}
|
||||
|
||||
private final WorldEdit we;
|
||||
|
||||
public ToolCommands(WorldEdit we) {
|
||||
this.we = we;
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "none",
|
||||
aliases = "unbind",
|
||||
desc = "Unbind a bound tool from your current item"
|
||||
)
|
||||
public void none(Player player, LocalSession session) throws WorldEditException {
|
||||
setToolNone(player, session, false);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "selwand",
|
||||
aliases = "/selwand",
|
||||
@@ -140,9 +171,7 @@ public class ToolCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.setwand")
|
||||
public void selwand(Player player, LocalSession session) throws WorldEditException {
|
||||
final ItemType itemType = player.getItemInHand(HandSide.MAIN_HAND).getType();
|
||||
session.setTool(player, SelectionWand.INSTANCE);
|
||||
player.printInfo(TranslatableComponent.of("worldedit.tool.selwand.equip", TextComponent.of(itemType.getName())));
|
||||
setTool(player, session, SelectionWand.INSTANCE, "worldedit.tool.selwand.equip");
|
||||
}
|
||||
|
||||
@Command(
|
||||
@@ -152,10 +181,7 @@ public class ToolCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.setwand")
|
||||
public void navwand(Player player, LocalSession session) throws WorldEditException {
|
||||
|
||||
final ItemType itemType = player.getItemInHand(HandSide.MAIN_HAND).getType();
|
||||
session.setTool(player, NavigationWand.INSTANCE);
|
||||
player.printInfo(TranslatableComponent.of("worldedit.tool.navwand.equip", TextComponent.of(itemType.getName())));
|
||||
setTool(player, session, NavigationWand.INSTANCE, "worldedit.tool.navwand.equip");
|
||||
}
|
||||
|
||||
@Command(
|
||||
@@ -165,10 +191,7 @@ public class ToolCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.tool.info")
|
||||
public void info(Player player, LocalSession session) throws WorldEditException {
|
||||
|
||||
final ItemType itemType = player.getItemInHand(HandSide.MAIN_HAND).getType();
|
||||
session.setTool(player, new QueryTool());
|
||||
player.printInfo(TranslatableComponent.of("worldedit.tool.info.equip", TextComponent.of(itemType.getName())));
|
||||
setTool(player, session, new QueryTool(), "worldedit.tool.info.equip");
|
||||
}
|
||||
|
||||
@Command(
|
||||
@@ -178,9 +201,7 @@ public class ToolCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.tool.inspect")
|
||||
public void inspectBrush(Player player, LocalSession session) throws WorldEditException {
|
||||
final ItemType itemType = player.getItemInHand(HandSide.MAIN_HAND).getType();
|
||||
session.setTool(player, new InspectBrush());
|
||||
player.printInfo(TranslatableComponent.of("worldedit.tool.inspect.equip", TextComponent.of(itemType.getName())));
|
||||
setTool(player, session, new InspectBrush(), "worldedit.tool.info.equip");
|
||||
}
|
||||
|
||||
@Command(
|
||||
@@ -192,10 +213,20 @@ public class ToolCommands {
|
||||
public void tree(Player player, LocalSession session,
|
||||
@Arg(desc = "Type of tree to generate", def = "tree")
|
||||
TreeGenerator.TreeType type) throws WorldEditException {
|
||||
setTool(player, session, new TreePlanter(type), "worldedit.tool.tree.equip");
|
||||
}
|
||||
|
||||
final ItemType itemType = player.getItemInHand(HandSide.MAIN_HAND).getType();
|
||||
session.setTool(player, new TreePlanter(type));
|
||||
player.printInfo(TranslatableComponent.of("worldedit.tool.tree.equip", TextComponent.of(itemType.getName())));
|
||||
@Command(
|
||||
name = "stacker",
|
||||
desc = "Block stacker tool"
|
||||
)
|
||||
@CommandPermissions("worldedit.tool.stack")
|
||||
public void stacker(Player player, LocalSession session,
|
||||
@Arg(desc = "The max range of the stack", def = "10")
|
||||
int range,
|
||||
@Arg(desc = "The mask to stack until", def = "!#existing")
|
||||
Mask mask) throws WorldEditException {
|
||||
setTool(player, session, new StackTool(range, mask), "worldedit.tool.stack.equip");
|
||||
}
|
||||
|
||||
@Command(
|
||||
@@ -207,10 +238,7 @@ public class ToolCommands {
|
||||
public void repl(Player player, LocalSession session,
|
||||
@Arg(desc = "The pattern of blocks to place")
|
||||
Pattern pattern) throws WorldEditException {
|
||||
|
||||
final ItemType itemType = player.getItemInHand(HandSide.MAIN_HAND).getType();
|
||||
session.setTool(player, new BlockReplacer(pattern));
|
||||
player.printInfo(TranslatableComponent.of("worldedit.tool.repl.equip", TextComponent.of(itemType.getName())));
|
||||
setTool(player, session, new BlockReplacer(pattern), "worldedit.tool.repl.equip");
|
||||
}
|
||||
|
||||
@Command(
|
||||
@@ -220,10 +248,7 @@ public class ToolCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.tool.data-cycler")
|
||||
public void cycler(Player player, LocalSession session) throws WorldEditException {
|
||||
|
||||
final ItemType itemType = player.getItemInHand(HandSide.MAIN_HAND).getType();
|
||||
session.setTool(player, new BlockDataCyler());
|
||||
player.printInfo(TranslatableComponent.of("worldedit.tool.data-cycler.equip", TextComponent.of(itemType.getName())));
|
||||
setTool(player, session, new BlockDataCyler(), "worldedit.tool.data-cycler.equip");
|
||||
}
|
||||
|
||||
@Command(
|
||||
@@ -241,13 +266,10 @@ public class ToolCommands {
|
||||
LocalConfiguration config = we.getConfiguration();
|
||||
|
||||
if (range > config.maxSuperPickaxeSize) {
|
||||
player.printError(TranslatableComponent.of("worldedit.superpickaxe.max-range", TextComponent.of(config.maxSuperPickaxeSize)));
|
||||
player.printError(TranslatableComponent.of("worldedit.tool.superpickaxe.max-range", TextComponent.of(config.maxSuperPickaxeSize)));
|
||||
return;
|
||||
}
|
||||
|
||||
final ItemType itemType = player.getItemInHand(HandSide.MAIN_HAND).getType();
|
||||
session.setTool(player, new FloodFillTool(range, pattern));
|
||||
player.printInfo(TranslatableComponent.of("worldedit.tool.floodfill.equip", TextComponent.of(itemType.getName())));
|
||||
setTool(player, session, new FloodFillTool(range, pattern), "worldedit.tool.floodfill.equip");
|
||||
}
|
||||
|
||||
@Command(
|
||||
@@ -257,10 +279,7 @@ public class ToolCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.tool.deltree")
|
||||
public void deltree(Player player, LocalSession session) throws WorldEditException {
|
||||
|
||||
final ItemType itemType = player.getItemInHand(HandSide.MAIN_HAND).getType();
|
||||
session.setTool(player, new FloatingTreeRemover());
|
||||
player.printInfo(TranslatableComponent.of("worldedit.tool.deltree.equip", TextComponent.of(itemType.getName())));
|
||||
setTool(player, session, new FloatingTreeRemover(), "worldedit.tool.deltree.equip");
|
||||
}
|
||||
|
||||
@Command(
|
||||
@@ -270,9 +289,7 @@ public class ToolCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.tool.farwand")
|
||||
public void farwand(Player player, LocalSession session) throws WorldEditException {
|
||||
final ItemType itemType = player.getItemInHand(HandSide.MAIN_HAND).getType();
|
||||
session.setTool(player, new DistanceWand());
|
||||
player.printInfo(TranslatableComponent.of("worldedit.tool.farwand.equip", TextComponent.of(itemType.getName())));
|
||||
setTool(player, session, new DistanceWand(), "worldedit.tool.farwand.equip");
|
||||
}
|
||||
|
||||
@Command(
|
||||
@@ -286,18 +303,19 @@ public class ToolCommands {
|
||||
Pattern primary,
|
||||
@Arg(desc = "Pattern to set on right-click")
|
||||
Pattern secondary) throws WorldEditException {
|
||||
|
||||
final ItemType itemType = player.getItemInHand(HandSide.MAIN_HAND).getType();
|
||||
session.setTool(player, new LongRangeBuildTool(primary, secondary));
|
||||
player.printInfo(TranslatableComponent.of("worldedit.tool.lrbuild.equip", TextComponent.of(itemType.getName())));
|
||||
String primaryName = "pattern";
|
||||
String secondaryName = "pattern";
|
||||
setTool(player, session, new LongRangeBuildTool(primary, secondary), "worldedit.tool.lrbuild.equip");
|
||||
Component primaryName;
|
||||
Component secondaryName;
|
||||
if (primary instanceof BlockStateHolder) {
|
||||
primaryName = ((BlockStateHolder<?>) primary).getBlockType().getName();
|
||||
primaryName = ((BlockStateHolder<?>) primary).getBlockType().getRichName();
|
||||
} else {
|
||||
primaryName = TextComponent.of("pattern");
|
||||
}
|
||||
if (secondary instanceof BlockStateHolder) {
|
||||
secondaryName = ((BlockStateHolder<?>) secondary).getBlockType().getName();
|
||||
secondaryName = ((BlockStateHolder<?>) secondary).getBlockType().getRichName();
|
||||
} else {
|
||||
secondaryName = TextComponent.of("pattern");
|
||||
}
|
||||
player.printInfo(TranslatableComponent.of("worldedit.tool.lrbuild.set", TextComponent.of(primaryName), TextComponent.of(secondaryName)));
|
||||
player.printInfo(TranslatableComponent.of("worldedit.tool.lrbuild.set", primaryName, secondaryName));
|
||||
}
|
||||
}
|
||||
|
@@ -78,7 +78,7 @@ public class BlockReplacer implements DoubleActionBlockTool {
|
||||
|
||||
if (targetBlock != null) {
|
||||
pattern = targetBlock;
|
||||
player.printInfo(TranslatableComponent.of("worldedit.tool.repl.switched", TextComponent.of(targetBlock.getBlockType().getName())));
|
||||
player.printInfo(TranslatableComponent.of("worldedit.tool.repl.switched", targetBlock.getBlockType().getRichName()));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@@ -59,7 +59,7 @@ public class QueryTool implements BlockTool {
|
||||
|
||||
TextComponent.Builder builder = TextComponent.builder();
|
||||
builder.append(TextComponent.of("@" + clicked.toVector().toBlockPoint() + ": ", TextColor.BLUE));
|
||||
builder.append(TextComponent.of(block.getBlockType().getName(), TextColor.YELLOW));
|
||||
builder.append(block.getBlockType().getRichName().color(TextColor.YELLOW));
|
||||
builder.append(TextComponent.of(" (" + block + ") ", TextColor.GRAY)
|
||||
.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TranslatableComponent.of("worldedit.tool.info.blockstate.hover"))));
|
||||
final int internalId = BlockStateIdAccess.getBlockStateId(block.toImmutableState());
|
||||
|
@@ -19,10 +19,12 @@
|
||||
|
||||
package com.sk89q.worldedit.command.util;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import org.enginehub.piston.Command;
|
||||
import org.enginehub.piston.inject.InjectedValueAccess;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
@@ -45,8 +47,8 @@ public final class SubCommandPermissionCondition extends PermissionCondition {
|
||||
public static class Generator {
|
||||
private final List<Command> subCommands;
|
||||
|
||||
public Generator(List<Command> subCommands) {
|
||||
this.subCommands = subCommands;
|
||||
public Generator(Collection<? extends Command> subCommands) {
|
||||
this.subCommands = ImmutableList.copyOf(subCommands);
|
||||
}
|
||||
|
||||
public Command.Condition build() {
|
||||
|
Reference in New Issue
Block a user