From 9c3122a2279b31e3a5c642496014b5b8c627f9b9 Mon Sep 17 00:00:00 2001 From: MattBDev <4009945+MattBDev@users.noreply.github.com> Date: Sun, 21 Jul 2019 22:49:08 -0400 Subject: [PATCH] More work on getting commands to compile --- .../voxelsniper/VoxelSniperListener.java | 25 +- .../voxelsniper/brush/CloneStampBrush.java | 4 +- .../voxelsniper/brush/ErodeBrush.java | 8 +- .../voxelsniper/brush/Rot3DBrush.java | 6 +- .../voxelsniper/brush/SnowConeBrush.java | 54 +-- .../voxelsniper/brush/perform/PerformerE.java | 4 +- .../command/VoxelBrushCommand.java | 6 +- .../com/boydti/fawe/bukkit/FaweBukkit.java | 6 +- .../boydti/fawe/bukkit/beta/BukkitQueue.java | 8 +- .../util/CommandsManagerRegistration.java | 78 ---- .../worldedit/bukkit/BukkitTextAdapter.java | 34 +- .../sk89q/worldedit/bukkit/BukkitWorld.java | 22 +- .../worldedit/bukkit/WorldEditListener.java | 28 +- .../worldedit/bukkit/WorldEditPlugin.java | 25 +- .../bukkit/adapter/BukkitImplLoader.java | 2 +- .../main/java/com/boydti/fawe/FaweCache.java | 16 +- .../java/com/boydti/fawe/FaweVersion.java | 6 +- .../boydti/fawe/command/AnvilCommands.java | 40 +- .../com/boydti/fawe/command/CFICommand.java | 4 - .../com/boydti/fawe/command/CFICommands.java | 112 +++--- .../com/boydti/fawe/command/FaweBinding.java | 32 +- .../com/boydti/fawe/command/MaskBinding.java | 58 +-- .../boydti/fawe/command/PatternBinding.java | 52 +-- .../com/boydti/fawe/command/PlotLoader.java | 25 +- .../com/boydti/fawe/command/Rollback.java | 27 +- .../com/boydti/fawe/object/FawePlayer.java | 18 +- .../fawe/object/brush/BrushSettings.java | 10 +- .../brush/heightmap/ScalableHeightMap.java | 10 +- .../main/java/com/boydti/fawe/util/Perm.java | 14 +- .../boydti/fawe/util/RandomTextureUtil.java | 2 +- .../java/com/boydti/fawe/util/StringMan.java | 107 +++--- .../com/boydti/fawe/util/TaskManager.java | 4 +- .../java/com/boydti/fawe/web/SchemSync.java | 48 ++- .../util/commands/CommandContext.java | 19 +- .../util/commands/CommandsManager.java | 6 +- .../util/commands/SimpleInjector.java | 53 --- .../worldedit/command/BrushCommands.java | 193 ++++++---- .../command/BrushOptionsCommands.java | 260 +++++++------ .../worldedit/command/ClipboardCommands.java | 6 +- .../worldedit/command/ExpandCommands.java | 27 +- .../worldedit/command/GenerationCommands.java | 16 +- .../worldedit/command/HistoryCommands.java | 15 +- .../worldedit/command/NavigationCommands.java | 3 - .../worldedit/command/PatternCommands.java | 3 +- .../worldedit/command/RegionCommands.java | 221 ++++++----- .../worldedit/command/ScriptingCommands.java | 24 +- .../worldedit/command/SelectionCommands.java | 5 +- .../worldedit/command/SnapshotCommands.java | 95 +++-- .../command/SuperPickaxeCommands.java | 40 +- .../worldedit/command/TransformCommands.java | 43 +-- .../worldedit/command/UtilityCommands.java | 11 +- .../factory/DefaultTransformParser.java | 2 +- .../platform/PlatformCommandManager.java | 348 +++++++++--------- .../scripting/CommandScriptLoader.java | 2 +- .../scripting/NashornCraftScriptEngine.java | 1 - .../scripting/RhinoCraftScriptEngine.java | 2 +- worldedit-libs/build.gradle | 3 +- 57 files changed, 1149 insertions(+), 1144 deletions(-) delete mode 100644 worldedit-bukkit/src/main/java/com/sk89q/bukkit/util/CommandsManagerRegistration.java delete mode 100644 worldedit-core/src/main/java/com/sk89q/minecraft/util/commands/SimpleInjector.java diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/VoxelSniperListener.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/VoxelSniperListener.java index eb0844e3f..da6e8eba5 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/VoxelSniperListener.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/VoxelSniperListener.java @@ -4,9 +4,27 @@ import com.boydti.fawe.config.BBC; import com.boydti.fawe.object.FawePlayer; import com.sk89q.minecraft.util.commands.CommandException; import com.sk89q.worldedit.extension.platform.PlatformCommandManager; -import com.sk89q.worldedit.util.command.parametric.ExceptionConverter; +import com.sk89q.worldedit.internal.command.exception.ExceptionConverter; import com.thevoxelbox.voxelsniper.api.command.VoxelCommand; -import com.thevoxelbox.voxelsniper.command.*; +import com.thevoxelbox.voxelsniper.command.VoxelBrushCommand; +import com.thevoxelbox.voxelsniper.command.VoxelBrushToolCommand; +import com.thevoxelbox.voxelsniper.command.VoxelCenterCommand; +import com.thevoxelbox.voxelsniper.command.VoxelChunkCommand; +import com.thevoxelbox.voxelsniper.command.VoxelDefaultCommand; +import com.thevoxelbox.voxelsniper.command.VoxelGoToCommand; +import com.thevoxelbox.voxelsniper.command.VoxelHeightCommand; +import com.thevoxelbox.voxelsniper.command.VoxelInkCommand; +import com.thevoxelbox.voxelsniper.command.VoxelInkReplaceCommand; +import com.thevoxelbox.voxelsniper.command.VoxelListCommand; +import com.thevoxelbox.voxelsniper.command.VoxelPaintCommand; +import com.thevoxelbox.voxelsniper.command.VoxelPerformerCommand; +import com.thevoxelbox.voxelsniper.command.VoxelReplaceCommand; +import com.thevoxelbox.voxelsniper.command.VoxelSniperCommand; +import com.thevoxelbox.voxelsniper.command.VoxelUndoCommand; +import com.thevoxelbox.voxelsniper.command.VoxelUndoUserCommand; +import com.thevoxelbox.voxelsniper.command.VoxelVoxelCommand; +import java.util.HashMap; +import java.util.Map; import org.bukkit.ChatColor; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -14,9 +32,6 @@ import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerJoinEvent; -import java.util.HashMap; -import java.util.Map; - public class VoxelSniperListener implements Listener { diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/CloneStampBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/CloneStampBrush.java index 189c0cbfc..334b7a5ed 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/CloneStampBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/CloneStampBrush.java @@ -17,7 +17,7 @@ public CloneStampBrush() { /** * The clone method is used to grab a snapshot of the selected area dictated blockPositionY targetBlock.x y z v.brushSize v.voxelHeight and v.cCen. *

- * x y z -- initial center of the selection v.brushSize -- the radius of the cylinder v.voxelHeight -- the heigth of the cylinder c.cCen -- the offset on + * x y z -- initial center of the selection v.brushSize -- the radius of the cylinder v.voxelHeight -- the height of the cylinder c.cCen -- the offset on * the Y axis of the selection ( bottom of the cylinder ) as blockPositionY: Bottom_Y = targetBlock.y + v.cCen; * * @param v Sniper Caller @@ -71,7 +71,7 @@ public CloneStampBrush() { } } } - v.sendMessage(ChatColor.GREEN + String.valueOf(this.clone.size()) + ChatColor.AQUA + " blocks copied sucessfully."); + v.sendMessage(ChatColor.GREEN + String.valueOf(this.clone.size()) + ChatColor.AQUA + " blocks copied successfully."); } @Override diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/ErodeBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/ErodeBrush.java index b2de663cd..d2e37f7e8 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/ErodeBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/ErodeBrush.java @@ -174,7 +174,7 @@ public class ErodeBrush extends Brush { vm.brushName(this.getName()); vm.size(); vm.custom(ChatColor.AQUA + "Erosion minimum exposed faces set to " + this.currentPreset.getErosionFaces()); - vm.custom(ChatColor.BLUE + "Fill minumum touching faces set to " + this.currentPreset.getFillFaces()); + vm.custom(ChatColor.BLUE + "Fill minimum touching faces set to " + this.currentPreset.getFillFaces()); vm.custom(ChatColor.DARK_BLUE + "Erosion recursion amount set to " + this.currentPreset.getErosionRecursion()); vm.custom(ChatColor.DARK_GREEN + "Fill recursion amount set to " + this.currentPreset.getFillRecursion()); } @@ -252,9 +252,9 @@ public class ErodeBrush extends Brush { /** * Generates a concat string of all options. * - * @param seperator Seperator for delimiting entries. + * @param separator Separator for delimiting entries. */ - public static String getValuesString(String seperator) { + public static String getValuesString(String separator) { StringBuilder valuesString = new StringBuilder(); boolean delimiterHelper = true; @@ -262,7 +262,7 @@ public class ErodeBrush extends Brush { if (delimiterHelper) { delimiterHelper = false; } else { - valuesString.append(seperator); + valuesString.append(separator); } valuesString.append(preset.name()); } diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/Rot3DBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/Rot3DBrush.java index 008d32d9e..651401d7b 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/Rot3DBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/Rot3DBrush.java @@ -102,10 +102,10 @@ public class Rot3DBrush extends Brush { private void rotate(final SnipeData v) { // basically 1) make it a sphere we are rotating in, not a cylinder - // 2) do three rotations in a row, one in each dimension, unless some dimensions are set to zero or udnefined or whatever, then skip those. - // --> Why not utilize Sniper'world new oportunities and have arrow rotate all 3, powder rotate x, goldsisc y, otherdisc z. Or something like that. Or + // 2) do three rotations in a row, one in each dimension, unless some dimensions are set to zero or undefined or whatever, then skip those. + // --> Why not utilize Sniper'world new opportunities and have arrow rotate all 3, powder rotate x, goldsisc y, otherdisc z. Or something like that. Or // we - // could just use arrow and powder and just differenciate between left and right click that gis 4 different situations + // could just use arrow and powder and just differentiate between left and right click that gis 4 different situations // --> Well, there would be 7 different possibilities... X, Y, Z, XY, XZ, YZ, XYZ, and different numbers of parameters for each, so I think each having // and item is too confusing. How about this: arrow = rotate one dimension, based on the face you click, and takes 1 param... powder: rotates all three // at once, and takes 3 params. diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SnowConeBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SnowConeBrush.java index a79a19339..0188ad5b3 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SnowConeBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SnowConeBrush.java @@ -27,8 +27,8 @@ public class SnowConeBrush extends Brush { } final int brushSizeDoubled = 2 * brushSize; - final int[][] snowcone = new int[brushSizeDoubled + 1][brushSizeDoubled + 1]; // Will hold block IDs - final int[][] snowconeData = new int[brushSizeDoubled + 1][brushSizeDoubled + 1]; // Will hold data values for snowcone + final int[][] snowCone = new int[brushSizeDoubled + 1][brushSizeDoubled + 1]; // Will hold block IDs + final int[][] snowConeData = new int[brushSizeDoubled + 1][brushSizeDoubled + 1]; // Will hold data values for snowCone final int[][] yOffset = new int[brushSizeDoubled + 1][brushSizeDoubled + 1]; // prime the arrays @@ -44,12 +44,12 @@ public class SnowConeBrush extends Brush { } } } - snowcone[x][z] = this.getBlockIdAt(blockPositionX - brushSize + x, blockPositionY - yOffset[x][z], blockPositionZ - brushSize + z); - snowconeData[x][z] = this.clampY(blockPositionX - brushSize + x, blockPositionY - yOffset[x][z], blockPositionZ - brushSize + z).getPropertyId(); + snowCone[x][z] = this.getBlockIdAt(blockPositionX - brushSize + x, blockPositionY - yOffset[x][z], blockPositionZ - brushSize + z); + snowConeData[x][z] = this.clampY(blockPositionX - brushSize + x, blockPositionY - yOffset[x][z], blockPositionZ - brushSize + z).getPropertyId(); } } - // figure out new snowheights + // figure out new snowHeights for (int x = 0; x <= brushSizeDoubled; x++) { final double xSquared = Math.pow(x - brushSize, 2); @@ -61,35 +61,35 @@ public class SnowConeBrush extends Brush { if (snowData >= 0) { // no funny business switch (snowData) { case 0: - if (BlockTypes.get(snowcone[x][z]).getMaterial().isAir()) { - snowcone[x][z] = BlockTypes.SNOW.getInternalId(); - snowconeData[x][z] = 0; + if (BlockTypes.get(snowCone[x][z]).getMaterial().isAir()) { + snowCone[x][z] = BlockTypes.SNOW.getInternalId(); + snowConeData[x][z] = 0; } break; - case 7: // Turn largest snowtile into snowblock - if (snowcone[x][z] == BlockTypes.SNOW.getInternalId()) { - snowcone[x][z] = BlockTypes.SNOW_BLOCK.getInternalId(); - snowconeData[x][z] = 0; + case 7: // Turn largest snowTile into snow block + if (snowCone[x][z] == BlockTypes.SNOW.getInternalId()) { + snowCone[x][z] = BlockTypes.SNOW_BLOCK.getInternalId(); + snowConeData[x][z] = 0; } break; - default: // Increase snowtile size, if smaller than target + default: // Increase snowTile size, if smaller than target - if (snowData > snowconeData[x][z]) { + if (snowData > snowConeData[x][z]) { BlockType blockType = - BlockTypes.get(snowcone[x][z]); + BlockTypes.get(snowCone[x][z]); if (blockType.getMaterial().isAir()) { - snowconeData[x][z] = snowData; - snowcone[x][z] = BlockTypes.SNOW.getInternalId(); + snowConeData[x][z] = snowData; + snowCone[x][z] = BlockTypes.SNOW.getInternalId(); - snowconeData[x][z] = snowData; + snowConeData[x][z] = snowData; } else if (blockType == BlockTypes.SNOW_BLOCK) { - snowconeData[x][z] = snowData; + snowConeData[x][z] = snowData; } - } else if (yOffset[x][z] > 0 && snowcone[x][z] == BlockTypes.SNOW.getInternalId()) { - snowconeData[x][z]++; - if (snowconeData[x][z] == 7) { - snowconeData[x][z] = 0; - snowcone[x][z] = BlockTypes.SNOW_BLOCK.getInternalId(); + } else if (yOffset[x][z] > 0 && snowCone[x][z] == BlockTypes.SNOW.getInternalId()) { + snowConeData[x][z]++; + if (snowConeData[x][z] == 7) { + snowConeData[x][z] = 0; + snowCone[x][z] = BlockTypes.SNOW_BLOCK.getInternalId(); } } break; @@ -103,11 +103,11 @@ public class SnowConeBrush extends Brush { for (int x = 0; x <= brushSizeDoubled; x++) { for (int z = 0; z <= brushSizeDoubled; z++) { - if (this.getBlockIdAt(blockPositionX - brushSize + x, blockPositionY - yOffset[x][z], blockPositionZ - brushSize + z) != snowcone[x][z] || this.clampY(blockPositionX - brushSize + x, blockPositionY - yOffset[x][z], blockPositionZ - brushSize + z).getPropertyId() != snowconeData[x][z]) { + if (this.getBlockIdAt(blockPositionX - brushSize + x, blockPositionY - yOffset[x][z], blockPositionZ - brushSize + z) != snowCone[x][z] || this.clampY(blockPositionX - brushSize + x, blockPositionY - yOffset[x][z], blockPositionZ - brushSize + z).getPropertyId() != snowConeData[x][z]) { undo.put(this.clampY(blockPositionX - brushSize + x, blockPositionY - yOffset[x][z], blockPositionZ - brushSize + z)); } - this.setBlockIdAt(blockPositionZ - brushSize + z, blockPositionX - brushSize + x, blockPositionY - yOffset[x][z], snowcone[x][z]); - this.clampY(blockPositionX - brushSize + x, blockPositionY - yOffset[x][z], blockPositionZ - brushSize + z).setPropertyId(snowconeData[x][z]); + this.setBlockIdAt(blockPositionZ - brushSize + z, blockPositionX - brushSize + x, blockPositionY - yOffset[x][z], snowCone[x][z]); + this.clampY(blockPositionX - brushSize + x, blockPositionY - yOffset[x][z], blockPositionZ - brushSize + z).setPropertyId(snowConeData[x][z]); } } diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/PerformerE.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/PerformerE.java index 273d9a3df..76faef954 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/PerformerE.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/PerformerE.java @@ -22,11 +22,11 @@ import java.util.logging.Logger; * * new extra: n = no undo * - * The main benefit of this system is that it provides the least possible number of characters in the paramaters + * The main benefit of this system is that it provides the least possible number of characters in the parameters * while guaranteeing that all sensible combinations will be made. Additionally, the names will be VERY consistent * * EX Old System: /b b isrcup (use /v, /vi, /vr and /vir, update graphics and no physics) - * EX New System: /b b ccup (two characters shorter, good because snipers have been complaing about keystrokes) + * EX New System: /b b ccup (two characters shorter, good because snipers have been complaining about keystrokes) * */ diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelBrushCommand.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelBrushCommand.java index 6762d723d..4cf614640 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelBrushCommand.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelBrushCommand.java @@ -43,12 +43,12 @@ public class VoxelBrushCommand extends VoxelCommand { Bukkit.getPluginManager().callEvent(event); snipeData.getVoxelMessage().size(); return true; - } catch (NumberFormatException ingored) { + } catch (NumberFormatException ignored) { } Class brush = plugin.getBrushManager().getBrushForHandle(args[0]); if (brush != null) { - IBrush orignalBrush = sniper.getBrush(currentToolId); + IBrush originalBrush = sniper.getBrush(currentToolId); sniper.setBrush(currentToolId, brush); if (args.length > 1) { @@ -63,7 +63,7 @@ public class VoxelBrushCommand extends VoxelCommand { return true; } } - SniperBrushChangedEvent event = new SniperBrushChangedEvent(sniper, currentToolId, orignalBrush, sniper.getBrush(currentToolId)); + SniperBrushChangedEvent event = new SniperBrushChangedEvent(sniper, currentToolId, originalBrush, sniper.getBrush(currentToolId)); sniper.displayInfo(); return true; } else { diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/FaweBukkit.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/FaweBukkit.java index 435366446..feecc0ce5 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/FaweBukkit.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/FaweBukkit.java @@ -458,10 +458,10 @@ public class FaweBukkit implements IFawe, Listener { e.printStackTrace(); } } - final Plugin preciousstonesPlugin = Bukkit.getServer().getPluginManager().getPlugin("PreciousStones"); - if (preciousstonesPlugin != null && preciousstonesPlugin.isEnabled()) { + final Plugin preciousStonesPlugin = Bukkit.getServer().getPluginManager().getPlugin("PreciousStones"); + if (preciousStonesPlugin != null && preciousStonesPlugin.isEnabled()) { try { - managers.add(new PreciousStonesFeature(preciousstonesPlugin, this)); + managers.add(new PreciousStonesFeature(preciousStonesPlugin, this)); Fawe.debug("Plugin 'PreciousStones' found. Using it now."); } catch (final Throwable e) { e.printStackTrace(); diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/beta/BukkitQueue.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/beta/BukkitQueue.java index 4cb3896bf..e23c09c0f 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/beta/BukkitQueue.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/beta/BukkitQueue.java @@ -284,7 +284,7 @@ public class BukkitQueue extends SimpleCharQueueExtent { } final int[] blockToPalette = FaweCache.BLOCK_TO_PALETTE.get(); final int[] paletteToBlock = FaweCache.PALETTE_TO_BLOCK.get(); - final long[] blockstates = FaweCache.BLOCK_STATES.get(); + final long[] blockStates = FaweCache.BLOCK_STATES.get(); final int[] blocksCopy = FaweCache.SECTION_BLOCKS.get(); try { int num_palette = 0; @@ -317,9 +317,9 @@ public class BukkitQueue extends SimpleCharQueueExtent { final int blockBitArrayEnd = (bitsPerEntry * 4096) >> 6; if (num_palette == 1) { - for (int i = 0; i < blockBitArrayEnd; i++) blockstates[i] = 0; + for (int i = 0; i < blockBitArrayEnd; i++) blockStates[i] = 0; } else { - final BitArray4096 bitArray = new BitArray4096(blockstates, bitsPerEntry); + final BitArray4096 bitArray = new BitArray4096(blockStates, bitsPerEntry); bitArray.fromRaw(blocksCopy); } @@ -327,7 +327,7 @@ public class BukkitQueue extends SimpleCharQueueExtent { final DataPaletteBlock dataPaletteBlocks = section.getBlocks(); // private DataPalette h; // protected DataBits a; - final long[] bits = Arrays.copyOfRange(blockstates, 0, blockBitArrayEnd); + final long[] bits = Arrays.copyOfRange(blockStates, 0, blockBitArrayEnd); final DataBits nmsBits = new DataBits(bitsPerEntry, 4096, bits); final DataPalette palette; // palette = new DataPaletteHash<>(Block.REGISTRY_ID, bitsPerEntry, dataPaletteBlocks, GameProfileSerializer::d, GameProfileSerializer::a); diff --git a/worldedit-bukkit/src/main/java/com/sk89q/bukkit/util/CommandsManagerRegistration.java b/worldedit-bukkit/src/main/java/com/sk89q/bukkit/util/CommandsManagerRegistration.java deleted file mode 100644 index 65c466ff3..000000000 --- a/worldedit-bukkit/src/main/java/com/sk89q/bukkit/util/CommandsManagerRegistration.java +++ /dev/null @@ -1,78 +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.bukkit.util; - -import org.enginehub.piston.annotation.Command; -import com.sk89q.worldedit.command.util.CommandPermissions; -import com.sk89q.minecraft.util.commands.CommandsManager; -import org.bukkit.command.CommandExecutor; -import org.bukkit.plugin.Plugin; - -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Map; - -@Deprecated -@SuppressWarnings("deprecation") -public class CommandsManagerRegistration extends CommandRegistration { - - protected CommandsManager commands; - - public CommandsManagerRegistration(Plugin plugin, CommandsManager commands) { - super(plugin); - this.commands = commands; - } - - public CommandsManagerRegistration(Plugin plugin, CommandExecutor executor, CommandsManager commands) { - super(plugin, executor); - this.commands = commands; - } - - public boolean register(Class clazz) { - return registerAll(commands.registerAndReturn(clazz)); - } - - public boolean registerAll(List registered) { - List toRegister = new ArrayList<>(); - for (Command command : registered) { - List permissions = null; - Method cmdMethod = commands.getMethods().get(null).get(command.aliases()[0]); - Map childMethods = commands.getMethods().get(cmdMethod); - - if (cmdMethod != null && cmdMethod.isAnnotationPresent(CommandPermissions.class)) { - permissions = Arrays.asList(cmdMethod.getAnnotation(CommandPermissions.class).value()); - } else if (cmdMethod != null && childMethods != null && !childMethods.isEmpty()) { - permissions = new ArrayList<>(); - for (Method m : childMethods.values()) { - if (m.isAnnotationPresent(CommandPermissions.class)) { - permissions.addAll(Arrays.asList(m.getAnnotation(CommandPermissions.class).value())); - } - } - } - - toRegister.add(new CommandInfo(command.usage(), command.desc(), command.aliases(), commands, permissions == null ? null : permissions.toArray(new String[permissions.size()]))); - } - - return register(toRegister); - } - -} diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitTextAdapter.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitTextAdapter.java index 1ff04325f..fba2c2b1e 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitTextAdapter.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitTextAdapter.java @@ -25,24 +25,24 @@ import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; public class BukkitTextAdapter { - public static String reduceToText(Component component) { - StringBuilder text = new StringBuilder(); - appendTextTo(text, component); - return text.toString(); - } - - private static void appendTextTo(StringBuilder builder, Component component) { - if (component instanceof TextComponent) { - builder.append(((TextComponent) component).content()); - } else if (component instanceof TranslatableComponent) { - builder.append(((TranslatableComponent) component).key()); + public static String reduceToText(Component component) { + StringBuilder text = new StringBuilder(); + appendTextTo(text, component); + return text.toString(); } - for (Component child : component.children()) { - appendTextTo(builder, child); - } - } - private BukkitTextAdapter() { - } + private static void appendTextTo(StringBuilder builder, Component component) { + if (component instanceof TextComponent) { + builder.append(((TextComponent) component).content()); + } else if (component instanceof TranslatableComponent) { + builder.append(((TranslatableComponent) component).key()); + } + for (Component child : component.children()) { + appendTextTo(builder, child); + } + } + + private BukkitTextAdapter() { + } } diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java index f04aac89f..df2193660 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java @@ -199,9 +199,9 @@ public class BukkitWorld extends AbstractWorld { // We have to restore the block if it was outside if (!region.contains(pt)) { - editSession.setBlock(pt, history[index]); + editSession.smartSetBlock(pt, history[index]); } else { // Otherwise fool with history - editSession.setBlock().add(new BlockChange(pt, history[index], editSession.getFullBlock(pt))); + editSession.getChangeSet().add(new BlockChange(pt, history[index], editSession.getFullBlock(pt))); } } } @@ -318,14 +318,13 @@ public class BukkitWorld extends AbstractWorld { @Override public boolean equals(Object other) { - World ref = worldRef.get(); - if (ref == null) { + if (worldRef.get() == null) { return false; } else if (other == null) { return false; } else if ((other instanceof BukkitWorld)) { World otherWorld = ((BukkitWorld) other).worldRef.get(); - return ref.equals(otherWorld); + return otherWorld != null && otherWorld.equals(getWorld()); } else if (other instanceof com.sk89q.worldedit.world.World) { return ((com.sk89q.worldedit.world.World) other).getName().equals(getName()); } else { @@ -420,8 +419,21 @@ public class BukkitWorld extends AbstractWorld { getWorld().getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()).breakNaturally(); } + private static volatile boolean hasWarnedImplError = false; + @Override public com.sk89q.worldedit.world.block.BlockState getBlock(BlockVector3 position) { + BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter(); + if (adapter != null) { + try { + return adapter.getBlock(BukkitAdapter.adapt(getWorld(), position)).toImmutableState(); + } catch (Exception e) { + if (!hasWarnedImplError) { + hasWarnedImplError = true; + logger.warn("Unable to retrieve block via impl adapter", e); + } + } + } Block bukkitBlock = getWorld().getBlockAt(position.getBlockX(), position.getBlockY(), position.getBlockZ()); return BukkitAdapter.adapt(bukkitBlock.getBlockData()); } diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditListener.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditListener.java index e3634a178..f32ca1ac5 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditListener.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditListener.java @@ -21,7 +21,6 @@ package com.sk89q.worldedit.bukkit; -import com.bekvon.bukkit.residence.commands.command; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.extension.platform.Actor; @@ -37,15 +36,12 @@ import org.bukkit.event.player.PlayerCommandSendEvent; import org.bukkit.event.player.PlayerGameModeChangeEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.EquipmentSlot; -import org.enginehub.piston.Command; import org.enginehub.piston.CommandManager; import org.enginehub.piston.inject.InjectedValueStore; import org.enginehub.piston.inject.Key; import org.enginehub.piston.inject.MapBackedValueStore; -import java.util.Iterator; import java.util.Optional; -import java.util.function.Predicate; /** * Handles all events thrown in relation to a Player @@ -75,22 +71,16 @@ public class WorldEditListener implements Listener { @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onPlayerCommandSend(PlayerCommandSendEvent event) { - InjectedValueStore store = null; + InjectedValueStore store = MapBackedValueStore.create(); + store.injectValue(Key.of(Actor.class), context -> + Optional.of(plugin.wrapCommandSender(event.getPlayer()))); CommandManager commandManager = plugin.getWorldEdit().getPlatformManager().getPlatformCommandManager().getCommandManager(); - Iterator iter = event.getCommands().iterator(); - while (iter.hasNext()) { - String name = iter.next(); - Optional optional = commandManager.getCommand(name); - if (optional.isPresent()) { - if (store == null) { - store = MapBackedValueStore.create(); - store.injectValue(Key.of(Actor.class), context -> Optional.of(plugin.wrapCommandSender(event.getPlayer()))); - } - if (!optional.get().getCondition().satisfied(store)) { - iter.remove(); - } - } - } + event.getCommands().removeIf(name -> + // remove if in the manager and not satisfied + commandManager.getCommand(name) + .filter(command -> !command.getCondition().satisfied(store)) + .isPresent() + ); } /** diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java index 2178212ee..dcc606800 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java @@ -217,7 +217,8 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter public void setupRegistries() { // Biome for (Biome biome : Biome.values()) { - BiomeType.REGISTRY.register("minecraft:" + biome.name().toLowerCase(Locale.ROOT), new BiomeType("minecraft:" + biome.name().toLowerCase(Locale.ROOT))); + String lowerCaseBiomeName = biome.name().toLowerCase(Locale.ROOT); + BiomeType.REGISTRY.register("minecraft:" + lowerCaseBiomeName, new BiomeType("minecraft:" + lowerCaseBiomeName)); } // Block & Item for (Material material : Material.values()) { @@ -254,7 +255,8 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter for (org.bukkit.entity.EntityType entityType : org.bukkit.entity.EntityType.values()) { String mcid = entityType.getName(); if (mcid != null) { - EntityType.REGISTRY.register("minecraft:" + mcid.toLowerCase(Locale.ROOT), new EntityType("minecraft:" + mcid.toLowerCase(Locale.ROOT))); + String lowerCaseMcId = mcid.toLowerCase(Locale.ROOT); + EntityType.REGISTRY.register("minecraft:" + lowerCaseMcId, new EntityType("minecraft:" + lowerCaseMcId)); } } } @@ -426,7 +428,7 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter // code of WorldEdit expects it String[] split = new String[args.length + 1]; System.arraycopy(args, 0, split, 1, args.length); - split[0] = cmd.getName(); + split[0] = "/" + cmd.getName(); CommandEvent event = new CommandEvent(wrapCommandSender(sender), Joiner.on(" ").join(split)); getWorldEdit().getEventBus().post(event); @@ -441,11 +443,12 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter // code of WorldEdit expects it String[] split = new String[args.length + 1]; System.arraycopy(args, 0, split, 1, args.length); - split[0] = cmd.getName(); + split[0] = "/" + cmd.getName(); - CommandSuggestionEvent event = new CommandSuggestionEvent(wrapCommandSender(sender), Joiner.on(" ").join(split)); + String arguments = Joiner.on(" ").join(split); + CommandSuggestionEvent event = new CommandSuggestionEvent(wrapCommandSender(sender), arguments); getWorldEdit().getEventBus().post(event); - return event.getSuggestions(); + return CommandUtil.fixSuggestions(arguments, event.getSuggestions()); } */ @@ -581,13 +584,9 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter CommandSuggestionEvent suggestEvent = new CommandSuggestionEvent(wrapCommandSender(event.getSender()), event.getBuffer()); getWorldEdit().getEventBus().post(suggestEvent); - List suggestions = suggestEvent.getSuggestions(); - if (suggestions != null && !suggestions.isEmpty()) { - event.setCompletions(suggestions); - event.setHandled(true); - } - //event.setCompletions(CommandUtil.fixSuggestions(event.getBuffer(), suggestEvent.getSuggestions())); - //event.setHandled(true); + + event.setCompletions(CommandUtil.fixSuggestions(event.getBuffer(), suggestEvent.getSuggestions())); + event.setHandled(true); } } } diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/BukkitImplLoader.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/BukkitImplLoader.java index fb59444cd..085c88226 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/BukkitImplLoader.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/BukkitImplLoader.java @@ -54,7 +54,7 @@ public class BukkitImplLoader { "** will be blank, and so on. There will be no support for entity\n" + "** and block property-related functions.\n" + "**\n" + - "** Please see http://wiki.sk89q.com/wiki/WorldEdit/Bukkit_adapters\n" + + "** Please see https://worldedit.rtfd.io/en/latest/faq/#bukkit-adapters\n" + "**********************************************\n"; /** diff --git a/worldedit-core/src/main/java/com/boydti/fawe/FaweCache.java b/worldedit-core/src/main/java/com/boydti/fawe/FaweCache.java index 470061db4..7742f5dda 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/FaweCache.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/FaweCache.java @@ -112,11 +112,11 @@ public final class FaweCache implements Trimable { */ public int[] paletteToBlock; - public int blockstatesLength; + public int blockStatesLength; /** - * Reusable buffer array, MUST check blockstatesLength for actual length + * Reusable buffer array, MUST check blockStatesLength for actual length */ - public long[] blockstates; + public long[] blockStates; } private static final IterableThreadLocal PALETTE_CACHE = new IterableThreadLocal() { @@ -149,7 +149,7 @@ public final class FaweCache implements Trimable { private static Palette toPalette(int layerOffset, int[] blocksInts, char[] blocksChars) { int[] blockToPalette = BLOCK_TO_PALETTE.get(); int[] paletteToBlock = PALETTE_TO_BLOCK.get(); - long[] blockstates = BLOCK_STATES.get(); + long[] blockStates = BLOCK_STATES.get(); int[] blocksCopy = SECTION_BLOCKS.get(); int blockIndexStart = layerOffset << 12; @@ -193,10 +193,10 @@ public final class FaweCache implements Trimable { int blockBitArrayEnd = (bitsPerEntry * 4096) >> 6; if (num_palette == 1) { // Set a value, because minecraft needs it for some reason - blockstates[0] = 0; + blockStates[0] = 0; blockBitArrayEnd = 1; } else { - BitArray4096 bitArray = new BitArray4096(blockstates, bitsPerEntry); + BitArray4096 bitArray = new BitArray4096(blockStates, bitsPerEntry); bitArray.fromRaw(blocksCopy); } @@ -205,8 +205,8 @@ public final class FaweCache implements Trimable { palette.paletteToBlockLength = num_palette; palette.paletteToBlock = paletteToBlock; - palette.blockstatesLength = blockBitArrayEnd; - palette.blockstates = blockstates; + palette.blockStatesLength = blockBitArrayEnd; + palette.blockStates = blockStates; return palette; } catch (Throwable e) { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/FaweVersion.java b/worldedit-core/src/main/java/com/boydti/fawe/FaweVersion.java index 04c334ef3..2fd3d242f 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/FaweVersion.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/FaweVersion.java @@ -24,8 +24,8 @@ public class FaweVersion { public static FaweVersion tryParse(String version, String commit, String date) { try { return new FaweVersion(version, commit, date); - } catch (Exception ignore) { - ignore.printStackTrace(); + } catch (Exception exception) { + exception.printStackTrace(); return new FaweVersion(0, 0, 0, 0, 0); } } @@ -41,4 +41,4 @@ public class FaweVersion { public boolean isNewer(FaweVersion other) { return other.build < this.build; } -} \ No newline at end of file +} diff --git a/worldedit-core/src/main/java/com/boydti/fawe/command/AnvilCommands.java b/worldedit-core/src/main/java/com/boydti/fawe/command/AnvilCommands.java index 4635b546c..3288c5e02 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/command/AnvilCommands.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/command/AnvilCommands.java @@ -1,37 +1,25 @@ package com.boydti.fawe.command; -import com.boydti.fawe.FaweAPI; -import com.boydti.fawe.config.BBC; -import com.boydti.fawe.object.FawePlayer; -import com.boydti.fawe.object.RegionWrapper; -import com.boydti.fawe.object.RunnableVal4; -import com.boydti.fawe.object.changeset.AnvilHistory; -import com.boydti.fawe.object.clipboard.remap.ClipboardRemapper; -import com.boydti.fawe.object.mask.FaweBlockMatcher; -import com.boydti.fawe.util.MainUtil; +import static com.google.common.base.Preconditions.checkNotNull; + import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.command.util.CommandPermissions; +import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator; import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.internal.annotation.Selection; -import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.Region; -import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.biome.BiomeType; +import java.io.IOException; 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.Switch; -import java.io.IOException; -import java.io.RandomAccessFile; - -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)") +@CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class) public class AnvilCommands { /** @@ -247,11 +235,10 @@ public class AnvilCommands { desc = "Trim chunks in a Plot World", descFooter = "Unclaimed chunks will be deleted\n" + - "Unmodified chunks will be deleted\n" + - "Use -v to also delete unvisited chunks\n" + "Unmodified chunks will be deleted\n" ) @CommandPermissions("worldedit.anvil.trimallplots") - public void trimAllPlots(Player player, @Switch(name='v', desc = "TODO") boolean deleteUnvisited) throws WorldEditException { + public void trimAllPlots(Player player, @Switch(name='v', desc = "Delete unvisited chunks") boolean deleteUnvisited) throws WorldEditException { // String folder = player.getWorld().getName(); TODO NOT IMPLEMENTED // int visitTime = deleteUnvisited ? 1 : -1; // PlotTrimFilter filter = new PlotTrimFilter(player.getWorld(), 0, visitTime, 600000); @@ -266,7 +253,6 @@ public class AnvilCommands { @Command( name = "deletebiomechunks", - desc = "Delete chunks matching a specific biome" ) @CommandPermissions("worldedit.anvil.trimallair") @@ -280,7 +266,6 @@ public class AnvilCommands { @Command( name = "trimallair", - desc = "Trim all air in the world" ) @CommandPermissions("worldedit.anvil.trimallair") @@ -310,7 +295,7 @@ public class AnvilCommands { name = "replaceallpattern", aliases = {"reap", "repallpat"}, desc = "Replace all blocks in the selection with another" -) + ) @CommandPermissions("worldedit.anvil.replaceall") public void replaceAllPattern(Player player, String folder, @Arg(name = "from", desc = "String", def = "") String from, final Pattern to, @Switch(name='d', desc = "TODO") boolean useData, @Switch(name='m', desc = "TODO") boolean useMap) throws WorldEditException { // MCAFilterCounter filter; TODO NOT IMPLEMENTED @@ -339,7 +324,7 @@ public class AnvilCommands { @Command( name = "countall", desc = "Count all blocks in a world" -) + ) @CommandPermissions("worldedit.anvil.countall") public void countAll(Player player, EditSession editSession, String folder, String arg, @Switch(name='d', desc = "TODO") boolean useData) throws WorldEditException { // Set searchBlocks = worldEdit.getBlocks(player, arg, true); @@ -413,7 +398,7 @@ public class AnvilCommands { @Command( name = "count", desc = "Count blocks in a selection" -) + ) @CommandPermissions("worldedit.anvil.count") public void count(Player player, EditSession editSession, @Selection Region selection, String arg, @Switch(name='d', desc = "TODO") boolean useData) throws WorldEditException { // Set searchBlocks = worldEdit.getBlocks(player, arg, true); TODO NOT IMPLEMENTED @@ -621,8 +606,7 @@ public class AnvilCommands { @Command( name = "paste", desc = "Paste chunks from your anvil clipboard", - descFooter = - "Paste the chunks from your anvil clipboard.\n" + + descFooter = "Paste the chunks from your anvil clipboard.\n" + "The -c flag will align the paste to the chunks." ) @CommandPermissions("worldedit.anvil.pastechunks") diff --git a/worldedit-core/src/main/java/com/boydti/fawe/command/CFICommand.java b/worldedit-core/src/main/java/com/boydti/fawe/command/CFICommand.java index ae93d2751..d846b8cbb 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/command/CFICommand.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/command/CFICommand.java @@ -82,10 +82,6 @@ public class CFICommand extends MethodCommands { dispatcher.call(cmd, context.getLocals(), new String[0]); return; } - case 2: - String cmd = Commands.getAlias(CFICommands.class, "empty") + " " + context.getJoinedStrings(0); - dispatcher.call(cmd, context.getLocals(), new String[0]); - return; } } dispatcher.call(remaining, context.getLocals(), new String[0]); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/command/CFICommands.java b/worldedit-core/src/main/java/com/boydti/fawe/command/CFICommands.java index 985d73ace..313d255a5 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/command/CFICommands.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/command/CFICommands.java @@ -1,13 +1,16 @@ package com.boydti.fawe.command; +import static com.boydti.fawe.util.image.ImageUtil.load; + import com.boydti.fawe.Fawe; import com.boydti.fawe.FaweAPI; +import com.boydti.fawe.beta.IQueueExtent; import com.boydti.fawe.beta.SingleFilterBlock; import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.Commands; -import com.boydti.fawe.object.brush.visualization.cfi.HeightMapMCAGenerator; import com.boydti.fawe.object.FawePlayer; import com.boydti.fawe.object.RunnableVal; +import com.boydti.fawe.object.brush.visualization.cfi.HeightMapMCAGenerator; import com.boydti.fawe.object.clipboard.MultiClipboardHolder; import com.boydti.fawe.util.CleanTextureUtil; import com.boydti.fawe.util.FilteredTextureUtil; @@ -18,17 +21,14 @@ import com.boydti.fawe.util.TaskManager; import com.boydti.fawe.util.TextureUtil; import com.boydti.fawe.util.chat.Message; import com.boydti.fawe.util.image.ImageUtil; -import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator; -import java.util.stream.IntStream; -import org.enginehub.piston.annotation.Command; -import org.enginehub.piston.inject.InjectedValueAccess; import com.sk89q.minecraft.util.commands.CommandException; -import com.sk89q.worldedit.command.util.CommandPermissions; import com.sk89q.worldedit.EmptyClipboardException; import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.command.MethodCommands; +import com.sk89q.worldedit.command.util.CommandPermissions; +import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator; import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.extension.input.InputParseException; import com.sk89q.worldedit.extension.input.ParserContext; @@ -44,14 +44,11 @@ import com.sk89q.worldedit.registry.state.PropertyKey; import com.sk89q.worldedit.session.ClipboardHolder; import com.sk89q.worldedit.session.request.Request; import com.sk89q.worldedit.util.Location; -import org.enginehub.piston.annotation.param.Switch; import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockTypes; - -import javax.imageio.ImageIO; import java.awt.image.BufferedImage; import java.awt.image.DataBufferInt; import java.io.ByteArrayOutputStream; @@ -67,15 +64,18 @@ import java.util.HashSet; import java.util.List; import java.util.Set; import java.util.function.Function; +import java.util.stream.IntStream; +import javax.imageio.ImageIO; +import org.enginehub.piston.annotation.Command; import org.enginehub.piston.annotation.CommandContainer; import org.enginehub.piston.annotation.param.Arg; - -import static com.boydti.fawe.util.image.ImageUtil.load; +import org.enginehub.piston.annotation.param.Switch; +import org.enginehub.piston.inject.InjectedValueAccess; @CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class) public class CFICommands extends MethodCommands { - private final Dispatcher dispathcer; + private final Dispatcher dispatcher; /** * Create a new instance. @@ -84,7 +84,7 @@ public class CFICommands extends MethodCommands { */ public CFICommands(WorldEdit worldEdit, Dispatcher dispatcher) { super(worldEdit); - this.dispathcer = dispatcher; + this.dispatcher = dispatcher; } public static File getFolder(String worldName) { @@ -99,7 +99,7 @@ public class CFICommands extends MethodCommands { desc = "Start CFI with a height map as a base" ) @CommandPermissions("worldedit.anvil.cfi") - public void heightmap(FawePlayer fp, FawePrimitiveBinding.ImageUri image, @Arg(name = "yscale", desc = "double", def = "1") double yscale) throws ParameterException { + public void heightmap(FawePlayer fp, FawePrimitiveBinding.ImageUri image, @Arg(name = "yscale", desc = "double", def = "1") double yscale) { if (yscale != 0) { int[] raw = ((DataBufferInt) image.load().getRaster().getDataBuffer()).getData(); int[] table = IntStream.range(0, 256).map(i -> Math.min(255, (int) (i * yscale))) @@ -121,7 +121,7 @@ public class CFICommands extends MethodCommands { desc = "Start CFI with an empty map as a base" ) @CommandPermissions("worldedit.anvil.cfi") - public void heightmap(FawePlayer fp, int width, int length) { + public void heightMap(FawePlayer fp, int width, int length) { HeightMapMCAGenerator generator = new HeightMapMCAGenerator(width, length, getFolder(generateName())); setup(generator, fp); } @@ -145,7 +145,7 @@ public class CFICommands extends MethodCommands { desc = "Info about using brushes with CFI" ) @CommandPermissions("worldedit.anvil.cfi") - public void brush(FawePlayer fp) throws ParameterException { + public void brush(FawePlayer fp) { CFISettings settings = assertSettings(fp); settings.popMessages(fp); Message msg; @@ -232,7 +232,7 @@ public class CFICommands extends MethodCommands { desc = "Set the floor and main block" ) @CommandPermissions("worldedit.anvil.cfi") - public void column(FawePlayer fp, Pattern pattern, @Optional FawePrimitiveBinding.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name='w', desc = "TODO") boolean disableWhiteOnly) throws ParameterException{ + public void column(FawePlayer fp, Pattern pattern, FawePrimitiveBinding.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name='w', desc = "TODO") boolean disableWhiteOnly) { HeightMapMCAGenerator gen = assertSettings(fp).getGenerator(); if (image != null) { gen.setColumn(load(image), pattern, !disableWhiteOnly); @@ -251,14 +251,14 @@ public class CFICommands extends MethodCommands { desc = "Set the floor (default: grass)" ) @CommandPermissions("worldedit.anvil.cfi") - public void floorCmd(FawePlayer fp, Pattern pattern, @Optional FawePrimitiveBinding.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name='w', desc = "TODO") boolean disableWhiteOnly) throws ParameterException{ + public void floorCmd(FawePlayer fp, Pattern pattern, FawePrimitiveBinding.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name='w', desc = "TODO") boolean disableWhiteOnly) { floor(fp, pattern, image, mask, disableWhiteOnly); fp.sendMessage("Set floor!"); assertSettings(fp).resetComponent(); component(fp); } - private void floor(FawePlayer fp, Pattern pattern, @Optional FawePrimitiveBinding.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name='w', desc = "TODO") boolean disableWhiteOnly) throws ParameterException { + private void floor(FawePlayer fp, Pattern pattern, FawePrimitiveBinding.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name='w', desc = "TODO") boolean disableWhiteOnly) { HeightMapMCAGenerator gen = assertSettings(fp).getGenerator(); if (image != null) { gen.setFloor(load(image), pattern, !disableWhiteOnly); @@ -274,14 +274,14 @@ public class CFICommands extends MethodCommands { desc = "Set the main block (default: stone)" ) @CommandPermissions("worldedit.anvil.cfi") - public void mainCmd(FawePlayer fp, Pattern pattern, @Optional FawePrimitiveBinding.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name='w', desc = "TODO") boolean disableWhiteOnly) throws ParameterException{ + public void mainCmd(FawePlayer fp, Pattern pattern, FawePrimitiveBinding.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name='w', desc = "TODO") boolean disableWhiteOnly){ main(fp, pattern, image, mask, disableWhiteOnly); fp.sendMessage("Set main!"); assertSettings(fp).resetComponent(); component(fp); } - public void main(FawePlayer fp, Pattern pattern, @Optional FawePrimitiveBinding.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name='w', desc = "TODO") boolean disableWhiteOnly) throws ParameterException{ + public void main(FawePlayer fp, Pattern pattern, FawePrimitiveBinding.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name='w', desc = "TODO") boolean disableWhiteOnly){ HeightMapMCAGenerator gen = assertSettings(fp).getGenerator(); if (image != null) { gen.setMain(load(image), pattern, !disableWhiteOnly); @@ -300,7 +300,7 @@ public class CFICommands extends MethodCommands { "e.g. Tallgrass" ) @CommandPermissions("worldedit.anvil.cfi") - public void overlay(FawePlayer fp, Pattern pattern, @Optional FawePrimitiveBinding.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name='w', desc = "TODO") boolean disableWhiteOnly) throws ParameterException{ + public void overlay(FawePlayer fp, Pattern pattern, FawePrimitiveBinding.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name='w', desc = "TODO") boolean disableWhiteOnly){ HeightMapMCAGenerator gen = assertSettings(fp).getGenerator(); if (image != null) { gen.setOverlay(load(image), pattern, !disableWhiteOnly); @@ -322,13 +322,13 @@ public class CFICommands extends MethodCommands { " - A good value for radius and iterations would be 1 8." ) @CommandPermissions("worldedit.anvil.cfi") - public void smoothCmd(FawePlayer fp, int radius, int iterations, @Optional FawePrimitiveBinding.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name='w', desc = "TODO") boolean disableWhiteOnly) throws ParameterException{ + public void smoothCmd(FawePlayer fp, int radius, int iterations, FawePrimitiveBinding.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name='w', desc = "TODO") boolean disableWhiteOnly) { smooth(fp, radius, iterations, image, mask, disableWhiteOnly); assertSettings(fp).resetComponent(); component(fp); } - private void smooth(FawePlayer fp, int radius, int iterations, @Optional FawePrimitiveBinding.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name='w', desc = "TODO") boolean disableWhiteOnly) throws ParameterException{ + private void smooth(FawePlayer fp, int radius, int iterations, FawePrimitiveBinding.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name='w', desc = "TODO") boolean disableWhiteOnly) { HeightMapMCAGenerator gen = assertSettings(fp).getGenerator(); if (image != null) { gen.smooth(load(image), !disableWhiteOnly, radius, iterations); @@ -342,7 +342,7 @@ public class CFICommands extends MethodCommands { desc = "Create some snow" ) @CommandPermissions("worldedit.anvil.cfi") - public void snow(FawePlayer fp, @Optional FawePrimitiveBinding.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name='w', desc = "TODO") boolean disableWhiteOnly) throws ParameterException{ + public void snow(FawePlayer fp, FawePrimitiveBinding.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name='w', desc = "TODO") boolean disableWhiteOnly) { HeightMapMCAGenerator gen = assertSettings(fp).getGenerator(); floor(fp, BlockTypes.SNOW.getDefaultState().with(PropertyKey.LAYERS, 7), image, mask, disableWhiteOnly); main(fp, BlockTypes.SNOW_BLOCK, image, mask, disableWhiteOnly); @@ -361,7 +361,7 @@ public class CFICommands extends MethodCommands { "Below 50 will prefer to color with blocks" ) @CommandPermissions("worldedit.anvil.cfi") - public void biomepriority(FawePlayer fp, int value) throws ParameterException { + public void biomepriority(FawePlayer fp, int value) { assertSettings(fp).getGenerator().setBiomePriority(value); coloring(fp); } @@ -374,7 +374,7 @@ public class CFICommands extends MethodCommands { "`#clipboard` will only use the blocks present in your clipboard." ) @CommandPermissions("worldedit.anvil.cfi") - public void paletteblocks(FawePlayer fp, Player player, LocalSession session, @Arg(name = "arg", desc = "String", def = "") String arg) throws ParameterException, EmptyClipboardException, InputParseException, FileNotFoundException { + public void paletteblocks(FawePlayer fp, Player player, LocalSession session, @Arg(name = "arg", desc = "String", def = "") String arg) throws EmptyClipboardException, InputParseException, FileNotFoundException { if (arg == null) { msg("What blocks do you want to color with?").newline() .text("[All]").cmdTip(alias() + " PaletteBlocks *").text(" - All available blocks") @@ -452,7 +452,7 @@ public class CFICommands extends MethodCommands { "Randomization will allow mixing biomes when coloring with biomes" ) @CommandPermissions("worldedit.anvil.cfi") - public void randomization(FawePlayer fp, boolean enabled) throws ParameterException { + public void randomization(FawePlayer fp, boolean enabled) { assertSettings(fp).getGenerator().setTextureRandomVariation(enabled); coloring(fp); } @@ -466,7 +466,7 @@ public class CFICommands extends MethodCommands { "Using 0 73 for the min/max would use the simplest 73% of blocks for coloring, and is a reasonable value." ) @CommandPermissions("worldedit.anvil.cfi") - public void complexity(FawePlayer fp, int min, int max) throws ParameterException, FileNotFoundException { + public void complexity(FawePlayer fp, int min, int max) throws FileNotFoundException { HeightMapMCAGenerator gen = assertSettings(fp).getGenerator(); if (min == 0 && max == 100) { gen.setTextureUtil(Fawe.get().getTextureUtil()); @@ -485,7 +485,7 @@ public class CFICommands extends MethodCommands { " - The distance is the spacing between each schematic" ) @CommandPermissions("worldedit.anvil.cfi") - public void schem(FawePlayer fp, @Optional FawePrimitiveBinding.ImageUri imageMask, Mask mask, String schematic, int rarity, int distance, boolean rotate) throws ParameterException, IOException, WorldEditException { + public void schem(FawePlayer fp, FawePrimitiveBinding.ImageUri imageMask, Mask mask, String schematic, int rarity, int distance, boolean rotate) throws IOException, WorldEditException { HeightMapMCAGenerator gen = assertSettings(fp).getGenerator(); World world = fp.getWorld(); @@ -511,7 +511,7 @@ public class CFICommands extends MethodCommands { " - If a mask is used, the biome will be set anywhere the mask applies" ) @CommandPermissions("worldedit.anvil.cfi") - public void biome(FawePlayer fp, BiomeType biome, @Optional FawePrimitiveBinding.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name='w', desc = "TODO") boolean disableWhiteOnly) throws ParameterException{ + public void biome(FawePlayer fp, BiomeType biome, FawePrimitiveBinding.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name='w', desc = "TODO") boolean disableWhiteOnly) { HeightMapMCAGenerator gen = assertSettings(fp).getGenerator(); if (image != null) { gen.setBiome(load(image), biome, !disableWhiteOnly); @@ -530,7 +530,7 @@ public class CFICommands extends MethodCommands { desc = "Generate vanilla caves" ) @CommandPermissions("worldedit.anvil.cfi") - public void caves(FawePlayer fp) throws ParameterException, WorldEditException { + public void caves(FawePlayer fp) throws WorldEditException { assertSettings(fp).getGenerator().addCaves(); msg("Added caves!").send(fp); populate(fp); @@ -542,7 +542,7 @@ public class CFICommands extends MethodCommands { descFooter = "Use a specific pattern and settings to generate ore" ) @CommandPermissions("worldedit.anvil.cfi") - public void ore(FawePlayer fp, Mask mask, Pattern pattern, int size, int frequency, int rariry, int minY, int maxY) throws ParameterException, WorldEditException { + public void ore(FawePlayer fp, Mask mask, Pattern pattern, int size, int frequency, int rariry, int minY, int maxY) throws WorldEditException { assertSettings(fp).getGenerator().addOre(mask, pattern, size, frequency, rariry, minY, maxY); msg("Added ore!").send(fp); populate(fp); @@ -553,7 +553,7 @@ public class CFICommands extends MethodCommands { desc = "Generate the vanilla ores" ) @CommandPermissions("worldedit.anvil.cfi") - public void ores(FawePlayer fp, Mask mask) throws ParameterException, WorldEditException { + public void ores(FawePlayer fp, Mask mask) throws WorldEditException { assertSettings(fp).getGenerator().addDefaultOres(mask); msg("Added ores!").send(fp); populate(fp); @@ -565,7 +565,7 @@ public class CFICommands extends MethodCommands { descFooter = "Set the terrain height either based on an image heightmap, or a numeric value." ) @CommandPermissions("worldedit.anvil.cfi") - public void height(FawePlayer fp, String arg) throws ParameterException, WorldEditException { + public void height(FawePlayer fp, String arg) throws WorldEditException { HeightMapMCAGenerator gen = assertSettings(fp).getGenerator(); if (!MathMan.isInteger(arg)) { gen.setHeight(ImageUtil.getImage(arg)); @@ -581,7 +581,7 @@ public class CFICommands extends MethodCommands { desc = "Change the block used for water\ne.g. Lava" ) @CommandPermissions("worldedit.anvil.cfi") - public void waterId(FawePlayer fp, BlockStateHolder block) throws ParameterException, WorldEditException { + public void waterId(FawePlayer fp, BlockStateHolder block) throws WorldEditException { CFISettings settings = assertSettings(fp); settings.getGenerator().setWaterId(block.getBlockType().getInternalId()); msg("Set water id!").send(fp); @@ -595,7 +595,7 @@ public class CFICommands extends MethodCommands { desc = "Change the block used for the base\ne.g. Bedrock" ) @CommandPermissions("worldedit.anvil.cfi") - public void baseId(FawePlayer fp, BlockStateHolder block) throws ParameterException, WorldEditException { + public void baseId(FawePlayer fp, BlockStateHolder block) throws WorldEditException { CFISettings settings = assertSettings(fp); settings.getGenerator().setBedrockId(block.getBlockType().getInternalId()); msg("Set base id!").send(fp); @@ -610,7 +610,7 @@ public class CFICommands extends MethodCommands { " - A value of 0 is the default and will not modify the height" ) @CommandPermissions("worldedit.anvil.cfi") - public void worldthickness(FawePlayer fp, int height) throws ParameterException, WorldEditException { + public void worldthickness(FawePlayer fp, int height) throws WorldEditException { assertSettings(fp).getGenerator().setWorldThickness(height); msg("Set world thickness!").send(fp); component(fp); @@ -623,7 +623,7 @@ public class CFICommands extends MethodCommands { " - A value of 0 is the default and will only set the top block" ) @CommandPermissions("worldedit.anvil.cfi") - public void floorthickness(FawePlayer fp, int height) throws ParameterException, WorldEditException { + public void floorthickness(FawePlayer fp, int height) throws WorldEditException { assertSettings(fp).getGenerator().setFloorThickness(height); msg("Set floor thickness!").send(fp); component(fp); @@ -635,7 +635,7 @@ public class CFICommands extends MethodCommands { desc = "Resend the CFI chunks" ) @CommandPermissions("worldedit.anvil.cfi") - public void update(FawePlayer fp) throws ParameterException, WorldEditException { + public void update(FawePlayer fp) throws WorldEditException { assertSettings(fp).getGenerator().update(); msg("Chunks refreshed!").send(fp); mainMenu(fp); @@ -647,7 +647,7 @@ public class CFICommands extends MethodCommands { desc = "Teleport to the CFI virtual world" ) @CommandPermissions("worldedit.anvil.cfi") - public void tp(FawePlayer fp) throws ParameterException, WorldEditException { + public void tp(FawePlayer fp) throws WorldEditException { HeightMapMCAGenerator gen = assertSettings(fp).getGenerator(); msg("Teleporting...").send(fp); Vector3 origin = gen.getOrigin(); @@ -665,7 +665,7 @@ public class CFICommands extends MethodCommands { " - By default water is disabled (with a value of 0)" ) @CommandPermissions("worldedit.anvil.cfi") - public void waterheight(FawePlayer fp, int height) throws ParameterException, WorldEditException { + public void waterheight(FawePlayer fp, int height) throws WorldEditException { assertSettings(fp).getGenerator().setWaterHeight(height); msg("Set water height!").send(fp); component(fp); @@ -678,7 +678,7 @@ public class CFICommands extends MethodCommands { ) // ![79,174,212,5:3,5:4,18,161,20] @CommandPermissions("worldedit.anvil.cfi") - public void glass(FawePlayer fp, FawePrimitiveBinding.ImageUri image, @Optional FawePrimitiveBinding.ImageUri imageMask, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name='w', desc = "TODO") boolean disableWhiteOnly) throws ParameterException, WorldEditException { + public void glass(FawePlayer fp, FawePrimitiveBinding.ImageUri image, FawePrimitiveBinding.ImageUri imageMask, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name='w', desc = "TODO") boolean disableWhiteOnly) throws WorldEditException { CFISettings settings = assertSettings(fp); settings.getGenerator().setColorWithGlass(load(image)); msg("Set color with glass!").send(fp); @@ -695,7 +695,7 @@ public class CFICommands extends MethodCommands { "The -w (disableWhiteOnly) will randomly apply depending on the pixel luminance" ) @CommandPermissions("worldedit.anvil.cfi") - public void color(FawePlayer fp, FawePrimitiveBinding.ImageUri image, @Optional FawePrimitiveBinding.ImageUri imageMask, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name='w', desc = "TODO") boolean disableWhiteOnly) throws ParameterException, WorldEditException { + public void color(FawePlayer fp, FawePrimitiveBinding.ImageUri image, FawePrimitiveBinding.ImageUri imageMask, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name='w', desc = "TODO") boolean disableWhiteOnly) throws WorldEditException { CFISettings settings = assertSettings(fp); HeightMapMCAGenerator gen = settings.getGenerator(); if (imageMask != null) { @@ -719,7 +719,7 @@ public class CFICommands extends MethodCommands { "The -w (disableWhiteOnly) will randomly apply depending on the pixel luminance" ) @CommandPermissions("worldedit.anvil.cfi") - public void blockbiome(FawePlayer fp, FawePrimitiveBinding.ImageUri image, @Optional FawePrimitiveBinding.ImageUri imageMask, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name='w', desc = "TODO") boolean disableWhiteOnly) throws ParameterException, WorldEditException { + public void blockbiome(FawePlayer fp, FawePrimitiveBinding.ImageUri image, FawePrimitiveBinding.ImageUri imageMask, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name='w', desc = "TODO") boolean disableWhiteOnly) throws WorldEditException { CFISettings settings = assertSettings(fp); settings.getGenerator().setBlockAndBiomeColor(load(image), mask, load(imageMask), !disableWhiteOnly); msg("Set color with blocks and biomes!").send(fp); @@ -735,7 +735,7 @@ public class CFICommands extends MethodCommands { " - If you changed the block to something other than grass you will not see anything." ) @CommandPermissions("worldedit.anvil.cfi") - public void biomecolor(FawePlayer fp, FawePrimitiveBinding.ImageUri image, @Optional FawePrimitiveBinding.ImageUri imageMask, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name='w', desc = "TODO") boolean disableWhiteOnly) throws ParameterException, WorldEditException { + public void biomecolor(FawePlayer fp, FawePrimitiveBinding.ImageUri image, FawePrimitiveBinding.ImageUri imageMask, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name='w', desc = "TODO") boolean disableWhiteOnly) throws WorldEditException { CFISettings settings = assertSettings(fp); settings.getGenerator().setBiomeColor(load(image)); msg("Set color with biomes!").send(fp); @@ -750,7 +750,7 @@ public class CFICommands extends MethodCommands { desc = "Color the world using an image" ) @CommandPermissions("worldedit.anvil.cfi") - public void coloring(FawePlayer fp) throws ParameterException { + public void coloring(FawePlayer fp) { CFISettings settings = assertSettings(fp); settings.popMessages(fp); settings.setCategory("coloring"); @@ -834,7 +834,7 @@ public class CFICommands extends MethodCommands { desc = "Select a mask" ) @CommandPermissions("worldedit.anvil.cfi") - public void mask(FawePlayer fp, @Optional FawePrimitiveBinding.ImageUri imageMask, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name='w', desc = "TODO") boolean disableWhiteOnly, InjectedValueAccess context) throws ParameterException{ + public void mask(FawePlayer fp, FawePrimitiveBinding.ImageUri imageMask, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name='w', desc = "TODO") boolean disableWhiteOnly, InjectedValueAccess context){ CFISettings settings = assertSettings(fp); String[] split = getArguments(context).split(" "); int index = 2; @@ -859,7 +859,7 @@ public class CFICommands extends MethodCommands { desc = "Select a pattern" ) @CommandPermissions("worldedit.anvil.cfi") - public void pattern(FawePlayer fp, @Arg(name = "pattern", desc = "Pattern", def = "") Pattern pattern, InjectedValueAccess context) throws ParameterException, CommandException { + public void pattern(FawePlayer fp, @Arg(name = "pattern", desc = "Pattern", def = "") Pattern pattern, InjectedValueAccess context) { CFISettings settings = assertSettings(fp); String[] split = getArguments(context).split(" "); int index = 2; @@ -869,7 +869,7 @@ public class CFICommands extends MethodCommands { StringBuilder cmd = new StringBuilder(alias() + " pattern "); if (pattern != null) { - dispathcer.call(settings.getCategory(), context.getLocals(), new String[0]); + dispatcher.call(settings.getCategory(), context.getLocals(), new String[0]); } else { msg(">> Current Settings <<").newline() .text("Pattern ").text("[Click Here]").suggestTip(cmd + " stone") @@ -883,7 +883,7 @@ public class CFICommands extends MethodCommands { desc = "Download the current image" ) @CommandPermissions("worldedit.anvil.cfi") - public void download(FawePlayer fp) throws ParameterException, IOException { + public void download(FawePlayer fp) throws IOException { CFISettings settings = assertSettings(fp); BufferedImage image = settings.getGenerator().draw(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); @@ -899,7 +899,7 @@ public class CFICommands extends MethodCommands { desc = "Select an image" ) @CommandPermissions("worldedit.anvil.cfi") - public void image(FawePlayer fp, @Optional FawePrimitiveBinding.ImageUri image, InjectedValueAccess context) throws ParameterException, CommandException { + public void image(FawePlayer fp, @Optional FawePrimitiveBinding.ImageUri image, InjectedValueAccess context) throws CommandException { CFISettings settings = getSettings(fp); String[] split = getArguments(context).split(" "); int index = 2; @@ -921,7 +921,7 @@ public class CFICommands extends MethodCommands { return; } else { String next = Commands.getAlias(CFICommands.class, "heightmap " + settings.imageArg); - dispathcer.call(next, context.getLocals(), new String[0]); + dispatcher.call(next, context.getLocals(), new String[0]); return; } } @@ -932,7 +932,7 @@ public class CFICommands extends MethodCommands { desc = "" ) @CommandPermissions("worldedit.anvil.cfi") - public void populate(FawePlayer fp) throws ParameterException { + public void populate(FawePlayer fp) { CFISettings settings = assertSettings(fp); settings.popMessages(fp); settings.setCategory("populate"); @@ -949,7 +949,7 @@ public class CFICommands extends MethodCommands { desc = "Components menu" ) @CommandPermissions("worldedit.anvil.cfi") - public void component(FawePlayer fp) throws ParameterException { + public void component(FawePlayer fp) { CFISettings settings = assertSettings(fp); settings.popMessages(fp); settings.setCategory("component"); @@ -1027,7 +1027,7 @@ public class CFICommands extends MethodCommands { } - private CFISettings assertSettings(FawePlayer fp) throws ParameterException { + private CFISettings assertSettings(FawePlayer fp) { CFISettings settings = getSettings(fp); if (!settings.hasGenerator()) { throw new ParameterException("Please use /" + alias()); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/command/FaweBinding.java b/worldedit-core/src/main/java/com/boydti/fawe/command/FaweBinding.java index 2973feb5e..89d3d9321 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/command/FaweBinding.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/command/FaweBinding.java @@ -1,16 +1,16 @@ -package com.boydti.fawe.command; - -import com.sk89q.worldedit.WorldEdit; -import com.sk89q.worldedit.util.command.parametric.BindingHelper; - -public class FaweBinding extends BindingHelper { - private final WorldEdit worldEdit; - - public FaweBinding(WorldEdit worldEdit) { - this.worldEdit = worldEdit; - } - - public WorldEdit getWorldEdit() { - return worldEdit; - } -} +//package com.boydti.fawe.command; +// +//import com.sk89q.worldedit.WorldEdit; +//import com.sk89q.worldedit.util.command.parametric.BindingHelper; +// +//public class FaweBinding extends BindingHelper { +// private final WorldEdit worldEdit; +// +// public FaweBinding(WorldEdit worldEdit) { +// this.worldEdit = worldEdit; +// } +// +// public WorldEdit getWorldEdit() { +// return worldEdit; +// } +//} diff --git a/worldedit-core/src/main/java/com/boydti/fawe/command/MaskBinding.java b/worldedit-core/src/main/java/com/boydti/fawe/command/MaskBinding.java index 5711c43a4..64f119ee8 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/command/MaskBinding.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/command/MaskBinding.java @@ -1,29 +1,29 @@ -package com.boydti.fawe.command; - -import com.sk89q.worldedit.WorldEdit; -import com.sk89q.worldedit.util.command.parametric.ParameterData; -import com.sk89q.worldedit.world.block.BlockTypes; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -public class MaskBinding extends FaweBinding { - private final WorldEdit worldEdit; - - public MaskBinding(WorldEdit worldEdit) { - super(worldEdit); - this.worldEdit = worldEdit; - } - - @Override - public List getSuggestions(ParameterData parameter, String prefix) { - if (prefix.isEmpty()) { - return Stream.concat(Stream.of("#"), BlockTypes.getNameSpaces().stream().map(n -> n + ":")).collect(Collectors.toList()); - } - return super.getSuggestions(parameter, prefix); - } -} \ No newline at end of file +//package com.boydti.fawe.command; +// +//import com.sk89q.worldedit.WorldEdit; +//import com.sk89q.worldedit.util.command.parametric.ParameterData; +//import com.sk89q.worldedit.world.block.BlockTypes; +// +//import java.util.ArrayList; +//import java.util.HashSet; +//import java.util.List; +//import java.util.Set; +//import java.util.stream.Collectors; +//import java.util.stream.Stream; +// +//public class MaskBinding extends FaweBinding { +// private final WorldEdit worldEdit; +// +// public MaskBinding(WorldEdit worldEdit) { +// super(worldEdit); +// this.worldEdit = worldEdit; +// } +// +// @Override +// public List getSuggestions(ParameterData parameter, String prefix) { +// if (prefix.isEmpty()) { +// return Stream.concat(Stream.of("#"), BlockTypes.getNameSpaces().stream().map(n -> n + ":")).collect(Collectors.toList()); +// } +// return super.getSuggestions(parameter, prefix); +// } +//} diff --git a/worldedit-core/src/main/java/com/boydti/fawe/command/PatternBinding.java b/worldedit-core/src/main/java/com/boydti/fawe/command/PatternBinding.java index fb05ed40a..d3fbc7897 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/command/PatternBinding.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/command/PatternBinding.java @@ -1,26 +1,26 @@ -package com.boydti.fawe.command; - -import com.sk89q.worldedit.WorldEdit; -import com.sk89q.worldedit.util.command.parametric.ParameterData; -import com.sk89q.worldedit.world.block.BlockTypes; - -import java.util.List; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -public class PatternBinding extends FaweBinding { - private final WorldEdit worldEdit; - - public PatternBinding(WorldEdit worldEdit) { - super(worldEdit); - this.worldEdit = worldEdit; - } - - @Override - public List getSuggestions(ParameterData parameter, String prefix) { - if (prefix.isEmpty()) { - return Stream.concat(Stream.of("#"), BlockTypes.getNameSpaces().stream()).collect(Collectors.toList()); - } - return super.getSuggestions(parameter, prefix); - } -} +//package com.boydti.fawe.command; +// +//import com.sk89q.worldedit.WorldEdit; +//import com.sk89q.worldedit.util.command.parametric.ParameterData; +//import com.sk89q.worldedit.world.block.BlockTypes; +// +//import java.util.List; +//import java.util.stream.Collectors; +//import java.util.stream.Stream; +// +//public class PatternBinding extends FaweBinding { +// private final WorldEdit worldEdit; +// +// public PatternBinding(WorldEdit worldEdit) { +// super(worldEdit); +// this.worldEdit = worldEdit; +// } +// +// @Override +// public List getSuggestions(ParameterData parameter, String prefix) { +// if (prefix.isEmpty()) { +// return Stream.concat(Stream.of("#"), BlockTypes.getNameSpaces().stream()).collect(Collectors.toList()); +// } +// return super.getSuggestions(parameter, prefix); +// } +//} diff --git a/worldedit-core/src/main/java/com/boydti/fawe/command/PlotLoader.java b/worldedit-core/src/main/java/com/boydti/fawe/command/PlotLoader.java index 5974a3bac..4ce6f4507 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/command/PlotLoader.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/command/PlotLoader.java @@ -21,8 +21,10 @@ import java.io.IOException; import java.util.function.Function; public class PlotLoader { + @Deprecated - public static void autoClaimFromDatabase(PlotPlayer player, PlotArea area, PlotId start, com.github.intellectualsites.plotsquared.plot.object.RunnableVal whenDone) { + public static void autoClaimFromDatabase(PlotPlayer player, PlotArea area, PlotId start, + com.github.intellectualsites.plotsquared.plot.object.RunnableVal whenDone) { final Plot plot = area.getNextFreePlot(player, start); if (plot == null) { whenDone.run(null); @@ -30,15 +32,12 @@ public class PlotLoader { } whenDone.value = plot; plot.owner = player.getUUID(); - DBFunc.createPlotSafe(plot, whenDone, new Runnable() { - @Override - public void run() { - autoClaimFromDatabase(player, area, plot.getId(), whenDone); - } - }); + DBFunc.createPlotSafe(plot, whenDone, + () -> autoClaimFromDatabase(player, area, plot.getId(), whenDone)); } - public void load(FawePlayer fp, CFICommands.CFISettings settings, Function createTask) throws IOException { + public void load(FawePlayer fp, CFICommands.CFISettings settings, + Function createTask) throws IOException { PlotAreaManager manager = PlotSquared.get().getPlotAreaManager(); if (manager instanceof SinglePlotAreaManager) { SinglePlotAreaManager sManager = (SinglePlotAreaManager) manager; @@ -49,7 +48,8 @@ public class PlotLoader { Plot plot = TaskManager.IMP.sync(new RunnableVal() { @Override public void run(Plot o) { - int currentPlots = Settings.Limit.GLOBAL ? player.getPlotCount() : player.getPlotCount(area.worldname); + int currentPlots = Settings.Limit.GLOBAL ? player.getPlotCount() + : player.getPlotCount(area.worldname); int diff = player.getAllowedPlots() - currentPlots; if (diff < 1) { Captions.CANT_CLAIM_MORE_PLOTS_NUM.send(player, -diff); @@ -73,12 +73,7 @@ public class PlotLoader { File folder = CFICommands.getFolder(plot.getWorldName()); Boolean result = createTask.apply(folder); if (result == Boolean.TRUE) { - TaskManager.IMP.sync(new RunnableVal() { - @Override - public void run(Object value) { - plot.teleportPlayer(player); - } - }); + TaskManager.IMP.sync(() -> plot.teleportPlayer(player)); } return; } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/command/Rollback.java b/worldedit-core/src/main/java/com/boydti/fawe/command/Rollback.java index a0a0a57ce..2d5dd1892 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/command/Rollback.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/command/Rollback.java @@ -25,7 +25,7 @@ public class Rollback extends FaweCommand { } @Override - public boolean execute(final FawePlayer player, final String... args) { + public boolean execute(FawePlayer player, String... args) { if (!Settings.IMP.HISTORY.USE_DATABASE) { BBC.SETTING_DISABLE.send(player, "history.use-database (Import with /frb #import )"); return false; @@ -50,12 +50,11 @@ public class Rollback extends FaweCommand { } World world = player.getWorld(); switch (args[0]) { - default: { + default: BBC.COMMAND_SYNTAX.send(player, "/frb info u: r: t: