From 6f32783e523484de524ccacc6d174696e5c57a4d Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Thu, 21 Nov 2019 14:07:07 +0000 Subject: [PATCH] Fix compile --- .../worldedit/command/SelectionCommands.java | 30 ++++--- .../worldedit/command/WorldEditCommands.java | 1 - .../component/BlockDistributionResult.java | 90 ------------------- .../src/main/resources/lang/strings.json | 2 +- 4 files changed, 17 insertions(+), 106 deletions(-) delete mode 100644 worldedit-core/src/main/java/com/sk89q/worldedit/util/formatting/component/BlockDistributionResult.java diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/SelectionCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/SelectionCommands.java index 3bfd7144c..58a867d72 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/SelectionCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/SelectionCommands.java @@ -46,7 +46,6 @@ import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Locatable; import com.sk89q.worldedit.extension.platform.permission.ActorSelectorLimits; import com.sk89q.worldedit.extent.AbstractDelegateExtent; -import com.sk89q.worldedit.command.util.WorldEditAsyncCommandBuilder; import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.internal.annotation.Direction; @@ -300,7 +299,7 @@ public class SelectionCommands { session.setTool(itemType, NavigationWand.INSTANCE); player.printInfo(TranslatableComponent.of("worldedit.wand.navwand.info")); } else { - session.setTool(itemType, new SelectionWand()); + session.setTool(itemType, SelectionWand.INSTANCE); player.printInfo(TranslatableComponent.of("worldedit.wand.selwand.info")); } if (!player.hasPermission("fawe.tips")) @@ -453,7 +452,7 @@ public class SelectionCommands { desc = "Get information about the selection" ) @CommandPermissions("worldedit.selection.size") - public void size(Player player, LocalSession session, + public void size(Actor actor, World world, LocalSession session, @Switch(name = 'c', desc = "Get clipboard info instead") boolean clipboardInfo) throws WorldEditException { Region region; @@ -477,16 +476,17 @@ public class SelectionCommands { region = clipboard.getRegion(); BlockVector3 size = region.getMaximumPoint() .subtract(region.getMinimumPoint()). - add(1, 1, 1); + add(1, 1, 1); BlockVector3 origin = clipboard.getOrigin(); String sizeStr = size.getBlockX() + "*" + size.getBlockY() + "*" + size.getBlockZ(); String originStr = origin.getBlockX() + "," + origin.getBlockY() + "," + origin.getBlockZ(); long numBlocks = ((long) size.getBlockX() * size.getBlockY() * size.getBlockZ()); - - BlockVector3 origin = clipboard.getOrigin(); - actor.printInfo(TranslatableComponent.of("worldedit.size.offset", TextComponent.of(origin.toString()))); + actor.printInfo(TranslatableComponent.of("worldedit.size.offset", TextComponent.of(name), TextComponent.of(sizeStr), TextComponent.of(originStr), TextComponent.of(numBlocks))); + index++; + } + return; } else { region = session.getSelection(world); @@ -524,11 +524,13 @@ public class SelectionCommands { desc = "Get the distribution of blocks in the selection" ) @CommandPermissions("worldedit.analysis.distr") - public void distr(Player player, LocalSession session, EditSession editSession, + public void distr(Actor actor, World world, LocalSession session, EditSession editSession, @Switch(name = 'c', desc = "Get the distribution of the clipboard instead") - boolean clipboardDistr, + boolean clipboardDistr, @Switch(name = 'd', desc = "Separate blocks by state") - boolean separateStates) throws WorldEditException { + boolean separateStates, + @ArgFlag(name = 'p', desc = "Gets page from a previous distribution.", def = "") + Integer page) throws WorldEditException { List distribution; Region region; @@ -538,7 +540,7 @@ public class SelectionCommands { region = clipboard.getRegion(); new ExtentTraverser(editSession).setNext(new AbstractDelegateExtent(clipboard)); } else { - region = session.getSelection(player.getWorld()); + region = session.getSelection(world); } if (separateStates) distribution = (List) editSession.getBlockDistributionWithData(region); @@ -553,16 +555,16 @@ public class SelectionCommands { BlockDistributionResult res = new BlockDistributionResult(distribution, separateStates); if (!actor.isPlayer()) res.formatForConsole(); - return res.create(finalPage); + actor.print(res.create(page)); } private static class BlockDistributionResult extends PaginationBox { - private final List> distribution; + private final List distribution; private final int totalBlocks; private final boolean separateStates; - BlockDistributionResult(List> distribution, boolean separateStates) { + BlockDistributionResult(List distribution, boolean separateStates) { super("Block Distribution", "//distr -p %page%" + (separateStates ? " -d" : "")); this.distribution = distribution; // note: doing things like region.getArea is inaccurate for non-cuboids. diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/WorldEditCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/WorldEditCommands.java index 57a496791..ec9977dd6 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/WorldEditCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/WorldEditCommands.java @@ -143,7 +143,6 @@ public class WorldEditCommands { public void report(Actor actor) throws WorldEditException, IOException { String dest = IncendoPaster.debugPaste(); actor.printInfo(TranslatableComponent.of("worldedit.report.written", TextComponent.of(dest))); - BBC.DOWNLOAD_LINK.send(actor, ); } @Command( diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/formatting/component/BlockDistributionResult.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/formatting/component/BlockDistributionResult.java deleted file mode 100644 index 7b9d27ec7..000000000 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/formatting/component/BlockDistributionResult.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * WorldEdit, a Minecraft world manipulation toolkit - * Copyright (C) sk89q - * 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 . - */ - -package com.sk89q.worldedit.util.formatting.component; - -import com.google.common.base.Strings; -import com.sk89q.worldedit.util.Countable; -import com.sk89q.worldedit.util.formatting.text.Component; -import com.sk89q.worldedit.util.formatting.text.TextComponent; -import com.sk89q.worldedit.util.formatting.text.event.HoverEvent; -import com.sk89q.worldedit.util.formatting.text.format.TextColor; -import com.sk89q.worldedit.world.block.BlockState; -import com.sk89q.worldedit.world.block.BlockType; - -import java.util.List; - -public class BlockDistributionResult extends PaginationBox { - - private final List distribution; - private final int totalBlocks; - private final boolean separateStates; - - public BlockDistributionResult(List distribution, boolean separateStates) { - super("Block Distribution", "//distr -p %page%" + (separateStates ? " -d" : "")); - this.distribution = distribution; - // note: doing things like region.getArea is inaccurate for non-cuboids. - this.totalBlocks = distribution.stream().mapToInt(Countable::getAmount).sum(); - this.separateStates = separateStates; - setComponentsPerPage(7); - } - - @Override - public Component getComponent(int number) { - Countable c = distribution.get(number); - TextComponent.Builder line = TextComponent.builder(); - - final int count = c.getAmount(); - - final double perc = count / (double) totalBlocks * 100; - final int maxDigits = (int) (Math.log10(totalBlocks) + 1); - final int curDigits = (int) (Math.log10(count) + 1); - line.append(String.format("%s%.3f%% ", perc < 10 ? " " : "", perc), TextColor.GOLD); - final int space = maxDigits - curDigits; - String pad = Strings.repeat(" ", space == 0 ? 2 : 2 * space + 1); - line.append(String.format("%s%s", count, pad), TextColor.YELLOW); - - final BlockState state = c.getID(); - final BlockType blockType = state.getBlockType(); - TextComponent blockName = TextComponent.of(blockType.getName(), TextColor.LIGHT_PURPLE); - TextComponent toolTip; - if (separateStates && state != blockType.getDefaultState()) { - toolTip = TextComponent.of(state.getAsString(), TextColor.GRAY); - blockName = blockName.append(TextComponent.of("*", TextColor.LIGHT_PURPLE)); - } else { - toolTip = TextComponent.of(blockType.getId(), TextColor.GRAY); - } - blockName = blockName.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, toolTip)); - line.append(blockName); - - return line.build(); - } - - @Override - public int getComponentsSize() { - return distribution.size(); - } - - @Override - public Component create(int page) throws InvalidComponentException { - super.getContents().append(TextComponent.of("Total Block Count: " + totalBlocks, TextColor.GRAY)) - .append(TextComponent.newline()); - return super.create(page); - } -} diff --git a/worldedit-core/src/main/resources/lang/strings.json b/worldedit-core/src/main/resources/lang/strings.json index 7c6ea3270..416a7a989 100644 --- a/worldedit-core/src/main/resources/lang/strings.json +++ b/worldedit-core/src/main/resources/lang/strings.json @@ -115,7 +115,7 @@ "worldedit.shift.shifted": "Region shifted.", "worldedit.outset.outset": "Region outset.", "worldedit.inset.inset": "Region inset.", - "worldedit.size.offset": "Offset: {0}", + "worldedit.size.offset": "{0}: {1} @ {2} ({3} blocks)", "worldedit.size.type": "Type: {0}", "worldedit.size.size": "Size: {0}", "worldedit.size.distance": "Cuboid distance: {0}",